Passage en v12 + preparation module officiel BoL

This commit is contained in:
2024-04-26 18:00:56 +02:00
parent ae43c7c920
commit 7ed9265a26
190 changed files with 767 additions and 1743 deletions

View File

@ -9,7 +9,7 @@ export class BoLActorSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["bol", "sheet", "actor"],
template: "systems/bol/templates/actor/actor-sheet.hbs",
width: 860,
@ -122,8 +122,8 @@ export class BoLActorSheet extends ActorSheet {
/** @override */
async getData(options) {
const data = super.getData(options)
const actorData = duplicate(data)
let formData = duplicate(data)
const actorData = foundry.utils.duplicate(data)
let formData = foundry.utils.duplicate(data)
formData.config = game.bol.config
formData.data = actorData
@ -160,6 +160,7 @@ export class BoLActorSheet extends ActorSheet {
formData.bougette = this.actor.getBougette()
formData.charType = this.actor.getCharType()
formData.villainy = this.actor.getVillainy()
formData.isUndead = this.actor.isUndead()
formData.biography = await TextEditor.enrichHTML(this.object.system.details?.biography || "", { async: true })
formData.notes = await TextEditor.enrichHTML(this.object.system.details.notes || "", { async: true })
formData.isSorcerer = this.actor.isSorcerer()
@ -187,7 +188,7 @@ export class BoLActorSheet extends ActorSheet {
// Get the type of item to create.
const type = header.dataset.type;
// Grab any data associated with this control.
const data = duplicate(header.dataset);
const data = foundry.utils.duplicate(header.dataset);
// Initialize a default name.
const name = `New ${type.capitalize()}`;
// Prepare the item object.

View File

@ -38,10 +38,7 @@ export class BoLActor extends Actor {
if (this.type === 'character') {
return true
}
if (this.type === 'encounter' && this.chartype == "adversary") {
return true
}
return false
return (this.type === 'encounter' && this.chartype == "adversary")
}
/* -------------------------------------------- */
@ -54,10 +51,10 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
getVillainy() {
if (this.type === 'encounter' && this.chartype == "adversary") {
return true
}
return false
return (this.type === 'encounter' && this.chartype == "adversary")
}
isUndead() {
return (this.type == "encounter" && this.system.isundead)
}
/* -------------------------------------------- */
getInitiativeMalus() {
@ -69,7 +66,7 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
getBougette() {
if (this.type == "character") {
let b = duplicate(this.system.bougette)
let b = foundry.utils.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"
return b
@ -80,7 +77,7 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
async rollBougette() {
if (this.type == "character") {
let attribute = duplicate(this.system.attributes.vigor)
let attribute = foundry.utils.duplicate(this.system.attributes.vigor)
let rollData = BoLRoll.getCommonRollData(this, "bougette", attribute, undefined)
rollData.formula = game.bol.config.bougetteDice[String(this.system.bougette.value)]
let r = new BoLDefaultRoll(rollData)
@ -91,7 +88,7 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
decBougette() {
if (this.type == "character") {
let bougette = duplicate(this.system.bougette)
let bougette = foundry.utils.duplicate(this.system.bougette)
bougette.value = Math.max(Number(bougette.value) - 1, 0)
this.update({ 'system.bougette': bougette })
}
@ -145,7 +142,7 @@ export class BoLActor extends Actor {
}
}
get attributes() {
let attrList = duplicate(Object.values(this.system.attributes))
let attrList = foundry.utils.duplicate(Object.values(this.system.attributes))
this.addEffectModifiers(attrList, "system.attributes.")
return attrList
}
@ -199,7 +196,7 @@ export class BoLActor extends Actor {
getActiveFightOption() {
let it = this.items.find(i => i.type === "feature" && i.system.subtype === "fightoption" && i.system.properties.activated)
if (it) {
return duplicate(it)
return foundry.utils.duplicate(it)
}
return undefined
}
@ -224,10 +221,10 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
incAttributeXP(key) {
let attr = duplicate(this.system.attributes[key])
let attr = foundry.utils.duplicate(this.system.attributes[key])
if (attr) {
let nextXP = (attr.value == -1) ? 2 : attr.value + (attr.value + 1)
let xp = duplicate(this.system.xp)
let xp = foundry.utils.duplicate(this.system.xp)
if (xp.total - xp.spent >= nextXP) {
attr.value += 1
xp.spent += nextXP
@ -241,10 +238,10 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
incAptitudeXP(key) {
let apt = duplicate(this.system.aptitudes[key])
let apt = foundry.utils.duplicate(this.system.aptitudes[key])
if (apt) {
let nextXP = (apt.value == -1) ? 1 : apt.value + 2
let xp = duplicate(this.system.xp)
let xp = foundry.utils.duplicate(this.system.xp)
if (xp.total - xp.spent >= nextXP) {
apt.value += 1
xp.spent += nextXP
@ -259,9 +256,9 @@ export class BoLActor extends Actor {
incCareerXP(itemId) {
let career = this.items.get(itemId)
if (career) {
career = duplicate(career)
career = foundry.utils.duplicate(career)
let nextXP = career.system.rank + 1
let xp = duplicate(this.system.xp)
let xp = foundry.utils.duplicate(this.system.xp)
if (xp.total - xp.spent >= nextXP) {
xp.spent += nextXP
this.update({ [`system.xp`]: xp })
@ -280,7 +277,7 @@ export class BoLActor extends Actor {
let updates = []
if (fightOption) {
fightOption = duplicate(fightOption)
fightOption = foundry.utils.duplicate(fightOption)
if (fightOption.system.properties.activated) {
state = false
} else {
@ -326,13 +323,13 @@ export class BoLActor extends Actor {
return this.items.filter(i => i.type === "feature" && i.system.subtype === "horoscope")
}
get boons() {
return duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "boon") || []);
return foundry.utils.duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "boon") || []);
}
get flaws() {
return duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "flaw") || []);
return foundry.utils.duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "flaw") || []);
}
get careers() {
return duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "career") || [])
return foundry.utils.duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "career") || [])
}
get origins() {
return this.items.filter(i => i.type === "feature" && i.system.subtype === "origin");
@ -414,10 +411,10 @@ export class BoLActor extends Actor {
get bonusBoons() {
let boons = this.items.filter(i => i.type === "feature" && i.system.subtype === "boon" && i.system.properties.isbonusdice)
return duplicate(boons || [])
return foundry.utils.duplicate(boons || [])
}
get malusFlaws() {
return duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "flaw" && i.system.properties.ismalusdice) || []);
return foundry.utils.duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "flaw" && i.system.properties.ismalusdice) || []);
}
isSorcerer() {
@ -500,7 +497,7 @@ export class BoLActor extends Actor {
/*-------------------------------------------- */
spentAstrologyPoints(points) {
let astrology = duplicate(this.system.resources.astrologypoints)
let astrology = foundry.utils.duplicate(this.system.resources.astrologypoints)
astrology.value -= points
astrology.value = Math.max(astrology.value, 0)
this.update({ 'system.resources.astrologypoints': astrology })
@ -551,8 +548,8 @@ export class BoLActor extends Actor {
rollData.horoscopeName = actorHoroscope.name
}
if (rollData.horoscopeType == "majorgroup") {
let rID = randomID(16)
let horoscopes = duplicate(game.settings.get("bol", "horoscope-group"))
let rID = foundry.utils.randomID(16)
let horoscopes = foundry.utils.duplicate(game.settings.get("bol", "horoscope-group"))
horoscopes[rID] = {
id: rID,
name: game.i18n.localize("BOL.ui.groupHoroscope") + this.name,
@ -645,7 +642,7 @@ export class BoLActor extends Actor {
resources['power'] = this.system.resources.power
}
if (this.system.chartype == 'adversary') {
resources['hero'] = duplicate(this.system.resources.hero)
resources['hero'] = foundry.utils.duplicate(this.system.resources.hero)
resources['hero'].label = "BOL.resources.villainy"
}
} else {
@ -791,17 +788,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.name == game.i18n.localize("EFFECT.StatusProne"))
let dead = this.effects.find(ef => ef.name == game.i18n.localize("EFFECT.StatusDead"))
if (this.system.resources.hp.value <= 0) {
if (!prone) {
await this.createEmbeddedDocuments("ActiveEffect", [
{ label: 'EFFECT.StatusProne', icon: 'icons/svg/falling.svg', flags: { core: { statusId: 'prone' } } }
{ name: game.i18n.localize('EFFECT.StatusProne'), icon: 'icons/svg/falling.svg', statuses: 'prone' }
])
}
if (this.system.resources.hp.value < -5 && !dead) {
await this.createEmbeddedDocuments("ActiveEffect", [
{ label: 'EFFECT.StatusDead', icon: 'icons/svg/skull.svg', flags: { core: { statusId: 'dead' } } }
{ name: game.i18n.localize('EFFECT.StatusDead'), icon: 'icons/svg/skull.svg', statuses: 'dead' }
])
}
ChatMessage.create({
@ -828,7 +825,7 @@ export class BoLActor extends Actor {
/*-------------------------------------------- */
storeVitaliteCombat() {
this.setFlag("world", "vitalite-before-combat", duplicate(this.system.resources.hp))
this.setFlag("world", "vitalite-before-combat", foundry.utils.duplicate(this.system.resources.hp))
}
/*-------------------------------------------- */
async displayRecuperation() {
@ -852,7 +849,7 @@ export class BoLActor extends Actor {
}
/*-------------------------------------------- */
async applyRecuperation(recupHP) {
let hp = duplicate(this.system.resources.hp)
let hp = foundry.utils.duplicate(this.system.resources.hp)
//console.log("RECUP !!!!", hp, recupHP)
hp.value += Number(recupHP)
hp.value = Math.min(hp.value, hp.max)
@ -1001,7 +998,7 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
rollProtection(itemId) {
let armor = duplicate(this.items.get(itemId))
let armor = foundry.utils.duplicate(this.items.get(itemId))
if (armor) {
let armorFormula = "max(" + armor.system.properties.soak.formula + ", 0)"
let rollArmor = new Roll(armorFormula)
@ -1011,9 +1008,9 @@ export class BoLActor extends Actor {
/* -------------------------------------------- */
rollWeaponDamage(itemId) {
let weapon = duplicate(this.items.get(itemId))
let weapon = foundry.utils.duplicate(this.items.get(itemId))
if (weapon) {
let r = new BoLDefaultRoll({ id: randomID(16), isSuccess: true, mode: "weapon", weapon: weapon, actorId: this.id, actor: this })
let r = new BoLDefaultRoll({ id: foundry.utils.randomID(16), isSuccess: true, mode: "weapon", weapon: weapon, actorId: this.id, actor: this })
r.setSuccess(true)
r.rollDamage()
}
@ -1023,7 +1020,7 @@ export class BoLActor extends Actor {
toggleEquipItem(item) {
const equipable = item.system.properties.equipable;
if (equipable) {
let itemData = duplicate(item);
let itemData = foundry.utils.duplicate(item);
itemData.system.worn = !itemData.system.worn;
return item.update(itemData);
}

View File

@ -9,7 +9,7 @@ export class BoLVehicleSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["bol", "sheet", "actor"],
template: "systems/bol/templates/actor/vehicle-sheet.hbs",
width: 860,
@ -116,12 +116,12 @@ export class BoLVehicleSheet extends ActorSheet {
/** @override */
async getData(options) {
const data = super.getData(options)
let formData = duplicate(data)
let formData = foundry.utils.duplicate(data)
formData.config = game.bol.config
formData.name = this.actor.name
formData.img = this.actor.img
formData.system = duplicate(this.actor.system)
formData.system = foundry.utils.duplicate(this.actor.system)
formData.weapons = this.actor.vehicleWeapons
formData.isGM = game.user.isGM
formData.options = this.options
@ -147,7 +147,7 @@ export class BoLVehicleSheet extends ActorSheet {
// Get the type of item to create.
const type = header.dataset.type;
// Grab any data associated with this control.
const data = duplicate(header.dataset);
const data = foundry.utils.duplicate(header.dataset);
// Initialize a default name.
const name = `New ${type.capitalize()}`;
// Prepare the item object.