fixed decay for absents bug

This commit is contained in:
peter
2020-08-26 17:05:50 +02:00
parent 3dd1c01d3d
commit abed080892
3 changed files with 27 additions and 7 deletions
+5 -2
View File
@@ -369,6 +369,8 @@ export class ItemManager
} }
decayTokens = async (tier: Tiers, amount = 1) => { decayTokens = async (tier: Tiers, amount = 1) => {
getLogger('ItemManager#decayTokens').debug(tier)
await this.admin await this.admin
.knex(tier + 'tokens') .knex(tier + 'tokens')
.decrement('level', Math.max(amount, 1)) .decrement('level', Math.max(amount, 1))
@@ -379,13 +381,14 @@ export class ItemManager
.del() .del()
} }
decayTokensOfCharacter = async (tier: Tiers, character:Character, amount = 1) => { decayTokensOfCharacter = async (tier: Tiers, character:Character) => {
getLogger('ItemManager#decayTokensOfCharacter').debug(character, tier)
await this.admin await this.admin
.knex(tier + 'tokens') .knex(tier + 'tokens')
.where({ .where({
characterid: character.id characterid: character.id
}) })
.decrement('level', Math.max(amount, 1)) .decrement('level')
await this.admin await this.admin
.knex(tier + 'tokens as t') .knex(tier + 'tokens as t')
+7 -1
View File
@@ -174,7 +174,13 @@ export class RaidManager
startRaid = async (raid: Raid): Promise<RaidData> => { startRaid = async (raid: Raid): Promise<RaidData> => {
const data = await this.getRaidData(raid) const data = await this.getRaidData(raid)
data.participants.absent.map(p => this.itemManager.decayTokensOfCharacter(raid.tier, p, 1)) await Promise.all(data.participants.absent.map(p => this.itemManager.decayTokensOfCharacter(raid.tier, {
charactername: p.charactername,
id: p.characterid,
race: p.race,
specid: p.specid,
userid: p.userid
}, 1)))
await this.itemManager.decayTokens(data.tier) await this.itemManager.decayTokens(data.tier)
const archived = await this.archiveRaid(raid) const archived = await this.archiveRaid(raid)
@@ -15,7 +15,7 @@
raid start. raid start.
</li> </li>
<li> <li>
When you sign up to a raid you can spend your reserves on an item When you sign up to a raid you can spend your reserves on an item.
</li> </li>
<li> <li>
Every week you can re-reserve the same item to build a streak on it Every week you can re-reserve the same item to build a streak on it
@@ -27,8 +27,7 @@
<h3>Priorities</h3> <h3>Priorities</h3>
<ul> <ul>
<li> <li>
Some classes and races may get an initial boost to specific streaks. The list is on the Some classes and races may get an initial boost to specific streaks.
right
</li> </li>
<li> <li>
If an item was not reserved at all, players may roll according to their priority <br />(e.g. If an item was not reserved at all, players may roll according to their priority <br />(e.g.
@@ -37,8 +36,20 @@
</li> </li>
</ul> </ul>
<br /> <br />
<h3>Streaks</h3> <h3>Streaks & Decay</h3>
<ul> <ul>
<li>
Spending your reserves will increase your streak by 1+#reserves. This number is affected by decay
</li>
<li>
Every time a raid starts, ALL streaks in that raid tier are reduced by 1 (this evens out the streak-gain for attendees back to 1)
</li>
<li>
Players that are marked absent have their streaks decay by 2 instead (which leaves the total unchanged)
</li>
<li>
If a player does not sign up as either "Attending" or "Absent" they are still subject to the decay, thereby decreasing the streak by 1
</li>
<li> <li>
Switching the selected item destroys previous streaks. (Streaks must be continued without Switching the selected item destroys previous streaks. (Streaks must be continued without
switchup) switchup)