Added SoftLock on NPC sheet and +/- button to add or subtract Casualties and Panic.

This commit is contained in:
Vlyan
2022-01-21 18:03:57 +01:00
parent d6ee391ff5
commit ff413ed894
11 changed files with 103 additions and 28 deletions

View File

@@ -1,8 +1,9 @@
# Changelog # Changelog
## 1.6.0 - SoftLock ## 1.6.0 - SoftLock
- Added SoftLock on PC/NPC sheet - Added SoftLock on PC/NPC/Armies sheet.
- PC & NPC Sheet : Added +/- button to add or subtract Fatigue and Strife - PC & NPC Sheet : Added +/- button to add or subtract Fatigue and Strife.
- Armies Sheet : Added +/- button to add or subtract Casualties and Panic.
- GmMonitor : Added ability to add or subtract fatigue/strife/void/casualties/panic points on mouse clic (left/right). - GmMonitor : Added ability to add or subtract fatigue/strife/void/casualties/panic points on mouse clic (left/right).
## 1.5.0 - FoundryVTT v9 Compatibility ## 1.5.0 - FoundryVTT v9 Compatibility

View File

@@ -113,6 +113,13 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
return; return;
} }
// Casualties/Panic +/-
html.find(".addsub-control").on("click", this._modifyCasualtiesOrPanic.bind(this));
if (this.actor.data.data.soft_locked) {
return;
}
// Delete the linked Actor (warlord/commander) // Delete the linked Actor (warlord/commander)
html.find(".actor-remove-control").on("click", this._removeLinkedActor.bind(this)); html.find(".actor-remove-control").on("click", this._removeLinkedActor.bind(this));
} }
@@ -152,7 +159,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
*/ */
async _onDrop(event) { async _onDrop(event) {
// *** Everything below here is only needed if the sheet is editable *** // *** Everything below here is only needed if the sheet is editable ***
if (!this.isEditable) { if (!this.isEditable || this.actor.data.data.soft_locked) {
return; return;
} }
@@ -184,7 +191,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
*/ */
async _onDropActors(type, event) { async _onDropActors(type, event) {
// *** Everything below here is only needed if the sheet is editable *** // *** Everything below here is only needed if the sheet is editable ***
if (!this.isEditable) { if (!this.isEditable || this.actor.data.data.soft_locked) {
return; return;
} }
@@ -270,4 +277,53 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
} }
return this.actor.update({ data: actorData }); return this.actor.update({ data: actorData });
} }
/**
* Add or Subtract Casualties/Panic (+/- buttons)
* @param {Event} event
* @private
*/
async _modifyCasualtiesOrPanic(event) {
event.preventDefault();
event.stopPropagation();
const elmt = $(event.currentTarget);
const type = elmt.data("type");
let mod = elmt.data("value");
if (!mod) {
return;
}
switch (type) {
case "casualties":
await this.actor.update({
data: {
battle_readiness: {
casualties_strength: {
value: Math.max(
0,
this.actor.data.data.battle_readiness.casualties_strength.value + mod
),
},
},
},
});
break;
case "panic":
await this.actor.update({
data: {
battle_readiness: {
panic_discipline: {
value: Math.max(0, this.actor.data.data.battle_readiness.panic_discipline.value + mod),
},
},
},
});
break;
default:
console.warn("L5R5E | Unsupported type", type);
break;
}
}
} }

View File

@@ -31,9 +31,6 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
// Split Items by types // Split Items by types
sheetData.data.splitItemsList = this._splitItems(sheetData); sheetData.data.splitItemsList = this._splitItems(sheetData);
// Shortcut for some tests
sheetData.data.editable_not_soft_locked = sheetData.editable && !sheetData.data.data.soft_locked;
return sheetData; return sheetData;
} }

View File

@@ -51,6 +51,9 @@ export class BaseSheetL5r5e extends ActorSheet {
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
}); });
// Shortcut for some tests
sheetData.data.editable_not_soft_locked = sheetData.editable && !sheetData.data.data.soft_locked;
return sheetData; return sheetData;
} }

File diff suppressed because one or more lines are too long

View File

