Manage wounds in fight
This commit is contained in:
parent
de104fb386
commit
de4bdb2403
@ -10,7 +10,7 @@
|
||||
"SCORES.Lifestyle": "Lifestyle",
|
||||
"SCORES.Defense": "Defense",
|
||||
"SCORES.DR": "DR",
|
||||
"SCORES.Totalwounds": "Totalwounds",
|
||||
"SCORES.Currentwounds": "Current Wounds",
|
||||
"SCORES.Shock": "Shock",
|
||||
"SCORES.Wounds": "Wounds",
|
||||
"SCORES.Encumbrance": "Encumbrance",
|
||||
|
@ -267,4 +267,62 @@ export class SoSActor extends Actor {
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
|
||||
new SoSFlipDialog(flipData, html).render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async applyConsequenceWound( severity, consequenceName) {
|
||||
if ( severity == 'none') return; // Nothing !
|
||||
|
||||
let wounds = duplicate(this.data.data.wounds);
|
||||
if (severity == 'light' ) wounds.light += 1;
|
||||
if (severity == 'moderate' ) wounds.moderate += 1;
|
||||
if (severity == 'severe' ) wounds.severe += 1;
|
||||
if (severity == 'critical' ) wounds.critical += 1;
|
||||
|
||||
let sumWound = wounds.light + (wounds.moderate*2) + (wounds.severe*3) + (wounds.critical*4);
|
||||
let currentWounds = duplicate(this.data.data.scores.currentwounds);
|
||||
currentWounds.value = sumWound;
|
||||
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
|
||||
|
||||
let woundData = {
|
||||
name: this.name,
|
||||
consequenceName: consequenceName,
|
||||
severity: severity,
|
||||
wounds: wounds,
|
||||
currentWounds: sumWound,
|
||||
totalWounds: this.data.data.scores.wound.value
|
||||
}
|
||||
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") ] } );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async applyWounds( flipData ) {
|
||||
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);
|
||||
currentWounds.value = sumWound;
|
||||
if ( sumWound >= this.data.data.scores.wound.value) {
|
||||
let bleeding = this.data.items.find( item => item.type == 'consequence' && item.name == 'Bleeding');
|
||||
let newSeverity = SoSUtility.increaseConsequenceSeverity( bleeding.severity );
|
||||
await this.updateOwnedItem( { _id: bleeding._id, 'data.severity': newSeverity});
|
||||
flipData.isBleeding = newSeverity;
|
||||
}
|
||||
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
|
||||
|
||||
flipData.defenderName = this.name;
|
||||
flipData.wounds = wounds;
|
||||
flipData.currentWounds = sumWound;
|
||||
flipData.totalWounds = this.data.data.scores.wound.value;
|
||||
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") ] } );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ export class SoSCardDeck {
|
||||
SoSUtility.applyDamage( flipData );
|
||||
} else {
|
||||
game.socket.emit("system.foundryvtt-shadows-over-sol", {
|
||||
msg: "msg_defense", data: flipData } );
|
||||
msg: "msg_request_defense", data: flipData } );
|
||||
}
|
||||
} else {
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-only.html', flipData );
|
||||
|
@ -39,6 +39,7 @@ export class SoSCombat extends Combat {
|
||||
gotoNextTurn() {
|
||||
this.phaseNumber -= 1;
|
||||
if ( this.phaseNumber <= 0) {
|
||||
this.applyConsequences();
|
||||
this.nextRound(); // Auto-switch to next round
|
||||
} else {
|
||||
this.nextTurn();
|
||||
@ -91,6 +92,16 @@ export class SoSCombat extends Combat {
|
||||
this.currentActions = actionList;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
applyConsequences( ) {
|
||||
if (game.user.isGM ) {
|
||||
for( let combatant of this.combatants) {
|
||||
let bleeding = combatant.actor.data.items.find( item => item.type == 'consequence' && item.name == 'Bleeding');
|
||||
combatant.actor.applyConsequenceWound( bleeding.severity, "bleeding" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
closeAction( uniqId) {
|
||||
let action = this.currentActions.find( _action => _action.uniqId == uniqId );
|
||||
@ -146,7 +157,7 @@ export class SoSCombat extends Combat {
|
||||
}
|
||||
if ( actionsDone ) {
|
||||
this.actionsRequested = false;
|
||||
ChatMessage.create( { content: `Action phase has been completed ! Now proceeding with actions.`,
|
||||
ChatMessage.create( { content: `Action declaration phase has been completed ! Now proceeding with actions.`,
|
||||
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
this.phaseNumber = 3;
|
||||
this.nextTurn();
|
||||
|
@ -44,6 +44,10 @@ export class SoSUtility {
|
||||
if (game.user.isGM) {
|
||||
game.combat.closeAction( msg.data.uniqId );
|
||||
}
|
||||
} else if (msg.name == 'msg_request_defense') {
|
||||
if (game.user.isGM) {
|
||||
SoSUtility.applyDamage( msg.data );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +144,15 @@ export class SoSUtility {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static increaseConsequenceSeverity( severity ) {
|
||||
if ( severity == 'none') return 'light';
|
||||
if ( severity == 'light') return 'moderate';
|
||||
if ( severity == 'moderate') return 'severe';
|
||||
if ( severity == 'severe') return 'critical';
|
||||
return 'critical';
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static increaseSeverity( severity ) {
|
||||
if ( severity == 'L') return 'M';
|
||||
@ -225,7 +238,16 @@ export class SoSUtility {
|
||||
flipData.defenderMelee = melee.data.value;
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-request-dodge.html', flipData );
|
||||
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(flipData.target.actor.name), ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
return; // Wait message response
|
||||
}
|
||||
}
|
||||
this.takeWounds( flipData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static takeWounds( flipData ) {
|
||||
let defender = game.actors.get( flipData.target.actor._id);
|
||||
defender.applyWounds( flipData );
|
||||
}
|
||||
|
||||
}
|
@ -819,7 +819,7 @@ ul, li {
|
||||
|
||||
.chat-message {
|
||||
background: rgba(220,220,210,0.5);
|
||||
font-size: 1rem;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.chat-message.whisper {
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "foundryvtt-shadows-over-sol",
|
||||
"title": "Shadows over Sol",
|
||||
"description": "Shadows over Sol for FoundryVTT",
|
||||
"version": "0.0.21",
|
||||
"version": "0.0.22",
|
||||
"manifestPlusVersion": "1.0.0",
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.7.9",
|
||||
|
@ -104,8 +104,8 @@
|
||||
"label": "SCORES.Shock",
|
||||
"value": 0
|
||||
},
|
||||
"totalwounds": {
|
||||
"label": "SCORES.Totalwounds",
|
||||
"currentwounds": {
|
||||
"label": "SCORES.Currentwounds",
|
||||
"value": 0
|
||||
},
|
||||
"wound": {
|
||||
|
9
templates/chat-damage-consequence.html
Normal file
9
templates/chat-damage-consequence.html
Normal file
@ -0,0 +1,9 @@
|
||||
<h4>{{name}} has taken a new {{severity}} wound, due to the {{consequenceName}} consequence !</h4>
|
||||
<div class="flexcol">
|
||||
<label>Light Wounds : {{wounds.light}}</label>
|
||||
<label>Moderate Wounds : {{wounds.moderate}}</label>
|
||||
<label>Severe Wounds : {{wounds.severe}}</label>
|
||||
<label>Critical Wounds : {{wounds.critical}}</label>
|
||||
<label>Current wounds value : {{currentWounds}}</label>
|
||||
<label>Total wounds : {{totalWounds}}</label>
|
||||
</div>
|
13
templates/chat-damage-taken.html
Normal file
13
templates/chat-damage-taken.html
Normal file
@ -0,0 +1,13 @@
|
||||
<h4>{{defenderName}} has taken damages !</h4>
|
||||
<div class="flexcol">
|
||||
<label>Light Wounds : {{wounds.light}}</label>
|
||||
<label>Moderate Wounds : {{wounds.moderate}}</label>
|
||||
<label>Severe Wounds : {{wounds.severe}}</label>
|
||||
<label>Critical Wounds : {{wounds.critical}}</label>
|
||||
<label>Current wounds value : {{currentWounds}}</label>
|
||||
<label>Total wounds : {{totalWounds}}</label>
|
||||
{{#if isBleeding}}
|
||||
<label>{{defenderName}} is bleeding with severity {{isBleeding}}. He will have a new {{isBleeding}} wound at the end of the round !</label>
|
||||
{{/if}}
|
||||
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user