Skip to content

Commit

Permalink
feat(combat tab): added all calculation of combat abilities and comba…
Browse files Browse the repository at this point in the history
…t statistics, displayed the data and changed the data template
  • Loading branch information
SouOWendel committed Jul 7, 2024
1 parent e3d19e9 commit b98f4d4
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 67 deletions.
67 changes: 53 additions & 14 deletions module/documents/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,69 @@ export class ShinobiActor extends Actor {

// const systemClone = actorData.system.deepClone();
// Loop de Atributos
for (let [abilityKey, ability] of Object.entries(system.abilities)) {
for (let [abilityKey, ability] of Object.entries(abilities)) {
// Soma de bônus em atributos
ability.tbonus = ability.value + ability.bonus;

// Perícias Gerais
for (let [skillKey, skill] of Object.entries(system.skills.geral)) {
// Soma de bônus em perícias
skill.tbonus = skill.value + skill.bonus;
// Recuperação do atributo correspondente e divisão por dois.
if (skill.ability == abilityKey) skill.abilityValue = ability.tbonus / 2;
// Soma do atributo derivado + total derivado.
skill.total = Math.round(skill.abilityValue + skill.tbonus);
for (let [skillKey, skill] of Object.entries(system.skills.geral)) {
if (skill.ability == abilityKey) {
// Soma de bônus em perícias
skill.tbonus = skill.value + skill.bonus;
// Recuperação do atributo correspondente e divisão por dois.
skill.abilityValue = ability.tbonus / 2;
// Soma do atributo derivado + total derivado.
skill.total = Math.round(skill.abilityValue + skill.tbonus);

// Perícia para Iniciativa
if (attributes.init.skill == skillKey) {
attributes.init.value += skill.total;
}
}
}

// Perícias Sociais
for (let [skillKey, skill] of Object.entries(system.skills.social)) {
// Soma de bônus em perícias
skill.tbonus = skill.value + skill.bonus;
// Recuperação do atributo correspondente e divisão por dois.
if (skill.ability == abilityKey) {
console.log(skill.ability, abilityKey);
// Soma de bônus em perícias
skill.tbonus = skill.value + skill.bonus;
// Recuperação do atributo correspondente e divisão por dois.
skill.abilityValue = ability.tbonus / 2;
// Soma do atributo derivado + total derivado.
skill.total = Math.round(skill.abilityValue + skill.tbonus);
}
}
}

for (let [abilityKey, ability] of Object.entries(abilities)) {
// Habilidades de Combate
for (let [cKey, c] of Object.entries(abilities.combate)) {
// Soma de bônus em perícias
if (c.ability == abilityKey) {
c.value = c.base + Number(c.bonus);
c.value = c.value + ability.tbonus;

// Cálculo de Esquiva
if (attributes.esquiva.combatAbility == cKey) {
attributes.esquiva.value += c.value;
attributes.esquiva.value += attributes.esquiva.bonus;
attributes.esquiva.value += attributes.esquiva.variavel;
}
}
// Soma do atributo derivado + total derivado.
skill.total = Math.round(skill.abilityValue + skill.tbonus);
}

// Cálculo de Iniciativa
if (attributes.init.ability == abilityKey) {
attributes.init.value += attributes.init.bonus;
attributes.init.value += ability.tbonus;
}

// Deslocamento
if (attributes.movement.ability == abilityKey) {
attributes.movement.andar += attributes.movement.base;
attributes.movement.andar = attributes.movement.andar + ability.tbonus / attributes.movement.divisor;
attributes.movement.andar += attributes.movement.bonus;
attributes.movement.andar = Math.round(attributes.movement.andar);
}
}
// Vitalidade e Chakra
Expand Down
15 changes: 6 additions & 9 deletions template.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,14 @@
"bonus": null,
"andar": 0,
"nadar": 0,
"ability": "",
"ability": "agi",
"escalar": 0,
"mod": {
"divisorAndar": 2,
"divisorNadar": 4,
"divisorEscalar": 4
}
"divisor": 2
},
"init": {
"ability": "",
"ability": "agi",
"bonus": null,
"skill": "",
"skill": "prontidao",
"value": 0,
"roll": {
"max": null,
Expand All @@ -121,7 +117,7 @@
},
"esquiva": {
"value": 0,
"ability": "",
"combatAbility": "E",
"bonus": null,
"variavel": 9
}
Expand Down Expand Up @@ -500,6 +496,7 @@
"testeResistencia": ""
},
"detalhes": {
"origem": "",
"tipo": "",
"subtipo": "",
"custoChakra": "",
Expand Down
84 changes: 40 additions & 44 deletions templates/actor/parts/actor-combate.hbs
Original file line number Diff line number Diff line change
@@ -1,84 +1,74 @@
<section id="habilidadesCombate" class="container">
<h3 class="section-title">Habilidades de Combate</h3>
<div class="item flexrow flex-group-center">
<div class='item-large item-prop bold'>Nome</div>
<div class='item-medium item-prop bold'>Nome</div>
<div class='item-mini item-prop bold'>Total</div>
<div class='item-medium item-prop bold'>Perícia</div>
{{!-- <div class='item-medium item-prop bold'>Perícia</div> --}}
<div class='item-medium item-prop bold'>Atributo</div>
<div class='item-small item-prop bold'>Bônus</div>
</div>
<div class="flexrow flex-group-center align-center">
<div class="item-name">
<label class="resource-label item-large">Combate Corporal (CC)</label>
<label class="resource-label item-medium">Combate Corporal (CC)</label>
</div>
<div class="resource-content flex flex-2 flex-group-center align-center">
<input type="text" name="system.abilities.combate.CC.value"
value="{{system.abilities.combate.CC.value}}" class="item-mini" data-dtype="text" disabled>
<i class="fas fa-equals"></i>
<select name="system.abilities.combate.CC.skill" class="item-medium">
{{selectOptions periciasGerais selected=system.abilities.combate.CC.skill localize=true}}
</select>
value="{{system.abilities.combate.CC.value}}" class="item-mini" data-dtype="Number" disabled>
<i class="fas fa-plus"></i>
<select name="system.abilities.combate.CC.ability" class="item-medium">
{{selectOptions atributos selected=system.abilities.combate.CC.ability localize=true}}
</select>
<i class="fas fa-plus"></i>
<input type="text" name="system.abilities.combate.CC.bonus" value="{{system.abilities.combate.CC.bonus}}" class="item-small" data-dtype="text">
<input type="text" name="system.abilities.combate.CC.bonus"
value="{{system.abilities.combate.CC.bonus}}" class="item-small" data-dtype="Number">
</div>
</div>
<div class="flexrow flex-group-center align-center">
<div class="item-name">
<label class="resource-label item-large">Combate à Distância (CD)</label>
<label class="resource-label item-medium">Combate à Distância (CD)</label>
</div>
<div class="resource-content flex flex-2 flex-group-center align-center">
<input type="text" name="system.abilities.combate.CD.value"
value="{{system.abilities.combate.CD.value}}" class="item-mini" data-dtype="text" disabled>
value="{{system.abilities.combate.CD.value}}" class="item-mini" data-dtype="Number" disabled>
<i class="fas fa-equals"></i>
<select name="system.abilities.combate.CD.skill" class="item-medium">
{{selectOptions periciasGerais selected=system.abilities.combate.CD.skill localize=true}}
</select>
<i class="fas fa-plus"></i>
<select name="system.abilities.combate.CD.ability" class="item-medium">
{{selectOptions atributos selected=system.abilities.combate.CD.ability localize=true}}
</select>
<i class="fas fa-plus"></i>
<input type="text" name="system.abilities.combate.CD.bonus" value="{{system.abilities.combate.CD.bonus}}" class="item-small" data-dtype="text">
<input type="text" name="system.abilities.combate.CD.bonus"
value="{{system.abilities.combate.CD.bonus}}" class="item-small" data-dtype="Number">
</div>
</div>
<div class="flexrow flex-group-center align-center">
<div class="item-name">
<label class="resource-label item-large">Esquiva</label>
<label class="resource-label item-medium">Esquiva</label>
</div>
<div class="resource-content flex flex-2 flex-group-center align-center">
<input type="text" name="system.abilities.combate.E.value" value="{{system.abilities.combate.E.value}}" class="item-mini" data-dtype="text" disabled>
<input type="text" name="system.abilities.combate.E.value"
value="{{system.abilities.combate.E.value}}" class="item-mini" data-dtype="Number" disabled>
<i class="fas fa-equals"></i>
<select name="system.abilities.combate.E.skill" class="item-medium">
{{selectOptions periciasGerais selected=system.abilities.combate.E.skill localize=true}}
</select>
<i class="fas fa-plus"></i>
<select name="system.abilities.combate.E.ability" class="item-medium">
{{selectOptions atributos selected=system.abilities.combate.E.ability localize=true}}
</select>
<i class="fas fa-plus"></i>
<input type="text" name="system.abilities.combate.E.bonus" value="{{system.abilities.combate.E.bonus}}" class="item-small" data-dtype="text">
<input type="text" name="system.abilities.combate.E.bonus"
value="{{system.abilities.combate.E.bonus}}" class="item-small" data-dtype="Number">
</div>
</div>
<div class="flexrow flex-group-center align-center">
<div class="item-name">
<label class="resource-label item-large">Ler Movimento (LM)</label>
<label class="resource-label item-medium">Ler Movimento (LM)</label>
</div>
<div class="resource-content flex flex-2 flex-group-center align-center">
<input type="text" name="system.abilities.combate.LM.value" value="{{system.abilities.combate.LM.value}}" class="item-mini" data-dtype="text" disabled>
<input type="text" name="system.abilities.combate.LM.value"
value="{{system.abilities.combate.LM.value}}" class="item-mini" data-dtype="Number" disabled>
<i class="fas fa-equals"></i>
<select name="system.abilities.combate.LM.skill" class="item-medium">
{{selectOptions periciasGerais selected=system.abilities.combate.LM.skill localize=true}}
</select>
<i class="fas fa-plus"></i>
<select name="system.abilities.combate.LM.ability" class="item-medium">
{{selectOptions atributos selected=system.abilities.combate.LM.ability localize=true}}
</select>
<i class="fas fa-plus"></i>
<input type="text" name="system.abilities.combate.LM.bonus" value="{{system.abilities.combate.LM.bonus}}" class="item-small" data-dtype="text">
<input type="text" name="system.abilities.combate.LM.bonus"
value="{{system.abilities.combate.LM.bonus}}" class="item-small" data-dtype="Number">
</div>
</div>
</section>
Expand All @@ -95,7 +85,7 @@
<div class="flex flex-group-center align-center">
<label class="resource-label flex-1 flex-group-center align-center">Iniciativa</label>
<div class="resource-content flex flex-2 flex-group-center align-center">
<input type="text" name="system.attributes.init.value" value="{{system.attributes.init.value}}" class="item-mini" data-dtype="text" disabled>
<input type="text" name="system.attributes.init.value" value="{{system.attributes.init.value}}" class="item-mini" data-dtype="Number" disabled>
<i class="fas fa-equals"></i>
<select name="system.attributes.init.skill" class="item-medium">
{{selectOptions periciasGerais selected=system.attributes.init.skill localize=true}}
Expand All @@ -105,40 +95,46 @@
{{selectOptions atributos selected=system.attributes.init.ability localize=true}}
</select>
<i class="fas fa-plus"></i>
<input type="text" name="system.attributes.init.bonus" value="{{system.attributes.init.bonus}}" class="item-small" data-dtype="text">
<input type="text" name="system.attributes.init.bonus"
value="{{system.attributes.init.bonus}}" class="item-small" data-dtype="Number">
</div>
</div>
<div class="flex flex-group-center align-center">
<label class="resource-label flex-1 flex-group-center align-center">Reação de Esquiva</label>
<div class="resource-content flex flex-2 flex-group-center align-center">
<input type="text" name="system.attributes.esquiva.value" value="{{system.attributes.esquiva.value}}" class="item-mini" data-dtype="text" disabled>
<input type="text" name="system.attributes.esquiva.value"
value="{{system.attributes.esquiva.value}}" class="item-mini" data-dtype="Number" disabled>
<i class="fas fa-equals"></i>
<select name="system.attributes.esquiva.ability" class="item-medium">
{{selectOptions habilidadesCombate selected=system.attributes.esquiva.ability localize=true}}
<select name="system.attributes.esquiva.combatAbility" class="item-medium">
{{selectOptions habilidadesCombate selected=system.attributes.esquiva.combatAbility localize=true}}
</select>
<i class="fas fa-plus"></i>
<input type="text" name="system.attributes.esquiva.variavel" value="{{system.attributes.esquiva.variavel}}" class="item-small" data-dtype="text">
<input type="text" name="system.attributes.esquiva.variavel"
value="{{system.attributes.esquiva.variavel}}" class="item-small" data-dtype="Number">
<i class="fas fa-plus"></i>
<input type="text" name="system.attributes.esquiva.bonus" value="{{system.attributes.esquiva.bonus}}" class="item-small" data-dtype="text">
<input type="text" name="system.attributes.esquiva.bonus"
value="{{system.attributes.esquiva.bonus}}" class="item-small" data-dtype="Number">
</div>
</div>
<hr>
<div class="flex flex-group-center align-center">
<label class="resource-label flex-1 flex-group-center align-center">Deslocamento</label>
<div class="resource-content flex flex-2 flex-group-center align-center">
<input type="text" name="system.attributes.movement.andar" value="{{system.attributes.movement.andar}}" class="item-mini" data-dtype="text" disabled>
<input type="text" name="system.attributes.movement.andar"
value="{{system.attributes.movement.andar}}" class="item-mini" data-dtype="Number" disabled>
<i class="fas fa-equals"></i>
<input type="text" name="system.attributes.movement.base" value="{{system.attributes.movement.base}}" class="item-mini" data-dtype="text">
<input type="text" name="system.attributes.movement.base"
value="{{system.attributes.movement.base}}" class="item-mini" data-dtype="Number">
<i class="fas fa-plus"></i>
<select name="system.attributes.movement.ability" class="item-medium">
<option>Atributos</option>
<option>Atributos</option>
<option>Atributos</option>
{{selectOptions atributos selected=system.attributes.movement.ability localize=true}}
</select>
<i class="fas fa-divide"></i>
<input type="text" name="system.attributes.movement.mod.divisorAndar" value="{{system.attributes.movement.mod.divisorAndar}}" class="item-mini" data-dtype="text" disabled>
<input type="text" name="system.attributes.movement.divisor"
value="{{system.attributes.movement.divisor}}" class="item-mini" data-dtype="Number" disabled>
<i class="fas fa-plus"></i>
<input type="text" name="system.attributes.movement.bonus" value="{{system.attributes.movement.bonus}}" class="item-small" data-dtype="text">
<input type="text" name="system.attributes.movement.bonus"
value="{{system.attributes.movement.bonus}}" class="item-small" data-dtype="Number">
</div>
</div>
</section>

0 comments on commit b98f4d4

Please sign in to comment.