@drincs/nqtr 0.0.9 → 0.1.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.
package/dist/index.js CHANGED
@@ -113,6 +113,7 @@ var TimeManager = class _TimeManager {
113
113
  }
114
114
  /**
115
115
  * Get time settings
116
+ * @default {}
116
117
  */
117
118
  static get settings() {
118
119
  let settings = import_pixi_vn.GameStorageManager.getVariable(TIME_SETTINGS_KEY) || {};
@@ -235,12 +236,13 @@ var TimeManager = class _TimeManager {
235
236
  /**
236
237
  * Get the current week day name. If the week days names are not defined, then it will return undefined.
237
238
  * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
239
+ * @default ""
238
240
  */
239
241
  static get currentDayName() {
240
242
  let weekDayNumber = _TimeManager.currentWeekDayNumber - 1;
241
243
  if (weekDayNumber >= _TimeManager.weekDaysNames.length) {
242
244
  console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, _TimeManager.weekDaysNames);
243
- return void 0;
245
+ return "";
244
246
  }
245
247
  return _TimeManager.weekDaysNames[weekDayNumber];
246
248
  }
@@ -262,14 +264,15 @@ var TimeManager = class _TimeManager {
262
264
  console.warn("[NQTR] Time slots are not defined");
263
265
  return 0;
264
266
  }
265
- _TimeManager.timeSlots.forEach((slot, index) => {
267
+ for (let index = 0; index < _TimeManager.timeSlots.length; index++) {
268
+ let slot = _TimeManager.timeSlots[index];
266
269
  if (_TimeManager.timeSlots.length > index + 1) {
267
270
  if (_TimeManager.nowIsBetween(slot.startHour, _TimeManager.timeSlots[index + 1].startHour)) {
268
271
  return index;
269
272
  }
270
273
  }
271
- });
272
- return 0;
274
+ }
275
+ return _TimeManager.timeSlots.length - 1;
273
276
  }
