@@ -90,6 +90,15 @@ export class MothershipCreatureSheet extends ActorSheet {
|
||||
return data.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remaining wounds of the creature
|
||||
* @param {JQuery} html
|
||||
* @returns {int} hits.max - hits.value
|
||||
*/
|
||||
getWoundsLeft(html){
|
||||
return html.find(`input[name="system.hits.max"]`).prop('value') - html.find(`input[name="system.hits.value"]`).prop('value');
|
||||
}
|
||||
|
||||
/**
|
||||
* Organize and classify Items for Character sheets.
|
||||
*
|
||||
@@ -175,6 +184,11 @@ export class MothershipCreatureSheet extends ActorSheet {
|
||||
} else {
|
||||
item = duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId));
|
||||
}
|
||||
if (this.actor.system.swarm && this.actor.system.swarm.enabled){
|
||||
//replace the roll damage for swarm actors
|
||||
let new_dice_ammount = item.system.damage.match(/([0-9]+)d[0-9]+/i)[1]*this.getWoundsLeft(html);
|
||||
item.system.damage = item.system.damage.replace(/([0-9]+)(d[0-9]+)/i,`${new_dice_ammount}$2`);
|
||||
}
|
||||
this.actor.rollCheck(null, 'low', 'combat', null, null, item);
|
||||
});
|
||||
|
||||
@@ -187,6 +201,11 @@ export class MothershipCreatureSheet extends ActorSheet {
|
||||
} else {
|
||||
item = duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId));
|
||||
}
|
||||
if (this.actor.system.swarm && this.actor.system.swarm.enabled){
|
||||
//replace the roll damage for swarm actors
|
||||
let new_dice_ammount = item.system.damage.match(/([0-9]+)d[0-9]+/i)[1]*this.getWoundsLeft(html);
|
||||
item.system.damage = item.system.damage.replace(/([0-9]+)(d[0-9]+)/i,`${new_dice_ammount}$2`);
|
||||
}
|
||||
this.actor.rollCheck(null, null, 'damage', null, null, item);
|
||||
});
|
||||
|
||||
@@ -263,6 +282,26 @@ export class MothershipCreatureSheet extends ActorSheet {
|
||||
});
|
||||
}
|
||||
|
||||
// update swarm combat
|
||||
html.find(`input[name="system.swarm.combat.value"]`).change(ev => {
|
||||
let new_combat_value = $(ev.currentTarget).prop('value') * this.getWoundsLeft(html);
|
||||
this.actor.update({"system.stats.combat.value":new_combat_value});
|
||||
});
|
||||
html.find(`input[name="system.hits.max"]`).change(ev => {
|
||||
//Max wounds changed -> calculate new combat stat
|
||||
if (this.actor.system.swarm && this.actor.system.swarm.enabled){
|
||||
let new_combat_value = html.find(`input[name="system.swarm.combat.value"]`).prop('value') * this.getWoundsLeft(html);
|
||||
this.actor.update({"system.stats.combat.value":new_combat_value});
|
||||
}
|
||||
});
|
||||
html.find(`input[name="system.hits.value"]`).change(ev => {
|
||||
//Current wounds changed -> calculate new combat stat
|
||||
if (this.actor.system.swarm && this.actor.system.swarm.enabled){
|
||||
let new_combat_value = html.find(`input[name="system.swarm.combat.value"]`).prop('value') * this.getWoundsLeft(html);
|
||||
this.actor.update({"system.stats.combat.value":new_combat_value});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
@@ -90,6 +90,15 @@ export class DLCreatureSettings extends FormApplication {
|
||||
"system.stats.sanity.enabled": ev.currentTarget.checked
|
||||
});
|
||||
});
|
||||
html.find(`input[type=checkbox][id="system.swarm.enabled"]`).click(ev => {
|
||||
if (ev.currentTarget.checked) {
|
||||
const sanity = html.find(`input[type=checkbox][id="system.swarm.enabled"]`).prop('checked', true);
|
||||
}
|
||||
|
||||
this.object.update({
|
||||
"system.swarm.enabled": ev.currentTarget.checked
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,6 +129,12 @@ export class DLCreatureSettings extends FormApplication {
|
||||
"data.stats.armor.enabled": true
|
||||
});
|
||||
}
|
||||
// swarm
|
||||
if (this.object.system.swarm.enabled) {
|
||||
await this.object.update({
|
||||
"data.swarm.enabled": true
|
||||
});
|
||||
}
|
||||
|
||||
await this.object.updateEmbeddedEntity("OwnedItem", update);
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
<!-- Combat -->
|
||||
<div class="mainstatwrapper">
|
||||
<div class="resource creature-mainstat">
|
||||
|
||||
<span class="ability-mod stat-roll rollable creaturestat" data-key="combat" data-roll="d100"
|
||||
data-label="Combat">{{ localize 'Mosh.Combat' }}</span>
|
||||
data-label="Combat">{{ localize 'Mosh.Combat' }}{{#if system.swarm.enabled}} {{ localize 'Mosh.SwarmWoundShort' }}</span>
|
||||
<input class="creaturestat noborder" style="width: 30px;" type="text" name="system.stats.combat.value"
|
||||
value="{{system.stats.combat.value}}" data-dtype="Number" />
|
||||
</div>
|
||||
@@ -168,11 +169,14 @@
|
||||
<ol class="items-list">
|
||||
<li class="item flexrow item-header">
|
||||
<div class="item-image"></div>
|
||||
|
||||
<div class="skill-stat" style="flex-grow: 2;">{{ localize 'Mosh.Name' }}</div>
|
||||
<div class="skill-stat">{{ localize 'Mosh.Damage' }}{{#if system.swarm.enabled}} {{ localize 'Mosh.SwarmWoundShort' }}{{/if}}</div>
|
||||
<div class="skill-stat">{{ localize 'Mosh.Damage' }}</div>
|
||||
<div class="skill-stat">{{ localize 'Mosh.Ammo' }}</div>
|
||||
<div class="skill-stat">{{ localize 'Mosh.Shots' }}</div>
|
||||
<div class="skill-stat">{{ localize 'Mosh.Range' }}</div>
|
||||
|
||||
<div class="item-controls">
|
||||
<a class="item-control weapon-create" title="{{ localize 'Mosh.CreateWeapon' }}" data-type="weapon"><i class="fas fa-plus"></i>
|
||||
{{ localize 'Mosh.Add' }}</a>
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
<label class="resource-label">{{ localize 'Mosh.Sanity' }}</label>
|
||||
<input type="checkbox" name="actor.system.stats.sanity.enabled" id="system.stats.sanity.enabled" value="{{system.stats.sanity.enabled}}" {{#if actor.system.stats.sanity.enabled}}checked{{/if}} data-dtype="Boolean" />
|
||||
</div>
|
||||
<div class="resource">
|
||||
<label class="resource-label">Swarm</label>
|
||||
<input type="checkbox" name="actor.system.swarm.enabled" id="system.swarm.enabled" value="{{system.swarm.enabled}}" {{#if actor.system.swarm.enabled}}checked{{/if}} data-dtype="Boolean" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user