Fixed swarm, fixed clickable dice hiding, all sheets update on change
This commit is contained in:
@@ -12,7 +12,8 @@ export class MothershipActorSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
template: "systems/mosh/templates/actor/actor-sheet.html",
|
||||
width: 820,
|
||||
height: 820,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "character" }]
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "character" }],
|
||||
submitOnChange: true
|
||||
}
|
||||
return foundry.utils.mergeObject(super.defaultOptions, options);
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ export class MothershipActor extends Actor {
|
||||
}
|
||||
//set values
|
||||
system.bleeding.value = Number(bleedingValue ?? 0);
|
||||
//keep combat updates for swarm types
|
||||
if (system.swarm && system.swarm.enabled){
|
||||
system.stats.combat.value = system.swarm.combat.value * ( system.hits.max - system.hits.value );
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare Ship type specific data
|
||||
@@ -482,7 +486,6 @@ export class MothershipActor extends Actor {
|
||||
enrichedRollResult.dice.forEach(function (roll) {
|
||||
//add header for this roll
|
||||
diceBlock = diceBlock + `
|
||||
<div class="wrapper">
|
||||
<section class="tooltip-part">
|
||||
<div class="dice">
|
||||
`;
|
||||
@@ -545,7 +548,6 @@ export class MothershipActor extends Actor {
|
||||
</ol>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
//set final roll variables in to template
|
||||
@@ -554,7 +556,9 @@ export class MothershipActor extends Actor {
|
||||
<div class="dice-result">
|
||||
<div class="dice-formula">${diceFormula}</div>
|
||||
<div class="dice-tooltip" hidden>
|
||||
${diceBlock}
|
||||
<div class="wrapper">
|
||||
${diceBlock}
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="dice-total">${enrichedRollResult.total}</h4>
|
||||
</div>
|
||||
@@ -1447,7 +1451,7 @@ export class MothershipActor extends Actor {
|
||||
};
|
||||
//create message
|
||||
const template = 'systems/mosh/templates/chat/rollCheck.html';
|
||||
const content = await foundry.applications.handlebars.renderTemplate(template, templateData);
|
||||
const content = await foundry.applications.handlebars.renderTemplate(template, messageData);
|
||||
chatData.content = content;
|
||||
await ChatMessage.create(chatData);
|
||||
//log what was done
|
||||
|
||||
@@ -13,7 +13,8 @@ export class MothershipCreatureSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
template: "systems/mosh/templates/actor/creature-sheet.html",
|
||||
width: 820,
|
||||
height: 770,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "character" }]
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "character" }],
|
||||
submitOnChange: true
|
||||
};
|
||||
|
||||
return foundry.utils.mergeObject(super.defaultOptions, options);
|
||||
@@ -121,15 +122,6 @@ export class MothershipCreatureSheet extends foundry.appv1.sheets.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.
|
||||
*
|
||||
@@ -142,6 +134,7 @@ export class MothershipCreatureSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
//console.log(sheetData);
|
||||
///console.log("sheetdata Above");
|
||||
// Initialize containers.
|
||||
const abilities = [];
|
||||
const gear = [];
|
||||
const skills = [];
|
||||
const weapons = [];
|
||||
@@ -155,7 +148,9 @@ export class MothershipCreatureSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
let item = i.system;
|
||||
i.img = i.img || DEFAULT_TOKEN;
|
||||
|
||||
if (i.type === 'item') {
|
||||
if (i.type === 'ability') {
|
||||
abilities.push(i);
|
||||
} else if (i.type === 'item') {
|
||||
gear.push(i);
|
||||
curWeight += item.weight * item.quantity;
|
||||
} else if (i.type === 'skill') {
|
||||
@@ -197,6 +192,7 @@ export class MothershipCreatureSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
}
|
||||
|
||||
// Assign and return
|
||||
actorData.abilities = abilities;
|
||||
actorData.gear = gear;
|
||||
actorData.skills = skills;
|
||||
actorData.armors = armors;
|
||||
@@ -363,20 +359,34 @@ export class MothershipCreatureSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
|
||||
// Rollable Weapon
|
||||
html.find('.weapon-roll').click(ev => {
|
||||
const li = ev.currentTarget.closest(".item");
|
||||
//const item = duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId));
|
||||
var item;
|
||||
item = foundry.utils.duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId));
|
||||
this.actor.rollCheck(null, 'low', 'combat', null, null, item);
|
||||
const li = ev.currentTarget.closest(".item");
|
||||
var item;
|
||||
item = foundry.utils.duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId));
|
||||
//use swarm combat and damage settings if enabled
|
||||
if (this.actor.system.swarm && this.actor.system.swarm.enabled){
|
||||
//calculate new damage string
|
||||
let new_dice_ammount = item.system.damage.match(/([0-9]+)d[0-9]+/i)[1]*(this.actor.system.hits.max-this.actor.system.hits.value);
|
||||
let swarm_damage_roll_string = item.system.damage.replace(/([0-9]+)(d[0-9]+)/i,`${new_dice_ammount}$2`);
|
||||
this.actor.rollCheck(null, 'low', 'combat', null, null, item, swarm_damage_roll_string);
|
||||
} else {
|
||||
this.actor.rollCheck(null, 'low', 'combat', null, null, item);
|
||||
}
|
||||
});
|
||||
|
||||
// Rollable Damage
|
||||
html.find('.dmg-roll').click(ev => {
|
||||
const li = ev.currentTarget.closest(".item");
|
||||
//const item = duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId));
|
||||
var item;
|
||||
item = foundry.utils.duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId));
|
||||
this.actor.rollCheck(null, null, 'damage', null, null, item);
|
||||
const li = ev.currentTarget.closest(".item");
|
||||
var item;
|
||||
item = foundry.utils.duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId));
|
||||
//use swarm combat and damage settings if enabled
|
||||
if (this.actor.system.swarm && this.actor.system.swarm.enabled){
|
||||
//calculate new damage string
|
||||
let new_dice_ammount = item.system.damage.match(/([0-9]+)d[0-9]+/i)[1]*(this.actor.system.hits.max-this.actor.system.hits.value);
|
||||
let swarm_damage_roll_string = item.system.damage.replace(/([0-9]+)(d[0-9]+)/i,`${new_dice_ammount}$2`);
|
||||
this.actor.rollCheck(null, null, 'damage', null, null, item, swarm_damage_roll_string);
|
||||
} else {
|
||||
this.actor.rollCheck(null, null, 'damage', null, null, item);
|
||||
}
|
||||
});
|
||||
|
||||
// Rollable Item/Anything with a description that we want to click on.
|
||||
@@ -502,25 +512,7 @@ export class MothershipCreatureSheet extends foundry.appv1.sheets.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});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ export class MothershipShipSheetSBT extends foundry.appv1.sheets.ActorSheet {
|
||||
tabs: [{ navSelector: "#sheet-tabs", contentSelector: "#sheet-body", initial: "character" },
|
||||
{ navSelector: "#side-tabs", contentSelector: "#side-body", initial: "close" }],
|
||||
// { navSelector: "#side-tabs", contentSelector: "#side-body", initial: "crew" }],
|
||||
scrollY: [".sheet-body", "scroll-lock"]
|
||||
scrollY: [".sheet-body", "scroll-lock"],
|
||||
submitOnChange: true
|
||||
}
|
||||
|
||||
return foundry.utils.mergeObject(super.defaultOptions, options);
|
||||
|
||||
@@ -11,7 +11,8 @@ export class MothershipShipSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
template: "systems/mosh/templates/actor/ship-sheet.html",
|
||||
width: 700,
|
||||
height: 650,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "character" }]
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "character" }],
|
||||
submitOnChange: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -95,17 +95,22 @@ export class DLCreatureSettings extends FormApplication {
|
||||
"system.swarm.enabled": ev.currentTarget.checked
|
||||
});
|
||||
|
||||
let new_combat = 0;
|
||||
let swarm_combat = 0;
|
||||
let current_combat = 0;
|
||||
|
||||
if (ev.currentTarget.checked) {
|
||||
//set backup of current combat
|
||||
swarm_combat = this.object.system.stats.combat.value;
|
||||
//calculate new combat stat based on wounds,
|
||||
new_combat = this.object.system.swarm.combat.value * ( this.object.system.hits.max - this.object.system.hits.value);
|
||||
current_combat = this.object.system.stats.combat.value * ( this.object.system.hits.max - this.object.system.hits.value);
|
||||
}
|
||||
else{
|
||||
//revert back combat if swarm is disabled
|
||||
new_combat = this.object.system.swarm.combat.value;
|
||||
current_combat = this.object.system.swarm.combat.value;
|
||||
}
|
||||
this.object.update({
|
||||
"system.stats.combat.value":new_combat
|
||||
"system.stats.combat.value":current_combat,
|
||||
"system.swarm.combat.value":swarm_combat
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
{{#if system.swarm.enabled}}
|
||||
<span class="ability-mod stat-roll rollable creaturestat" data-key="combat" data-roll="d100"
|
||||
data-label="Combat">{{ localize 'Mosh.Combat' }} {{ localize 'Mosh.SwarmWoundShort' }}</span>
|
||||
<input class="creaturestat noborder" style="width: 30px;" type="text" name="system.swarm.combat.value"
|
||||
value="{{system.swarm.combat.value}}" data-dtype="Number" />
|
||||
<input class="creaturestat noborder" style="width: 30px;" type="text" name="system.stats.combat.value"
|
||||
value="{{system.stats.combat.value}}" data-dtype="Number" />
|
||||
{{else}}
|
||||
<span class="ability-mod stat-roll rollable creaturestat" data-key="combat" data-roll="d100"
|
||||
data-label="Combat">{{ localize 'Mosh.Combat' }}</span>
|
||||
|
||||
Reference in New Issue
Block a user