Compare commits

...

3 Commits

Author SHA1 Message Date
8f10b9825e Fixes from 29th of june 2023-06-30 22:20:44 +02:00
297c94adb7 Fixes from 29th of june 2023-06-30 21:11:29 +02:00
b535a86116 Fixes from 29th of june 2023-06-30 17:21:11 +02:00
16 changed files with 165 additions and 121 deletions

View File

@ -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);

View File

@ -385,16 +385,49 @@ 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 disableAbortAction() {
await this.setFlag("world", "abort-action", { state: false, count: 0 })
}
async abortAction() {
let abort = this.getFlag("world", "abort-action")
if ( abort.state) {
await this.setFlag("world", "abort-action", { state: false, count: 0 })
} else {
await this.setFlag("world", "abort-action", { state: true, count: 0 })
}
game.combat.rebuildInitiative()
}
getHoldAction() {
return this.getFlag("world", "hold-action")
}
getAbortAction() {
let abort = this.getFlag("world", "abort-action")
return abort?.state || false
}
/* -------------------------------------------- */
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)
}
/* -------------------------------------------- */
getSegments() {
let index = [ Math.min(Math.max(this.system.characteristics.spd.value, 1), 12) ] // Security bounds
let index = [Math.min(Math.max(this.system.characteristics.spd.value, 1), 12)] // Security bounds
return __speed2Segments[index]
}
/* -------------------------------------------- */
@ -612,12 +645,15 @@ export class Hero6Actor extends Actor {
let myRoll = new Roll(rollData.diceFormula).roll({ async: false })
await Hero6Utility.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = duplicate(myRoll)
rollData.bodyValue = Hero6Utility.computeBodyValue(myRoll)
rollData.result = myRoll.total
rollData.roll = duplicate(myRoll)
let msg = await Hero6Utility.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-hero-system-6/templates/chat/chat-lift-dice-result.hbs`, rollData)
let msgFlavor = await renderTemplate(`systems/fvtt-hero-system-6/templates/chat/chat-lift-dice-result.hbs`, rollData)
let msg = await myRoll.toMessage({
user: game.user.id,
rollMode: game.settings.get("core", "rollMode"),
flavor: msgFlavor
})
msg.setFlag("world", "rolldata", rollData)
console.log("Rolldata result", rollData)

View File

@ -5,7 +5,7 @@ export class Hero6CombatTracker extends CombatTracker {
/* -------------------------------------------- */
static get defaultOptions() {
var path = "systems/fvtt-hero-system-6/templates/apps/combat-tracker.hbs";
let path = "systems/fvtt-hero-system-6/templates/apps/combat-tracker.hbs";
return foundry.utils.mergeObject(super.defaultOptions, {
template: path,
});
@ -16,78 +16,108 @@ 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) {
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()
}
/* -------------------------------------------- */
constructor(data, context) {
super(data, context);
this.turnNumber = 1;
this.turnNumber = 0;
this.segmentNumber = 12;
}
/* -------------------------------------------- */
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)"
c.actor.disableAbortAction()
}
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.
@ -104,13 +134,13 @@ export class Hero6Combat extends Combat {
let turnData = this.getFlag("world", "hero6-turn-data")
if (!turnData) {
turnData = { turnNumber: 1, segmentNumber: 12 }
turnData = { turnNumber: 0, segmentNumber: 12 }
this.setFlag("world", "hero6-turn-data", turnData)
}
turnData = duplicate(turnData)
turnData.segmentNumber -= 1
if (turnData.segmentNumber <= 0) {
turnData.segmentNumber = 12
turnData.segmentNumber += 1
if (turnData.segmentNumber > 12) {
turnData.segmentNumber = 1
turnData.turnNumber++
}
this.setFlag("world", "hero6-turn-data", turnData)
@ -118,9 +148,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 };
@ -132,7 +160,6 @@ export class Hero6Combat extends Combat {
/* -------------------------------------------- */
async _onCreateEmbeddedDocuments(type, documents, result, options, userId) {
console.log(">>>>", documents)
super._onCreateEmbeddedDocuments(type, documents, result, options, userId)
}

View File

@ -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,6 +96,8 @@ Hooks.once("ready", function () {
welcomeMessage();
Hero6Utility.ready()
Hero6Commands.ready()
Hero6Combat.ready()
})
/* -------------------------------------------- */

View File

@ -52,6 +52,11 @@ export class Hero6Utility {
}
return false
})
Handlebars.registerHelper('checkInit', function (value) {
let myValue = Number(value) || 0
return myValue > 0
})
this.gameSettings()
@ -388,18 +393,22 @@ export class Hero6Utility {
// Ensure we have no space at all
//hero6Formula = hero6Formula.replace(/\s/g, '')
let hasHalfDice = ""
if (hero6Formula.match("1/2d6")) {
hero6Formula = hero6Formula.replace("1/2d6", "d6")
hasHalfDice = "+round(1d6/2)"
let newFormula = hero6Formula
let form1 = hero6Formula.match(/\s*(\d*)\s*1\/2d6/)
if ( form1 ) {
let nbDice = form1[1] || 0
newFormula = nbDice+"d6+round(1d6/2)"
}
if (hero6Formula.match(".5")) {
hero6Formula = hero6Formula.replace(".5", "")
hasHalfDice = "+round(1d6/2)"
let form3 = hero6Formula.match(/\s*(\d*)\.5d6/)
if ( form3 ) {
let nbDice = form3[1] || 0
newFormula = nbDice+"d6+round(1d6/2)"
}
let foundryFormula = hero6Formula + hasHalfDice
foundryFormula = foundryFormula.replace(' ', '')
console.log("Parsed formula : ", hero6Formula, foundryFormula)
return foundryFormula
console.log("Parsed formula : ", hero6Formula, newFormula)
return newFormula
}
/* -------------- ----------------------------- */

View File

@ -1309,6 +1309,11 @@ Focus FOC: #ff0084
max-width: 9rem;
min-width: 9rem;
}
.item-field-label-very-short {
flex-grow:1;
max-width: 2.5rem;
min-width: 2.5rem;
}
.item-field-label-short {
flex-grow:1;
max-width: 4rem;

View File

@ -91,7 +91,7 @@
"styles": [
"styles/simple.css"
],
"version": "10.0.41",
"version": "10.0.43",
"compatibility": {
"minimum": "10",
"verified": "10",
@ -99,7 +99,7 @@
},
"title": "Hero System v6 for FoundrtVTT (Official)",
"manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/raw/branch/main/system.json",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.41.zip",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.43.zip",
"url": "https://www.uberwald.me/gitea/uberwald/",
"background": "images/ui/hro6_welcome_page.webp",
"id": "fvtt-hero-system-6"

View File

@ -351,8 +351,8 @@
],
"maneuvertype": "general",
"pha": "",
"ocv": 0,
"dcv" : 0,
"ocv": "",
"dcv" : "",
"isstock": false,
"active": false
},

View File

@ -139,18 +139,18 @@
<ul class="stat-list alternate-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-field-label-long-img">
<label class="">{{upperFirst key}} Standard Maneuver</label>
<label class="">{{upperFirst key}} Maneuver</label>
</span>
<span class="item-field-label-short">
<span class="item-field-label-very-short">
<label class="short-label">PHA</label>
</span>
<span class="item-field-label-short">
<span class="item-field-label-very-short">
<label class="short-label">OCV</label>
</span>
<span class="item-field-label-short">
<label class="short-label">DCV</label>
</span>
<span class="item-field-label-medium">
<span class="item-field-label-long">
<label class="short-label">Effects</label>
</span>
</li>
@ -160,12 +160,13 @@
src="{{maneuver.img}}" /></a>
<span class="item-field-label-long">{{maneuver.name}}</span>
<span class="item-field-label-short">{{maneuver.system.pha}}</span>
<span class="item-field-label-short">{{maneuver.system.ocv}}</span>
<span class="item-field-label-very-short">{{maneuver.system.pha}}</span>
<span class="item-field-label-very-short">{{maneuver.system.ocv}}</span>
<span class="item-field-label-short">{{maneuver.system.dcv}}</span>
<span class="item-field-label-medium">{{maneuver.system.effects}}</span>
<span class="item-field-label-long">{{maneuver.system.effects}}</span>
<span class="item-field-label-short">&nbsp;</span>
<div class="item-controls item-controls-fixed">
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
@ -181,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">&nbsp;</label>
<span class="item-field-label-very-short">&nbsp;</span>
<button class="chat-card-button item-field-label-medium hold-action">Hold/Unhold</button>
<button class="chat-card-button item-field-label-medium abort-action">Abort/Unabort</button>
<span class="">&nbsp;</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>

View File

@ -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">

View File

@ -20,7 +20,7 @@
<ul>
<li>Name : {{title}}</li>
<li>Damage formula : {{diceFormula}}</li>
<li><strong>Result : {{result}}</strong></li>
<li><strong>TOTAL : {{result}}</strong></li>
<li><strong>BODY : {{bodyValue}}</strong></li>
</ul>

View File

@ -40,7 +40,7 @@
</li>
{{/if}}
<li><strong>Result : {{result}}</strong>
<li><strong>TOTAL : {{result}}</strong>
{{#if (exists margin)}}
({{#if isSuccess}}Success!!{{else}}Failure!{{/if}})
{{/if}}

View File

@ -21,7 +21,7 @@
<li>Lift dice formula : {{diceFormula}}</li>
<li>BODY : {{bodyValue}}</li>
<li><strong>Result : {{result}}</strong></li>
<li><strong>TOTAL : {{result}}</strong></li>
</ul>
</div>

View File

@ -1,46 +0,0 @@
<div class="chat-message-header">
{{#if actorImg}}
<img class="actor-icon" src="{{actorImg}}" alt="{{alias}}" />
{{/if}}
<h4 class=chat-actor-name>{{alias}}</h4>
</div>
<hr>
{{#if img}}
<div>
<img class="chat-icon" src="{{img}}" alt="{{name}}" />
</div>
{{/if}}
<div class="flexcol">
</div>
<div>
{{#if isRangedAttack}}
<div>{{defender.name}} is under Ranged attack. He must roll a Target Roll to defend himself.</div>
{{else}}
<div>{{defender.name}} is under Melee attack. He must roll a Defense Roll to defend himself.</div>
{{/if}}
<ul>
{{#if isRangedAttack}}
<li>
<button class="chat-card-button roll-defense-ranged" data-roll-id="{{@root.rollId}}">Roll Target !</button>
</li>
{{else}}
<li>
{{#each defenderWeapons as |weapon idx|}}
<button class="chat-card-button roll-defense-melee" data-defense-weapon-id="{{weapon._id}}"
data-roll-id="{{@root.rollId}}">{{weapon.name}}</button>
{{/each}}
</li>
{{/if}}
</ul>
<!-- <button class="chat-card-button reroll-level-remaining" data-roll-id="{{rollId}}">Reroll</button> -->
</ul>
</div>
</div>

View File

@ -38,11 +38,11 @@
</li>
<li class="flexrow"><label class="item-field-label-medium">OCV</label>
<input type="text" class="item-field-label-medium" name="system.ocv" value="{{system.ocv}}" data-dtype="Number"/>
<input type="text" class="item-field-label-medium" name="system.ocv" value="{{system.ocv}}" data-dtype="String"/>
</li>
<li class="flexrow"><label class="item-field-label-medium">DCV</label>
<input type="text" class="item-field-label-medium" name="system.dcv" value="{{system.dcv}}" data-dtype="Number"/>
<input type="text" class="item-field-label-medium" name="system.dcv" value="{{system.dcv}}" data-dtype="String"/>
</li>
<li class="flexrow"><label class="item-field-label-medium">Effects</label>

View File

@ -4,7 +4,7 @@
<label class="">&nbsp;</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>