Skip to content

Commit f152716

Browse files
committed
Support equipping/unequipping EVA suits.
1 parent f0708de commit f152716

File tree

10 files changed

+106
-6
lines changed

10 files changed

+106
-6
lines changed

css/deathinspace.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,15 @@
608608
.deathinspace.sheet.actor.character .belongings-tab .item-controls {
609609
border-left: 1px dotted black;
610610
}
611+
.deathinspace.sheet.actor.character .belongings-tab .item-equip {
612+
margin-left: 4px;
613+
}
614+
.deathinspace.sheet.actor.character .belongings-tab .item-equip.equipped {
615+
color: red;
616+
}
617+
.deathinspace.sheet.actor.character .belongings-tab .item-equip.unequipped {
618+
color: gray;
619+
}
611620
.deathinspace.sheet.actor.character .belongings-tab .belongings-wrapper {
612621
display: flex;
613622
flex-direction: column;

module/actor/sheet/character-sheet.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class DISCharacterSheet extends DISActorSheet {
3434
.on("click", this._onDamageRoll.bind(this));
3535
html.find(".add-belonging").click(this._onAddBelonging.bind(this));
3636
html.find("a.regenerate").click(this._onRegenerate.bind(this));
37+
html.find("a.item-equip").click(this._onEquipToggle.bind(this));
3738
}
3839

3940
/** @override */
@@ -63,18 +64,28 @@ export class DISCharacterSheet extends DISActorSheet {
6364
.filter((item) => item.type === CONFIG.DIS.itemTypes.weapon)
6465
.sort(byName);
6566
sheetData.data.armor = sheetData.items
66-
.filter((item) => item.type === CONFIG.DIS.itemTypes.armor)
67+
.filter((item) => {
68+
return (
69+
item.type === CONFIG.DIS.itemTypes.armor &&
70+
(!item.data.equippable || item.data.equipped)
71+
)
72+
})
6773
.sort(byName);
6874
sheetData.data.equipment = sheetData.items
69-
.filter((item) => item.type === CONFIG.DIS.itemTypes.equipment)
70-
.sort(byName);
75+
.filter((item) => {
76+
return (
77+
item.type === CONFIG.DIS.itemTypes.equipment ||
78+
(item.type === CONFIG.DIS.itemTypes.armor && (item.data.equippable && !item.data.equipped))
79+
);
80+
})
81+
.sort(byName);
7182
const allSlotItems = [
7283
...sheetData.data.weapons,
7384
...sheetData.data.armor,
7485
...sheetData.data.equipment,
7586
];
7687
sheetData.data.totalSlots = allSlotItems
77-
.map((item) => item.data.slots)
88+
.map((item) => item.data.equippable ? (item.data.equipped ? 0 : item.data.slots) : item.data.slots)
7889
.reduce((prev, next) => prev + next, 0);
7990
sheetData.data.maxSlots = 12 + sheetData.data.abilities.body.value;
8091
}
@@ -129,6 +140,19 @@ export class DISCharacterSheet extends DISActorSheet {
129140
this.actor.rollItemDamage(itemId);
130141
}
131142

143+
async _onEquipToggle(event) {
144+
event.preventDefault();
145+
const anchor = $(event.currentTarget);
146+
const li = anchor.parents(".item");
147+
const itemId = li.data("itemId");
148+
const item = this.actor.items.get(itemId);
149+
if (item.equipped) {
150+
await item.unequip();
151+
} else {
152+
await item.equip();
153+
}
154+
}
155+
132156
_onRegenerate(event) {
133157
event.preventDefault();
134158
// confirm before regenerating

module/item/item.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,15 @@
22
* @extends {Item}
33
*/
44
export class DISItem extends Item {
5+
get equipped() {
6+
return this.data.data.equipped === true;
7+
}
8+
9+
async equip() {
10+
await this.update({ "data.equipped": true });
11+
}
12+
13+
async unequip() {
14+
await this.update({ "data.equipped": false });
15+
}
516
}

packs/armor.db

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
{"name":"EVA Suit - Light","type":"armor","img":"systems/deathinspace/assets/images/icons/armor/eva-suit-light.png","data":{"cost":200,"notes":"<p>Defense rating +0, 4 item slots when carried, donning time 5 minutes.</p>\n<ul>\n<li>No thrusters. Can instead use a manned maneuvering unit (MMU), a propulsion unit carrying the same nitrogen thrusters as the heavy EVA suit. When using the MMU, the wearer can not climb, dodge or perform similar tasks requiring dexterity.</li>\n</ul>\n<p>&nbsp;</p>\n<p>ALL EVA SUITS ARE EQUIPPED WITH&nbsp;THE FOLLOWING:</p>\n<ul>\n<li>Seven hours of oxygen supply and built-in life support.</li>\n<li>Two-way voice communication.</li>\n<li>Display for the suit&rsquo;s status&nbsp;and the wearer&rsquo;s health&nbsp;parameters.</li>\n<li>Cooling system and pressure&nbsp;regulation functions.</li>\n<li>An umbilical cable with which&nbsp;the wearer can connect the&nbsp;suit to the life support&nbsp;system of a spacecraft or a&nbsp; mobile life support system.</li>\n<li>A can of repair foam for unexpected damage, like bullet holes or other penetrating trauma.</li>\n<li>Magnetic boots.</li>\n</ul>\n<p>&nbsp;</p>","slots":4,"units":1,"defenseRatingBonus":0,"lifeSupport":{"max":7,"value":7},"protectsAgainst":"","condition":{"max":0,"value":0}},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"BSEmAXWYPuoWh3m2":3},"flags":{},"_id":"VZKHAQi2XgrZTUYD"}
55
{"name":"Riot Shield","type":"armor","img":"systems/deathinspace/assets/images/icons/armor/riot-shield.png","data":{"cost":400,"notes":"","slots":4,"units":1,"defenseRatingBonus":0,"lifeSupport":{"max":["",""],"value":0},"protectsAgainst":"All projectiles","condition":{"max":0,"value":0}},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"BSEmAXWYPuoWh3m2":3},"flags":{},"_id":"mz1R4Le7TO7wviX0"}
66
{"name":"Medium: Flak Jacket","type":"armor","img":"systems/deathinspace/assets/images/icons/armor/medium-flak-jacket.png","data":{"cost":250,"notes":"","slots":3,"units":1,"defenseRatingBonus":2,"lifeSupport":{"max":null,"value":0},"protectsAgainst":"Explosives, shotguns and small arms"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"BSEmAXWYPuoWh3m2":3},"flags":{},"_id":"uCSGLAAjQ61dcdZQ"}
7+
{"_id":"9XJfAnUe6U02vLbk","name":"EVA Suit - Heavy","type":"armor","img":"systems/deathinspace/assets/images/icons/armor/eva-suit-heavy.png","data":{"cost":400,"notes":"<p>Defense rating +2 (only against melee weapons), 8 item slots when carried, donning time 30 minutes.</p>\n<ul>\n<li>Heavy and unwieldy, suitable only in low gravity environments.</li>\n<li>Power system with nitrogen-propelled thrusters.</li>\n<li>Protects against jagged rocks and radiation.</li>\n</ul>\n<p>&nbsp;</p>\n<p>ALL EVA SUITS ARE EQUIPPED WITH THE FOLLOWING:</p>\n<ul>\n<li>Seven hours of oxygen supply and built-in life support.</li>\n<li>Two-way voice communication.</li>\n<li>Display for the suit&rsquo;s status and the wearer&rsquo;s health parameters.</li>\n<li>Cooling system and pressure&nbsp;regulation functions.</li>\n<li>An umbilical cable with which the wearer can connect the suit to the life support system of a spacecraft or a&nbsp; mobile life support system.</li>\n<li>A can of repair foam for unexpected damage, like bullet holes or other penetrating trauma.</li>\n<li>Magnetic boots.</li>\n</ul>\n<p>&nbsp;</p>","slots":8,"defenseRatingBonus":2,"protectsAgainst":"Melee weapons","units":1,"lifeSupport":{"max":7,"value":7},"condition":{"max":0,"value":0},"equippable":true},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"BSEmAXWYPuoWh3m2":3},"flags":{}}
8+
{"_id":"VZKHAQi2XgrZTUYD","name":"EVA Suit - Light","type":"armor","img":"systems/deathinspace/assets/images/icons/armor/eva-suit-light.png","data":{"cost":200,"notes":"<p>Defense rating +0, 4 item slots when carried, donning time 5 minutes.</p>\n<ul>\n<li>No thrusters. Can instead use a manned maneuvering unit (MMU), a propulsion unit carrying the same nitrogen thrusters as the heavy EVA suit. When using the MMU, the wearer can not climb, dodge or perform similar tasks requiring dexterity.</li>\n</ul>\n<p>&nbsp;</p>\n<p>ALL EVA SUITS ARE EQUIPPED WITH&nbsp;THE FOLLOWING:</p>\n<ul>\n<li>Seven hours of oxygen supply and built-in life support.</li>\n<li>Two-way voice communication.</li>\n<li>Display for the suit&rsquo;s status&nbsp;and the wearer&rsquo;s health&nbsp;parameters.</li>\n<li>Cooling system and pressure&nbsp;regulation functions.</li>\n<li>An umbilical cable with which&nbsp;the wearer can connect the&nbsp;suit to the life support&nbsp;system of a spacecraft or a&nbsp; mobile life support system.</li>\n<li>A can of repair foam for unexpected damage, like bullet holes or other penetrating trauma.</li>\n<li>Magnetic boots.</li>\n</ul>\n<p>&nbsp;</p>","slots":4,"defenseRatingBonus":0,"protectsAgainst":"","units":1,"lifeSupport":{"max":7,"value":7},"condition":{"max":0,"value":0},"equippable":true},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"BSEmAXWYPuoWh3m2":3},"flags":{}}

