Update combat tab

This commit is contained in:
LeRatierBretonnien 2023-03-24 10:17:20 +01:00
parent 4ca23257cb
commit 0368be050b
11 changed files with 163 additions and 97 deletions

View File

@ -44,8 +44,8 @@ export class Hero6ActorSheet extends ActorSheet {
powers: await this.actor.getPowers( ), powers: await this.actor.getPowers( ),
talents: this.actor.getTalents( ), talents: this.actor.getTalents( ),
complications: this.actor.getComplications( ), complications: this.actor.getComplications( ),
martialarts: this.actor.getMartialArts( ),
maneuvers: this.actor.getManeuvers( ), maneuvers: this.actor.getManeuvers( ),
nonstockmaneuvers: this.actor.getNonStockManeuvers(),
weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ), weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ),
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())), armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())), shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())),
@ -153,9 +153,9 @@ export class Hero6ActorSheet extends ActorSheet {
this.actor.rollCharac(characKey); this.actor.rollCharac(characKey);
}); });
html.find('.roll-direct').click((event) => { html.find('.roll-direct').click((event) => {
const rollFormula = $(event.currentTarget).data("roll-formula"); const rollFormula = $(event.currentTarget).data("roll-formula")
let roll = new Roll(rollFormula).roll({async: false}) const rollSource = $(event.currentTarget).data("roll-source")
roll.toMessage() Hero6Utility.processDirectRoll( { actorId: this.actor.id, rollFormula: rollFormula, rollSource: rollSource, mode:"directroll"} )
}); });
html.find('.roll-item').click((event) => { html.find('.roll-item').click((event) => {

View File

@ -67,8 +67,8 @@ export class Hero6Actor extends Actor {
} }
} }
computeDicesValue() { computeDicesValue() {
this.system.biodata.presenceattack = Hero6Utility.getDerivatedDiceValue(this.system.characteristics.pre.value ) this.system.biodata.presenceattack = Hero6Utility.getDerivatedDiceFormulas(this.system.characteristics.pre.value )
this.system.characteristics.str.strdice = Hero6Utility.getDerivatedDiceValue(this.system.characteristics.str.value ) this.system.characteristics.str.strdice = Hero6Utility.getDerivatedDiceFormulas(this.system.characteristics.str.value )
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
prepareDerivedData() { prepareDerivedData() {
@ -235,11 +235,6 @@ export class Hero6Actor extends Actor {
Hero6Utility.sortArrayObjectsByName(comp) Hero6Utility.sortArrayObjectsByName(comp)
return comp return comp
} }
getMartialArts() {
let comp = duplicate(this.items.filter(item => item.type == 'martialart') || [])
Hero6Utility.sortArrayObjectsByName(comp)
return comp
}
getComplications() { getComplications() {
let comp = duplicate(this.items.filter(item => item.type == 'complication') || []) let comp = duplicate(this.items.filter(item => item.type == 'complication') || [])
Hero6Utility.sortArrayObjectsByName(comp) Hero6Utility.sortArrayObjectsByName(comp)
@ -285,25 +280,45 @@ export class Hero6Actor extends Actor {
offensive: this.items.filter(item => item.type == "maneuver" && item.system.maneuvertype == "offensive"), offensive: this.items.filter(item => item.type == "maneuver" && item.system.maneuvertype == "offensive"),
defensive: this.items.filter(item => item.type == "maneuver" && item.system.maneuvertype == "defensive") defensive: this.items.filter(item => item.type == "maneuver" && item.system.maneuvertype == "defensive")
} }
Hero6Utility.sortArrayObjectsByName(maneuvers.general)
Hero6Utility.sortArrayObjectsByName(maneuvers.offensive)
Hero6Utility.sortArrayObjectsByName(maneuvers.defensive)
return maneuvers
}
getNonStockManeuvers() {
let maneuvers = this.items.filter(item => item.type == "maneuver" && !item.system.isstock)
Hero6Utility.sortArrayObjectsByName(maneuvers)
return maneuvers return maneuvers
} }
getEquipments() { getEquipments() {
return this.items.filter(item => item.type == "equipment" && item.system.subtype == "equipment"); let list = this.items.filter(item => item.type == "equipment" && item.system.subtype == "equipment");
Hero6Utility.sortArrayObjectsByName(list)
return list
} }
getWeapons() { getWeapons() {
return this.items.filter(item => item.type == "equipment" && item.system.subtype == "weapon"); let list = this.items.filter(item => item.type == "equipment" && item.system.subtype == "weapon");
Hero6Utility.sortArrayObjectsByName(list)
return list
} }
getArmors() { getArmors() {
return this.items.filter(item => item.type == "equipment" && item.system.subtype == "armor"); let list = this.items.filter(item => item.type == "equipment" && item.system.subtype == "armor");
Hero6Utility.sortArrayObjectsByName(list)
return list
} }
getShields() { getShields() {
return this.items.filter(item => item.type == "equipment" && item.system.subtype == "shield"); let list = this.items.filter(item => item.type == "equipment" && item.system.subtype == "shield");
Hero6Utility.sortArrayObjectsByName(list)
return list
} }
getEquipmentsMoneys() { getEquipmentsMoneys() {
return duplicate(this.items.filter(item => item.type == "equipment" && (item.system.subtype == "equipment" || item.system.subtype == "money")) || []) let list = duplicate(this.items.filter(item => item.type == "equipment" && (item.system.subtype == "equipment" || item.system.subtype == "money")) || [])
Hero6Utility.sortArrayObjectsByName(list)
return list
} }
getEquipmentsOnly() { getEquipmentsOnly() {
return duplicate(this.items.filter(item => item.type == "equipment" && item.system.subtype == "equipment") || []) let list = duplicate(this.items.filter(item => item.type == "equipment" && item.system.subtype == "equipment") || [])
Hero6Utility.sortArrayObjectsByName(list)
return list
} }
/* ------------------------------------------- */ /* ------------------------------------------- */

View File

@ -20,6 +20,9 @@ export class Hero6Utility {
Handlebars.registerHelper('count', function (list) { Handlebars.registerHelper('count', function (list) {
return list.length; return list.length;
}) })
Handlebars.registerHelper('exists', function (val) {
return val != null && val != undefined;
});
Handlebars.registerHelper('includes', function (array, val) { Handlebars.registerHelper('includes', function (array, val) {
return array.includes(val); return array.includes(val);
}) })
@ -78,12 +81,16 @@ export class Hero6Utility {
/*-------------------------------------------- */ /*-------------------------------------------- */
static getDerivatedDiceValue(value) { static getDerivatedDiceFormulas(value) {
let dices = Math.floor(value/5) +"d6" let rollFormula = Math.floor(value/5) +"d6"
let displayFormula = Math.floor(value/5)
if ( value % 5 > 2) { if ( value % 5 > 2) {
dices += "+1d3" rollFormula += "+round(1d6/2)"
displayFormula += " 1/2d6"
} else {
displayFormula += "d6"
} }
return dices return {rollFormula:rollFormula, displayFormula: displayFormula}
} }
/*-------------------------------------------- */ /*-------------------------------------------- */
static upperFirst(text) { static upperFirst(text) {
@ -340,15 +347,53 @@ export class Hero6Utility {
} }
rollData.margin = target - rollData.result rollData.margin = target - rollData.result
this.outputRollMessage(rollData)
}
/* -------------- ----------------------------- */
static processDirectRoll(rollData ) {
let roll = new Roll(rollData.rollFormula).roll({async: false})
rollData.roll = roll
// Compute BODY
let bodyValue = 0
for (let term of roll.terms) {
if ( term.constructor.name == "Die") {
for (let value of term.values) {
if (value > 1) {
bodyValue +=1
}
if (value == 6) {
bodyValue +=1
}
}
}
if ( term.constructor.name == "NumericTerm") {
if (term.total > 1) {
bodyValue +=1
}
if (term.total == 6) {
bodyValue +=1
}
}
}
rollData.result = roll.total
rollData.bodyValue = bodyValue
this.outputRollMessage(rollData)
}
/* -------------- ----------------------------- */
static async outputRollMessage(rollData) {
let msg = await this.createChatWithRollMode(rollData.alias, { let msg = await this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-hero-system-6/templates/chat/chat-generic-result.hbs`, rollData) content: await renderTemplate(`systems/fvtt-hero-system-6/templates/chat/chat-generic-result.hbs`, rollData)
}) })
msg.setFlag("world", "rolldata", rollData) msg.setFlag("world", "rolldata", rollData)
console.log("Rolldata result", rollData) console.log("Rolldata result", rollData)
} }
/* -------------------------------------------- */ /* -------------- ----------------------------- */
static sortArrayObjectsByName(myArray) { static sortArrayObjectsByName(myArray) {
myArray.sort((a, b) => { myArray.sort((a, b) => {
let fa = a.name.toLowerCase(); let fa = a.name.toLowerCase();

View File

@ -1452,3 +1452,7 @@ Focus FOC: #ff0084
min-height: 512px; min-height: 512px;
min-width: 256px; min-width: 256px;
} }
.textarea-full-height {
min-height: 100%;
height: 100%;
}

View File

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

View File

@ -31,8 +31,9 @@
"xpearned": 0, "xpearned": 0,
"xpspent": 0, "xpspent": 0,
"combatskills": "", "combatskills": "",
"presenceattack": "", "presenceattack": {},
"gmnotes": "" "gmnotes": "",
"combatnotes1":""
} }
}, },
"characteristics": { "characteristics": {
@ -42,7 +43,7 @@
"value": 10, "value": 10,
"base": 10, "base": 10,
"category": "main", "category": "main",
"strdice": "", "strdice": {},
"lift": "", "lift": "",
"strend": 0, "strend": 0,
"hasroll": true, "hasroll": true,
@ -68,7 +69,8 @@
"hasroll": true, "hasroll": true,
"category": "main", "category": "main",
"value": 10, "value": 10,
"base": 10 "base": 10,
"perceptionroll": 10
}, },
"ego": { "ego": {
"label": "Ego", "label": "Ego",
@ -314,7 +316,6 @@
"power", "power",
"advantage", "advantage",
"maneuver", "maneuver",
"martialart",
"limitation", "limitation",
"complication", "complication",
"equipment" "equipment"
@ -355,6 +356,7 @@
"pha": "", "pha": "",
"ocv": 0, "ocv": 0,
"dcv" : 0, "dcv" : 0,
"isstock": false,
"active": false "active": false
}, },
"advantage": { "advantage": {
@ -458,15 +460,6 @@
"templates": [ "templates": [
"common" "common"
] ]
},
"martialart": {
"maneuver_phase": 0,
"maneuver_ocv": 0,
"maneuver_dcv": 0,
"maneuver_effect": "",
"templates": [
"common"
]
} }
} }
} }

View File

@ -98,7 +98,7 @@
<a class="" data-tab="skills">Skills</a> <a class="" data-tab="skills">Skills</a>
<a class="" data-tab="perks">Perks</a> <a class="" data-tab="perks">Perks</a>
<a class="" data-tab="talents">Talents</a> <a class="" data-tab="talents">Talents</a>
<a class="" data-tab="martial">Martial Arts</a> <a class="" data-tab="maneuver">Maneuvers</a>
<a class="" data-tab="powers">Powers</a> <a class="" data-tab="powers">Powers</a>
<a class="" data-tab="complications">Complications</a> <a class="" data-tab="complications">Complications</a>
<a class="" data-tab="equipment">Equipment</a> <a class="" data-tab="equipment">Equipment</a>
@ -117,7 +117,7 @@
<ul class="item-list alternate-list"> <ul class="item-list alternate-list">
<li class="item"> <li class="item">
<label class="item-field-label-medium">STR Dice</label> <label class="item-field-label-medium">STR Dice</label>
<a class="roll-direct" data-roll-formula="{{characteristics.str.strdice}}"><i class="fas fa-dice"></i>{{characteristics.str.strdice}}</a> <a class="roll-direct" data-roll-source="STR Dice" data-roll-formula="{{characteristics.str.strdice.rollFormula}}"><i class="fas fa-dice"></i>{{characteristics.str.strdice.displayFormula}}</a>
<label class="item-field-label-short">&nbsp;</label> <label class="item-field-label-short">&nbsp;</label>
<label class="item-field-label-medium">Lift</label> <label class="item-field-label-medium">Lift</label>
<input type="text" class="item-field-label-short update-field" data-field-name="system.characteristics.str.lift" value="{{characteristics.str.lift}}" data-dtype="String" /> <input type="text" class="item-field-label-short update-field" data-field-name="system.characteristics.str.lift" value="{{characteristics.str.lift}}" data-dtype="String" />
@ -127,7 +127,7 @@
</li> </li>
<li class="flexrow item"> <li class="flexrow item">
<label class="item-field-label-long">Presence attack</label> <label class="item-field-label-long">Presence attack</label>
<a class="roll-direct" data-roll-formula="{{system.biodata.presenceattack}}"><i class="fas fa-dice"></i>{{system.biodata.presenceattack}}</a> <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>
</li> </li>
</ul> </ul>
@ -187,10 +187,10 @@
<label class="">Vitals</label> <label class="">Vitals</label>
</span> </span>
<span class="item-field-label-short"> <span class="item-field-label-short">
<label class="short-label">Val.</label> <label class="short-label">Val</label>
</span> </span>
<span class="item-field-label-short"> <span class="item-field-label-short">
<label class="short-label">Dam.</label> <label class="short-label">Dmg</label>
</span> </span>
</li> </li>
{{#each characteristics as |char key|}} {{#each characteristics as |char key|}}
@ -214,10 +214,10 @@
<label class="">Defenses</label> <label class="">Defenses</label>
</span> </span>
<span class="item-field-label-short"> <span class="item-field-label-short">
<label class="short-label">Val.</label> <label class="short-label">Val</label>
</span> </span>
<span class="item-field-label-short"> <span class="item-field-label-short">
<label class="short-label">Res.</label> <label class="short-label">Res</label>
</span> </span>
</li> </li>
{{#each characteristics as |char key|}} {{#each characteristics as |char key|}}
@ -277,16 +277,14 @@
<label class="">Senses</label> <label class="">Senses</label>
</span> </span>
<span class="item-field-label-short"> <span class="item-field-label-short">
<label class="short-label">Val.</label>
</span> </span>
</li> </li>
{{#each senses as |sense key|}}
<li class="item flexrow list-item list-item-shadow" data-charac-key="{{key}}"> <li class="item flexrow list-item list-item-shadow" data-charac-key="{{key}}">
<span class="item-field-label-long">{{sense.label}}</span> <span class="item-field-label-long">Perception Roll</span>
<span class="item-field-label-short">{{sense.value}}</span> <input type="text" class="item-field-label-short update-field" data-field-name="system.characteristics.int.perceptionroll" value="{{characteristics.int.perceptionroll}}" data-dtype="Number" />
</li> </li>
{{/each}}
</ul> </ul>
<textarea type="text" class="textarea-full-height padd-right" name="system.biodata.combatnotes1" data-dtype="String">{{system.biodata.combatnotes1}}</textarea>
</div> </div>
<div> <div>
@ -296,10 +294,10 @@
<label class="">Movement</label> <label class="">Movement</label>
</span> </span>
<span class="item-field-label-short"> <span class="item-field-label-short">
<label class="short-label">C.</label> <label class="short-label">C</label>
</span> </span>
<span class="item-field-label-short"> <span class="item-field-label-short">
<label class="short-label">Non-C.</label> <label class="short-label">NC</label>
</span> </span>
</li> </li>
{{#each characteristics as |char key|}} {{#each characteristics as |char key|}}
@ -457,28 +455,39 @@
</ul> </ul>
</div> </div>
{{!-- Martial Tab --}} {{!-- Maneuvers Tab --}}
<div class="tab martial" data-group="primary" data-tab="martial"> <div class="tab maneuver" data-group="primary" data-tab="maneuver">
<ul class="stat-list alternate-list item-list"> <ul class="stat-list alternate-list item-list">
<li class="item flexrow list-item items-title-bg"> <li class="item flexrow list-item items-title-bg">
<span class="item-field-label-long-img"> <span class="item-field-label-long-img">
<label class="">Martial Arts</label> <label class="">Maneuvers</label>
</span> </span>
<span class="item-field-label-short"> <span class="item-field-label-short">
<label class="short-label">Roll</label> <label class="short-label">PHA</label>
</span>
<span class="item-field-label-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-long">
<label class="short-label">Effects</label>
</span> </span>
</li> </li>
{{#each martialarts as |martial key|}} {{#each nonstockmaneuvers as |maneuver key|}}
<li class="item stat flexrow list-item list-item-shadow" data-item-id="{{martial._id}}"> <li class="item stat flexrow list-item list-item-shadow" data-item-id="{{maneuver._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img" <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{martial.img}}" /></a> src="{{maneuver.img}}" /></a>
<span class="item-name-label"><a class="roll-item" data-type="talent">{{martial.name}}</a></span> <span class="item-field-label-long">{{maneuver.name}}</span>
{{#if martial.system.hasroll}}
<span class="item-field-label-short">{{martial.system.roll}}-</span> <span class="item-field-label-short">{{maneuver.system.pha}}</span>
{{else}} <span class="item-field-label-short">{{maneuver.system.ocv}}</span>
<span class="item-field-label-short">&nbsp;</span> <span class="item-field-label-short">{{maneuver.system.dcv}}</span>
{{/if}}
<span class="item-field-label-long">{{maneuver.system.effects}}</span>
<div class="item-filler">&nbsp;</div> <div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed"> <div class="item-controls item-controls-fixed">
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a> <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>

View File

@ -18,8 +18,14 @@
<div> <div>
<ul> <ul>
{{#if target}}
<li>Target Roll : {{target}}- <li>Target Roll : {{target}}-
</li> </li>
{{/if}}
{{#if rollSource}}
<li>Roll : {{rollSource}}</li>
{{/if}}
{{#if charac}} {{#if charac}}
<li>CHAR : {{charac.label}}</li> <li>CHAR : {{charac.label}}</li>
@ -29,11 +35,24 @@
<li>{{item.name}} ({{upperFirst item.type}})</li> <li>{{item.name}} ({{upperFirst item.type}})</li>
{{/if}} {{/if}}
{{#if (exists bonusMalus)}}
<li>Bonus/Penalty : {{bonusMalus}} <li>Bonus/Penalty : {{bonusMalus}}
</li> </li>
{{/if}}
<li><strong>Result : {{result}}</strong> ({{#if isSuccess}}Success!!{{else}}Failure!{{/if}})</li> <li><strong>Result : {{result}}</strong>
{{#if (exists margin)}}
({{#if isSuccess}}Success!!{{else}}Failure!{{/if}})
{{/if}}
</li>
{{#if (exists bodyValue)}}
<li><strong>BODY : {{bodyValue}}</strong>
{{/if}}
{{#if (exists margin)}}
<li><strong>Margin : {{margin}}</strong> <li><strong>Margin : {{margin}}</strong>
{{/if}}
</ul> </ul>
</div> </div>

View File

@ -27,6 +27,10 @@
</select> </select>
</li> </li>
<li class="flexrow"><label class="item-field-label-medium">Is stock ?</label>
<label class="item-field-label-medium"><input type="checkbox" name="system.isstock" {{checked system.isstock}}/></label>
</li>
<li class="flexrow"><label class="item-field-label-medium">PHA</label> <li class="flexrow"><label class="item-field-label-medium">PHA</label>
<input type="text" class="item-field-label-medium" name="system.pha" value="{{system.pha}}" data-dtype="String"/> <input type="text" class="item-field-label-medium" name="system.pha" value="{{system.pha}}" data-dtype="String"/>
</li> </li>

View File

@ -1,23 +0,0 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="item-sheet-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{> systems/fvtt-hero-system-6/templates/partials/partial-item-nav.hbs}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="tab details" data-group="primary" data-tab="details">
<ul>
{{> systems/fvtt-hero-system-6/templates/partials/partial-item-description.hbs}}
{{> systems/fvtt-hero-system-6/templates/partials/partial-item-cost.hbs}}
</ul>
</div>
</section>
</form>