notherbase-fs 1.4.4 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,534 +0,0 @@
1
- <!-- The Tamago Watch itself. -->
2
- <div class="watch">
3
- <img src="img/console.png" class="console">
4
- <div class="screen">
5
- <img src="img/mon_base.png" class="pet" id="p0">
6
- <img src="img/mon_base.png" class="pet" id="p1">
7
- <img src="img/mon_base.png" class="pet" id="p2">
8
- <img src="img/music.png" class="music">
9
- <img src="img/food.png" class="food">
10
- </div>
11
- <!-- Clock, status bars and buttons. -->
12
- <div class="hud">
13
- <img src="img/hand.png" class="clock-hand">
14
- <div class="status" id="s0">
15
- <div class="point bloom"></div>
16
- <div class="point bloom"></div>
17
- <div class="point bloom"></div>
18
- <div class="point bloom"></div>
19
- <div class="point bloom"></div>
20
- <div class="point bloom"></div>
21
- <div class="point bloom"></div>
22
- <div class="point bloom"></div>
23
- <div class="point bloom"></div>
24
- <div class="point bloom"></div>
25
- </div>
26
- <div class="status" id="s1">
27
- <div class="point bloom"></div>
28
- <div class="point bloom"></div>
29
- <div class="point bloom"></div>
30
- <div class="point bloom"></div>
31
- <div class="point bloom"></div>
32
- <div class="point bloom"></div>
33
- <div class="point bloom"></div>
34
- <div class="point bloom"></div>
35
- <div class="point bloom"></div>
36
- <div class="point bloom"></div>
37
- </div>
38
- <div class="status" id="s2">
39
- <div class="point bloom"></div>
40
- <div class="point bloom"></div>
41
- <div class="point bloom"></div>
42
- <div class="point bloom"></div>
43
- <div class="point bloom"></div>
44
- <div class="point bloom"></div>
45
- <div class="point bloom"></div>
46
- <div class="point bloom"></div>
47
- <div class="point bloom"></div>
48
- <div class="point bloom"></div>
49
- </div>
50
- <div class="button" id="b0"></div>
51
- <div class="button" id="b1"></div>
52
- <div class="button" id="b2"></div>
53
- </div>
54
- </div>
55
-
56
- <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
57
- <script>
58
- /**
59
- * @description Cut-down timing class just for easily getting time since last frame.
60
- */
61
- class Timing {
62
- constructor() {
63
- this.deltaTime = 0;
64
- this.lastTime = Date.now();
65
- }
66
-
67
- /**
68
- * @description Evoke this somewhere every frame to get accurate delta times.
69
- */
70
- update() {
71
- this.deltaTime = Date.now() - this.lastTime;
72
- this.lastTime = Date.now();
73
- }
74
- }
75
-
76
- let timing = new Timing();
77
-
78
- class Pet {
79
- /**
80
- * @description Initializes your pets values and grabs relevant DOM elements
81
- */
82
- constructor() {
83
- this.food = 10;
84
- this.sleep = 10;
85
- this.fun = 10;
86
- this.secondsPerFill = 1;
87
- this.tilNextFill = this.secondsPerFill * 1000;
88
- this.secondsPerDrain = 10;
89
- this.tilNextDrain = this.secondsPerDrain * 1000;
90
- this.stage = 0;
91
- this.tilNextStage = [3, 5];
92
- this.state = "idle";
93
- this.$pets = [$("#p0"), $("#p1"), $("#p2")];
94
- this.spot = 0;
95
- this.pics = {
96
- egg: "/img/egg.png",
97
- idle: "/img/mon_base.png",
98
- stand: "/img/mon_stand.png",
99
- sleep: "/img/mon_sleep.png",
100
- eat: "/img/mon_eat.png",
101
- dead: "/img/mon_dead.png"
102
- };
103
- this.bigPics = {
104
- idle: "/img/big_idle.png",
105
- stand: "/img/big_stand.png",
106
- sleep: "/img/big_sleep.png",
107
- eat: "/img/big_eat.png",
108
- dead: "/img/big_dead.png"
109
- };
110
- this.currentPicSet = this.pics;
111
- this.currentPic = this.pics.egg;
112
- }
113
-
114
- /**
115
- * @description Must be called on every frame for your pet to be alive.
116
- */
117
- update() {
118
- if (this.state !== "dead") {
119
- if (this.stage > 0) {
120
- this.changePic();
121
-
122
- if (this.state !== "sleeping") {
123
- if (this.state === "idle") this.moveRandomly();
124
- if (this.state === "feeding") {
125
- this.moveFeeding();
126
-
127
- this.food = this.increaseStat(this.food);
128
- }
129
- if (this.state === "dancing") {
130
- this.moveDancing();
131
-
132
- this.fun = this.increaseStat(this.fun);
133
- }
134
-
135
- this.tilNextDrain -= timing.deltaTime;
136
- if (this.tilNextDrain <= 0) {
137
- switch (Math.floor(Math.random() * 3)) {
138
- case 0:
139
- this.food = this.decreaseStat(this.food);
140
- this.tryToEvolve();
141
- break;
142
- case 1:
143
- this.sleep = this.decreaseStat(this.sleep);
144
- break;
145
- case 2:
146
- this.fun = this.decreaseStat(this.fun);
147
- break;
148
- }
149
-
150
- this.tilNextDrain = this.secondsPerDrain * 1000;
151
- }
152
- }
153
- else {
154
- this.sleep = this.increaseStat(this.sleep);
155
- }
156
- }
157
- else this.moveEgg();
158
- }
159
- }
160
-
161
- /**
162
- * @description An egg will hatch when this function is invoked a sufficient number of times.
163
- */
164
- crackEgg() {
165
- this.tilNextStage[0]--;
166
- if (this.tilNextStage[0] <= 0) {
167
- this.tilNextStage[0] = 0;
168
- this.birth();
169
- }
170
- }
171
-
172
- /**
173
- * @description A mon will grow when this function is invoked a sufficient number of times.
174
- */
175
- tryToEvolve() {
176
- if (this.stage === 1){
177
- this.tilNextStage[1]--;
178
- if (this.tilNextStage[1] <= 0) {
179
- this.tilNextStage[1] = 0;
180
- this.stage++;
181
- this.currentPicSet = this.bigPics;
182
- }
183
- }
184
- }
185
-
186
- /**
187
- * @description Transform egg into mon.
188
- */
189
- birth() {
190
- this.stage = 1;
191
- this.currentPic = this.currentPicSet.idle;
192
- }
193
-
194
- /**
195
- * @description Your pet will die!
196
- */
197
- die() {
198
- this.state = "dead";
199
- this.$pets[this.spot].attr("src", this.currentPicSet.dead);
200
- }
201
-
202
- /**
203
- * @description Increases the input (by value) by one and caps it at 10;
204
- * @param {number} stat
205
- * @returns stat
206
- */
207
- increaseStat(stat) {
208
- this.tilNextFill -= timing.deltaTime;
209
- if (this.tilNextFill <= 0) {
210
- stat++;
211
- if (stat > 10) stat = 10;
212
- this.tilNextFill = this.secondsPerFill * 1000;
213
- }
214
-
215
- return stat;
216
- }
217
-
218
- /**
219
- * @description Decreases the input (by value) by one and limits it to 0. May kill your pet.
220
- * @param {number} stat
221
- * @returns stat
222
- */
223
- decreaseStat(stat) {
224
- stat--;
225
- if (stat <= 0) {
226
- stat = 0;
227
- this.die();
228
- }
229
-
230
- return stat;
231
- }
232
-
233
- /**
234
- * @description Toggle's your pet's feeding mode. Will toggle-off other modes.
235
- * @returns Your pet's food value.
236
- */
237
- toggleFeeding() {
238
- if (this.stage === 0) this.crackEgg();
239
-
240
- if (this.state !== "dead") {
241
- if (this.state !== "feeding") {
242
- this.state = "feeding";
243
- }
244
- else this.state = "idle";
245
- }
246
-
247
- return this.food;
248
- }
249
-
250
- /**
251
- * @description Toggle's your pet's sleeping mode. Will toggle-off other modes.
252
- * @returns Your pet's sleep value.
253
- */
254
- toggleSleeping() {
255
- if (this.stage === 0) this.crackEgg();
256
-
257
- if (this.state !== "dead") {
258
- if (this.state !== "sleeping") {
259
- this.state = "sleeping";
260
- if (this.stage > 0) this.$pets[this.spot].attr("src", this.currentPicSet.sleep);
261
- }
262
- else this.state = "idle";
263
- }
264
-
265
- return this.sleep;
266
- }
267
-
268
- /**
269
- * @description Toggle's your pet's dancing mode. Will toggle-off other modes.
270
- * @returns Your pet's fun value.
271
- */
272
- toggleDancing() {
273
- if (this.stage === 0) this.crackEgg();
274
-
275
- if (this.state !== "dead") {
276
- if (this.state !== "dancing") {
277
- this.state = "dancing";
278
- }
279
- else this.state = "idle";
280
- }
281
-
282
- return this.fun;
283
- }
284
-
285
- /**
286
- * @description Moves your pet to screen center.
287
- */
288
- moveEgg() {
289
- this.clearDisplay();
290
-
291
- this.spot = 1;
292
- this.$pets[this.spot].attr("src", this.currentPic);
293
- this.$pets[this.spot].css("display", "initial");
294
- }
295
-
296
- /**
297
- * @description Moves your pet to any spot.
298
- */
299
- moveRandomly() {
300
- this.clearDisplay();
301
-
302
- let chosen = Math.floor(Math.random() * 3);
303
- this.spot = chosen;
304
- this.$pets[chosen].attr("src", this.currentPic);
305
- this.$pets[chosen].css("display", "initial");
306
- }
307
-
308
- /**
309
- * @description Moves your pet to the right spot.
310
- */
311
- moveFeeding() {
312
- this.clearDisplay();
313
-
314
- this.spot = 2;
315
- this.$pets[this.spot].attr("src", this.currentPic);
316
- this.$pets[this.spot].css("display", "initial");
317
- }
318
-
319
- /**
320
- * @description Move your pet randomly between the left and center spots.
321
- */
322
- moveDancing() {
323
- this.clearDisplay();
324
-
325
- let chosen = Math.floor(Math.random() * 2);
326
- this.spot = chosen;
327
- this.$pets[chosen].attr("src", this.currentPic);
328
- this.$pets[chosen].css("display", "initial");
329
- }
330
-
331
- /**
332
- * @description Updates your pet's current sprite based on its current action.
333
- */
334
- changePic() {
335
- if (Math.floor(Math.random() * 2) > 0) {
336
- switch (this.state) {
337
- case "sleeping":
338
- this.currentPic = this.currentPicSet.sleep;
339
- break;
340
- case "dancing":
341
- this.currentPic = this.currentPicSet.stand;
342
- break;
343
- case "feeding":
344
- this.currentPic = this.currentPicSet.eat;
345
- break;
346
- }
347
- }
348
- else this.currentPic = this.currentPicSet.idle;
349
- }
350
-
351
- /**
352
- * @description No pet will show on screen.
353
- */
354
- clearDisplay() {
355
- for (let i = 0; i < 3; i++) {
356
- this.$pets[i].css("display", "none");
357
- }
358
- }
359
-
360
- /**
361
- *
362
- * @returns Your pet's stats.
363
- */
364
- getStats() {
365
- return [this.food, this.sleep, this.fun];
366
- }
367
- }
368
-
369
- class Game {
370
- /**
371
- * @description Initializes the game's values, grabs relevant DOM elements and gives buttons listeners.
372
- */
373
- constructor() {
374
- this.on = false;
375
- this.paused = false;
376
- this.pet = new Pet();
377
- this.$screen = $(".screen");
378
- this.$music = $(".music");
379
- this.$food = $(".food");
380
- this.$hand = $(".clock-hand");
381
- this.statusBars = [$("#s0"), $("#s1"), $("#s2")];
382
- $("#b0").on("click", function(e) {game.pressBrown();});
383
- $("#b1").on("click", function(e) {game.pressBlue();});
384
- $("#b2").on("click", function(e) {game.pressGreen();});
385
- $(".cartridge").hover(function(e) {game.togglePause();});
386
- }
387
-
388
- /**
389
- * @description Call this every main game loop for the game to run.
390
- */
391
- update() {
392
- if (this.on) {
393
- this.updateClock();
394
- if (!this.paused) {
395
- this.pet.update();
396
- this.updateStats();
397
- }
398
- }
399
- }
400
-
401
- /**
402
- * @description Toggles power and updates the display accordingly.
403
- * @returns Current power state.
404
- */
405
- togglePower() {
406
- this.on = !this.on;
407
-
408
- if (this.on) {
409
- this.updateClock();
410
- this.$screen.css("display", "initial");
411
- this.$screen.toggleClass("bloom");
412
- $("main").css("background-color", "var(--extreme-dark)");
413
- this.updateStats();
414
- }
415
- else {
416
- this.resetClock();
417
- this.$screen.css("display", "none");
418
- this.$screen.toggleClass("bloom");
419
- $("main").css("background-color", "var(--very-dark)");
420
- this.updateStats();
421
- }
422
-
423
- return this.on;
424
- }
425
-
426
- /**
427
- * @description Pauses the watch's game logic.
428
- */
429
- togglePause() {
430
- this.paused = !this.paused;
431
- }
432
-
433
- /**
434
- * @description Will turn on the game if off or initiate feeding mode. Will turn off other modes.
435
- */
436
- pressBrown() {
437
- if (!this.on) this.togglePower();
438
- else {
439
- this.pet.toggleFeeding();
440
-
441
- if (this.$music.css("display") !== "none") this.$music.css("display", "none");
442
-
443
- if (this.$food.css("display") === "none") {
444
- this.$food.css("display", "initial");
445
- }
446
- else {
447
- this.$food.css("display", "none");
448
- }
449
-
450
- this.$screen.addClass("bloom");
451
- }
452
- }
453
-
454
- /**
455
- * @description Will turn on the game if off or initiate sleeping mode. Will turn off other modes.
456
- */
457
- pressBlue() {
458
- if (!this.on) this.togglePower();
459
- else {
460
- this.pet.toggleSleeping();
461
-
462
- if (this.$food.css("display") !== "none") this.$food.css("display", "none");
463
- if (this.$music.css("display") !== "none") this.$music.css("display", "none");
464
-
465
- this.$screen.toggleClass("bloom");
466
- }
467
- }
468
-
469
- /**
470
- * @description Will turn on the game if off or initiate dancing mode. Will turn off other modes.
471
- */
472
- pressGreen() {
473
- if (!this.on) this.togglePower();
474
- else {
475
- this.pet.toggleDancing();
476
-
477
- if (this.$food.css("display") !== "none") this.$food.css("display", "none");
478
-
479
- if (this.$music.css("display") === "none") {
480
- this.$music.css("display", "initial");
481
- }
482
- else {
483
- this.$music.css("display", "none");
484
- }
485
-
486
- this.$screen.addClass("bloom");
487
- }
488
- }
489
-
490
- /**
491
- * @description Invoke this at your desired frequency. This makes the clock match real life time.
492
- */
493
- updateClock() {
494
- let time = new Date();
495
- let rotation = ((time.getHours() % 12 / 12) + (time.getMinutes() / 60 / 12)) * 360;
496
- this.$hand.css("transform", `rotate(${rotation}deg)`);
497
- }
498
-
499
- /**
500
- * @description Invoke this if the game loses power.
501
- */
502
- resetClock() {
503
- this.$hand.css("transform", "rotate(0)");
504
- }
505
-
506
- /**
507
- * @description Updates the DOM status bars based on your pet's stats.
508
- */
509
- updateStats() {
510
- let stats = this.pet.getStats();
511
-
512
- for (let i = 0; i < 3; i++) {
513
- let bar = this.statusBars[i];
514
-
515
- for (let j = 0; j < 10; j++) {
516
- bar.children().eq(j).css("display", "none");
517
- }
518
-
519
- if (this.on) {
520
- for (let j = 0; j < stats[i]; j++) {
521
- bar.children().eq(j).css("display", "initial");
522
- }
523
- }
524
- }
525
- }
526
- }
527
- const game = new Game();
528
-
529
- //main game loop
530
- setInterval(function() {
531
- timing.update();
532
- game.update();
533
- }, 1000);
534
- </script>
@@ -1,36 +0,0 @@
1
- require("dotenv").config();
2
- const mongoose = require("mongoose");
3
-
4
- let success = null;
5
-
6
- //handlers
7
- mongoose.connection.on('connected', (err) => {
8
- console.log(`Mongoose connected to db`);
9
- success = true;
10
- });
11
-
12
- mongoose.connection.on('error', (err) => {
13
- console.log(`Mongoose ${err}`);
14
- success = false;
15
- });
16
-
17
- mongoose.connection.on('disconnected', () => {
18
- console.log('Mongoose disconnected');
19
- success = false;
20
- });
21
-
22
- try {
23
- mongoose.connect(process.env.MONGODB_URI, {
24
- useNewUrlParser: true,
25
- useUnifiedTopology: true
26
- });
27
-
28
- success = true;
29
- }
30
- catch (err) {
31
- console.log(`Mongoose on connect: ${err}`);
32
-
33
- success = false;
34
- }
35
-
36
- module.exports = success;