Rename insurance field

This commit is contained in:
フズキ 2021-04-06 08:02:52 +02:00
parent 1351f3250b
commit dc33dbd180
No known key found for this signature in database
GPG Key ID: AD7750AB4625F1DD
3 changed files with 10 additions and 10 deletions

View File

@ -96,8 +96,8 @@ export const BetCommand = new Command({
sender.money -= amount; sender.money -= amount;
receiver.money -= amount; receiver.money -= amount;
// Very hacky solution for persistence but better than no solution, backup returns runs during the bot's setup code. // Very hacky solution for persistence but better than no solution, backup returns runs during the bot's setup code.
sender.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled += amount; sender.ecoBetInsurance += amount;
receiver.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled += amount; receiver.ecoBetInsurance += amount;
Storage.save(); Storage.save();
// Notify both users. // Notify both users.
@ -141,8 +141,8 @@ export const BetCommand = new Command({
receiver.money += amount; receiver.money += amount;
channel.send(`By the people's votes, <@${target.id}> couldn't be determined to have won or lost the bet that <@${author.id}> had sent them.`); channel.send(`By the people's votes, <@${target.id}> couldn't be determined to have won or lost the bet that <@${author.id}> had sent them.`);
} }
sender.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled -= amount; sender.ecoBetInsurance -= amount;
receiver.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled -= amount; receiver.ecoBetInsurance -= amount;
Storage.save(); Storage.save();
}); });
}, duration); }, duration);

View File

@ -26,7 +26,7 @@ class User {
public lastMonday: number; public lastMonday: number;
public timezone: number | null; // This is for the standard timezone only, not the daylight savings timezone public timezone: number | null; // This is for the standard timezone only, not the daylight savings timezone
public daylightSavingsRegion: "na" | "eu" | "sh" | null; public daylightSavingsRegion: "na" | "eu" | "sh" | null;
public quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled: number; public ecoBetInsurance: number;
constructor(data?: GenericJSON) { constructor(data?: GenericJSON) {
this.money = select(data?.money, 0, Number); this.money = select(data?.money, 0, Number);
@ -36,7 +36,7 @@ class User {
this.daylightSavingsRegion = /^((na)|(eu)|(sh))$/.test(data?.daylightSavingsRegion) this.daylightSavingsRegion = /^((na)|(eu)|(sh))$/.test(data?.daylightSavingsRegion)
? data?.daylightSavingsRegion ? data?.daylightSavingsRegion
: null; : null;
this.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled = select(data?.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled, 0, Number); this.ecoBetInsurance = select(data?.ecoBetInsurance, 0, Number);
} }
} }

View File

@ -19,10 +19,10 @@ export default new Event<"ready">({
for (const id in Storage.users) { for (const id in Storage.users) {
const user = Storage.users[id]; const user = Storage.users[id];
if(user.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled > 0) { if(user.ecoBetInsurance > 0) {
client.users.cache.get(id)?.send(`Because my system either crashed or restarted while you had a pending bet, the total amount of money that you bet, which was \`${user.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled}\`, has been restored.`); client.users.cache.get(id)?.send(`Because my system either crashed or restarted while you had a pending bet, the total amount of money that you bet, which was \`${user.ecoBetInsurance}\`, has been restored.`);
user.money += user.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled; user.money += user.ecoBetInsurance;
user.quoteUnquoteSoCalledInsuranceForEcoBetIfItEvenCanBeSoCalled = 0; user.ecoBetInsurance = 0;
} }
} }
Storage.save(); Storage.save();