@@ -24,6 +24,11 @@
display: inline-grid; display: inline-grid;
position: relative; position: relative;
.attributes-buttons {
line-height: 13px;
text-align: center;
}
strong { strong {
color: $l5r5e-label; color: $l5r5e-label;
text-align: center; text-align: center;

View File

@@ -147,6 +147,7 @@
} }
}, },
"army": { "army": {
"templates": ["softlock"],
"warlord": "", "warlord": "",
"warlord_actor_id": null, "warlord_actor_id": null,
"allies_backers": "", "allies_backers": "",

View File

@@ -1,25 +1,33 @@
<form class="{{cssClass}}" data-lang="{{localize 'I18N.Language'}}" autocomplete="off"> <form class="{{cssClass}}" data-lang="{{localize 'I18N.Language'}}" autocomplete="off">
{{!-- Sheet Header --}} {{!-- Sheet Header --}}
<header class="sheet-header"> <header class="sheet-header">
<img class="profile-img dragndrop-actor-id pointer" src="{{data.img}}" data-edit="img" data-actor-id="{{actor.id}}" draggable="true" title="{{data.name}}"/> <img class="profile-img dragndrop-actor-id pointer" src="{{data.img}}" {{#if data.editable_not_soft_locked}}data-edit="img"{{/if}} data-actor-id="{{actor.id}}" draggable="true" title="{{data.name}}"/>
<div class="header-fields identity-wrapper"> <div class="header-fields identity-wrapper">
<h1 class="charname"><input name="name" type="text" value="{{data.name}}" placeholder="Name"/></h1> <h1 class="charname"><input name="name" type="text" value="{{data.name}}" placeholder="Name" {{^if data.editable_not_soft_locked}}disabled{{/if}}/></h1>
<div class="readiness"> <div class="readiness">
<ul> <ul>
<li> <li>
<input name="data.battle_readiness.casualties_strength.value" type="number" value="{{data.data.battle_readiness.casualties_strength.value}}" /> <input name="data.battle_readiness.casualties_strength.value" type="number" value="{{data.data.battle_readiness.casualties_strength.value}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
<strong>{{localize 'l5r5e.army.battle_readiness.casualties'}}</strong> <strong>{{localize 'l5r5e.army.battle_readiness.casualties'}}</strong>
<span class="attributes-buttons">
<i class="addsub-control pointer-choice fa fa-minus-square" data-type="casualties" data-value="-1"></i>
<i class="addsub-control pointer-choice fa fa-plus-square" data-type="casualties" data-value="1"></i>
</span>
</li> </li>
<li> <li>
<input name="data.battle_readiness.casualties_strength.max" type="number" value="{{data.data.battle_readiness.casualties_strength.max}}" /> <input name="data.battle_readiness.casualties_strength.max" type="number" value="{{data.data.battle_readiness.casualties_strength.max}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
<strong>{{localize 'l5r5e.army.battle_readiness.strength'}}</strong> <strong>{{localize 'l5r5e.army.battle_readiness.strength'}}</strong>
</li> </li>
<li> <li>
<input name="data.battle_readiness.panic_discipline.value" type="number" value="{{data.data.battle_readiness.panic_discipline.value}}" /> <input name="data.battle_readiness.panic_discipline.value" type="number" value="{{data.data.battle_readiness.panic_discipline.value}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
<strong>{{localize 'l5r5e.army.battle_readiness.panic'}}</strong> <strong>{{localize 'l5r5e.army.battle_readiness.panic'}}</strong>
<span class="attributes-buttons">
<i class="addsub-control pointer-choice fa fa-minus-square" data-type="panic" data-value="-1"></i>
<i class="addsub-control pointer-choice fa fa-plus-square" data-type="panic" data-value="1"></i>
</span>
</li> </li>
<li> <li>
<input name="data.battle_readiness.panic_discipline.max" type="number" value="{{data.data.battle_readiness.panic_discipline.max}}" /> <input name="data.battle_readiness.panic_discipline.max" type="number" value="{{data.data.battle_readiness.panic_discipline.max}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
<strong>{{localize 'l5r5e.army.battle_readiness.discipline'}}</strong> <strong>{{localize 'l5r5e.army.battle_readiness.discipline'}}</strong>
</li> </li>
</ul> </ul>

View File

@@ -1,58 +1,62 @@
<div class="header-fields warlord"> <div class="header-fields warlord">
<fieldset> <fieldset>
<legend>{{^if data.data.warlord_actor_id}}<i class="fa fa-sign-in-alt" aria-hidden="true"></i> {{/if}}{{localize 'l5r5e.army.warlord'}}</legend> <legend>{{#if data.editable_not_soft_locked}}{{^if data.data.warlord_actor_id}}<i class="fa fa-sign-in-alt" aria-hidden="true"></i> {{/if}}{{/if}}{{localize 'l5r5e.army.warlord'}}</legend>
<p class="warlord-name"> <p class="warlord-name">
{{#if data.data.warlord_actor_id}} {{#if data.data.warlord_actor_id}}
<label> <label>
<a data-actor-id="{{data.data.warlord_actor_id}}" class="open-sheet-actor-id">{{data.data.warlord}}</a> <a data-actor-id="{{data.data.warlord_actor_id}}" class="open-sheet-actor-id">{{data.data.warlord}}</a>
{{#if data.editable_not_soft_locked}}
<span data-actor-id="{{actor.id}}" data-type="warlord" class="actor-remove-control pointer" title="{{localize 'Delete'}}"><i class="fas fa-trash"></i></span> <span data-actor-id="{{actor.id}}" data-type="warlord" class="actor-remove-control pointer" title="{{localize 'Delete'}}"><i class="fas fa-trash"></i></span>
{{/if}}
</label> </label>
{{else}} {{else}}
<input name="data.warlord" type="text" value="{{data.data.warlord}}" /> <input name="data.warlord" type="text" value="{{data.data.warlord}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
{{/if}} {{/if}}
</p> </p>
<p> <p>
<strong>{{localize 'l5r5e.army.allies_backers'}}</strong> <strong>{{localize 'l5r5e.army.allies_backers'}}</strong>
<textarea type="text" name="data.allies_backers">{{data.data.allies_backers}}</textarea> <textarea type="text" name="data.allies_backers" {{^if data.editable_not_soft_locked}}disabled{{/if}}>{{data.data.allies_backers}}</textarea>
</p> </p>
<p> <p>
<strong>{{localize 'l5r5e.army.purpose_mustering'}}</strong> <strong>{{localize 'l5r5e.army.purpose_mustering'}}</strong>
<textarea type="text" name="data.purpose_mustering">{{data.data.purpose_mustering}}</textarea> <textarea type="text" name="data.purpose_mustering" {{^if data.editable_not_soft_locked}}disabled{{/if}}>{{data.data.purpose_mustering}}</textarea>
</p> </p>
</fieldset> </fieldset>
</div> </div>
<div class="header-fields commander"> <div class="header-fields commander">
<fieldset> <fieldset>
<legend>{{^if data.data.commander_actor_id}}<i class="fa fa-sign-in-alt" aria-hidden="true"></i> {{/if}}{{localize 'l5r5e.army.commander'}}</legend> <legend>{{#if data.editable_not_soft_locked}}{{^if data.data.commander_actor_id}}<i class="fa fa-sign-in-alt" aria-hidden="true"></i> {{/if}}{{/if}}{{localize 'l5r5e.army.commander'}}</legend>
<div class="warlord-name"> <div class="warlord-name">
{{#if data.data.commander_actor_id}} {{#if data.data.commander_actor_id}}
<label> <label>
<a data-actor-id="{{data.data.commander_actor_id}}" class="open-sheet-actor-id">{{data.data.commander}}</a> <a data-actor-id="{{data.data.commander_actor_id}}" class="open-sheet-actor-id">{{data.data.commander}}</a>
{{#if data.editable_not_soft_locked}}
<span data-actor-id="{{actor.id}}" data-type="commander" class="actor-remove-control pointer" title="{{localize 'Delete'}}"><i class="fas fa-trash"></i></span> <span data-actor-id="{{actor.id}}" data-type="commander" class="actor-remove-control pointer" title="{{localize 'Delete'}}"><i class="fas fa-trash"></i></span>
{{/if}}
</label> </label>
{{else}} {{else}}
<input name="data.commander" type="text" value="{{data.data.commander}}" /> <input name="data.commander" type="text" value="{{data.data.commander}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
{{/if}} {{/if}}
</div> </div>
<div class="standing"> <div class="standing">
<ul> <ul>
<li> <li>
<strong>{{localize 'l5r5e.social.honor'}}</strong> <strong>{{localize 'l5r5e.social.honor'}}</strong>
<input name="data.commander_standing.honor" type="number" value="{{data.data.commander_standing.honor}}" /> <input name="data.commander_standing.honor" type="number" value="{{data.data.commander_standing.honor}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
</li> </li>
<li> <li>
<strong>{{localize 'l5r5e.social.glory'}}</strong> <strong>{{localize 'l5r5e.social.glory'}}</strong>
<input name="data.commander_standing.glory" type="number" value="{{data.data.commander_standing.glory}}" /> <input name="data.commander_standing.glory" type="number" value="{{data.data.commander_standing.glory}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
</li> </li>
<li> <li>
<strong>{{localize 'l5r5e.social.status'}}</strong> <strong>{{localize 'l5r5e.social.status'}}</strong>
<input name="data.commander_standing.status" type="number" value="{{data.data.commander_standing.status}}" /> <input name="data.commander_standing.status" type="number" value="{{data.data.commander_standing.status}}" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>
</li> </li>
</ul> </ul>
</div> </div>
<label> <label>
<strong>{{localize 'l5r5e.army.commander_abilities'}}</strong> <strong>{{localize 'l5r5e.army.commander_abilities'}}</strong>
<textarea type="text" name="data.commander_abilities">{{data.data.commander_abilities}}</textarea> <textarea type="text" name="data.commander_abilities" {{^if data.editable_not_soft_locked}}disabled{{/if}}>{{data.data.commander_abilities}}</textarea>
</label> </label>
</fieldset> </fieldset>
<fieldset class="army-abilities"> <fieldset class="army-abilities">

View File

@@ -1,13 +1,13 @@
<fieldset class="cohort-content"> <fieldset class="cohort-content">
<legend class="section-header"> <legend class="section-header">
{{localize 'l5r5e.army.cohort.title'}} {{localize 'l5r5e.army.cohort.title'}}
{{#if options.editable}} {{#if data.editable_not_soft_locked}}
<a data-item-type="army_cohort" class="army-cohort-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a> <a data-item-type="army_cohort" class="army-cohort-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
{{/if}} {{/if}}
</legend> </legend>
<ul class="item-list"> <ul class="item-list">
{{#each data.splitItemsList.army_cohort as |item|}} {{#each data.splitItemsList.army_cohort as |item|}}
{{> 'systems/l5r5e/templates/items/army-cohort/army-cohort-entry.html' cohort=item editable=../options.editable}} {{> 'systems/l5r5e/templates/items/army-cohort/army-cohort-entry.html' cohort=item editable=../data.editable_not_soft_locked}}
{{/each}} {{/each}}
</ul> </ul>
</fieldset> </fieldset>

View File

@@ -1,13 +1,13 @@
<fieldset class="fortification-content"> <fieldset class="fortification-content">
<legend class="section-header"> <legend class="section-header">
{{localize 'l5r5e.army.fortification.title'}} {{localize 'l5r5e.army.fortification.title'}}
{{#if options.editable}} {{#if data.editable_not_soft_locked}}
<a data-item-type="army_fortification" class="army-fortification-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a> <a data-item-type="army_fortification" class="army-fortification-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
{{/if}} {{/if}}
</legend> </legend>
<ul class="item-list"> <ul class="item-list">
{{#each data.splitItemsList.army_fortification as |item|}} {{#each data.splitItemsList.army_fortification as |item|}}
{{> 'systems/l5r5e/templates/items/army-fortification/army-fortification-entry.html' fortification=item editable=../options.editable}} {{> 'systems/l5r5e/templates/items/army-fortification/army-fortification-entry.html' fortification=item editable=../data.editable_not_soft_locked}}
{{/each}} {{/each}}
</ul> </ul>
</fieldset> </fieldset>