Gestion assommer/charge

This commit is contained in:
LeRatierBretonnien 2023-04-09 21:45:46 +02:00
parent 5e5ddd1c3b
commit 6497369d7f
11 changed files with 226 additions and 88 deletions

View File

@ -158,6 +158,22 @@ export class HeritiersActorSheet extends ActorSheet {
let armeId = li.data("item-id")
this.actor.rollAttaqueArme(armeId)
})
html.find('.roll-attaque-brutale-arme').click((event) => {
const li = $(event.currentTarget).parents(".item")
let armeId = li.data("item-id")
this.actor.rollAttaqueBrutaleArme(armeId)
})
html.find('.roll-attaque-charge-arme').click((event) => {
const li = $(event.currentTarget).parents(".item")
let armeId = li.data("item-id")
this.actor.rollAttaqueChargeArme(armeId)
})
html.find('.roll-assomer-arme').click((event) => {
const li = $(event.currentTarget).parents(".item")
let armeId = li.data("item-id")
this.actor.rollAssomerArme(armeId)
})
html.find('.roll-pouvoir').click((event) => {
const li = $(event.currentTarget).parents(".item")
let pouvoirId = li.data("item-id")

View File

@ -55,25 +55,7 @@ export class HeritiersActor extends Actor {
/* -------------------------------------------- */
prepareArme(arme) {
arme = duplicate(arme)
let combat = this.getCombatValues()
if (arme.system.typearme == "contact" || arme.system.typearme == "contactjet") {
let bonusDefense = 0
arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée"))
arme.system.attrKey = "pui"
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.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense + bonusDefense
arme.system.isdefense = true
}
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.attrKey = "adr"
arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
arme.system.totalDegats = arme.system.degats
if (arme.system.isdefense) {
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense
}
}
arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
return arme
}
@ -104,46 +86,46 @@ export class HeritiersActor extends Actor {
}
/* ----------------------- --------------------- */
getItemSorted( types) {
let items = this.items.filter(item => types.includes(item.type )) || []
getItemSorted(types) {
let items = this.items.filter(item => types.includes(item.type)) || []
HeritiersUtility.sortArrayObjectsByName(items)
return items
}
getEquipments() {
return this.getItemSorted( ["equipement", "accessoire"] )
return this.getItemSorted(["equipement", "accessoire"])
}
getAvantages() {
return this.getItemSorted( ["avantage"])
return this.getItemSorted(["avantage"])
}
getDesavantages() {
return this.getItemSorted( ["desavantage"])
return this.getItemSorted(["desavantage"])
}
getMonnaies() {
return this.getItemSorted( ["monnaie"])
return this.getItemSorted(["monnaie"])
}
getArmors() {
return this.getItemSorted( ["protection"])
return this.getItemSorted(["protection"])
}
getTalents() {
return this.getItemSorted( ["talent"])
return this.getItemSorted(["talent"])
}
getContacts() {
return this.getItemSorted( ["contact"])
return this.getItemSorted(["contact"])
}
getAtouts() {
return this.getItemSorted( ["atoutfeerique"])
return this.getItemSorted(["atoutfeerique"])
}
getCapacites() {
return this.getItemSorted( ["capacitenaturelle"])
return this.getItemSorted(["capacitenaturelle"])
}
getFee() {
return this.items.find(item => item.type =="fee")
return this.items.find(item => item.type == "fee")
}
getProfils() {
return this.getItemSorted( ["profil"])
return this.getItemSorted(["profil"])
}
getPouvoirs() {
return this.getItemSorted( ["pouvoir"])
return this.getItemSorted(["pouvoir"])
}
/* -------------------------------------------- */
getSkills() {
@ -173,8 +155,8 @@ export class HeritiersActor extends Actor {
organizeUtileSkills(kind = "mental") {
let comp = {}
for (let key in game.system.lesheritiers.config.competenceProfil) {
if ( game.system.lesheritiers.config.competenceProfil[key].kind == kind)
comp[key] = { skills: [], niveau: this.system.competences[key].niveau }
if (game.system.lesheritiers.config.competenceProfil[key].kind == kind)
comp[key] = { skills: [], niveau: this.system.competences[key].niveau }
}
for (let item of this.items) {
if (item.type == "competence") {
@ -297,7 +279,7 @@ export class HeritiersActor extends Actor {
let item = this.items.find(item => item.id == itemId)
if (item) {
console.log("Item ", item, itemField, dataType, value)
if (dataType) {
if (dataType) {
if (dataType.toLowerCase() == "number") {
value = Number(value)
} else {
@ -313,14 +295,14 @@ export class HeritiersActor extends Actor {
getPvMalus() {
if (this.system.pv.value > 0) {
if (this.system.pv.value < this.system.pv.max / 2) {
return -1
return { name: "Santé", value: -1 }
}
if (this.system.pv.value < 5) {
return -2
return { name: "Santé", value: -2 }
}
return 0
return { name: "Santé", value: 0 }
}
return "Moribond(e)"
return { name: "Moribond(e)", value: -50 }
}
/* -------------------------------------------- */
@ -482,19 +464,21 @@ export class HeritiersActor extends Actor {
}
/* -------------------------------------------- */
getCurrentParade() {
if ( this.system.statutmasque == "masque") {
if (this.system.statutmasque == "masque") {
return this.system.combat.parade.masquee
}
return this.system.combat.parade.demasquee
}
/* -------------------------------------------- */
getCurrentEsquive() {
if ( this.system.statutmasque == "masque") {
if (this.system.statutmasque == "masque") {
return this.system.combat.esquive.masquee
}
return this.system.combat.esquive.demasquee
}
getCurrentResistancePhysique() {
return this.system.combat.resistancephysique.value
}
/* -------------------------------------------- */
getTricherie() {
return this.system.rang.tricherie.value
@ -511,7 +495,19 @@ export class HeritiersActor extends Actor {
tricherie.value = Math.min(tricherie.value, tricherie.max)
this.update({ 'system.rang.tricherie': tricherie })
}
/* -------------------------------------------- */
getPireCompetence(compName1, compName2) {
let comp1 = this.items.find( it => it.name == compName1)
let comp2 = this.items.find( it => it.name == compName2)
if ( comp1 && comp2 ) {
if (comp1.system.niveau > comp2.system.niveau) {
return comp1
} else {
return comp2
}
}
return undefined
}
/* -------------------------------------------- */
getCommonRollData(compId = undefined, compName = undefined) {
let rollData = HeritiersUtility.getBasicRollData()
@ -527,7 +523,7 @@ export class HeritiersActor extends Actor {
rollData.useTricherie = false
rollData.useSpecialite = false
rollData.useHeritage = false
rollData.pvMalus = this.getPvMalus()
rollData.rulesMalus.push(this.getPvMalus())
if (compId) {
rollData.competence = duplicate(this.items.get(compId) || {})
@ -538,7 +534,7 @@ export class HeritiersActor extends Actor {
rollData.competence = duplicate(this.items.find(item => item.name.toLowerCase() == compName.toLowerCase()) || {})
if (rollData.competence && rollData.competence.name) {
this.prepareUtileSkill(rollData.competence)
rollData.actionImg = rollData.competence?.img
rollData.actionImg = rollData.competence?.img
} else {
rollData.competence = undefined
}
@ -585,7 +581,7 @@ export class HeritiersActor extends Actor {
let rollData = this.getCommonRollData()
rollData.mode = "competence"
console.log("Compkey", compKey)
rollData.competence = {name: this.system.competences[compKey].label, system: { niveau: this.system.competences[compKey].niveau }}
rollData.competence = { name: this.system.competences[compKey].label, system: { niveau: this.system.competences[compKey].niveau } }
console.log("RollDatra", rollData)
let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true)
@ -599,13 +595,15 @@ export class HeritiersActor extends Actor {
let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true)
}
/* -------------------------------------------- */
async rollAttaqueArme(armeId) {
let arme = this.items.get(armeId)
if (arme) {
let competenceName = "Tir"
let key = "prec"
if (arme.system.categorie == "blanche" || arme.system.categorie == "improvise") {
arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
if ( arme.system.isMelee) {
competenceName = "Mêlée"
key = "agi"
}
@ -614,16 +612,70 @@ export class HeritiersActor extends Actor {
rollData.caracKey = key
rollData.arme = duplicate(arme)
rollData.mode = "arme"
if (rollData.defenderTokenId && arme.system.isMelee ) {
rollData.cacheDifficulte = true
}
let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true)
}
}
/* -------------------------------------------- */
async rollAttaqueBrutaleArme(armeId) {
let arme = this.items.get(armeId)
if (arme) {
let key = "for"
let competenceName = "Mêlée"
let rollData = this.getCommonRollData(undefined, competenceName)
rollData.carac = this.system.caracteristiques[key]
rollData.caracKey = key
rollData.arme = duplicate(arme)
rollData.mode = "attaquebrutale"
rollData.rulesMalus.push({ name: "Attaque brutale", value: -2 } )
let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true)
}
}
/* -------------------------------------------- */
async rollAttaqueChargeArme(armeId) {
let arme = this.items.get(armeId)
if (arme) {
let key = "agi"
let pireCompetence = this.getPireCompetence("Mêlée", "Mouvement")
let rollData = this.getCommonRollData(undefined, pireCompetence.name)
rollData.carac = this.system.caracteristiques[key]
rollData.caracKey = key
rollData.arme = duplicate(arme)
rollData.mode = "attaquecharge"
let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true)
}
}
/* -------------------------------------------- */
async rollAssomerArme(armeId) {
let arme = this.items.get(armeId)
if (arme) {
let competenceName = "Mêlée"
let rollData = this.getCommonRollData(undefined, competenceName)
rollData.carac = this.system.caracteristiques["agi"]
rollData.caracKey = "agi"
rollData.arme = duplicate(arme)
rollData.mode = "assommer"
if (rollData.defenderTokenId) {
rollData.cacheDifficulte = true
}
let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true)
}
}
/* -------------------------------------------- */
async rollPouvoir(pouvoirId) {
let pouvoir = this.items.get(pouvoirId)
if (pouvoir) {
let rollData = this.getCommonRollData(undefined, undefined)
if ( pouvoir.system.feeriemasque != "autre") {
if (pouvoir.system.feeriemasque != "autre") {
rollData.pouvoirBase = duplicate(this.system.rang[pouvoir.system.feeriemasque.toLowerCase()])
rollData.pouvoirBase.label = "Féerie"
rollData.carac = duplicate(this.system.caracteristiques[pouvoir.system.carac])

View File

@ -62,6 +62,7 @@ export class HeritiersItemSheet extends ItemSheet {
options: this.options,
owner: this.document.isOwner,
config: game.system.lesheritiers.config,
isArmeMelee: HeritiersUtility.isArmeMelee(this.object),
description: await TextEditor.enrichHTML(this.object.system.description, {async: true}),
mr: (this.object.type == 'specialisation'),
isGM: game.user.isGM

View File

@ -110,14 +110,8 @@ export class HeritiersRollDialog extends Dialog {
html.find('#bonus-malus-context').change((event) => {
this.rollData.bonusMalusContext = Number(event.currentTarget.value)
})
html.find('#useTricherie').change((event) => {
this.rollData.useTricherie = event.currentTarget.checked
})
html.find('#useSpecialite').change((event) => {
this.rollData.useSpecialite = event.currentTarget.checked
})
html.find('#useHeritage').change((event) => {
this.rollData.useHeritage = event.currentTarget.checked
})
}
}

View File

@ -290,11 +290,11 @@ export class HeritiersUtility {
if (isTricherieHeritage) {
let resTab = [rollData.roll.terms[0].results[0].result, rollData.roll.terms[0].results[1].result, rollData.roll.terms[0].results[2].result]
rollData.diceResult = resTab[0] + "," + resTab[1] + "," + resTab[2]
let subResult = Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
let foundryTotal = resTab[0] + resTab[1] + resTab[2]
if (resTab[1] == 1) { resTab[1] -= 4 }
if (resTab[2] == 1) { resTab[2] -= 6 }
if (resTab[2] == 2) { resTab[2] -= 7 }
rollData.finalResult = rollData.roll.total - subResult + Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
rollData.finalResult = rollData.roll.total - foundryTotal + Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
// Gestion des résultats spéciaux
resTab = resTab.sort()
@ -344,6 +344,9 @@ export class HeritiersUtility {
if (rollData.arme.system.categorie == "blanche" || rollData.arme.system.categorie == "improvise") {
rollData.degatsArme += Math.max(0, actor.system.caracteristiques.for.value - 2)
}
if (rollData.mode == "attaquecharge") {
rollData.degatsArme += 3
}
}
/* -------------------------------------------- */
@ -368,19 +371,24 @@ export class HeritiersUtility {
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-les-heritiers/templates/chat-cc-result.html`, rollData)
}, rollData, "selfroll")
}
/* -------------------------------------------- */
static async displayAsssomer(rollData, actor, nomAttaque, etatAssomer, valeurDefense) {
rollData.defenderMode = nomAttaque
rollData.etatAssommer = etatAssomer
rollData.defenderValue = valeurDefense
rollData.marge = 0
this.computeMarge(rollData, valeurDefense)
rollData.dureeAssommer = (rollData.marge) ? rollData.marge*2 : 1
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-les-heritiers/templates/chat-assommer-result.html`, rollData)
}, rollData, "selfroll")
}
/* -------------------------------------------- */
static async rollHeritiers(rollData) {
let actor = this.getActorFromRollData(rollData)
if (typeof (rollData.pvMalus) != "number") {
ui.notifications.warn("Votre personnage est Moribond(e). Aucun jet autorisé")
return
}
//rollData.actionImg = "systems/fvtt-les-heritiers/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp"
rollData.carac = duplicate(actor.system.caracteristiques[rollData.caracKey])
@ -403,7 +411,11 @@ export class HeritiersUtility {
} else {
rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.bonusMalusContext}`
}
rollData.diceFormula += `+${rollData.pvMalus}`
let ruleMalus = 0
for (let malus of rollData.rulesMalus) {
ruleMalus += malus.value
}
rollData.diceFormula += `+${ruleMalus}`
let myRoll = new Roll(rollData.diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
@ -420,7 +432,9 @@ export class HeritiersUtility {
content: await renderTemplate(`systems/fvtt-les-heritiers/templates/chat-generic-result.html`, rollData)
}, rollData)
if (rollData.defenderTokenId && rollData.arme) {
// Gestion attaque standard
if ( (rollData.mode == "arme" || rollData.mode == "attaquebrutale" || rollData.mode == "attaquecharge") &&
rollData.defenderTokenId && rollData.arme) {
if (rollData.arme.system.categorie != "trait" && rollData.arme.system.categorie != "poing" && rollData.arme.system.categorie != "epaule" ) {
await this.displayUneDefense(rollData, actor, "Parade", rollData.defenderParade)
await this.displayUneDefense(rollData, actor, "Esquive", rollData.defenderEsquive)
@ -430,6 +444,13 @@ export class HeritiersUtility {
ui.notifications.warn("Pas de difficulté positionnée pour l'attaque à distance.")
}
}
// Gestion assomer
if (rollData.mode == "assommer" && rollData.defenderTokenId && rollData.arme) {
await this.displayAsssomer(rollData, actor, "Assommer", "Surprise", rollData.defenderResistancePhysique)
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Résistance+6", rollData.defenderResistancePhysique+6)
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Parade", rollData.defenderParade)
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Esquive", rollData.defenderEsquive+6)
}
}
@ -456,6 +477,10 @@ export class HeritiersUtility {
return game.users.filter(filter).map(user => user._id);
}
/* -------------------------------------------- */
static isArmeMelee(arme) {
return (arme.type == "arme" && (arme.system.categorie == "lourde" || arme.system.categorie == "blanche" || arme.system.categorie == "improvise")) ? true : false
}
/* -------------------------------------------- */
static getWhisperRecipients(rollMode, name) {
switch (rollMode) {
@ -541,7 +566,8 @@ export class HeritiersUtility {
rollMode: game.settings.get("core", "rollMode"),
sdList: game.system.lesheritiers.config.seuilsDifficulte,
sdValue: -1,
bonusMalusContext: 0
bonusMalusContext: 0,
rulesMalus : []
}
return rollData
}
@ -555,6 +581,7 @@ export class HeritiersUtility {
rollData.defenderName = defender.name
rollData.defenderParade = defender.getCurrentParade()
rollData.defenderEsquive = defender.getCurrentEsquive()
rollData.defenderResistancePhysique = defender.getCurrentResistancePhysique()
}
}

View File

@ -1245,7 +1245,10 @@ ul, li {
position:relative;
top:1px;
}
.button-sheet-roll-long1 {
max-width: 6.1rem;
min-width: 6.1rem;
}
.defense-sheet {
border-radius: 4px;
text-align: center;

View File

@ -1,7 +1,7 @@
{
"id": "fvtt-les-heritiers",
"description": "Les Héritiers pour FoundryVTT",
"version": "10.0.35",
"version": "10.0.36",
"authors": [
{
"name": "Uberwald/LeRatierBretonnien",
@ -19,7 +19,7 @@
"gridUnits": "m",
"license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/raw/branch/master/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.35.zip",
"download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.36.zip",
"languages": [
{
"lang": "fr",

View File

@ -176,20 +176,6 @@
<label class="item-field-label-long">Dissimulation : </label>
<input type="text" class="item-field-label-short" name="system.combat.dissimulation.value" value="{{system.combat.dissimulation.value}}" data-dtype="Number" />
</li>
<!-- <li class="item flexrow list-item items-title-bg">
<label class="item-field-label-long"><strong>Corps à Corps</strong></label>
<label class="item-field-label-medium">Masqué</label>
<input type="text" class="item-field-label-short" name="system.combat.corpsacorps.masquee" value="{{system.combat.corpsacorps.masquee}}" data-dtype="Number" />
<label class="item-field-label-medium">Démasqué</label>
<input type="text" class="item-field-label-short" name="system.combat.corpsacorps.demasquee" value="{{system.combat.corpsacorps.demasquee}}" data-dtype="Number" />
</li>
<li class="item flexrow list-item items-title-bg">
<label class="item-field-label-long"><strong>A distance</strong></label>
<label class="item-field-label-medium">Masqué</label>
<input type="text" class="item-field-label-short" name="system.combat.tir.masquee" value="{{system.combat.tir.masquee}}" data-dtype="Number" />
<label class="item-field-label-medium">Démasqué</label>
<input type="text" class="item-field-label-short" name="system.combat.tir.demasquee" value="{{system.combat.tir.demasquee}}" data-dtype="Number" />
</li> -->
</ul>
<div class="flexcol">
@ -201,10 +187,10 @@
<h3><label class="items-title-text">Armes</label></h3>
</span>
<span class="item-field-label-short">
<label class="short-label">Attaque</label>
<label class="short-label">Dégats</label>
</span>
<span class="item-field-label-short">
<label class="short-label">Dégats</label>
<label class="short-label">Attaque</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
@ -218,13 +204,26 @@
<span class="item-name-label competence-name">{{arme.name}}</span>
<span class="item-field-label-short">
<button class="roll-attaque-arme button-sheet-roll">Attaquer</button>
{{arme.system.degats}}
</span>
<span class="item-field-label-short">
{{arme.system.degats}}
<button class="roll-attaque-arme button-sheet-roll">Attaque</button>
</span>
<span class="item-field-label-short">
<button class="roll-assomer-arme button-sheet-roll">Assomer</button>
</span>
{{#if arme.system.isMelee}}
<span class="item-field-label-short">
<button class="roll-attaque-charge-arme button-sheet-roll">Charger</button>
</span>
<span class="item-field-label-short">
<button class="roll-attaque-brutale-arme button-sheet-roll button-sheet-roll-long1">Attaque brutale</button>
</span>
{{/if}}
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-equip" title="Worn">{{#if arme.system.equipped}}<i

View File

@ -0,0 +1,30 @@
<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 actionImg}}
<div>
<img class="chat-icon" src="{{actionImg}}" alt="{{name}}" />
</div>
{{/if}}
<div class="flexcol">
</div>
<div>
<ul>
<li>Assomer {{defenderName}} en état de : {{etatAssommer}}</li>
{{#if isSuccess}}
<li>Marge : {{marge}}</li>
<li>{{defenderName}} est assomé pour {{dureeAssommer}} minutes !</li>
{{else}}
<li>{{defenderName}} n'a pas été assomé et est conscient la tentative !</li>
{{/if}}
</ul>
</div>

View File

@ -33,6 +33,9 @@
{{#if arme}}
<li>Attaque avec : {{arme.name}}</li>
{{#if (eq mode "assommer")}}
<li>Attaque pour assommer</li>
{{/if}}
{{/if}}
{{#if pouvoir}}

View File

@ -66,6 +66,13 @@
{{/if}}
{{/if}}
{{#each rulesMalus as |malus key|}}
<div class="flexrow">
<span class="roll-dialog-label">{{malus.name}}</span>
<span class="small-label roll-dialog-label">{{malus.value}}</span>
</div>
{{/each}}
<div class="flexrow">
<span class="roll-dialog-label">Malus de Santé</span>
<span class="small-label roll-dialog-label">{{pvMalus}}</span>
@ -93,6 +100,11 @@
</select>
</div>
{{#if cacheDifficulte}}
<div class="flexrow">
<span class="roll-dialog-label">Difficulté Cachée/Inconnue</span>
</div>
{{else}}
<div class="flexrow">
<span class="roll-dialog-label">Difficulté</span>
<select class="status-small-label color-class-common" id ="sdValue" type="text" name="sdValue" value="sdValue" data-dtype="string" >
@ -103,6 +115,7 @@
{{/select}}
</select>
</div>
{{/if}}
</div>