Manye enhancements for combat
This commit is contained in:
@@ -212,7 +212,7 @@ export class TeDeumUtility {
|
||||
let isAttackWinner = true
|
||||
let rWinner = this.currentOpposition
|
||||
let rLooser = rollData
|
||||
if (rWinner.total < rLooser.total) {
|
||||
if (rWinner.total <= rLooser.total) {
|
||||
rWinner = rollData
|
||||
rLooser = this.currentOpposition
|
||||
isAttackWinner = false
|
||||
@@ -222,17 +222,33 @@ export class TeDeumUtility {
|
||||
winner: rWinner,
|
||||
looser: rLooser
|
||||
}
|
||||
// Update difficulty
|
||||
rWinner.difficulty = rLooser.total
|
||||
rLooser.difficulty = rWinner.total
|
||||
await this.computeResults(rWinner)
|
||||
await this.computeResults(rLooser)
|
||||
// Auto XP management when opposed
|
||||
if (rWinner.isReussiteCritique) {
|
||||
let actor = this.getActorFromRollData(rWinner)
|
||||
actor.modifyXP(rWinner.carac.key, 1)
|
||||
}
|
||||
if (rLooser.isEchecCritique) {
|
||||
let actor = this.getActorFromRollData(rLooser)
|
||||
actor.modifyXP(rLooser.carac.key, 1)
|
||||
}
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-te-deum/templates/chat/chat-opposition-result.hbs`, oppositionData)
|
||||
})
|
||||
await msg.setFlag("world", "te-deum-rolldata", rollData)
|
||||
|
||||
// Si le gagnant est l'attaquant, appliquer les dégats sur la victime
|
||||
if ( isAttackWinner && rWinner.isSuccess && rWinner.mode == "arme" && rWinner.arme?.system.typeArme == "melee" && rWinner.defenderTokenId) {
|
||||
this.appliquerDegats(rWinner)
|
||||
if (isAttackWinner && rWinner.isSuccess && rWinner.mode == "arme" && rWinner.arme?.system.typeArme == "melee" && rWinner.defenderTokenId) {
|
||||
await this.appliquerDegats(rWinner)
|
||||
}
|
||||
|
||||
console.log("Rolldata result", rollData)
|
||||
|
||||
console.log("Opposition result", rollData, isAttackWinner, oppositionData)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +259,12 @@ export class TeDeumUtility {
|
||||
if (defenderToken) {
|
||||
let actor = defenderToken.actor
|
||||
await actor.appliquerDegats(rollData)
|
||||
// Attaque naturelle avec dégats inférieur à -2
|
||||
if ((rollData?.arme?.system.specificites?.poing?.hasSpec || rollData?.arme?.system.specificites?.pied?.hasSpec) && rollData.degats < -2) {
|
||||
let attacker = this.getActorFromRollData(rollData)
|
||||
attacker.appliquerBlessure("estafilade", "maindroite", "Contusion suite à une attaque naturelle")
|
||||
ui.notifications.info(`${attacker.name} subit 1 contusion en infligeant ${rollData.degats} dégâts à mains nues`)
|
||||
}
|
||||
} else {
|
||||
ui.notifications.error("Impossible de trouver la cible de l'attaque, aucun degats appliqué")
|
||||
}
|
||||
@@ -267,6 +289,17 @@ export class TeDeumUtility {
|
||||
TeDeumUtility.appliquerDegats(rollData, messageId)
|
||||
}
|
||||
})
|
||||
$(html).on("click", '.chat-command-gain-xp', event => {
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "te-deum-rolldata")
|
||||
if (rollData) {
|
||||
let actor = TeDeumUtility.getActorFromRollData(rollData)
|
||||
actor.modifyXP(rollData.carac.key, 1)
|
||||
// Hide this button
|
||||
event.currentTarget.style.display = 'none';
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -477,6 +510,15 @@ export class TeDeumUtility {
|
||||
if (rollData.isMouvement) {
|
||||
localModifier -= 1
|
||||
}
|
||||
if (rollData.arme && rollData.allongeId) {
|
||||
localModifier += rollData.allonges[rollData.allongeId].malus
|
||||
rollData.allongeMalus = rollData.allonges[rollData.allongeId].malus
|
||||
rollData.nbEsquives = rollData.allonges[rollData.allongeId]?.esquive || 0
|
||||
}
|
||||
if (rollData.attaqueCiblee && rollData.attaqueCiblee != "aucune") {
|
||||
localModifier -= 1
|
||||
rollData.loc = foundry.utils.duplicate(game.system.tedeum.config.LOCALISATION[rollData.attaqueCiblee])
|
||||
}
|
||||
let diceBase = this.modifyDice(rollData.carac.dice, localModifier + Number(rollData.bonusMalus) + rollData.santeModifier)
|
||||
if (!diceBase) return;
|
||||
diceFormula = diceBase + "x + " + rollData.compScore
|
||||
@@ -489,24 +531,30 @@ export class TeDeumUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getLocalisation(rollData) {
|
||||
let locRoll = await new Roll("1d20").roll()
|
||||
await this.showDiceSoNice(locRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.locRoll = foundry.utils.duplicate(locRoll)
|
||||
for (let key in game.system.tedeum.config.LOCALISATION) {
|
||||
let loc = game.system.tedeum.config.LOCALISATION[key]
|
||||
if (locRoll.total >= loc.score.min && locRoll.total <= loc.score.max) {
|
||||
rollData.loc = foundry.utils.duplicate(loc)
|
||||
break
|
||||
let locRoll
|
||||
if (rollData.loc) {
|
||||
locRoll = await new Roll(String(rollData.loc.score.min)).roll()
|
||||
} else {
|
||||
locRoll = await new Roll("1d20").roll()
|
||||
await this.showDiceSoNice(locRoll, game.settings.get("core", "rollMode"))
|
||||
for (let key in game.system.tedeum.config.LOCALISATION) {
|
||||
let loc = game.system.tedeum.config.LOCALISATION[key]
|
||||
if (locRoll.total >= loc.score.min && locRoll.total <= loc.score.max) {
|
||||
rollData.loc = foundry.utils.duplicate(loc)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
rollData.locRoll = foundry.utils.duplicate(locRoll)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processAttaqueMelee(rollData) {
|
||||
await this.getLocalisation(rollData)
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let bDegats = actor.getBonusDegats()
|
||||
let degatsRoll = await new Roll(rollData.arme.system.degats + "+" + bDegats.value).roll()
|
||||
let bDegats = actor.getAttaqueBonusDegats(rollData)
|
||||
rollData.degatsFormula = rollData.arme.system.degats + "+" + bDegats
|
||||
let degatsRoll = await new Roll(rollData.degatsFormula).roll()
|
||||
await this.showDiceSoNice(degatsRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.degatsRoll = foundry.utils.duplicate(degatsRoll)
|
||||
rollData.degats = degatsRoll.total
|
||||
@@ -522,7 +570,7 @@ export class TeDeumUtility {
|
||||
await this.getLocalisation(rollData)
|
||||
// Now the degats
|
||||
let degatsRoll = await new Roll(rollData.arme.system.degats).roll()
|
||||
await this.showDiceSoNice(rollData.locRoll, game.settings.get("core", "rollMode"))
|
||||
await this.showDiceSoNice(rollData.degatsRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.degatsRoll = foundry.utils.duplicate(degatsRoll)
|
||||
rollData.degats = degatsRoll.total
|
||||
}
|
||||
@@ -538,8 +586,8 @@ export class TeDeumUtility {
|
||||
}
|
||||
rollData.difficulty = game.system.tedeum.config.difficulte[rollData.difficulty].value
|
||||
// Compute the real competence score
|
||||
if ( rollData.competence ) {
|
||||
if ( rollData.competence.system.isBase) {
|
||||
if (rollData.competence) {
|
||||
if (rollData.competence.system.isBase) {
|
||||
rollData.compScore = actor.system.caracteristiques[rollData.competence.system.caracteristique].value
|
||||
} else {
|
||||
rollData.compScore = rollData.competence.system.score
|
||||
@@ -571,10 +619,6 @@ export class TeDeumUtility {
|
||||
if (rollData.enableProvidence) {
|
||||
actor.modifyProvidence(-1)
|
||||
}
|
||||
// Manage XP
|
||||
if (rollData.isReussiteCritique || rollData.isEchecCritique) {
|
||||
actor.modifyXP(rollData.carac.key, 1)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user