Manage wounds

This commit is contained in:
sladecraven 2021-02-16 21:14:13 +01:00
parent de4bdb2403
commit cfcc3b3201
8 changed files with 119 additions and 34 deletions

View File

@ -14,7 +14,7 @@ export class SoSActorSheet extends ActorSheet {
classes: ["sos", "sheet", "actor"], classes: ["sos", "sheet", "actor"],
template: "systems/foundryvtt-shadows-over-sol/templates/actor-sheet.html", template: "systems/foundryvtt-shadows-over-sol/templates/actor-sheet.html",
width: 640, width: 640,
//height: 720, height: 720,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }], tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
editStatSkill: false 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.weapons = this.actor.data.items.filter( item => item.type == 'weapon');
data.data.armors = this.actor.data.items.filter( item => item.type == 'armor'); data.data.armors = this.actor.data.items.filter( item => item.type == 'armor');
data.data.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.data.items); 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.subculture = this.actor.data.items.find( item => item.type == 'subculture');
data.data.geneline = this.actor.data.items.find( item => item.type == 'geneline'); 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); //console.log("Competence changed :", skillName);
this.actor.updateSkillExperience(skillName, parseInt(event.target.value)); 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) => { html.find('.reset-deck-full').click((event) => {
this.actor.resetDeckFull(); this.actor.resetDeckFull();
this.render(true); this.render(true);

View File

@ -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) { async updateSkill(skillName, value) {
let skill = this.data.items.find( item => item.name == skillName); 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); 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) { async applyConsequenceWound( severity, consequenceName) {
if ( severity == 'none') return; // Nothing ! 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 ); 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") ] } ); ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
this.checkDeath();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -323,6 +352,7 @@ export class SoSActor extends Actor {
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-taken.html', flipData ); 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") ] } ); ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
this.checkDeath();
} }
} }

View File

@ -157,7 +157,7 @@ export class SoSCombat extends Combat {
} }
if ( actionsDone ) { if ( actionsDone ) {
this.actionsRequested = false; 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") ] } ); whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
this.phaseNumber = 3; this.phaseNumber = 3;
this.nextTurn(); this.nextTurn();

View File

@ -307,6 +307,11 @@ table {border: 1px solid #7a7971;}
.foundryvtt-shadows-over-sol .sheet-body .tab .editor { .foundryvtt-shadows-over-sol .sheet-body .tab .editor {
height: 100%; height: 100%;
} }
.editor {
border: 2;
height: 300px;
padding: 0 3px;
}
.medium-editor { .medium-editor {
border: 2; border: 2;
@ -628,6 +633,7 @@ ul, li {
} }
.skill-label, .skill-label,
.conseq-label,
.generic-label { .generic-label {
font-weight: bold; font-weight: bold;
flex-grow: 2; flex-grow: 2;
@ -640,7 +646,8 @@ ul, li {
margin-left: 4px; margin-left: 4px;
} }
.sante-value, .sante-value,
.skill-value { .skill-value,
.wound-value {
flex-grow: 0; flex-grow: 0;
flex-basis: 2rem; flex-basis: 2rem;
margin-right: 0.25rem; margin-right: 0.25rem;
@ -819,7 +826,7 @@ ul, li {
.chat-message { .chat-message {
background: rgba(220,220,210,0.5); background: rgba(220,220,210,0.5);
font-size: 0.8rem; font-size: 0.9rem;
} }
.chat-message.whisper { .chat-message.whisper {

View File

@ -2,11 +2,11 @@
"name": "foundryvtt-shadows-over-sol", "name": "foundryvtt-shadows-over-sol",
"title": "Shadows over Sol", "title": "Shadows over Sol",
"description": "Shadows over Sol for FoundryVTT", "description": "Shadows over Sol for FoundryVTT",
"version": "0.0.22", "version": "0.0.25",
"manifestPlusVersion": "1.0.0", "manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9", "compatibleCoreVersion": "0.7.9",
"templateVersion": 15, "templateVersion": 17,
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"esmodules": [ "module/sos-main.js" ], "esmodules": [ "module/sos-main.js" ],
"styles": ["styles/simple.css"], "styles": ["styles/simple.css"],

View File

@ -121,7 +121,7 @@
"background": { "background": {
"geneline": "", "geneline": "",
"subculture": "", "subculture": "",
"history": "", "history": "Background",
"notes": "Notes", "notes": "Notes",
"gmnotes": "GM notes", "gmnotes": "GM notes",
"eyes": "", "eyes": "",

View File

@ -154,17 +154,42 @@
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
{{!-- Consequences Tab --}} {{!-- Consequences Tab --}}
<div class="tab consequences" data-group="primary" data-tab="consequences"> <div class="tab consequences" data-group="primary" data-tab="consequences">
<ul class="item-list alternate-list"> <span><a class="lock-unlock-sheet"><img class="small-button-container"
src="systems/foundryvtt-shadows-over-sol/img/icons/{{#if data.editStatSkill}}unlocked.svg{{else}}locked.svg{{/if}}" alt="lock/unlock"
>{{#if data.editStatSkill}}Lock{{else}}Unlock{{/if}}</a></span>
<h4>Wounds & Conséquences</h4>
<div class="grid grid-2col">
<div class="flex-group-left flexcol skill-column">
<ul class="item-list alterne-list">
<li class="item flexrow list-item" data-wound-name="light"><h4>Wounds : </h4></li>
<li class="item flexrow list-item" data-wound-name="light"><span class="skill-label">Light :</span>
<input class="wound-value" type="text" woundname="light" value="{{numberFormat data.wounds.light decimals=0}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
</li>
<li class="item flexrow list-item" data-wound-name="moderate"><span class="skill-label">Moderate :</span>
<input class="wound-value" type="text" woundname="moderate" value="{{numberFormat data.wounds.moderate decimals=0}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
</li>
<li class="item flexrow list-item" data-wound-name="severe"><span class="skill-label">Severe :</span>
<input class="wound-value" type="text" woundname="severe" value="{{numberFormat data.wounds.severe decimals=0}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
</li>
<li class="item flexrow list-item" data-wound-name="critical"><span class="skill-label">Critical :</span>
<input class="wound-value" type="text" woundname="critical" value="{{numberFormat data.wounds.critical decimals=0}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
</li>
<li class="item flexrow list-item" data-wound-name="critical"><span class="skill-label">Total :</span>
<span class="skill-label">{{data.currentWounds}} / {{data.totalWounds}}</span>
</li>
</ul>
</div>
<div class="flex-group-left flexcol skill-column">
<ul class="item-list alterne-list">
{{#each data.consequences as |conseq key|}} {{#each data.consequences as |conseq key|}}
<li class="item flexrow list-item" data-item-id="{{conseq._id}}"> <li class="item flexrow list-item" data-item-id="{{conseq._id}}">
<img class="sheet-skill-img" src="{{conseq.img}}"/> <img class="sheet-skill-img" src="{{conseq.img}}"/>
<span class="conseq-label">{{conseq.name}}</span> <span class="conseq-label">{{conseq.name}}</span>
<select class="stat-value flexrow consequence-severity" type="text" name="conseq.data.severity" value="{{conseq.data.severity}}" data-dtype="String"> <select class="consequence-severity" type="text" name="conseq.data.severity" value="{{conseq.data.severity}}" data-dtype="String">
{{#select conseq.data.severity}} {{#select conseq.data.severity}}
<option value="none">None</option> <option value="none">None</option>
<option value="light">Light</option> <option value="light">Light</option>
@ -181,6 +206,8 @@
{{/each}} {{/each}}
</ul> </ul>
</div> </div>
</div>
</div>
{{!-- Gears Tab --}} {{!-- Gears Tab --}}
<div class="tab gears" data-group="primary" data-tab="gears"> <div class="tab gears" data-group="primary" data-tab="gears">
@ -274,14 +301,17 @@
</article> </article>
<article class="flexcol"> <article class="flexcol">
<hr>
<h3>Biography : </h3> <h3>Biography : </h3>
<div class="form-group medium-editor"> <div class="form-group editor">
{{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}} {{editor content=data.history target="data.history" button=true owner=owner editable=editable}}
</div> </div>
<hr>
<h3>Notes : </h3> <h3>Notes : </h3>
<div class="form-group medium-editor"> <div class="form-group editor">
{{editor content=data.notes target="data.notes" button=true owner=owner editable=editable}} {{editor content=data.notes target="data.notes" button=true owner=owner editable=editable}}
</div> </div>
<hr>
{{>"systems/foundryvtt-shadows-over-sol/templates/editor-notes-gm.html"}} {{>"systems/foundryvtt-shadows-over-sol/templates/editor-notes-gm.html"}}
</article> </article>
</div> </div>

View File

@ -0,0 +1,9 @@
<h2>{{name}} is dead ! </h2>
<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>