@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.mjs CHANGED
@@ -60,6 +60,7 @@ var TimeManager = class _TimeManager {
60
60
  }
61
61
  /**
62
62
  * Get time settings
63
+ * @default {}
63
64
  */
64
65
  static get settings() {
65
66
  let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY) || {};
@@ -182,12 +183,13 @@ var TimeManager = class _TimeManager {
182
183
  /**
183
184
  * Get the current week day name. If the week days names are not defined, then it will return undefined.
184
185
  * 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'.
186
+ * @default ""
185
187
  */
186
188
  static get currentDayName() {
187
189
  let weekDayNumber = _TimeManager.currentWeekDayNumber - 1;
188
190
  if (weekDayNumber >= _TimeManager.weekDaysNames.length) {
189
191
  console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, _TimeManager.weekDaysNames);
190
- return void 0;
192
+ return "";
191
193
  }
192
194
  return _TimeManager.weekDaysNames[weekDayNumber];
193
195
  }
@@ -209,14 +211,15 @@ var TimeManager = class _TimeManager {
209
211
  console.warn("[NQTR] Time slots are not defined");
210
212
  return 0;
211
213
  }
212
- _TimeManager.timeSlots.forEach((slot, index) => {
214
+ for (let index = 0; index < _TimeManager.timeSlots.length; index++) {
215
+ let slot = _TimeManager.timeSlots[index];
213
216
  if (_TimeManager.timeSlots.length > index + 1) {
214
217
  if (_TimeManager.nowIsBetween(slot.startHour, _TimeManager.timeSlots[index + 1].startHour)) {
215
218
  return index;
216
219
  }
217
220
  }
218
- });
219
- return 0;
221
+ }
222
+ return _TimeManager.timeSlots.length - 1;
220
223
  }
