Update rolls and similar stuff

This commit is contained in:
sladecraven 2022-11-10 11:04:05 +01:00
parent ad5f91fbb2
commit 927ddf1328
7 changed files with 103 additions and 60 deletions

View File

@ -89,6 +89,13 @@ export class HawkmoonActorSheet extends ActorSheet {
this.actor.editItemField(itemId, itemType, itemField, dataType, value) this.actor.editItemField(itemId, itemType, itemField, dataType, value)
}) })
html.find('.adversite-modify').click(event => {
const li = $(event.currentTarget).parents(".item")
let adv = li.data("adversite")
let value = Number($(event.currentTarget).data("adversite-value"))
this.actor.incDecAdversite(adv, value)
})
html.find('.quantity-minus').click(event => { html.find('.quantity-minus').click(event => {
const li = $(event.currentTarget).parents(".item"); const li = $(event.currentTarget).parents(".item");
this.actor.incDecQuantity( li.data("item-id"), -1 ); this.actor.incDecQuantity( li.data("item-id"), -1 );

View File

@ -56,9 +56,8 @@ export class HawkmoonActor extends Actor {
arme.system.attrKey = "pui" arme.system.attrKey = "pui"
arme.system.totalDegats = arme.system.degats + "+" + combat.bonusDegatsTotal arme.system.totalDegats = arme.system.degats + "+" + combat.bonusDegatsTotal
arme.system.totalOffensif = this.system.attributs.pui.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff arme.system.totalOffensif = this.system.attributs.pui.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
if (arme.system.isdefense) { arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef arme.system.isdefense = true
}
} }
if (arme.system.typearme == "jet" || arme.system.typearme == "tir") { if (arme.system.typearme == "jet" || arme.system.typearme == "tir") {
arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance")) arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance"))
@ -66,7 +65,7 @@ export class HawkmoonActor extends Actor {
arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
arme.system.totalDegats = arme.system.degats arme.system.totalDegats = arme.system.degats
if (arme.system.isdefense) { if (arme.system.isdefense) {
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense
} }
} }
return arme return arme
@ -135,13 +134,26 @@ export class HawkmoonActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getDefenseBase() { getDefenseBase() {
return this.system.attributs.tre.value return Math.max(this.system.attributs.tre.value, this.system.attributs.pui.value)
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getVitesseBase() { getVitesseBase() {
return 5 + __vitesseBonus[this.system.attributs.adr.value] return 5 + __vitesseBonus[this.system.attributs.adr.value]
} }
/* -------------------------------------------- */
getProtection() {
let equipProtection = 0
for(let armor in this.items) {
if (armor.type == "protection" && armor.system.equipped) {
equipProtection += Number(armor.system.protection)
}
}
if (equipProtection < 4) {
return 4 + equipProtection // Cas des boucliers + sans armure
}
return equipProtection // Uniquement la protection des armures + boucliers
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getCombatValues() { getCombatValues() {
@ -153,7 +165,8 @@ export class HawkmoonActor extends Actor {
vitesseBase: this.getVitesseBase(), vitesseBase: this.getVitesseBase(),
vitesseTotal: this.getVitesseBase() + this.system.combat.vitessebonus, vitesseTotal: this.getVitesseBase() + this.system.combat.vitessebonus,
defenseBase: this.getDefenseBase(), defenseBase: this.getDefenseBase(),
defenseTotal: this.getDefenseBase() + this.system.combat.defensebonus protection : this.getProtection(),
defenseTotal: this.getDefenseBase() + this.system.combat.defensebonus + this.getProtection() - this.getTotalAdversite()
} }
return combat return combat
} }
@ -305,7 +318,7 @@ export class HawkmoonActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getBonusDegats() { getBonusDegats() {
return __degatsBonus[this.system.attributs.pui.value] return 0;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -342,11 +355,24 @@ export class HawkmoonActor extends Actor {
await this.update({ 'system.subactors': newArray }); await this.update({ 'system.subactors': newArray });
} }
/* -------------------------------------------- */
getTotalAdversite() {
return this.system.adversite.bleue + this.system.adversite.rouge + this.system.adversite.noire
}
/* -------------------------------------------- */
async incDecAdversite(adv, incDec = 0) {
let adversite = duplicate(this.system.adversite)
adversite[adv] += Number(incDec)
adversite[adv] = Math.max(adversite[adv], 0)
this.update({ 'system.adversite': adversite })
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async incDecQuantity(objetId, incDec = 0) { async incDecQuantity(objetId, incDec = 0) {
let objetQ = this.items.get(objetId) let objetQ = this.items.get(objetId)
if (objetQ) { if (objetQ) {
let newQ = objetQ.system.quantity + incDec; let newQ = objetQ.system.quantity + incDec
newQ = Math.max(newQ, 0)
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity
} }
} }
@ -420,11 +446,13 @@ export class HawkmoonActor extends Actor {
rollData.maitriseId = "none" rollData.maitriseId = "none"
rollData.nbEclat = this.system.eclat.value rollData.nbEclat = this.system.eclat.value
rollData.nbBA = this.system.bonneaventure.actuelle rollData.nbBA = this.system.bonneaventure.actuelle
rollData.nbAdversites = this.getTotalAdversite()
rollData.talents = []
if (attrKey) { if (attrKey) {
rollData.attrKey = attrKey rollData.attrKey = attrKey
if (attrKey != "tochoose") { if (attrKey != "tochoose") {
rollData.actionImg = "systems/fvtt-mournblade-cyd/assets/icons/" + this.system.attributs[attrKey].labelnorm + ".webp" rollData.actionImg = "systems/fvtt-hawkmoon-cyd/assets/icons/" + this.system.attributs[attrKey].labelnorm + ".webp"
rollData.attr = duplicate(this.system.attributs[attrKey]) rollData.attr = duplicate(this.system.attributs[attrKey])
} }
} }
@ -481,7 +509,8 @@ export class HawkmoonActor extends Actor {
if (arme.type == "bouclier") { if (arme.type == "bouclier") {
arme = this.prepareBouclier(arme) arme = this.prepareBouclier(arme)
} }
let roll = new Roll(arme.system.totalDegats).roll({ async: false }) console.log("DEGATS", arme)
let roll = new Roll( "1d10+"+arme.system.totalDegats).roll({ async: false })
await HawkmoonUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode")); await HawkmoonUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"));
let rollData = { let rollData = {
arme: arme, arme: arme,
@ -492,7 +521,7 @@ export class HawkmoonActor extends Actor {
actionImg: arme.img, actionImg: arme.img,
} }
HawkmoonUtility.createChatWithRollMode(rollData.alias, { HawkmoonUtility.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-mournblade/templates/chat-degats-result.html`, rollData) content: await renderTemplate(`systems/fvtt-hawkmoon-cyd/templates/chat-degats-result.html`, rollData)
}) })
} }

View File

@ -336,6 +336,8 @@ export class HawkmoonUtility {
rollData.diceFormula += `+${rollData.attr.value}*2+${rollData.modificateur}` rollData.diceFormula += `+${rollData.attr.value}*2+${rollData.modificateur}`
} }
// Ajout adversités
rollData.diceFormula += `-${rollData.nbAdversites}`
if (rollData.arme && rollData.arme.type == "arme") { if (rollData.arme && rollData.arme.type == "arme") {
rollData.diceFormula += `+${rollData.arme.system.bonusmaniementoff}` rollData.diceFormula += `+${rollData.arme.system.bonusmaniementoff}`

View File

@ -1,7 +1,7 @@
{ {
"id": "fvtt-hawkmoon-cyd", "id": "fvtt-hawkmoon-cyd",
"description": "Hawmoon RPG for FoundryVTT (CYD system - French)", "description": "Hawmoon RPG for FoundryVTT (CYD system - French)",
"version": "10.0.8", "version": "10.0.9",
"authors": [ "authors": [
{ {
"name": "Uberwald/LeRatierBretonnien", "name": "Uberwald/LeRatierBretonnien",
@ -15,7 +15,7 @@
"gridUnits": "m", "gridUnits": "m",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json", "manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.0.8.zip", "download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.0.9.zip",
"packs": [ "packs": [
{ {
"type": "Item", "type": "Item",

View File

@ -67,7 +67,7 @@
<img class="item-name-img" src="systems/fvtt-hawkmoon-cyd/assets/icons/{{attr.labelnorm}}.webp"> <img class="item-name-img" src="systems/fvtt-hawkmoon-cyd/assets/icons/{{attr.labelnorm}}.webp">
<span class="item-name-label competence-name item-field-label-medium"><a <span class="item-name-label competence-name item-field-label-medium"><a
class="roll-attribut">{{attr.label}}</a></span> class="roll-attribut">{{attr.label}}</a></span>
<select class="status-small-label color-class-common item-field-label-short" type="text" <select class="status-small-label color-class-common edit-item-data competence-niveau" type="text"
name="system.attributs.{{key}}.value" value="{{attr.value}}" data-dtype="Number"> name="system.attributs.{{key}}.value" value="{{attr.value}}" data-dtype="Number">
{{#select attr.value}} {{#select attr.value}}
{{> systems/fvtt-hawkmoon-cyd/templates/partial-list-niveau.html}} {{> systems/fvtt-hawkmoon-cyd/templates/partial-list-niveau.html}}
@ -81,18 +81,16 @@
<div class="sheet-box color-bg-archetype"> <div class="sheet-box color-bg-archetype">
<h4 class="item-name-label competence-name">Adversité</h4> <h4 class="item-name-label competence-name">Adversité</h4>
<ul class="item-list alternate-list"> <ul class="item-list alternate-list">
<li class="item flexrow"> {{#each system.adversite as |adv key|}}
<label class="label-name item-field-label-short">Bleue</label> <li class="item flexrow" data-adversite="{{key}}">
<label class="label-name item-field-label-short">{{system.adversite.bleue}}</label> <label class="label-name item-field-label-short">{{upperFirst key}}</label>
</li> <label class="label-name item-field-label-short">{{adv}}</label>
<li class="item flexrow"> <span class="status-small-label no-grow">
<label class="label-name item-field-label-short">Rouge</label> <a class="adversite-modify plus-minus-button" data-adversite-value="1">+</a>
<label class="label-name item-field-label-short">{{system.adversite.rouge}}</label> <a class="adversite-modify plus-minus-button" data-adversite-value="-1">&nbsp;-</a>
</li> </span>
<li class="item flexrow">
<label class="label-name item-field-label-short">Noire</label>
<label class="label-name item-field-label-short">{{system.adversite.noire}}</label>
</li> </li>
{{/each}}
</ul> </ul>
</div> </div>

View File

@ -19,7 +19,7 @@
<div> <div>
<ul> <ul>
<li>Arme : {{arme.name}} (+{{arme.system.totalDegats}})</li> <li>Arme : {{arme.name}} (+{{arme.system.totalDegats}})</li>
<li>Dégats : {{finalResult}} {{#if arme.system.nonletaux}}(Non létaux){{else}}(Létaux){{/if}}</li> <li>Dégats : {{finalResult}}</li>
</ul> </ul>
</div> </div>

View File

@ -24,6 +24,13 @@
{{/if}} {{/if}}
</div> </div>
{{#if nbAdversites}}
<div class="flexrow">
<span class="roll-dialog-label">Malus d'adversités : </span>
<span class="small-label">- {{nbAdversites}}</span>
</div>
{{/if}}
{{#if competence}} {{#if competence}}
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">{{competence.name}}</span> <span class="roll-dialog-label">{{competence.name}}</span>