mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
better init for perkMonthCount
This commit is contained in:
@@ -18,7 +18,7 @@ export const schema = new mongoose.Schema({
|
|||||||
dateUpdated: Date,
|
dateUpdated: Date,
|
||||||
dateCurrentTypeCreated: Date,
|
dateCurrentTypeCreated: Date,
|
||||||
extraMonths: { $type: Number, default: 0 },
|
extraMonths: { $type: Number, default: 0 },
|
||||||
perkMonthCount: { $type: Number, default: 0 },
|
perkMonthCount: { $type: Number, default: -1 },
|
||||||
gemsBought: { $type: Number, default: 0 },
|
gemsBought: { $type: Number, default: 0 },
|
||||||
mysteryItems: { $type: Array, default: () => [] },
|
mysteryItems: { $type: Array, default: () => [] },
|
||||||
lastReminderDate: Date, // indicates the last time a subscription reminder was sent
|
lastReminderDate: Date, // indicates the last time a subscription reminder was sent
|
||||||
@@ -57,7 +57,7 @@ schema.methods.incrementPerkCounterAndReward = async function incrementPerkCount
|
|||||||
addingNumber = parseInt(adding, 10);
|
addingNumber = parseInt(adding, 10);
|
||||||
}
|
}
|
||||||
// if perkMonthCount wasn't used before, initialize it.
|
// if perkMonthCount wasn't used before, initialize it.
|
||||||
if (this.perkMonthCount === undefined && addingNumber === 1) {
|
if ((this.perkMonthCount === undefined || this.perkMonthCount === -1) && addingNumber === 1) {
|
||||||
this.perkMonthCount = (this.consecutive.count - 1) % SUBSCRIPTION_BASIC_BLOCK_LENGTH;
|
this.perkMonthCount = (this.consecutive.count - 1) % SUBSCRIPTION_BASIC_BLOCK_LENGTH;
|
||||||
} else {
|
} else {
|
||||||
this.perkMonthCount += addingNumber;
|
this.perkMonthCount += addingNumber;
|
||||||
|
|||||||
Reference in New Issue
Block a user