274
277
  /**
275
278
  * This function will increase the current hour by the given time spent.
@@ -315,6 +318,10 @@ var TimeManager = class _TimeManager {
315
318
 
316
319
  // src/classes/Activity.ts
317
320
  var ActivityStoredAbstract = class {
321
+ /**
322
+ * @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.
323
+ * @param props The activity properties.
324
+ */
318
325
  constructor(onRun, props) {
319
326
  this.defaultName = props.name;
320
327
  this.defaultFromHour = props.fromHour;
@@ -326,36 +333,54 @@ var ActivityStoredAbstract = class {
326
333
  this._icon = props.icon;
327
334
  this._onRun = onRun;
328
335
  }
336
+ /**
337
+ * The name
338
+ */
329
339
  get name() {
330
340
  return this.getStorageProperty("name") || this.defaultName || "";
331
341
  }
332
342
  set name(value) {
333
343
  this.setStorageProperty("name", value);
334
344
  }
345
+ /**
346
+ * The hour when the activity starts. If the activity is not started yet, it will be hidden.
347
+ */
335
348
  get fromHour() {
336
349
  return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
337
350
  }
338
351
  set fromHour(value) {
339
352
  this.setStorageProperty("fromHour", value);
340
353
  }
354
+ /**
355
+ * The hour when the activity ends. If the activity is ended yet, it will be hidden.
356
+ */
341
357
  get toHour() {
342
358
  return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
343
359
  }
344
360
  set toHour(value) {
345
361
  this.setStorageProperty("toHour", value);
346
362
  }
363
+ /**
364
+ * The day when the activity starts. If the activity is not started yet, it will be hidden.
365
+ */
347
366
  get fromDay() {
348
367
  return this.getStorageProperty("fromDay") || this.defaultFromDay;
349
368
  }
350
369
  set fromDay(value) {
351
370
  this.setStorageProperty("fromDay", value);
352
371
  }
372
+ /**
373
+ * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
374
+ */
353
375
  get toDay() {
354
376
  return this.getStorageProperty("toDay") || this.defaultToDay;
355
377
  }
356
378
  set toDay(value) {
357
379
  this.setStorageProperty("toDay", value);
358
380
  }
381
+ /**
382
+ * Whether is disabled.
383
+ */
359
384
  get disabled() {
360
385
  let value = this.getStorageProperty("disabled") || this.defaultDisabled;
361
386
  if (typeof value === "string") {
@@ -366,6 +391,9 @@ var ActivityStoredAbstract = class {
366
391
  set disabled(value) {
367
392
  this.setStorageProperty("disabled", value);
368
393
  }
394
+ /**
395
+ * Whether is hidden. If the activity is not started yet, it will be hidden.
396
+ */
369
397
  get hidden() {
370
398
  if (this.fromDay && this.fromDay > TimeManager.currentDay) {
371
399
  return true;
@@ -385,18 +413,32 @@ var ActivityStoredAbstract = class {
385
413
  set hidden(value) {
386
414
  this.setStorageProperty("hidden", value);
387
415
  }
416
+ /**
417
+ * The icon element.
418
+ */
388
419
  get icon() {
389
420
  return this._icon;
390
421
  }
422
+ /**
423
+ * The function that is called when the activity is runned.
424
+ */
391
425
  get onRun() {
392
- return this._onRun;
426
+ return () => this._onRun(this);
393
427
  }
428
+ /**
429
+ * Whether the activity is a deadline.
430
+ * @returns Whether the activity is a deadline.
431
+ */
394
432
  isExpired() {
395
433
  if (this.toDay && this.toDay <= TimeManager.currentDay) {
396
434
  return true;
397
435
  }
398
436
  return false;
399
437
  }
438
+ /**
439
+ * Export the activity properties.
440
+ * @returns The activity properties.
441
+ */
400
442
  export() {
401
443
  return {
402
444
  name: this.getStorageProperty("name") || this.defaultName,
@@ -411,6 +453,11 @@ var ActivityStoredAbstract = class {
411
453
  }
412
454
  };
413
455
  var ActivityModel = class {
456
+ /**
457
+ * @param id The activity id, that must be unique.
458
+ * @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.
459
+ * @param props The activity properties.
460
+ */
414
461
  constructor(id, onRun, props) {
415
462
  this._id = id;
416
463
  this._name = props.name;
@@ -423,30 +470,54 @@ var ActivityModel = class {
423
470
  this._icon = props.icon;
424
471
  this._onRun = onRun;
425
472
  }
473
+ /**
474
+ * The activity id, that is unique.
475
+ */
426
476
  get id() {
427
477
  return this._id;
428
478
  }
479
+ /**
480
+ * The name
481
+ */
429
482
  get name() {
430
483
  return this._name;
431
484
  }
485
+ /**
486
+ * The hour when the activity starts. If the activity is not started yet, it will be hidden.
487
+ */
432
488
  get fromHour() {
433
489
  return this._fromHour;
434
490
  }
491
+ /**
492
+ * The hour when the activity ends. If the activity is ended yet, it will be hidden.
493
+ */
435
494
  get toHour() {
436
495
  return this._toHour;
437
496
  }
497
+ /**
498
+ * The day when the activity starts. If the activity is not started yet, it will be hidden.
499
+ */
438
500
  get fromDay() {
439
501
  return this._fromDay;
440
502
  }
503
+ /**
504
+ * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
505
+ */
441
506
  get toDay() {
442
507
  return this._toDay;
443
508
  }
509
+ /**
510
+ * Whether is disabled.
511
+ */
444
512
  get disabled() {
445
513
  if (typeof this._disabled === "string") {
446
514
  return (0, import_pixi_vn2.getFlag)(this._disabled);
447
515
  }
448
516
  return this._disabled;
449
517
  }
518
+ /**
519
+ * Whether is hidden. If the activity is not started yet, it will be hidden.
520
+ */
450
521
  get hidden() {
451
522
  if (this.fromDay && this.fromDay > TimeManager.currentDay) {
452
523
  return true;
@@ -459,18 +530,32 @@ var ActivityModel = class {
459
530
  }
460
531
  return this._hidden;
461
532
  }
533
+ /**
534
+ * The icon element.
535
+ */
462
536
  get icon() {
463
537
  return this._icon;
464
538
  }
539
+ /**
540
+ * The function that is called when the activity is runned.
541
+ */
465
542
  get onRun() {
466
- return this._onRun;
543
+ return () => this._onRun(this);
467
544
  }
545
+ /**
546
+ * Whether the activity is a deadline.
547
+ * @returns Whether the activity is a deadline.
548
+ */
468
549
  isDeadline() {
469
550
  if (this.toDay && this.toDay <= TimeManager.currentDay) {
470
551
  return true;
471
552
  }
472
553
  return false;
473
554
  }
555
+ /**
556
+ * Export the activity properties.
557
+ * @returns The activity properties.
558
+ */
474
559
  export() {
475
560
  return {
476
561
  name: this._name,