Messages de recuperation

This commit is contained in:
2023-03-18 10:24:30 +01:00
parent 0c502a2188
commit 83d3f17dd0
7 changed files with 193 additions and 115 deletions

View File

@ -40,10 +40,10 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
getBougette() {
if ( this.type == "character") {
if (this.type == "character") {
let b = duplicate(this.system.bougette)
b.label = game.i18n.localize( game.bol.config.bougetteState[String(this.system.bougette.value)] )
b.diceImg = "icons/dice/" + game.bol.config.bougetteDice[String(this.system.bougette.value)] + "black.svg"
b.label = game.i18n.localize(game.bol.config.bougetteState[String(this.system.bougette.value)])
b.diceImg = "icons/dice/" + game.bol.config.bougetteDice[String(this.system.bougette.value)] + "black.svg"
return b
}
return undefined
@ -51,9 +51,9 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
async rollBougette() {
if ( this.type == "character") {
if (this.type == "character") {
let attribute = duplicate(this.system.attributes.vigor)
let rollData = BoLRoll.getCommonRollData(this, "bougette", attribute, undefined )
let rollData = BoLRoll.getCommonRollData(this, "bougette", attribute, undefined)
rollData.formula = game.bol.config.bougetteDice[String(this.system.bougette.value)]
let r = new BoLDefaultRoll(rollData)
r.roll()
@ -62,13 +62,13 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
decBougette() {
if ( this.type == "character") {
let bougette = duplicate(this.system.bougette)
bougette.value = Math.max( Number(bougette.value) - 1, 0)
this.update( { 'system.bougette': bougette } )
if (this.type == "character") {
let bougette = duplicate(this.system.bougette)
bougette.value = Math.max(Number(bougette.value) - 1, 0)
this.update({ 'system.bougette': bougette })
}
}
/* -------------------------------------------- */
updateResourcesData() {
if (this.type == 'character') {
@ -137,7 +137,7 @@ export class BoLActor extends Actor {
}
// Apply defense effects
for (let i of this.items) {
if (i.type === "feature" && i.system.subtype === "boleffect" && i.system.properties.identifier.includes("aptitudes.def") ) {
if (i.type === "feature" && i.system.subtype === "boleffect" && i.system.properties.identifier.includes("aptitudes.def")) {
defMod += Number(i.system.properties.modifier)
}
}
@ -389,7 +389,7 @@ export class BoLActor extends Actor {
}
// Apply vigor effects
for (let i of this.items) {
if (i.type === "feature" && i.system.subtype === "boleffect" && i.system.properties.identifier.includes("vigor") ) {
if (i.type === "feature" && i.system.subtype === "boleffect" && i.system.properties.identifier.includes("vigor")) {
attrDamageValue += Number(i.system.properties.modifier)
}
}
@ -432,25 +432,25 @@ export class BoLActor extends Actor {
this.updateEmbeddedDocuments('Item', [{ _id: alchemy.id, 'system.properties.pccurrent': 0 }])
}
}
/*-------------------------------------------- */
spentAstrologyPoints(points) {
let astrology = duplicate(this.system.resources.astrologypoints)
astrology.value -= points
astrology.value = Math.max(astrology.value,0)
this.update( { 'system.resources.astrologypoints': astrology} )
astrology.value = Math.max(astrology.value, 0)
this.update({ 'system.resources.astrologypoints': astrology })
}
/*-------------------------------------------- */
getHoroscopesBonus() {
let astro = this.items.filter(it => it.type == "feature" && it.system.subtype == "horoscope" && !it.system.properties.ishoroscopemajor
&& it.system.properties.horoscopeanswer == "favorable")
let astro = this.items.filter(it => it.type == "feature" && it.system.subtype == "horoscope" && !it.system.properties.ishoroscopemajor
&& it.system.properties.horoscopeanswer == "favorable")
return astro
}
/*-------------------------------------------- */
getHoroscopesMalus() {
let astro = this.items.filter(it => it.type == "feature" && it.system.subtype == "horoscope" && !it.system.properties.ishoroscopemajor
&& it.system.properties.horoscopeanswer == "unfavorable")
let astro = this.items.filter(it => it.type == "feature" && it.system.subtype == "horoscope" && !it.system.properties.ishoroscopemajor
&& it.system.properties.horoscopeanswer == "unfavorable")
return astro
}
@ -458,26 +458,28 @@ export class BoLActor extends Actor {
manageHoroscope(rollData) {
//Spent points
this.spentAstrologyPoints(rollData.astrologyPointsCost)
if ( rollData.horoscopeType == "minor") {
let horoscope = { name: "SITUATION A SPECIFIER", type :"feature",
if (rollData.horoscopeType == "minor") {
let horoscope = {
name: "SITUATION A SPECIFIER", type: "feature",
img: "icons/magic/perception/eye-ringed-glow-angry-large-red.webp",
system :{subtype: "horoscope", properties: {
ishoroscopemajor: false,
horoscopeanswer: (rollData.isSuccess) ? "favorable": "unfavorable",
rank: rollData.careerBonus
}
system: {
subtype: "horoscope", properties: {
ishoroscopemajor: false,
horoscopeanswer: (rollData.isSuccess) ? "favorable" : "unfavorable",
rank: rollData.careerBonus
}
}
}
this.createEmbeddedDocuments('Item', [horoscope])
}
if ( rollData.horoscopeType == "major" ) {
if ( rollData.isSuccess) {
if (rollData.horoscopeType == "major") {
if (rollData.isSuccess) {
this.subHeroPoints(1)
} else {
this.addHeroPoints(1)
}
}
}
if ( rollData.horoscopeType == "majorgroup" ) {
if (rollData.horoscopeType == "majorgroup") {
let rID = randomID(16)
let horoscopes = duplicate(game.settings.get("bol", "horoscope-group"))
horoscopes[rID] = {
@ -485,7 +487,7 @@ export class BoLActor extends Actor {
name: game.i18n.localize("BOL.ui.groupHoroscope") + this.name,
maxDice: rollData.careerBonus,
availableDice: rollData.careerBonus,
type: (rollData.isSuccess) ? "bonus": "malus"
type: (rollData.isSuccess) ? "bonus" : "malus"
}
game.settings.set("bol", "horoscope-group", horoscopes)
}
@ -497,10 +499,10 @@ export class BoLActor extends Actor {
return this.system.resources.astrologypoints.value
}
/*-------------------------------------------- */
removeHoroscopeMinor( rollData) {
removeHoroscopeMinor(rollData) {
let toDel = []
for(let horo of rollData.selectedHoroscope) {
toDel.push( horo._id )
for (let horo of rollData.selectedHoroscope) {
toDel.push(horo._id)
}
if (toDel.length > 0) {
this.deleteEmbeddedDocuments('Item', toDel)
@ -519,7 +521,7 @@ export class BoLActor extends Actor {
newPC = alchemy.system.properties.pccurrent + pcCost
await this.updateEmbeddedDocuments('Item', [{ _id: alchemy.id, 'system.properties.pccurrent': newPC }])
} else {
ui.notifications.warn( game.i18n.localize("BOL.ui.nomorealchemypoints") )
ui.notifications.warn(game.i18n.localize("BOL.ui.nomorealchemypoints"))
}
}
}
@ -716,17 +718,17 @@ export class BoLActor extends Actor {
let lastHP = await this.getFlag("world", hpID)
if (lastHP != this.system.resources.hp.value && game.user.isGM) { // Only GM sends this
await this.setFlag("world", hpID, this.system.resources.hp.value)
let prone = this.effects.find( ef => ef.label == "EFFECT.StatusProne")
let dead = this.effects.find( ef => ef.label == "EFFECT.StatusDead")
let prone = this.effects.find(ef => ef.label == "EFFECT.StatusProne")
let dead = this.effects.find(ef => ef.label == "EFFECT.StatusDead")
if (this.system.resources.hp.value <= 0) {
if ( !prone) {
if (!prone) {
await this.createEmbeddedDocuments("ActiveEffect", [
{label: 'EFFECT.StatusProne', icon: 'icons/svg/falling.svg', flags: { core: { statusId: 'prone' } } }
{ label: 'EFFECT.StatusProne', icon: 'icons/svg/falling.svg', flags: { core: { statusId: 'prone' } } }
])
}
if ( this.system.resources.hp.value < -5 && !dead) {
if (this.system.resources.hp.value < -5 && !dead) {
await this.createEmbeddedDocuments("ActiveEffect", [
{label: 'EFFECT.StatusDead', icon: 'icons/svg/skull.svg', flags: { core: { statusId: 'dead' } } }
{ label: 'EFFECT.StatusDead', icon: 'icons/svg/skull.svg', flags: { core: { statusId: 'dead' } } }
])
}
ChatMessage.create({
@ -735,11 +737,11 @@ export class BoLActor extends Actor {
content: await renderTemplate('systems/bol/templates/chat/chat-vitality-zero.hbs', { name: this.name, img: this.img, hp: this.system.resources.hp.value })
})
} else {
if ( prone ) {
await this.deleteEmbeddedDocuments("ActiveEffect", [ prone.id ] )
if (prone) {
await this.deleteEmbeddedDocuments("ActiveEffect", [prone.id])
}
if ( dead ) {
await this.deleteEmbeddedDocuments("ActiveEffect", [ dead.id ] )
if (dead) {
await this.deleteEmbeddedDocuments("ActiveEffect", [dead.id])
}
}
}
@ -751,9 +753,45 @@ 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" )
this.unsetFlag("world", "last-initiative")
}
/*-------------------------------------------- */
@ -766,50 +804,50 @@ export class BoLActor extends Actor {
/*-------------------------------------------- */
getInitiativeRank(rollData = undefined, isCombat = false, combatData) {
if (!rollData) {
if (!rollData) {
rollData = this.getFlag("world", "last-initiative")
}
let fvttInit = 4 // Pietaille par defaut
if (this.type == 'character' ) {
if (this.type == 'character') {
fvttInit = 5
if (!rollData) {
if (!rollData) {
fvttInit = -1
if ( isCombat ) {
if (isCombat) {
ui.notifications.info(game.i18n.localize("BOL.ui.warninitiative"))
BoLRoll.aptitudeCheck(this, "init", undefined, combatData )
BoLRoll.aptitudeCheck(this, "init", undefined, combatData)
}
} else {
if (rollData.isLegendary) {
fvttInit = 10
} else if (rollData.isCritical) {
fvttInit = 9
} else if (rollData.isSuccess ) {
} else if (rollData.isSuccess) {
fvttInit = 8
} else if (rollData.isFumble) {
fvttInit = 3
}
}
}
}
if ( this.getCharType() == 'adversary') {
if (this.getCharType() == 'adversary') {
fvttInit = 7
}
if ( this.getCharType() == 'tough') {
}
if (this.getCharType() == 'tough') {
fvttInit = 6
}
if ( this.getCharType() == 'creature') {
if (this.getCharType() == 'creature') {
let mySize = this.getSize()
let sizeSmall = game.bol.config.creatureSize["small"].order
let sizeMedium = game.bol.config.creatureSize["medium"].order
if ( mySize >= sizeSmall && mySize <= sizeMedium) {
if (mySize >= sizeSmall && mySize <= sizeMedium) {
fvttInit = 6
}
if ( mySize > sizeMedium) {
if (mySize > sizeMedium) {
fvttInit = 7
}
}
return fvttInit
}
/*-------------------------------------------- */
async subHeroPoints(nb) {
let newHeroP = this.system.resources.hero.value - nb;
@ -839,13 +877,13 @@ export class BoLActor extends Actor {
} else if (protect.system.subtype == 'armor') {
if (BoLUtility.getRollArmor()) {
if (!protect.system.properties.soak.formula || protect.system.properties.soak.formula == "") {
ui.notifications.warn( game.i18n.localize("BOL.ui.armornoformula", protect.name) )
ui.notifications.warn(game.i18n.localize("BOL.ui.armornoformula", protect.name))
} else {
formula += "+" + " max(" + protect.system.properties.soak.formula + ",0)"
}
} else {
if (protect.system.properties.soak.value == undefined) {
ui.notifications.warn( game.i18n.localize("BOL.ui.armornoformula", protect.name) )
ui.notifications.warn(game.i18n.localize("BOL.ui.armornoformula", protect.name))
} else {
formula += "+ " + protect.system.properties.soak.value
}