Manage wounds
This commit is contained in:
@ -14,7 +14,7 @@ export class SoSActorSheet extends ActorSheet {
|
||||
classes: ["sos", "sheet", "actor"],
|
||||
template: "systems/foundryvtt-shadows-over-sol/templates/actor-sheet.html",
|
||||
width: 640,
|
||||
//height: 720,
|
||||
height: 720,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
||||
editStatSkill: false
|
||||
@ -40,6 +40,10 @@ export class SoSActorSheet extends ActorSheet {
|
||||
data.data.weapons = this.actor.data.items.filter( item => item.type == 'weapon');
|
||||
data.data.armors = this.actor.data.items.filter( item => item.type == 'armor');
|
||||
data.data.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.data.items);
|
||||
data.data.wounds = duplicate(this.actor.data.data.wounds);
|
||||
data.data.isGM = game.user.isGM;
|
||||
data.data.currentWounds = this.actor.computeCurrentWounds();
|
||||
data.data.totalWounds = this.actor.data.data.scores.wound.value;
|
||||
|
||||
data.data.subculture = this.actor.data.items.find( item => item.type == 'subculture');
|
||||
data.data.geneline = this.actor.data.items.find( item => item.type == 'geneline');
|
||||
@ -113,6 +117,11 @@ export class SoSActorSheet extends ActorSheet {
|
||||
//console.log("Competence changed :", skillName);
|
||||
this.actor.updateSkillExperience(skillName, parseInt(event.target.value));
|
||||
});
|
||||
html.find('.wound-value').change((event) => {
|
||||
let woundName = event.currentTarget.attributes.woundname.value;
|
||||
//console.log("Competence changed :", skillName);
|
||||
this.actor.updateWound(woundName, parseInt(event.target.value));
|
||||
});
|
||||
html.find('.reset-deck-full').click((event) => {
|
||||
this.actor.resetDeckFull();
|
||||
this.render(true);
|
||||
|
@ -175,6 +175,13 @@ export class SoSActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateWound(woundName, value) {
|
||||
let wounds = duplicate(this.data.data.wounds)
|
||||
wounds[woundName] = value;
|
||||
await this.update( { 'data.wounds': wounds } );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateSkill(skillName, value) {
|
||||
let skill = this.data.items.find( item => item.name == skillName);
|
||||
@ -268,6 +275,26 @@ export class SoSActor extends Actor {
|
||||
new SoSFlipDialog(flipData, html).render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async checkDeath( ) {
|
||||
if ( this.data.data.scores.currentwounds.value >= this.data.data.scores.wound.value*2) {
|
||||
let woundData = {
|
||||
name: this.name,
|
||||
wounds: this.data.data.wounds,
|
||||
currentWounds: this.data.data.scores.currentwounds.value,
|
||||
totalWounds: this.data.data.scores.wound.value
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-character-death.html', woundData );
|
||||
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeCurrentWounds( ) {
|
||||
let wounds = this.data.data.wounds;
|
||||
return wounds.light + (wounds.moderate*2) + (wounds.severe*3) + (wounds.critical*4);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async applyConsequenceWound( severity, consequenceName) {
|
||||
if ( severity == 'none') return; // Nothing !
|
||||
@ -293,6 +320,8 @@ export class SoSActor extends Actor {
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-consequence.html', woundData );
|
||||
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
|
||||
this.checkDeath();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -315,7 +344,7 @@ export class SoSActor extends Actor {
|
||||
flipData.isBleeding = newSeverity;
|
||||
}
|
||||
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
|
||||
|
||||
|
||||
flipData.defenderName = this.name;
|
||||
flipData.wounds = wounds;
|
||||
flipData.currentWounds = sumWound;
|
||||
@ -323,6 +352,7 @@ export class SoSActor extends Actor {
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-taken.html', flipData );
|
||||
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
|
||||
this.checkDeath();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ export class SoSCombat extends Combat {
|
||||
}
|
||||
if ( actionsDone ) {
|
||||
this.actionsRequested = false;
|
||||
ChatMessage.create( { content: `Action declaration phase has been completed ! Now proceeding with actions.`,
|
||||
ChatMessage.create( { content: `Action declaration has been completed ! Now proceeding with actions.`,
|
||||
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
this.phaseNumber = 3;
|
||||
this.nextTurn();
|
||||
|
Reference in New Issue
Block a user