Fixes from 29th of june
This commit is contained in:
parent
b535a86116
commit
297c94adb7
@ -185,6 +185,13 @@ export class Hero6ActorSheet extends ActorSheet {
|
||||
this.actor.rollWeapon(skillId)
|
||||
});
|
||||
|
||||
html.find('.hold-action').click((event) => {
|
||||
this.actor.holdAction()
|
||||
});
|
||||
html.find('.abort-action').click((event) => {
|
||||
this.actor.abortAction()
|
||||
});
|
||||
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
this.options.editScore = !this.options.editScore;
|
||||
this.render(true);
|
||||
|
@ -385,11 +385,39 @@ export class Hero6Actor extends Actor {
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async cleanCombat() {
|
||||
await this.setFlag("world", "hold-action", false)
|
||||
await this.setFlag("world", "abort-action", false)
|
||||
}
|
||||
async holdAction() {
|
||||
if (this.getFlag("world", "hold-action")) {
|
||||
await this.setFlag("world", "hold-action", false)
|
||||
} else {
|
||||
await this.setFlag("world", "hold-action", true)
|
||||
}
|
||||
game.combat.rebuildInitiative()
|
||||
}
|
||||
async abortAction() {
|
||||
if (this.getFlag("world", "abort-action")) {
|
||||
await this.setFlag("world", "abort-action", false)
|
||||
} else {
|
||||
await this.setFlag("world", "abort-action", true)
|
||||
}
|
||||
game.combat.rebuildInitiative()
|
||||
}
|
||||
getHoldAction() {
|
||||
return this.getFlag("world", "hold-action")
|
||||
}
|
||||
getAbortAction() {
|
||||
return this.getFlag("world", "abort-action")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
hasPhase(segmentNumber) {
|
||||
let index = Math.min(Math.max(this.system.characteristics.spd.value, 1), 12) // Security bounds
|
||||
let phases = __speed2Segments[index]
|
||||
console.log("index", segmentNumber, index, phases, phases.includes(segmentNumber))
|
||||
return phases.includes(segmentNumber)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
|
@ -16,47 +16,33 @@ export class Hero6CombatTracker extends CombatTracker {
|
||||
export class Hero6Combat extends Combat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static init() {
|
||||
static ready() {
|
||||
Hooks.on("getCombatTrackerEntryContext", (html, options) => { Hero6Combat.pushMenuOptions(html, options); });
|
||||
game.combat.settings.resource = "characteristics.spd.value";
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static pushMenuOptions(html, options) {
|
||||
console.log(">>>>>>>>>>>>>>>>>>>>>>>< MENU OPTIONS!!!!!")
|
||||
let newOpt
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
let option = options[i];
|
||||
if (option.name == 'COMBAT.CombatantReroll') { // Replace !
|
||||
option.name = "Hold action";
|
||||
option.name = "Hold/Unhold action";
|
||||
option.condition = true;
|
||||
option.icon = '<i class="far fa-question-circle"></i>';
|
||||
option.callback = target => {
|
||||
Hero6Combat.holdAction(target.data('combatant-id'));
|
||||
}
|
||||
newOpt = duplicate(option)
|
||||
//newOpt = duplicate(option)
|
||||
}
|
||||
}
|
||||
newOpt.name = "Abort action"
|
||||
newOpt.callback = target => {
|
||||
Hero6Combat.abortAction(target.data('combatant-id'));
|
||||
}
|
||||
options.push( newOpt)
|
||||
//options.push(newOpt)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static holdAction(combatantId) {
|
||||
console.log("Combatant HOLD : ", combatantId)
|
||||
const combatant = game.combat.combatants.get(combatantId)
|
||||
combatant.setFlag("world", "hero6-hold-action", true)
|
||||
combatant.update({name: combatant.name + " (H)"})
|
||||
console.log("HOLD", combatant)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static abortAction(html, combatantId) {
|
||||
console.log("Combatant ABORT : ", combatantId);
|
||||
const combatant = game.combat.combatants.get(combatantId);
|
||||
combatant.setFlag("world", "hero6-abort-action", true)
|
||||
combatant.update({name: combatant.name + " (A)"})
|
||||
console.log("ABORT", combatant)
|
||||
combatant.actor.holdAction()
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -68,27 +54,69 @@ export class Hero6Combat extends Combat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async computeInitiative(c) {
|
||||
let id = c._id || c.id
|
||||
if (c.actor.hasPhase(this.segmentNumber)) {
|
||||
let baseInit = c.actor ? c.actor.getBaseInit() : - 1;
|
||||
await this.updateEmbeddedDocuments("Combatant", [{ _id: id, initiative: baseInit }]);
|
||||
} else {
|
||||
await this.updateEmbeddedDocuments("Combatant", [{ _id: id, initiative: -1, visible: false, active: false }]);
|
||||
async startCombat() {
|
||||
game.combat.settings.resource = "characteristics.spd.value";
|
||||
|
||||
let updList = []
|
||||
for (let c of this.combatants) {
|
||||
this.computeInitiative(c, updList)
|
||||
await c.actor.cleanCombat()
|
||||
}
|
||||
console.log("Combatant", c)
|
||||
if (updList.length > 0) {
|
||||
await this.updateEmbeddedDocuments("Combatant", updList);
|
||||
}
|
||||
|
||||
super.startCombat();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeInitiative(c, updList) {
|
||||
let id = c._id || c.id
|
||||
if (c.actor.hasPhase(this.segmentNumber) || c.actor.getHoldAction()) {
|
||||
let baseInit = c.actor ? c.actor.getBaseInit() : 0;
|
||||
let name = c.actor.name
|
||||
if (c.actor.getHoldAction()) {
|
||||
name = c.actor.name + " (H)"
|
||||
}
|
||||
if (c.actor.getAbortAction()) {
|
||||
name = c.actor.name + " (A)"
|
||||
}
|
||||
updList.push({ _id: id, name: name, initiative: baseInit, holdAction: c.holdAction })
|
||||
} else {
|
||||
updList.push({ _id: id, name: name, initiative: 0, holdAction: c.holdAction })
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
|
||||
ids = typeof ids === "string" ? [ids] : ids;
|
||||
|
||||
console.log("Roll INIT")
|
||||
let updList = []
|
||||
for (let cId = 0; cId < ids.length; cId++) {
|
||||
const c = this.combatants.get(ids[cId])
|
||||
await this.computeInitiative(c)
|
||||
this.computeInitiative(c, updList)
|
||||
}
|
||||
|
||||
if (updList.length > 0) {
|
||||
await this.updateEmbeddedDocuments("Combatant", updList);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rebuildInitiative() {
|
||||
let updList = []
|
||||
for (let c of this.combatants) {
|
||||
this.computeInitiative(c, updList)
|
||||
}
|
||||
console.log(this.combatants, updList)
|
||||
if (updList.length > 0) {
|
||||
await this.updateEmbeddedDocuments("Combatant", updList);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
nextRound() {
|
||||
let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently.
|
||||
@ -119,9 +147,7 @@ export class Hero6Combat extends Combat {
|
||||
this.segmentNumber = turnData.segmentNumber;
|
||||
|
||||
// Re-compute init of actors
|
||||
for (let c of this.combatants) {
|
||||
this.computeInitiative(c)
|
||||
}
|
||||
this.rebuildInitiative()
|
||||
|
||||
// Update the document, passing data through a hook first
|
||||
const updateData = { round: nextRound, turn, segmentNumber: turnData.segmentNumber, turnNumber: turnData.turnNumber };
|
||||
@ -133,7 +159,6 @@ export class Hero6Combat extends Combat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onCreateEmbeddedDocuments(type, documents, result, options, userId) {
|
||||
console.log(">>>>", documents)
|
||||
super._onCreateEmbeddedDocuments(type, documents, result, options, userId)
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ Hooks.once("init", async function () {
|
||||
formula: "1d6",
|
||||
decimals: 3
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/* ------------------------------- ------------- */
|
||||
game.socket.on("system.fvtt-hero-system-6", data => {
|
||||
Hero6Utility.onSocketMesssage(data)
|
||||
});
|
||||
@ -96,7 +96,7 @@ Hooks.once("ready", function () {
|
||||
welcomeMessage();
|
||||
Hero6Utility.ready()
|
||||
Hero6Commands.ready()
|
||||
Hero6Combat.init()
|
||||
Hero6Combat.ready()
|
||||
|
||||
})
|
||||
|
||||
|
@ -52,6 +52,11 @@ export class Hero6Utility {
|
||||
}
|
||||
return false
|
||||
})
|
||||
Handlebars.registerHelper('checkInit', function (value) {
|
||||
let myValue = Number(value) || 0
|
||||
return myValue > 0
|
||||
})
|
||||
|
||||
|
||||
this.gameSettings()
|
||||
|
||||
|
@ -182,7 +182,10 @@
|
||||
<label class="item-field-label-medium">SPD</label>
|
||||
<input type="text" class="item-field-label-short update-field" data-field-name="system.characteristics.spd.value" value="{{characteristics.spd.value}}" data-dtype="Number" />
|
||||
|
||||
<label class="item-field-label-short"> </label>
|
||||
<span class="item-field-label-very-short"> </span>
|
||||
<button class="chat-card-button item-field-label-medium hold-action">Hold action</button>
|
||||
<button class="chat-card-button item-field-label-medium abort-action">Abort action</button>
|
||||
<span class=""> </span>
|
||||
|
||||
<label class="item-field-label-long">Presence attack</label>
|
||||
<a class="roll-direct" data-roll-source="Presence attack" data-roll-formula="{{system.biodata.presenceattack.rollFormula}}"><i class="fas fa-dice"></i>{{system.biodata.presenceattack.displayFormula}}</a>
|
||||
|
@ -60,11 +60,11 @@
|
||||
|
||||
<ol id="combat-tracker" class="directory-list">
|
||||
{{#each turns}}
|
||||
{{#if (ne this.initiative "-1")}}
|
||||
{{#if (checkInit this.initiative)}}
|
||||
<li class="combatant actor directory-item flexrow {{this.css}}" data-combatant-id="{{this.id}}">
|
||||
<img class="token-image" data-src="{{this.img}}" alt="{{this.name}}"/>
|
||||
<div class="token-name flexcol">
|
||||
<h4>{{this.name}} {{log this}} {{#if this.holdAction}}(H){{/if}}</h4>
|
||||
<h4>{{this.name}} </h4>
|
||||
<div class="combatant-controls flexrow">
|
||||
{{#if ../user.isGM}}
|
||||
<a class="combatant-control {{#if this.hidden}}active{{/if}}" data-tooltip="COMBAT.ToggleVis" data-control="toggleHidden">
|
||||
|
@ -4,7 +4,7 @@
|
||||
<label class=""> </label>
|
||||
</span>
|
||||
<span class="item-field-label-short">
|
||||
<label class="item-field-label-short">Q.</label>
|
||||
<label class="item-field-label-short">Qty</label>
|
||||
</span>
|
||||
<span class="item-field-label-long3">
|
||||
<label class="item-field-label-long3">{{title}}</label>
|
||||
|
Loading…
Reference in New Issue
Block a user