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"],
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);

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) {
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();
}
}

View File

@ -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();

View File

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

View File

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

View File

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

View File

@ -154,32 +154,59 @@
</ul>
</div>
</div>
</div>
</div>
{{!-- Consequences Tab --}}
<div class="tab consequences" data-group="primary" data-tab="consequences">
<ul class="item-list alternate-list">
{{#each data.consequences as |conseq key|}}
<li class="item flexrow list-item" data-item-id="{{conseq._id}}">
<img class="sheet-skill-img" src="{{conseq.img}}"/>
<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 conseq.data.severity}}
<option value="none">None</option>
<option value="light">Light</option>
<option value="moderate">Moderate</option>
<option value="severe">Severe</option>
<option value="critical">Critical</option>
{{/select}}
</select>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
<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|}}
<li class="item flexrow list-item" data-item-id="{{conseq._id}}">
<img class="sheet-skill-img" src="{{conseq.img}}"/>
<span class="conseq-label">{{conseq.name}}</span>
<select class="consequence-severity" type="text" name="conseq.data.severity" value="{{conseq.data.severity}}" data-dtype="String">
{{#select conseq.data.severity}}
<option value="none">None</option>
<option value="light">Light</option>
<option value="moderate">Moderate</option>
<option value="severe">Severe</option>
<option value="critical">Critical</option>
{{/select}}
</select>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</div>
</div>
</div>
{{!-- Gears Tab --}}
@ -274,14 +301,17 @@
</article>
<article class="flexcol">
<hr>
<h3>Biography : </h3>
<div class="form-group medium-editor">
{{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}}
<div class="form-group editor">
{{editor content=data.history target="data.history" button=true owner=owner editable=editable}}
</div>
<hr>
<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}}
</div>
<hr>
{{>"systems/foundryvtt-shadows-over-sol/templates/editor-notes-gm.html"}}
</article>
</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>