v10 first release

This commit is contained in:
2022-09-20 08:57:40 +02:00
parent 4a0a57870c
commit 1730a8d390
26 changed files with 194 additions and 324 deletions

View File

@ -51,22 +51,22 @@ export class MournbladeActor extends Actor {
prepareArme(arme) {
arme = duplicate(arme)
let combat = this.getCombatValues()
if (arme.data.typearme == "contact" || arme.data.typearme == "contactjet") {
arme.data.competence = duplicate(this.data.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée"))
arme.data.attrKey = "pui"
arme.data.totalDegats = arme.data.degats + "+" + combat.bonusDegatsTotal
arme.data.totalOffensif = this.data.data.attributs.pui.value + arme.data.competence.data.niveau + arme.data.bonusmaniementoff
if (arme.data.isdefense) {
arme.data.totalDefensif = combat.defenseTotal + arme.data.competence.data.niveau + arme.data.bonusmaniementdef
if (arme.system.typearme == "contact" || arme.system.typearme == "contactjet") {
arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée"))
arme.system.attrKey = "pui"
arme.system.totalDegats = arme.system.degats + "+" + combat.bonusDegatsTotal
arme.system.totalOffensif = this.system.attributs.pui.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
if (arme.system.isdefense) {
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef
}
}
if (arme.data.typearme == "jet" || arme.data.typearme == "tir") {
arme.data.competence = duplicate(this.data.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance"))
arme.data.attrKey = "adr"
arme.data.totalOffensif = this.data.data.attributs.adr.value + arme.data.competence.data.niveau + arme.data.bonusmaniementoff
arme.data.totalDegats = arme.data.degats
if (arme.data.isdefense) {
arme.data.totalDefensif = combat.defenseTotal + arme.data.competence.data.niveau + arme.data.bonusmaniementdef
if (arme.system.typearme == "jet" || arme.system.typearme == "tir") {
arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance"))
arme.system.attrKey = "adr"
arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
arme.system.totalDegats = arme.system.degats
if (arme.system.isdefense) {
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef
}
}
return arme
@ -75,7 +75,7 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getWeapons() {
let armes = []
for (let arme of this.data.items) {
for (let arme of this.items) {
if (arme.type == "arme") {
armes.push(this.prepareArme(arme))
}
@ -85,49 +85,49 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getDons() {
return this.data.items.filter(item => item.type == "don")
return this.items.filter(item => item.type == "don")
}
/* -------------------------------------------- */
getTendances() {
return this.data.items.filter(item => item.type == "tendance")
return this.items.filter(item => item.type == "tendance")
}
getRunes() {
return this.data.items.filter(item => item.type == "rune")
return this.items.filter(item => item.type == "rune")
}
/* -------------------------------------------- */
getEquipments() {
return this.data.items.filter(item => item.type == "equipement")
return this.items.filter(item => item.type == "equipement")
}
/* -------------------------------------------- */
getArmors() {
return this.data.items.filter(item => item.type == "protection")
return this.items.filter(item => item.type == "protection")
}
getOrigine() {
return this.data.items.find(item => item.type == "origine")
return this.items.find(item => item.type == "origine")
}
getMetier() {
return this.data.items.find(item => item.type == "metier")
return this.items.find(item => item.type == "metier")
}
getHeritage() {
return this.data.items.find(item => item.type == "heritage")
return this.items.find(item => item.type == "heritage")
}
/* -------------------------------------------- */
getSkills() {
let comp = []
for (let item of this.data.items) {
for (let item of this.items) {
item = duplicate(item)
if (item.type == "competence") {
item.data.attribut1total = item.data.niveau + (this.data.data.attributs[item.data.attribut1]?.value || 0)
item.data.attribut2total = item.data.niveau + (this.data.data.attributs[item.data.attribut2]?.value || 0)
item.data.attribut3total = item.data.niveau + (this.data.data.attributs[item.data.attribut3]?.value || 0)
if (item.data.niveau == 0) {
item.data.attribut1total -= 3
item.data.attribut2total -= 3
item.data.attribut3total -= 3
item.system.attribut1total = item.system.niveau + (this.system.attributs[item.system.attribut1]?.value || 0)
item.system.attribut2total = item.system.niveau + (this.system.attributs[item.system.attribut2]?.value || 0)
item.system.attribut3total = item.system.niveau + (this.system.attributs[item.system.attribut3]?.value || 0)
if (item.system.niveau == 0) {
item.system.attribut1total -= 3
item.system.attribut2total -= 3
item.system.attribut3total -= 3
}
item.data.attribut1label = this.data.data.attributs[item.data.attribut1]?.label || ""
item.data.attribut2label = this.data.data.attributs[item.data.attribut2]?.label || ""
item.data.attribut3label = this.data.data.attributs[item.data.attribut3]?.label || ""
item.system.attribut1label = this.system.attributs[item.system.attribut1]?.label || ""
item.system.attribut2label = this.system.attributs[item.system.attribut2]?.label || ""
item.system.attribut3label = this.system.attributs[item.system.attribut3]?.label || ""
comp.push(item)
}
}
@ -146,30 +146,30 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getAlignement() {
return (this.data.data.balance.loi > this.data.data.balance.chaos) ? "loyal" : "chaotique"
return (this.system.balance.loi > this.system.balance.chaos) ? "loyal" : "chaotique"
}
/* -------------------------------------------- */
getDefenseBase() {
return this.data.data.attributs.tre.value + 5
return this.system.attributs.tre.value + 5
}
/* -------------------------------------------- */
getVitesseBase() {
return 5 + __vitesseBonus[this.data.data.attributs.adr.value]
return 5 + __vitesseBonus[this.system.attributs.adr.value]
}
/* -------------------------------------------- */
getCombatValues() {
let combat = {
initBase: this.data.data.attributs.adr.value,
initTotal: this.data.data.attributs.adr.value + this.data.data.combat.initbonus,
initBase: this.system.attributs.adr.value,
initTotal: this.system.attributs.adr.value + this.system.combat.initbonus,
bonusDegats: this.getBonusDegats(),
bonusDegatsTotal: this.getBonusDegats() + this.data.data.combat.bonusdegats,
bonusDegatsTotal: this.getBonusDegats() + this.system.combat.bonusdegats,
vitesseBase: this.getVitesseBase(),
vitesseTotal: this.getVitesseBase() + this.data.data.combat.vitessebonus,
vitesseTotal: this.getVitesseBase() + this.system.combat.vitessebonus,
defenseBase: this.getDefenseBase(),
defenseTotal: this.getDefenseBase() + this.data.data.combat.defensebonus
defenseTotal: this.getDefenseBase() + this.system.combat.defensebonus
}
return combat
}
@ -186,12 +186,12 @@ export class MournbladeActor extends Actor {
prepareDerivedData() {
if (this.type == 'personnage') {
let newSante = this.data.data.sante.bonus + (this.data.data.attributs.pui.value + this.data.data.attributs.tre.value) * 2 + 5
if (this.data.data.sante.base != newSante) {
let newSante = this.system.sante.bonus + (this.system.attributs.pui.value + this.system.attributs.tre.value) * 2 + 5
if (this.system.sante.base != newSante) {
this.update({ 'data.sante.base': newSante })
}
let newAme = (this.data.data.attributs.cla.value + this.data.data.attributs.tre.value) * this.data.data.biodata.amemultiplier + 5
if (this.data.data.ame.fullmax != newAme) {
let newAme = (this.system.attributs.cla.value + this.system.attributs.tre.value) * this.system.biodata.amemultiplier + 5
if (this.system.ame.fullmax != newAme) {
this.update({ 'data.ame.fullmax': newAme })
}
}
@ -207,7 +207,7 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getItemById(id) {
let item = this.data.items.find(item => item.id == id);
let item = this.items.find(item => item.id == id);
if (item) {
item = duplicate(item)
}
@ -216,16 +216,16 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
async equipItem(itemId) {
let item = this.data.items.find(item => item.id == itemId);
if (item && item.data.data) {
let update = { _id: item.id, "data.equipped": !item.data.data.equipped };
let item = this.items.find(item => item.id == itemId);
if (item && item.system.data) {
let update = { _id: item.id, "data.equipped": !item.system.equipped };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
}
}
/* -------------------------------------------- */
editItemField(itemId, itemType, itemField, dataType, value) {
let item = this.data.items.find(item => item.id == itemId)
let item = this.items.find(item => item.id == itemId)
if (item) {
console.log("Item ", item, itemField, dataType, value)
if (dataType.toLowerCase() == "number") {
@ -240,35 +240,35 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getBonneAventure() {
return this.data.data.bonneaventure.actuelle
return this.system.bonneaventure.actuelle
}
/* -------------------------------------------- */
changeBonneAventure(value) {
let newBA = this.data.data.bonneaventure.actuelle
let newBA = this.system.bonneaventure.actuelle
newBA += value
this.update({ 'data.bonneaventure.actuelle': newBA })
}
/* -------------------------------------------- */
getEclat() {
return this.data.data.eclat.value
return this.system.eclat.value
}
/* -------------------------------------------- */
changeEclat(value) {
let newE = this.data.data.eclat.value
let newE = this.system.eclat.value
newE += value
this.update({ 'data.eclat.value': newE })
}
/* -------------------------------------------- */
canEclatDoubleD20() {
return (this.getAlignement() == "loyal" && this.data.data.eclat.value > 0)
return (this.getAlignement() == "loyal" && this.system.eclat.value > 0)
}
/* -------------------------------------------- */
subPointsAme(runeMode, value) {
let ame = duplicate(this.data.data.ame)
let ame = duplicate(this.system.ame)
if(runeMode == "prononcer") {
ame.value -= value
} else {
@ -290,19 +290,19 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getAttribute(attrKey) {
return this.data.data.attributes[attrKey]
return this.system.attributes[attrKey]
}
/* -------------------------------------------- */
getBonusDegats() {
return __degatsBonus[this.data.data.attributs.pui.value]
return __degatsBonus[this.system.attributs.pui.value]
}
/* -------------------------------------------- */
async equipGear(equipmentId) {
let item = this.data.items.find(item => item.id == equipmentId);
if (item && item.data.data) {
let update = { _id: item.id, "data.equipped": !item.data.data.equipped };
let item = this.items.find(item => item.id == equipmentId);
if (item && item.system.data) {
let update = { _id: item.id, "data.equipped": !item.system.equipped };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
}
}
@ -310,21 +310,21 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getSubActors() {
let subActors = [];
for (let id of this.data.data.subactors) {
for (let id of this.system.subactors) {
subActors.push(duplicate(game.actors.get(id)));
}
return subActors;
}
/* -------------------------------------------- */
async addSubActor(subActorId) {
let subActors = duplicate(this.data.data.subactors);
let subActors = duplicate(this.system.subactors);
subActors.push(subActorId);
await this.update({ 'data.subactors': subActors });
}
/* -------------------------------------------- */
async delSubActor(subActorId) {
let newArray = [];
for (let id of this.data.data.subactors) {
for (let id of this.system.subactors) {
if (id != subActorId) {
newArray.push(id);
}
@ -334,22 +334,22 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
async incDecQuantity(objetId, incDec = 0) {
let objetQ = this.data.items.get(objetId)
let objetQ = this.items.get(objetId)
if (objetQ) {
let newQ = objetQ.data.data.quantity + incDec;
let newQ = objetQ.system.quantity + incDec;
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantity': newQ }]); // pdates one EmbeddedEntity
}
}
/* -------------------------------------------- */
getCompetence(compId) {
return this.data.items.get(compId)
return this.items.get(compId)
}
/* -------------------------------------------- */
async setPredilectionUsed(compId, predIdx) {
let comp = this.data.items.get(compId)
let pred = duplicate(comp.data.data.predilections)
let comp = this.items.get(compId)
let pred = duplicate(comp.system.predilections)
pred[predIdx].used = true
await this.updateEmbeddedDocuments('Item', [{ _id: compId, 'data.predilections': pred }])
}
@ -368,16 +368,16 @@ export class MournbladeActor extends Actor {
if (attrKey) {
rollData.attrKey = attrKey
if (attrKey != "tochoose") {
rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + this.data.data.attributs[attrKey].labelnorm + ".webp"
rollData.attr = duplicate(this.data.data.attributs[attrKey])
rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + this.system.attributs[attrKey].labelnorm + ".webp"
rollData.attr = duplicate(this.system.attributs[attrKey])
}
}
if (compId) {
rollData.competence = duplicate(this.data.items.get(compId) || {})
rollData.competence = duplicate(this.items.get(compId) || {})
rollData.actionImg = rollData.competence?.img
}
if (compName) {
rollData.competence = duplicate(this.data.items.find( item => item.name.toLowerCase() == compName.toLowerCase()) || {})
rollData.competence = duplicate(this.items.find( item => item.name.toLowerCase() == compName.toLowerCase()) || {})
rollData.actionImg = rollData.competence?.img
}
return rollData
@ -402,7 +402,7 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
async rollRune(runeId) {
let rollData = this.getCommonRollData("cla", undefined, "Savoir : Runes")
rollData.rune = duplicate(this.data.items.get(runeId) || {})
rollData.rune = duplicate(this.items.get(runeId) || {})
rollData.difficulte = rollData.rune?.data?.seuil || 0
rollData.runemode = "prononcer"
rollData.runeame = 1
@ -413,9 +413,9 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
async rollArmeOffensif(armeId) {
let arme = this.data.items.get(armeId)
let arme = this.items.get(armeId)
arme = this.prepareArme(arme)
let rollData = this.getCommonRollData(arme.data.attrKey, arme.data.competence._id)
let rollData = this.getCommonRollData(arme.system.attrKey, arme.system.competence._id)
rollData.arme = arme
console.log("ARME!", rollData)
let rollDialog = await MournbladeRollDialog.create(this, rollData)
@ -424,9 +424,9 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
async rollArmeDegats(armeId) {
let arme = this.data.items.get(armeId)
let arme = this.items.get(armeId)
arme = this.prepareArme(arme)
let roll = new Roll(arme.data.totalDegats).roll({ async: false })
let roll = new Roll(arme.system.totalDegats).roll({ async: false })
await MournbladeUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"));
let rollData = {
arme: arme,