221
224
  /**
222
225
  * This function will increase the current hour by the given time spent.
@@ -262,6 +265,10 @@ var TimeManager = class _TimeManager {
262
265
 
263
266
  // src/classes/Activity.ts
264
267
  var ActivityStoredAbstract = class {
268
+ /**
269
+ * @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.
270
+ * @param props The activity properties.
271
+ */
265
272
  constructor(onRun, props) {
266
273
  this.defaultName = props.name;
267
274
  this.defaultFromHour = props.fromHour;
@@ -273,36 +280,54 @@ var ActivityStoredAbstract = class {
273
280
  this._icon = props.icon;
274
281
  this._onRun = onRun;
275
282
  }
283
+ /**
284
+ * The name
285
+ */
276
286
  get name() {
277
287
  return this.getStorageProperty("name") || this.defaultName || "";
278
288
  }
279
289
  set name(value) {
280
290
  this.setStorageProperty("name", value);
281
291
  }
292
+ /**
293
+ * The hour when the activity starts. If the activity is not started yet, it will be hidden.
294
+ */
282
295
  get fromHour() {
283
296
  return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
284
297
  }
285
298
  set fromHour(value) {
286
299
  this.setStorageProperty("fromHour", value);
287
300
  }
301
+ /**
302
+ * The hour when the activity ends. If the activity is ended yet, it will be hidden.
303
+ */
288
304
  get toHour() {
289
305
  return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
290
306
  }
291
307
  set toHour(value) {
292
308
  this.setStorageProperty("toHour", value);
293
309
  }
310
+ /**
311
+ * The day when the activity starts. If the activity is not started yet, it will be hidden.
312
+ */
294
313
  get fromDay() {
295
314
  return this.getStorageProperty("fromDay") || this.defaultFromDay;
296
315
  }
297
316
  set fromDay(value) {
298
317
  this.setStorageProperty("fromDay", value);
299
318
  }
319
+ /**
320
+ * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
321
+ */
300
322
  get toDay() {
301
323
  return this.getStorageProperty("toDay") || this.defaultToDay;
302
324
  }
303
325
  set toDay(value) {
304
326
  this.setStorageProperty("toDay", value);
305
327
  }
328
+ /**
329
+ * Whether is disabled.
330
+ */
306
331
  get disabled() {
307
332
  let value = this.getStorageProperty("disabled") || this.defaultDisabled;
308
333
  if (typeof value === "string") {
@@ -313,6 +338,9 @@ var ActivityStoredAbstract = class {
313
338
  set disabled(value) {
314
339
  this.setStorageProperty("disabled", value);
315
340
  }
341
+ /**
342
+ * Whether is hidden. If the activity is not started yet, it will be hidden.
343
+ */
316
344
  get hidden() {
317
345
  if (this.fromDay && this.fromDay > TimeManager.currentDay) {
318
346
  return true;
@@ -332,18 +360,32 @@ var ActivityStoredAbstract = class {
332
360
  set hidden(value) {
333
361
  this.setStorageProperty("hidden", value);
334
362
  }
363
+ /**
364
+ * The icon element.
365
+ */
335
366
  get icon() {
336
367
  return this._icon;
337
368
  }
369
+ /**
370
+ * The function that is called when the activity is runned.
371
+ */
338
372
  get onRun() {
339
- return this._onRun;
373
+ return () => this._onRun(this);
340
374
  }
375
+ /**
376
+ * Whether the activity is a deadline.
377
+ * @returns Whether the activity is a deadline.
378
+ */
341
379
  isExpired() {
342
380
  if (this.toDay && this.toDay <= TimeManager.currentDay) {
343
381
  return true;
344
382
  }
345
383
  return false;
346
384
  }
385
+ /**
386
+ * Export the activity properties.
387
+ * @returns The activity properties.
388
+ */
347
389
  export() {
348
390
  return {
349
391
  name: this.getStorageProperty("name") || this.defaultName,
@@ -358,6 +400,11 @@ var ActivityStoredAbstract = class {
358
400
  }
359
401
  };
360
402
  var ActivityModel = class {
403
+ /**
404
+ * @param id The activity id, that must be unique.
405
+ * @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.
406
+ * @param props The activity properties.
407
+ */
361
408
  constructor(id, onRun, props) {
362
409
  this._id = id;
363
410
  this._name = props.name;
@@ -370,30 +417,54 @@ var ActivityModel = class {
370
417
  this._icon = props.icon;
371
418
  this._onRun = onRun;
372
419
  }
420
+ /**
421
+ * The activity id, that is unique.
422
+ */
373
423
  get id() {
374
424
  return this._id;
375
425
  }
426
+ /**
427
+ * The name
428
+ */
376
429
  get name() {
377
430
  return this._name;
378
431
  }
432
+ /**
433
+ * The hour when the activity starts. If the activity is not started yet, it will be hidden.
434
+ */
379
435
  get fromHour() {
380
436
  return this._fromHour;
381
437
  }
438
+ /**
439
+ * The hour when the activity ends. If the activity is ended yet, it will be hidden.
440
+ */
382
441
  get toHour() {
383
442
  return this._toHour;
384
443
  }
444
+ /**
445
+ * The day when the activity starts. If the activity is not started yet, it will be hidden.
446
+ */
385
447
  get fromDay() {
386
448
  return this._fromDay;
387
449
  }
450
+ /**
451
+ * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
452
+ */
388
453
  get toDay() {
389
454
  return this._toDay;
390
455
  }
456
+ /**
457
+ * Whether is disabled.
458
+ */
391
459
  get disabled() {
392
460
  if (typeof this._disabled === "string") {
393
461
  return getFlag(this._disabled);
394
462
  }
395
463
  return this._disabled;
396
464
  }
465
+ /**
466
+ * Whether is hidden. If the activity is not started yet, it will be hidden.
467
+ */
397
468
  get hidden() {
398
469
  if (this.fromDay && this.fromDay > TimeManager.currentDay) {
399
470
  return true;
@@ -406,18 +477,32 @@ var ActivityModel = class {
406
477
  }
407
478
  return this._hidden;
408
479
  }
480
+ /**
481
+ * The icon element.
482
+ */
409
483
  get icon() {
410
484
  return this._icon;
411
485
  }
486
+ /**
487
+ * The function that is called when the activity is runned.
488
+ */
412
489
  get onRun() {
413
- return this._onRun;
490
+ return () => this._onRun(this);
414
491
  }
492
+ /**
493
+ * Whether the activity is a deadline.
494
+ * @returns Whether the activity is a deadline.
495
+ */
415
496
  isDeadline() {
416
497
  if (this.toDay && this.toDay <= TimeManager.currentDay) {
417
498
  return true;
418
499
  }
419
500
  return false;
420
501
  }
502
+ /**
503
+ * Export the activity properties.
504
+ * @returns The activity properties.
505
+ */
421
506
  export() {
422
507
  return {
423
508
  name: this._name,