forked from public/bol
Messages de recuperation
This commit is contained in:
parent
0c502a2188
commit
83d3f17dd0
@ -535,6 +535,10 @@
|
||||
"BOL.chat.criticalinfo": "C'est un succès Héroïque ou Légendaire ! Choisissez vos options et effets !",
|
||||
"BOL.chat.criticalbuttonjournal": "Succès Héroïque/Légendaire",
|
||||
|
||||
"BOL.chat.losshp": "{name}} a perdu {lossHP} points de Vitalité. Si il se repose quelques minutes, il peut récupérer {recupHP} points de Vitalité.",
|
||||
"BOL.chat.applyrecup": "Récupérer pendant quelques minutes (+{recupHP} Vitalité)",
|
||||
"BOL.chat.inforecup": "{name} vient de récupérer {recupHP} points de Vitalité après quelques minutes de repos.",
|
||||
|
||||
"BOL.dialog.soeasy": "Inmanquable (+4)",
|
||||
"BOL.dialog.veryeasy": "Trés Facile (+2)",
|
||||
"BOL.dialog.easy": "Facile (+1)",
|
||||
|
@ -459,9 +459,11 @@ export class BoLActor extends Actor {
|
||||
//Spent points
|
||||
this.spentAstrologyPoints(rollData.astrologyPointsCost)
|
||||
if (rollData.horoscopeType == "minor") {
|
||||
let horoscope = { name: "SITUATION A SPECIFIER", type :"feature",
|
||||
let horoscope = {
|
||||
name: "SITUATION A SPECIFIER", type: "feature",
|
||||
img: "icons/magic/perception/eye-ringed-glow-angry-large-red.webp",
|
||||
system :{subtype: "horoscope", properties: {
|
||||
system: {
|
||||
subtype: "horoscope", properties: {
|
||||
ishoroscopemajor: false,
|
||||
horoscopeanswer: (rollData.isSuccess) ? "favorable" : "unfavorable",
|
||||
rank: rollData.careerBonus
|
||||
@ -751,6 +753,42 @@ export class BoLActor extends Actor {
|
||||
await this.setFlag("world", "last-initiative", rollData)
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
storeVitaliteCombat() {
|
||||
this.setFlag("world", "vitalite-before-combat", duplicate(this.system.resources.hp))
|
||||
}
|
||||
/*-------------------------------------------- */
|
||||
async displayRecuperation() {
|
||||
let previousHP = this.getFlag("world", "vitalite-before-combat")
|
||||
let lossHP = previousHP.value - this.system.resources.hp.value
|
||||
console.log(">>>>> RECUP INFO", previousHP, this.system.resources.hp.value)
|
||||
if (previousHP && lossHP > 0 && this.system.resources.hp.value > 0) {
|
||||
let msg = await ChatMessage.create({
|
||||
alias: this.name,
|
||||
whisper: BoLUtility.getWhisperRecipientsAndGMs(this.name),
|
||||
content: await renderTemplate('systems/bol/templates/chat/chat-recup-information.hbs', {
|
||||
name: this.name,
|
||||
actorId: this.id,
|
||||
lossHP: lossHP,
|
||||
recupHP: Math.floor(lossHP / 2)
|
||||
})
|
||||
})
|
||||
}
|
||||
this.unsetFlag("world", "vitalite-before-combat")
|
||||
}
|
||||
/*-------------------------------------------- */
|
||||
async applyRecuperation(recupHP) {
|
||||
let hp = duplicate(this.system.resources.hp)
|
||||
hp.value += recupHP
|
||||
hp.value = Math.min(hp.value, hp.max)
|
||||
this.update({ 'system.resources.hp': hp })
|
||||
let msg = await ChatMessage.create({
|
||||
alias: this.name,
|
||||
whisper: BoLUtility.getWhisperRecipientsAndGMs(this.name),
|
||||
content: game.i18n.format( "BOL.chat.inforecup", {name: this.name, recupHP: recupHP} )
|
||||
})
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
clearInitiative() {
|
||||
this.unsetFlag("world", "last-initiative")
|
||||
|
@ -766,13 +766,13 @@ export class BoLDefaultRoll {
|
||||
let weaponFormula = BoLUtility.getDamageFormula(this.rollData.weapon.system, this.rollData.fightOption)
|
||||
|
||||
let damageFormula = weaponFormula + "+" + bonusDmg + "+" + attrDamageValue
|
||||
console.log("DAMAGE !!!", damageFormula, attrDamageValue, this.rollData)
|
||||
|
||||
//console.log("Formula", weaponFormula, damageFormula, this.rollData.weapon.data.data.properties.damage)
|
||||
this.rollData.damageFormula = damageFormula
|
||||
this.rollData.damageRoll = new Roll(damageFormula)
|
||||
await this.rollData.damageRoll.roll({ "async": false })
|
||||
this.rollData.damageTotal = this.rollData.damageRoll.total
|
||||
console.log("DAMAGE !!!", damageFormula, attrDamageValue, this.rollData)
|
||||
}
|
||||
BoLUtility.cleanupButtons(this.rollData.optionsId)
|
||||
this.sendDamageMessage()
|
||||
|
@ -41,12 +41,23 @@ export class BoLCombatManager extends Combat {
|
||||
super.nextRound()
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
startCombat() {
|
||||
let combatants = this.combatants.contents
|
||||
for (let c of combatants) {
|
||||
let actor = game.actors.get( c.actorId )
|
||||
actor.storeVitaliteCombat()
|
||||
}
|
||||
return super.startCombat()
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
_onDelete() {
|
||||
let combatants = this.combatants.contents
|
||||
for (let c of combatants) {
|
||||
let actor = game.actors.get(c.actorId)
|
||||
actor.clearInitiative()
|
||||
actor.displayRecuperation()
|
||||
}
|
||||
super._onDelete()
|
||||
}
|
||||
|
@ -8,8 +8,6 @@ export class BoLUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static init() {
|
||||
this.attackStore = {}
|
||||
|
||||
game.settings.register("bol", "rollArmor", {
|
||||
name: "Effectuer des jets pour les armures",
|
||||
hint: "Effectue un jet de dés pour les armures (valeur fixe si désactivé)",
|
||||
@ -298,13 +296,13 @@ export class BoLUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static sendAttackSuccess(attackDef) {
|
||||
if (attackDef.targetId) {
|
||||
static sendAttackSuccess(rollData) {
|
||||
if (rollData.targetId) {
|
||||
// Broadcast to GM or process it directly in case of GM defense
|
||||
if (!game.user.isGM) {
|
||||
game.socket.emit("system.bol", { name: "msg_attack_success", data: duplicate(attackDef) })
|
||||
game.socket.emit("system.bol", { name: "msg_attack_success", data: duplicate(rollData) })
|
||||
} else {
|
||||
BoLUtility.processAttackSuccess(attackDef)
|
||||
BoLUtility.processAttackSuccess(rollData)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -397,6 +395,19 @@ export class BoLUtility {
|
||||
game.socket.emit("system.bol", { name: "msg_damage_handling", data: { msgId: msgId, attackId: attackId, defenseMode: defenseMode, weaponId: weaponId } })
|
||||
}
|
||||
})
|
||||
|
||||
html.on("click", '.recup-vitalite', event => {
|
||||
event.preventDefault()
|
||||
let actorId = event.currentTarget.attributes['data-actor-id'].value
|
||||
let recupHP = event.currentTarget.attributes['data-recup-hp'].value
|
||||
let actor = game.actors.get(actorId)
|
||||
|
||||
let messageId = BoLUtility.findChatMessageId(event.currentTarget)
|
||||
BoLUtility.removeChatMessageId(messageId)
|
||||
|
||||
actor.applyRecuperation(recupHP)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -404,48 +415,50 @@ export class BoLUtility {
|
||||
if (!game.user.isGM) {
|
||||
return
|
||||
}
|
||||
let message = game.messages.get(msgId)
|
||||
let rollData = message.getFlag("world", "bol-roll-data")
|
||||
BoLUtility.removeChatMessageId(msgId)
|
||||
|
||||
console.log("Damage Handling", attackId, defenseMode, weaponId)
|
||||
// Only GM process this
|
||||
let attackDef = this.attackStore[attackId]
|
||||
if (attackDef && attackDef.defenderId) {
|
||||
if (attackDef.defenseDone) {
|
||||
if (rollData && rollData.defenderId) {
|
||||
if (rollData.defenseDone) {
|
||||
return
|
||||
} // ?? Why ???
|
||||
attackDef.defenseDone = true
|
||||
attackDef.defenseMode = defenseMode
|
||||
let token = game.scenes.current.tokens.get(attackDef.targetId)
|
||||
rollData.defenseDone = true
|
||||
rollData.defenseMode = defenseMode
|
||||
let token = game.scenes.current.tokens.get(rollData.targetId)
|
||||
let defender = token.actor
|
||||
|
||||
if (defenseMode == 'damage-with-armor') {
|
||||
let armorFormula = defender.getArmorFormula()
|
||||
attackDef.rollArmor = new Roll(armorFormula)
|
||||
attackDef.rollArmor.roll({ async: false })
|
||||
attackDef.armorProtect = (attackDef.rollArmor.total < 0) ? 0 : attackDef.rollArmor.total
|
||||
attackDef.finalDamage = attackDef.damageTotal - attackDef.armorProtect
|
||||
attackDef.finalDamage = (attackDef.finalDamage < 0) ? 0 : attackDef.finalDamage
|
||||
defender.sufferDamage(attackDef.finalDamage)
|
||||
console.log("Armor roll -> result ", attackDef)
|
||||
rollData.rollArmor = new Roll(armorFormula)
|
||||
rollData.rollArmor.roll({ async: false })
|
||||
rollData.armorProtect = (rollData.rollArmor.total < 0) ? 0 : rollData.rollArmor.total
|
||||
rollData.finalDamage = rollData.damageTotal - rollData.armorProtect
|
||||
rollData.finalDamage = (rollData.finalDamage < 0) ? 0 : rollData.finalDamage
|
||||
defender.sufferDamage(rollData.finalDamage)
|
||||
console.log("Armor roll -> result ", rollData)
|
||||
}
|
||||
if (defenseMode == 'damage-without-armor') {
|
||||
attackDef.finalDamage = attackDef.damageTotal
|
||||
defender.sufferDamage(attackDef.finalDamage)
|
||||
rollData.finalDamage = atrollDatatackDef.damageTotal
|
||||
defender.sufferDamage(rollData.finalDamage)
|
||||
}
|
||||
if (defenseMode == 'hero-reduce-damage') {
|
||||
let armorFormula = defender.getArmorFormula()
|
||||
attackDef.rollArmor = new Roll(armorFormula)
|
||||
attackDef.rollArmor.roll({ async: false })
|
||||
attackDef.armorProtect = (attackDef.rollArmor.total < 0) ? 0 : attackDef.rollArmor.total
|
||||
attackDef.rollHero = new Roll("1d6")
|
||||
attackDef.rollHero.roll({ async: false })
|
||||
attackDef.finalDamage = attackDef.damageTotal - attackDef.rollHero.total - attackDef.armorProtect
|
||||
attackDef.finalDamage = (attackDef.finalDamage < 0) ? 0 : attackDef.finalDamage
|
||||
defender.sufferDamage(attackDef.finalDamage)
|
||||
rollData.rollArmor = new Roll(armorFormula)
|
||||
rollData.rollArmor.roll({ async: false })
|
||||
rollData.armorProtect = (rollData.rollArmor.total < 0) ? 0 : rollData.rollArmor.total
|
||||
rollData.rollHero = new Roll("1d6")
|
||||
rollData.rollHero.roll({ async: false })
|
||||
rollData.finalDamage = rollData.damageTotal - rollData.rollHero.total - rollData.armorProtect
|
||||
rollData.finalDamage = (rollData.finalDamage < 0) ? 0 : rollData.finalDamage
|
||||
defender.sufferDamage(rollData.finalDamage)
|
||||
defender.subHeroPoints(1)
|
||||
}
|
||||
if (defenseMode == 'hero-in-extremis') {
|
||||
attackDef.finalDamage = 0;
|
||||
attackDef.weaponHero = defender.weapons.find(item => item._id == weaponId);
|
||||
rollData.finalDamage = 0;
|
||||
rollData.weaponHero = defender.weapons.find(item => item._id == weaponId);
|
||||
defender.deleteEmbeddedDocuments("Item", [weaponId]);
|
||||
}
|
||||
|
||||
@ -456,16 +469,16 @@ export class BoLUtility {
|
||||
}
|
||||
}
|
||||
let damageResults = {
|
||||
attackId: attackDef.id,
|
||||
attacker: attackDef.attacker,
|
||||
rollArmor: attackDef.rollArmor,
|
||||
rollHero: attackDef.rollHero,
|
||||
weaponHero: attackDef.weaponHero,
|
||||
armorProtect: attackDef.armorProtect,
|
||||
attackId: rollData.id,
|
||||
attacker: rollData.attacker,
|
||||
rollArmor: rollData.rollArmor,
|
||||
rollHero: rollData.rollHero,
|
||||
weaponHero: rollData.weaponHero,
|
||||
armorProtect: rollData.armorProtect,
|
||||
name: defender.name,
|
||||
defender: defender,
|
||||
defenseMode: attackDef.defenseMode,
|
||||
finalDamage: attackDef.finalDamage
|
||||
defenseMode: rollData.defenseMode,
|
||||
finalDamage: rollData.finalDamage
|
||||
}
|
||||
ChatMessage.create({
|
||||
alias: defender.name,
|
||||
@ -552,28 +565,28 @@ export class BoLUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processAttackSuccess(attackDef) {
|
||||
console.log("Attack success processing", attackDef)
|
||||
if (!game.user.isGM || !attackDef.defenderId) { // Only GM process this
|
||||
static async processAttackSuccess(rollData) {
|
||||
console.log("Attack success processing", rollData)
|
||||
if (!game.user.isGM || !rollData.defenderId) { // Only GM process this
|
||||
return
|
||||
}
|
||||
// Build and send the defense message to the relevant people (ie GM + defender)
|
||||
let defender = game.actors.get(attackDef.defenderId)
|
||||
console.log("DEF WEP", attackDef, defender)
|
||||
let defender = game.actors.get(rollData.defenderId)
|
||||
let defenderWeapons = defender.weapons || []
|
||||
this.attackStore[attackDef.id] = attackDef // Store !
|
||||
ChatMessage.create({
|
||||
let msg = await ChatMessage.create({
|
||||
alias: defender.name,
|
||||
whisper: BoLUtility.getWhisperRecipientsAndGMs(defender.name),
|
||||
content: await renderTemplate('systems/bol/templates/chat/rolls/defense-request-card.hbs', {
|
||||
attackId: attackDef.id,
|
||||
attacker: attackDef.attacker,
|
||||
attackId: rollData.id,
|
||||
attacker: rollData.attacker,
|
||||
defender: defender,
|
||||
defenderWeapons: defenderWeapons,
|
||||
damageTotal: attackDef.damageRoll.total,
|
||||
damagesIgnoresArmor: attackDef.damagesIgnoresArmor,
|
||||
damageTotal: rollData.damageTotal,
|
||||
damagesIgnoresArmor: rollData.damagesIgnoresArmor,
|
||||
})
|
||||
})
|
||||
msg.setFlag("world", "bol-roll-data", rollData)
|
||||
console.log("DEF WEP", rollData, defender)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -14,7 +14,7 @@
|
||||
],
|
||||
"url": "https://www.uberwald.me/gitea/public/bol",
|
||||
"license": "LICENSE.txt",
|
||||
"version": "10.5.8",
|
||||
"version": "10.5.9",
|
||||
"compatibility": {
|
||||
"minimum": "10",
|
||||
"verified": "10"
|
||||
@ -202,7 +202,7 @@
|
||||
],
|
||||
"socket": true,
|
||||
"manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json",
|
||||
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.8.zip",
|
||||
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.9.zip",
|
||||
"background": "systems/bol/ui/page_accueil.webp",
|
||||
"gridDistance": 1.5,
|
||||
"gridUnits": "m",
|
||||
|
12
templates/chat/chat-recup-information.hbs
Normal file
12
templates/chat/chat-recup-information.hbs
Normal file
@ -0,0 +1,12 @@
|
||||
<div>
|
||||
<img class="chat-icon" src="{{img}}" alt="{{name}}"/>
|
||||
<h2 class="bad"><strong>{{name}}</strong></h2>
|
||||
</div>
|
||||
|
||||
<div class="flexrow">
|
||||
|
||||
{{localize "BOL.chat.losshp" lossHP=lossHP recupHP=recupHP}}
|
||||
<button class="recup-vitalite" data-actor-id="{{actorId}}" data-recup-hp="{{recupHP}}">{{localize "BOL.chat.applyrecup" recupHP=recupHP}}</button>
|
||||
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user