Update pour v11/v12 et correction d'un bug sur les defenses

This commit is contained in:
2024-04-26 18:35:39 +02:00
parent 234bd44742
commit ec06f0fdcb
47 changed files with 205 additions and 186 deletions

View File

@@ -11,7 +11,7 @@ export class MaleficesActorSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["fvtt-malefices", "sheet", "actor", "malefices-actor-sheet"],
template: "systems/fvtt-malefices/templates/actors/actor-sheet.hbs",
width: 640,
@@ -33,14 +33,14 @@ export class MaleficesActorSheet extends ActorSheet {
name: this.actor.name,
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
system: duplicate(this.object.system),
system: foundry.utils.duplicate(this.object.system),
limited: this.object.limited,
armes: duplicate(this.actor.getArmes()),
tarots: duplicate(this.actor.getTarots()),
tarotsCache: duplicate(this.actor.getHiddenTarots()),
archetype: duplicate(this.actor.getArchetype()),
equipements: duplicate(this.actor.getEquipements()),
subActors: duplicate(this.actor.getSubActors()),
armes: foundry.utils.duplicate(this.actor.getArmes()),
tarots: foundry.utils.duplicate(this.actor.getTarots()),
tarotsCache: foundry.utils.duplicate(this.actor.getHiddenTarots()),
archetype: foundry.utils.duplicate(this.actor.getArchetype()),
equipements: foundry.utils.duplicate(this.actor.getEquipements()),
subActors: foundry.utils.duplicate(this.actor.getSubActors()),
phyMalus: this.actor.getPhysiqueMalus(),
elementsbio: this.actor.getElementsBio(),
sorts: this.actor.getSorts(),

View File

@@ -29,7 +29,7 @@ export class MaleficesActor extends Actor {
if (data instanceof Array) {
return super.create(data, options);
}
// If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
// If the created actor has items (only applicable to foundry.utils.duplicated actors) bypass the new actor creation logic
if (data.items) {
let actor = super.create(data, options);
return actor;
@@ -92,7 +92,7 @@ export class MaleficesActor extends Actor {
return comp;
}
getArchetype() {
let comp = duplicate(this.items.find(item => item.type == 'archetype') || {name: "Pas d'archetype"})
let comp = foundry.utils.duplicate(this.items.find(item => item.type == 'archetype') || {name: "Pas d'archetype"})
if (comp && comp.system) {
comp.tarot = MaleficesUtility.getTarot(comp.system.lametutelaire)
}
@@ -101,25 +101,25 @@ export class MaleficesActor extends Actor {
}
/* -------------------------------------------- */
getElementsBio() {
let comp = duplicate(this.items.filter(item => item.type == 'elementbio') || [])
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'elementbio') || [])
MaleficesUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getTarots() {
let comp = duplicate(this.items.filter(item => item.type == 'tarot' && !item.system.isgm) || [])
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'tarot' && !item.system.isgm) || [])
MaleficesUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getHiddenTarots() {
let comp = duplicate(this.items.filter(item => item.type == 'tarot' && item.system.isgm) || [])
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'tarot' && item.system.isgm) || [])
MaleficesUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getArmes() {
let comp = duplicate(this.items.filter(item => item.type == 'arme') || [])
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'arme') || [])
MaleficesUtility.sortArrayObjectsByName(comp)
return comp;
}
@@ -127,7 +127,7 @@ export class MaleficesActor extends Actor {
getItemById(id) {
let item = this.items.find(item => item.id == id);
if (item) {
item = duplicate(item)
item = foundry.utils.duplicate(item)
}
return item;
}
@@ -173,7 +173,7 @@ export class MaleficesActor extends Actor {
/* ------------------------------------------- */
async buildContainerTree() {
let equipments = duplicate(this.items.filter(item => item.type == "equipment") || [])
let equipments = foundry.utils.duplicate(this.items.filter(item => item.type == "equipment") || [])
for (let equip1 of equipments) {
if (equip1.system.iscontainer) {
equip1.system.contents = []
@@ -238,13 +238,13 @@ export class MaleficesActor extends Actor {
getSubActors() {
let subActors = [];
for (let id of this.system.subactors) {
subActors.push(duplicate(game.actors.get(id)))
subActors.push(foundry.utils.duplicate(game.actors.get(id)))
}
return subActors;
}
/* -------------------------------------------- */
async addSubActor(subActorId) {
let subActors = duplicate(this.system.subactors);
let subActors = foundry.utils.duplicate(this.system.subactors);
subActors.push(subActorId);
await this.update({ 'system.subactors': subActors });
}
@@ -291,7 +291,7 @@ export class MaleficesActor extends Actor {
}
/* -------------------------------------------- */
incDecAttr(attrKey, value) {
let attr = duplicate(this.system.attributs[attrKey])
let attr = foundry.utils.duplicate(this.system.attributs[attrKey])
attr.value += value
this.update( { [`system.attributs.${attrKey}`]: attr})
}
@@ -341,6 +341,7 @@ export class MaleficesActor extends Actor {
rollData.isReroll = false
rollData.confrontationDegre = 0
rollData.confrontationModif = 0
rollData.config = game.system.malefices.config
console.log("ROLLDATA", rollData)
@@ -358,7 +359,7 @@ export class MaleficesActor extends Actor {
rollAttribut(attrKey) {
let attr = this.system.attributs[attrKey]
let rollData = this.getCommonRollData()
rollData.attr = duplicate(attr)
rollData.attr = foundry.utils.duplicate(attr)
rollData.mode = "attribut"
rollData.title = attr.label
rollData.img = this.getAtttributImage(attrKey)
@@ -369,12 +370,12 @@ export class MaleficesActor extends Actor {
rollArme(weaponId) {
let arme = this.items.get(weaponId)
if (arme) {
arme = duplicate(arme)
arme = foundry.utils.duplicate(arme)
let rollData = this.getCommonRollData()
if (arme.system.armetype == "mainsnues" || arme.system.armetype == "epee") {
rollData.attr = { label: "(Physique+Habilité)/2", value: Math.floor( (this.getPhysiqueMalus()+this.system.attributs.physique.value+this.system.attributs.habilite.value) / 2) }
} else {
rollData.attr = duplicate(this.system.attributs.habilite)
rollData.attr = foundry.utils.duplicate(this.system.attributs.habilite)
}
rollData.mode = "arme"
rollData.arme = arme

View File

@@ -115,7 +115,7 @@ export class MaleficesCommands {
maxPlayerCard: 4,
maxSecretCard: 1,
cards: [],
players: duplicate(game.users),
players: foundry.utils.duplicate(game.users),
secretCards: [],
deck: MaleficesUtility.getTarots()
}

View File

@@ -27,4 +27,41 @@ export const MALEFICES_CONFIG = {
"epee": "Epée, sabre, javelot, etc",
"mainsnues": "Mains Nues"
},
confrontationDegreOptions :{
"0": "0",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5"
},
confrontationModifOptions: {
"-1": "-1",
"0": "0",
"1": "+1"
},
bonusMalusPersoOptions: [
{value: "-3", label: "-3"},
{value: "-2", label: "-2"},
{value: "-1", label: "-1"},
{value: "0", label: "0"},
{value: "+1", label: "+1"},
{value: "+2", label: "+2"},
{value: "+3", label: "+3"}
],
bonusMalusDefOptions: [
{value: "-6", label: "-6 (réussite critique)"},
{value: "-3", label: "-3 (réussite)"},
{value: "0", label: "0 (echec ou pas d'esquive)"},
{value: "+3", label: "+3 (echec critique)"}
],
bonusMalusPorteeOptions: [
{value: "1", label: "+1 (Portée courte)"},
{value: "0", label: "0 (Portée moyenne)"},
{value: "-1", label: "-1 (Portée longue)"}
]
}

View File

@@ -9,7 +9,7 @@ export class MaleficesItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["fvtt-malefices", "sheet", "item"],
template: "systems/fvtt-malefices/templates/item-sheet.hbs",
dragDrop: [{ dragSelector: null, dropSelector: null }],
@@ -43,8 +43,8 @@ export class MaleficesItemSheet extends ItemSheet {
name: this.object.name,
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
system: duplicate(this.object.system),
config: duplicate(game.system.malefices.config),
system: foundry.utils.duplicate(this.object.system),
config: foundry.utils.duplicate(game.system.malefices.config),
limited: this.object.limited,
options: this.options,
owner: this.document.isOwner,
@@ -76,7 +76,7 @@ export class MaleficesItemSheet extends ItemSheet {
/* -------------------------------------------- */
postItem() {
let chatData = duplicate(this.item)
let chatData = foundry.utils.duplicate(this.item)
if (this.actor) {
chatData.actor = { id: this.actor.id };
}

View File

@@ -11,7 +11,7 @@ export class MaleficesNPCSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["Malefices", "sheet", "actor"],
template: "systems/fvtt-malefices/templates/npc-sheet.html",
width: 640,
@@ -25,7 +25,7 @@ export class MaleficesNPCSheet extends ActorSheet {
/* -------------------------------------------- */
async getData() {
const objectData = this.object.system
let actorData = duplicate(objectData)
let actorData = foundry.utils.duplicate(objectData)
let formData = {
title: this.title,
@@ -38,16 +38,16 @@ export class MaleficesNPCSheet extends ActorSheet {
data: actorData,
limited: this.object.limited,
skills: this.actor.getSkills( ),
weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ),
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())),
spells: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getLore())),
equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ),
equippedWeapons: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquippedWeapons()) ),
weapons: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getWeapons()) ),
armors: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getArmors())),
shields: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getShields())),
spells: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getLore())),
equipments: this.actor.checkAndPrepareEquipments(foundry.utils.duplicate(this.actor.getEquipmentsOnly()) ),
equippedWeapons: this.actor.checkAndPrepareEquipments(foundry.utils.duplicate(this.actor.getEquippedWeapons()) ),
equippedArmor: this.actor.getEquippedArmor(),
equippedShield: this.actor.getEquippedShield(),
subActors: duplicate(this.actor.getSubActors()),
moneys: duplicate(this.actor.getMoneys()),
subActors: foundry.utils.duplicate(this.actor.getSubActors()),
moneys: foundry.utils.duplicate(this.actor.getMoneys()),
encCapacity: this.actor.getEncumbranceCapacity(),
saveRolls: this.actor.getSaveRoll(),
conditions: this.actor.getConditions(),

View File

@@ -43,7 +43,7 @@ export class MaleficesCharacterSummary extends Application {
/* -------------------------------------------- */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template: "systems/fvtt-malefices/templates/dialogs/character-summary.hbs",
popOut: true,
resizable: true,

View File

@@ -94,7 +94,7 @@ export class MaleficesTirageTarotDialog extends Dialog {
}
this.tirageData.secretCards.push(selectedCard)
}
this.tirageData.actors = duplicate(game.actors)
this.tirageData.actors = foundry.utils.duplicate(game.actors)
this.tirageData.state = 'attribute-to-actor'
}else {
this.sendCardRequest()

View File

@@ -65,7 +65,7 @@ export class MaleficesUtility {
/*-------------------------------------------- */
static getTarots() {
return duplicate(this.tarots)
return foundry.utils.duplicate(this.tarots)
}
static getTarot(tId) {
return this.tarots.find(t => t._id == tId)
@@ -196,7 +196,7 @@ export class MaleficesUtility {
let id = rollData.rollId
let oldRollData = this.rollDataStore[id] || {}
let newRollData = mergeObject(oldRollData, rollData)
let newRollData = foundry.utils.mergeObject(oldRollData, rollData)
this.rollDataStore[id] = newRollData
}
@@ -402,9 +402,9 @@ export class MaleficesUtility {
// Performs roll
console.log("Roll formula", diceFormula)
let myRoll = new Roll(diceFormula).roll({ async: false })
let myRoll = await new Roll(diceFormula).roll()
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = duplicate(myRoll)
rollData.roll = foundry.utils.duplicate(myRoll)
rollData.total = myRoll.total
this.computeResults(rollData)
@@ -462,7 +462,7 @@ export class MaleficesUtility {
/* -------------------------------------------- */
static blindMessageToGM(chatOptions) {
let chatGM = duplicate(chatOptions);
let chatGM = foundry.utils.duplicate(chatOptions);
chatGM.whisper = this.getUsers(user => user.isGM);
chatGM.content = "Blinde message of " + game.user.name + "<br>" + chatOptions.content;
console.log("blindMessageToGM", chatGM);
@@ -512,7 +512,7 @@ export class MaleficesUtility {
/* -------------------------------------------- */
static getBasicRollData() {
let rollData = {
rollId: randomID(16),
rollId: foundry.utils.randomID(16),
bonusMalusPerso: 0,
bonusMalusSituation: 0,
bonusMalusDef: 0,