source/templates/actor/character-sheet.pug

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,23 @@ form(class="{{cssClass}}" autocomplete="off")
214214
| -
215215
| {{/if}}
216216
.equipment-slots
217+
| {{#if item.data.equippable}}
218+
| {{#if item.data.equipped}}
219+
| -
220+
a.item-control.item-equip.equipped(title="Unequip")
221+
i.fas.fa-shield-alt
222+
| {{else}}
223+
| {{item.data.slots}}
224+
a.item-control.item-equip.unequipped(title="Equip")
225+
i.fas.fa-shield-alt
226+
| {{/if}}
227+
| {{else}}
217228
| {{#if item.data.slots}}
218229
| {{ item.data.slots}}
219230
| {{else}}
220231
| -
221232
| {{/if}}
233+
| {{/if}}
222234
.item-controls
223235
a.item-control.item-edit
224236
i.fas.fa-edit
@@ -292,7 +304,19 @@ form(class="{{cssClass}}" autocomplete="off")
292304
.armor-dr-bonus
293305
| {{item.data.defenseRatingBonus}}
294306
.armor-slots
307+
| {{#if item.data.equippable}}
308+
| {{#if item.data.equipped}}
309+
| -
310+
a.item-control.item-equip.equipped(title="Unequip")
311+
i.fas.fa-shield-alt
312+
| {{else}}
313+
| {{item.data.slots}}
314+
a.item-control.item-equip.unequipped(title="Equip")
315+
i.fas.fa-shield-alt
316+
| {{/if}}
317+
| {{else}}
295318
| {{item.data.slots}}
319+
| {{/if}}
296320
.item-controls
297321
a.item-control.item-edit
298322
i.fas.fa-edit

source/templates/actor/character-sheet.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,15 @@
419419
.item-controls {
420420
border-left: 1px dotted black;
421421
}
422+
.item-equip {
423+
margin-left: 4px;
424+
}
425+
.item-equip.equipped {
426+
color: red;
427+
}
428+
.item-equip.unequipped {
429+
color: gray;
430+
}
422431
.belongings-wrapper {
423432
display: flex;
424433
flex-direction: column;

source/templates/item/armor-sheet.pug

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ form(class="{{cssClass}}")
4747
label
4848
| Defense Rating Bonus
4949
input(type="number" name="data.defenseRatingBonus" value="{{data.data.defenseRatingBonus}}" placeholder="0" data-dtype="Number")
50+
.form-group
51+
label
52+
| Equippable
53+
| <input type="checkbox" name="data.equippable" {{checked data.data.equippable}} />

template.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"armor": {
121121
"templates": ["baseEquipment"],
122122
"defenseRatingBonus": 0,
123+
"equippable": false,
123124
"protectsAgainst": ""
124125
},
125126
"equipment": {

templates/actor/character-sheet.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,17 @@
248248
{{/if}}
249249
</div>
250250
<div class="equipment-slots">
251-
{{#if item.data.slots}}
251+
{{#if item.data.equippable}}
252+
{{#if item.data.equipped}}
253+
-<a class="item-control item-equip equipped" title="Unequip"><i class="fas fa-shield-alt"></i></a>{{else}}
254+
{{item.data.slots}}<a class="item-control item-equip unequipped" title="Equip"><i class="fas fa-shield-alt"></i></a>{{/if}}
255+
{{else}}
256+
{{#if item.data.slots}}
252257
{{ item.data.slots}}
253258
{{else}}
254259
-
255260
{{/if}}
261+
{{/if}}
256262
</div>
257263
<div class="item-controls"><a class="item-control item-edit"><i class="fas fa-edit"> </i></a><a class="item-control item-delete"><i class="fas fa-trash"> </i></a></div>
258264
</div>{{/each}}
@@ -321,7 +327,14 @@
321327
<div class="armor-dr-bonus">
322328
{{item.data.defenseRatingBonus}}</div>
323329
<div class="armor-slots">
324-
{{item.data.slots}}</div>
330+
{{#if item.data.equippable}}
331+
{{#if item.data.equipped}}
332+
-<a class="item-control item-equip equipped" title="Unequip"><i class="fas fa-shield-alt"></i></a>{{else}}
333+
{{item.data.slots}}<a class="item-control item-equip unequipped" title="Equip"><i class="fas fa-shield-alt"></i></a>{{/if}}
334+
{{else}}
335+
{{item.data.slots}}
336+
{{/if}}
337+
</div>
325338
<div class="item-controls"><a class="item-control item-edit"><i class="fas fa-edit"> </i></a><a class="item-control item-delete"><i class="fas fa-trash"> </i></a></div>
326339
</div>{{/each}}
327340
</div>

templates/item/armor-sheet.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
<label>Defense Rating Bonus</label>
4545
<input type="number" name="data.defenseRatingBonus" value="{{data.data.defenseRatingBonus}}" placeholder="0" data-dtype="Number"/>
4646
</div>
47+
<div class="form-group">
48+
<label>Equippable</label><input type="checkbox" name="data.equippable" {{checked data.data.equippable}} />
49+
</div>
4750
</div>
4851
</div>
4952
</section>

0 commit comments

Comments
 (0)