#8 - Weapn/armor management

This commit is contained in:
2021-03-13 22:33:24 +01:00
parent 9d610215d4
commit 2353ba5ff9
6 changed files with 63 additions and 17 deletions

View File

@@ -374,13 +374,19 @@ export class SoSActor extends Actor {
/* -------------------------------------------- */
async applyWounds( flipData ) {
if ( flipData.damageStatus == 'no_damage') {
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-nodamage-taken.html', flipData );
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
return;
}
let wounds = duplicate(this.data.data.wounds);
for (let wound of flipData.woundsList ) {
if (wound == 'L' ) wounds.light += 1;
if (wound == 'M' ) wounds.moderate += 1;
if (wound == 'S' ) wounds.severe += 1;
if (wound == 'C' ) wounds.critical += 1;
}
}
// Compute total
let sumWound = wounds.light + (wounds.moderate*2) + (wounds.severe*3) + (wounds.critical*4);
let currentWounds = duplicate(this.data.data.scores.currentwounds);
@@ -391,6 +397,16 @@ export class SoSActor extends Actor {
await this.updateOwnedItem( { _id: bleeding._id, 'data.severity': newSeverity});
flipData.isBleeding = newSeverity;
}
// Stun consequence
if ( flipData.nbStun > 0) {
let stun = this.data.items.find( item => item.type == 'consequence' && item.name == 'Sun');
let newSeverity = stun.severity;
for(i=0; i<flipData.nbStun; i++) {
newSeverity = SoSUtility.increaseConsequenceSeverity( newSeverity );
}
await this.updateOwnedItem( { _id: stun._id, 'data.severity': newSeverity});
flipData.isStun = newSeverity;
}
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
flipData.defenderName = this.name;