Enhance armes+armures
This commit is contained in:
@ -48,6 +48,9 @@ export class TeDeumActorPJSheet extends ActorSheet {
|
||||
maladies: this.actor.getMaladies(),
|
||||
poisons: this.actor.getPoisons(),
|
||||
combat: this.actor.prepareCombat(),
|
||||
bonusDegats: this.actor.getBonusDegats(),
|
||||
pointsArmuresLourdes: this.actor.getNbArmures(),
|
||||
nbArmuresLourdes: this.actor.getNbArmuresLourdesActuel(),
|
||||
santeModifier: this.actor.getSanteModifier(),
|
||||
description: await TextEditor.enrichHTML(this.object.system.description, { async: true }),
|
||||
notes: await TextEditor.enrichHTML(this.object.system.notes, { async: true }),
|
||||
|
@ -86,7 +86,16 @@ export class TeDeumActor extends Actor {
|
||||
getNbActions() {
|
||||
return game.system.tedeum.config.ACTIONS_PAR_TOUR[this.system.caracteristiques.adresse.value]
|
||||
}
|
||||
|
||||
getNbArmuresLourdesActuel() {
|
||||
let armures = this.getArmures()
|
||||
let nb = 0
|
||||
for (let armure of armures) {
|
||||
if (armure.system.equipe) {
|
||||
nb += armure.system.coutArmureLourde
|
||||
}
|
||||
}
|
||||
return nb
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCompetences() {
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'competence') || [])
|
||||
@ -156,7 +165,7 @@ export class TeDeumActor extends Actor {
|
||||
modTotal += maladieDef.modifier
|
||||
}
|
||||
}
|
||||
let simples= foundry.utils.duplicate(this.items.filter(item => item.type == 'simple') || [])
|
||||
let simples = foundry.utils.duplicate(this.items.filter(item => item.type == 'simple') || [])
|
||||
for (let c of simples) {
|
||||
if (c.system.appliquee) {
|
||||
let simpleDef = game.system.tedeum.config.virulencePoison[c.system.virulence]
|
||||
@ -170,11 +179,43 @@ export class TeDeumActor extends Actor {
|
||||
}
|
||||
// Si le nombre de blessures est supérieur au score d'endurance, alors malus supplémentaire
|
||||
let endurance = this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "endurance")
|
||||
if ( blessures.length > endurance.system.score) {
|
||||
if (blessures.length > endurance.system.score) {
|
||||
modTotal += -1
|
||||
}
|
||||
}
|
||||
return modTotal
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async appliquerDegats(rollData) {
|
||||
let combat = this.prepareCombat()
|
||||
rollData.defenderName = this.name
|
||||
let touche = combat[rollData.loc.id].touche
|
||||
if (rollData.degats > 0 && rollData.degats > touche) {
|
||||
let diff = rollData.degats - touche
|
||||
for (let bId in game.system.tedeum.config.blessures) {
|
||||
let blessure = game.system.tedeum.config.blessures[bId]
|
||||
if (diff >= blessure.degatsMin && diff <= blessure.degatsMax) {
|
||||
// Create a new blessure object
|
||||
let blessureObj = {
|
||||
name: blessure.label,
|
||||
type: "blessure",
|
||||
system: {
|
||||
typeBlessure: bId,
|
||||
localisation: rollData.loc.id,
|
||||
appliquee: true,
|
||||
description: "Blessure infligée par un coup de " + rollData.arme.name + " de " + rollData.alias,
|
||||
}
|
||||
}
|
||||
rollData.blessure = blessureObj
|
||||
this.createEmbeddedDocuments('Item', [blessureObj]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Display the relevant chat message
|
||||
let msg = await TeDeumUtility.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-te-deum/templates/chat/chat-blessure-result.hbs`, rollData)
|
||||
})
|
||||
await msg.setFlag("world", "te-deum-rolldata", rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updateCarac(c, key) {
|
||||
@ -188,7 +229,7 @@ export class TeDeumActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
prepareCaracteristiques() {
|
||||
let carac = foundry.utils.deepClone(this.system.caracteristiques)
|
||||
let carac = foundry.utils.deepClone(this.system.caracteristiques)
|
||||
for (let key in carac) {
|
||||
let c = carac[key]
|
||||
this.updateCarac(c, key)
|
||||
@ -199,7 +240,7 @@ export class TeDeumActor extends Actor {
|
||||
prepareProvidence() {
|
||||
let providence = foundry.utils.deepClone(this.system.providence)
|
||||
providence.name = "Providence"
|
||||
providence.qualite = game.system.tedeum.config.providence[providence.value].labelM
|
||||
providence.qualite = game.system.tedeum.config.providence[providence.value].labelM
|
||||
providence.dice = game.system.tedeum.config.providence[providence.value].diceValue
|
||||
return providence
|
||||
}
|
||||
@ -234,13 +275,13 @@ export class TeDeumActor extends Actor {
|
||||
modifyProvidence(value) {
|
||||
let providence = foundry.utils.duplicate(this.system.providence)
|
||||
providence.value = Math.min(Math.max(providence.value + value, 0), 6)
|
||||
this.update( { "system.providence": providence } )
|
||||
this.update({ "system.providence": providence })
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
modifyXP(key, value) {
|
||||
let xp = this.system.caracteristiques[key].experience
|
||||
xp = Math.max(xp + value, 0)
|
||||
this.update( { [`system.caracteristiques.${key}.experience`]: xp } )
|
||||
this.update({ [`system.caracteristiques.${key}.experience`]: xp })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -253,7 +294,7 @@ export class TeDeumActor extends Actor {
|
||||
let caracDice = game.system.tedeum.config.descriptionValeur[this.system.caracteristiques[c.system.caracteristique].value].dice
|
||||
c.system.formula = caracDice + "+" + c.system.score
|
||||
})
|
||||
return foundry.utils.deepClone( comp || {} )
|
||||
return foundry.utils.deepClone(comp || {})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -279,10 +320,55 @@ export class TeDeumActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async equipItem(itemId) {
|
||||
let item = this.items.find(item => item.id == itemId)
|
||||
if (!this.checkArmure(item)) {
|
||||
return
|
||||
}
|
||||
let update = { _id: item.id, "system.equipe": !item.system.equipe };
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
|
||||
/* ------------------------------------------- */
|
||||
checkArmure(item) {
|
||||
if (item.type != "armure") {
|
||||
return true
|
||||
}
|
||||
if (item.system.equipe) {
|
||||
return true
|
||||
}
|
||||
let nbArmuresLourdes = this.getNbArmuresLourdesActuel()
|
||||
if (nbArmuresLourdes + item.system.coutArmureLourde > this.getNbArmures().value) {
|
||||
ui.notifications.warn("Impossible d'équiper cette armure, nombre d'armures lourdes maximum atteint")
|
||||
return false
|
||||
}
|
||||
|
||||
// Loop thru localisation
|
||||
let armures = this.getArmures()
|
||||
for (let loc in item.system.localisation) {
|
||||
if (item.system.localisation[loc].protege) {
|
||||
for (let armure of armures) {
|
||||
if (armure.system.equipe && armure.system.localisation[loc].protege) {
|
||||
let flag = true
|
||||
//console.log("Check armure", armure, item)=
|
||||
if (item.system.typeArmure == "cuir") {
|
||||
flag = armure.system.superposableCuir
|
||||
}
|
||||
if (item.system.typeArmure == "maille") {
|
||||
flag = armure.system.superposableMaille
|
||||
}
|
||||
if (item.system.typeArmure == "plate") {
|
||||
flag = armure.system.superposablePlate
|
||||
}
|
||||
if (!flag) {
|
||||
ui.notifications.warn("Impossible d'équiper cette armure, non superposable")
|
||||
return flag
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------- */
|
||||
async buildContainerTree() {
|
||||
let equipments = foundry.utils.duplicate(this.items.filter(item => item.type == "equipment") || [])
|
||||
@ -342,8 +428,8 @@ export class TeDeumActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeScore() {
|
||||
let initiative = this.items.find(it=>it.type == "competence" && it.name.toLowerCase() == "initiative")
|
||||
if ( initiative ) {
|
||||
let initiative = this.items.find(it => it.type == "competence" && it.name.toLowerCase() == "initiative")
|
||||
if (initiative) {
|
||||
return initiative.system.score
|
||||
}
|
||||
ui.notifications.warn("Impossible de trouver la compétence Initiative pour l'acteur " + this.name)
|
||||
@ -374,7 +460,7 @@ export class TeDeumActor extends Actor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData() {
|
||||
let rollData = TeDeumUtility.getBasicRollData()
|
||||
@ -384,19 +470,19 @@ export class TeDeumActor extends Actor {
|
||||
rollData.img = this.img
|
||||
rollData.providence = this.prepareProvidence()
|
||||
rollData.santeModifier = this.getSanteModifier()
|
||||
|
||||
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonCompetence(compId) {
|
||||
let rollData = this.getCommonRollData()
|
||||
|
||||
let competence = foundry.utils.duplicate(this.items.find(it => it.type =="competence" && it.id == compId))
|
||||
|
||||
let competence = foundry.utils.duplicate(this.items.find(it => it.type == "competence" && it.id == compId))
|
||||
|
||||
rollData.competence = competence
|
||||
let c = foundry.utils.duplicate(this.system.caracteristiques[competence.system.caracteristique])
|
||||
this.updateCarac( c, competence.system.caracteristique)
|
||||
this.updateCarac(c, competence.system.caracteristique)
|
||||
rollData.carac = c
|
||||
rollData.img = competence.img
|
||||
|
||||
@ -419,22 +505,32 @@ export class TeDeumActor extends Actor {
|
||||
weapon = foundry.utils.duplicate(weapon)
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "arme"
|
||||
rollData.isTir = weapon.system.typeArme == "tir"
|
||||
rollData.arme = weapon
|
||||
rollData.img = weapon.img
|
||||
rollData.title = weapon.name
|
||||
|
||||
rollData.porteeTir = "courte"
|
||||
rollData.porteeLabel = game.system.tedeum.config.ARME_PORTEES.courte.label
|
||||
rollData.isViser = false
|
||||
rollData.isMouvement = false
|
||||
|
||||
// Display warning if not target defined
|
||||
if (!rollData.defenderTokenId) {
|
||||
ui.notifications.warn("Vous attaquez avec une arme : afin de bénéficier des automatisations, il est conseillé de selectionner une cible")
|
||||
}
|
||||
|
||||
// Setup competence + carac
|
||||
if (!compName) {
|
||||
compName = weapon.system.competence
|
||||
}
|
||||
let competence = this.items.find(item => item.type == "competence" && item.name.toLowerCase() == compName.toLowerCase())
|
||||
if ( competence) {
|
||||
}
|
||||
let competence = this.items.find(item => item.type == "competence" && item.name.toLowerCase() == compName.toLowerCase())
|
||||
if (competence) {
|
||||
rollData.competence = competence
|
||||
let c = foundry.utils.duplicate(this.system.caracteristiques[competence.system.caracteristique])
|
||||
this.updateCarac( c, competence.system.caracteristique)
|
||||
this.updateCarac(c, competence.system.caracteristique)
|
||||
rollData.carac = c
|
||||
} else {
|
||||
ui.notifications.warn("Impossible de trouver la compétence " + compName)
|
||||
ui.notifications.warn("Impossible de trouver la compétence " + compName)
|
||||
return
|
||||
}
|
||||
this.startRoll(rollData).catch("Error on startRoll")
|
||||
|
@ -86,7 +86,12 @@ export const TEDEUM_CONFIG = {
|
||||
puissance: { id: "puissance", value: "puissance", label: "Puissance" },
|
||||
adresse: { id: "adresse", value: "adresse", label: "Adresse" },
|
||||
},
|
||||
|
||||
allonges: {
|
||||
courte: { courte: {malus: 0}, moyenne: {malus:-1}, longue: {malus:-2}, treslongue:{malus:0, esquive: 2 } },
|
||||
moyenne: { courte: {malus: 0}, moyenne: {malus:0}, longue: {malus:-1}, treslongue:{malus:0, esquive: 2 } },
|
||||
longue: { courte: {malus: -2}, moyenne: {malus:-1}, longue: {malus:0}, treslongue:{malus:-1, esquive: 1 } },
|
||||
treslongue: { courte: {malus:0, esquive: 2 }, moyenne:{malus:0, esquive: 2 }, longue: {malus:0, esquive: 1 }, treslongue:{malus:0 } },
|
||||
},
|
||||
providence: [
|
||||
{ labelM: "Brebis égarée", labelF: "Brebis égarée", value: 0, diceValue: "0" },
|
||||
{ labelM: "Pauvre pêcheur", labelF: "Pauvre pêcheresse", value: 1, diceValue: "d4" },
|
||||
@ -96,7 +101,11 @@ export const TEDEUM_CONFIG = {
|
||||
{ labelM: "Oint du Seigneur", labelF: "Ointe du Seigneur", value: 5, diceValue: "d12" },
|
||||
{ labelM: "Dans la main de Dieu", labelF: "Dans la main de Dieu", value: 6, diceValue: "d20" },
|
||||
],
|
||||
|
||||
armureTypes: {
|
||||
cuir: { label: "Cuir", value: "cuir" },
|
||||
maille: { label: "Maille", value: "maille" },
|
||||
plate: { label: "Plate", value: "plate" },
|
||||
},
|
||||
armeTypes: {
|
||||
melee: { label: "Mêlée", value: "melee" },
|
||||
tir: { label: "Tir", value: "tir" }
|
||||
@ -162,11 +171,11 @@ export const TEDEUM_CONFIG = {
|
||||
],
|
||||
blessures: {
|
||||
indemne: { value: 0, label: "Indemne", key: "indemne", degatsMax: -1, count: 0, modifier: 0 },
|
||||
estafilade: { value: 1, label: "Estafilade", key: "estafilade", degatsMax: 2, count: 1, modifier: 0 },
|
||||
plaie: { value: 2, label: "Plaie", key: "plaie", degatsMax: 4, count: 1, modifier: -1 },
|
||||
plaiebeante: { value: 3, label: "Plaie béante", key: "plaiebeante", degatsMax: 6, count: 1, modifier: -2 },
|
||||
plaieatroce: { value: 4, label: "Plaie atroce", key: "plaieatroce", degatsMax: 6, count: 1, horsCombat: true, modifier: -12 },
|
||||
tunenet: { value: 5, label: "Tué net", key: "tuenet", degatsMax: 100, count: 1, horsCombat: true, mort: true, modifier: -12 }
|
||||
estafilade: { value: 1, label: "Estafilade", key: "estafilade", degatsMin: 0, degatsMax: 2, count: 1, modifier: 0 },
|
||||
plaie: { value: 2, label: "Plaie", key: "plaie", degatsMin: 3, degatsMax: 4, count: 1, modifier: -1 },
|
||||
plaiebeante: { value: 3, label: "Plaie béante", key: "plaiebeante", degatsMin: 5, degatsMax: 6, count: 1, modifier: -2 },
|
||||
plaieatroce: { value: 4, label: "Plaie atroce", key: "plaieatroce", degatsMin: 7, degatsMax: 8, count: 1, horsCombat: true, modifier: -12 },
|
||||
tunenet: { value: 5, label: "Tué net", key: "tuenet", degatsMin: 9, degatsMax: 100, count: 1, horsCombat: true, mort: true, modifier: -12 }
|
||||
},
|
||||
virulence: {
|
||||
fatigue: { label: "Fatigue", value: "fatigue", modifier: 0 },
|
||||
|
@ -46,22 +46,22 @@ export class TeDeumUtility {
|
||||
accum += block.fn(i);
|
||||
return accum;
|
||||
})
|
||||
Handlebars.registerHelper('getConfigLabel', function (configName, key) {
|
||||
Handlebars.registerHelper('getConfigLabel', function (configName, key) {
|
||||
//console.log("getConfigLabel", configName, key)
|
||||
return game.system.tedeum.config[configName][key].label
|
||||
})
|
||||
Handlebars.registerHelper('getConfigLabelArray', function (configName, key) {
|
||||
Handlebars.registerHelper('getConfigLabelArray', function (configName, key) {
|
||||
//console.log("getConfigLabel", configName, key)
|
||||
return game.system.tedeum.config[configName][key].label
|
||||
})
|
||||
Handlebars.registerHelper('isSpecArmeType', function (key, armeType) {
|
||||
return game.system.tedeum.config.ARME_SPECIFICITE[key][armeType]
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('getConfigLabelWithGender', function (configName, key, genderKey) {
|
||||
return game.system.tedeum.config[configName][key]["label"+genderKey]
|
||||
|
||||
Handlebars.registerHelper('getConfigLabelWithGender', function (configName, key, genderKey) {
|
||||
return game.system.tedeum.config[configName][key]["label" + genderKey]
|
||||
})
|
||||
Handlebars.registerHelper('getCaracDescription', function (key, value) {
|
||||
Handlebars.registerHelper('getCaracDescription', function (key, value) {
|
||||
return game.system.tedeum.config.descriptionValeur[Number(value)][key]
|
||||
})
|
||||
|
||||
@ -74,7 +74,7 @@ export class TeDeumUtility {
|
||||
this.competences = competences.map(i => i.toObject())
|
||||
this.competencesList = {}
|
||||
for (let i of this.competences) {
|
||||
this.competencesList[i.name.toLowerCase()] = {name:i.name, id: i._id}
|
||||
this.competencesList[i.name.toLowerCase()] = { name: i.name, id: i._id }
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ export class TeDeumUtility {
|
||||
if (!this.currentOpposition) {
|
||||
// Store rollData as current GM opposition
|
||||
this.currentOpposition = rollData
|
||||
ui.notifications.info("Opposition démarrée avec " + rollData.alias );
|
||||
ui.notifications.info("Opposition démarrée avec " + rollData.alias);
|
||||
} else {
|
||||
// Perform the opposition
|
||||
let rWinner = this.currentOpposition
|
||||
@ -160,7 +160,7 @@ export class TeDeumUtility {
|
||||
content: await renderTemplate(`systems/fvtt-te-deum/templates/chat/chat-opposition-result.hbs`, oppositionData)
|
||||
})
|
||||
await msg.setFlag("world", "te-deum-rolldata", rollData)
|
||||
console.log("Rolldata result", rollData)
|
||||
console.log("Rolldata result", rollData)
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ export class TeDeumUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async preloadHandlebarsTemplates() {
|
||||
|
||||
|
||||
const templatePaths = [
|
||||
'systems/fvtt-te-deum/templates/actors/editor-notes-gm.hbs',
|
||||
'systems/fvtt-te-deum/templates/items/partial-item-nav.hbs',
|
||||
@ -260,7 +260,7 @@ export class TeDeumUtility {
|
||||
console.log("SOCKET MESSAGE", msg)
|
||||
if (msg.name == "msg_gm_chat_message") {
|
||||
let rollData = msg.data.rollData
|
||||
if ( game.user.isGM ) {
|
||||
if (game.user.isGM) {
|
||||
let chatMsg = await this.createChatMessage(rollData.alias, "blindroll", {
|
||||
content: await renderTemplate(msg.data.template, rollData),
|
||||
whisper: game.user.id
|
||||
@ -355,7 +355,7 @@ export class TeDeumUtility {
|
||||
let critiqueRoll = await new Roll(rollData.carac.negativeDice).roll()
|
||||
await this.showDiceSoNice(critiqueRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.critiqueRoll = foundry.utils.duplicate(critiqueRoll)
|
||||
if (critiqueRoll.total > rollData.competence.score) {
|
||||
if (critiqueRoll.total > rollData.competence.score) {
|
||||
rollData.isEchecCritique = true
|
||||
}
|
||||
}
|
||||
@ -371,13 +371,20 @@ export class TeDeumUtility {
|
||||
newIndex = Math.min(Math.max(newIndex, 0), game.system.tedeum.config.diceValeur.length - 1)
|
||||
return game.system.tedeum.config.diceValeur[newIndex]
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeRollFormula(rollData, actor, isConfrontation = false) {
|
||||
let diceFormula = ""
|
||||
if (rollData.competence) {
|
||||
let diceBase = this.modifyDice(rollData.carac.dice, Number(rollData.bonusMalus)+rollData.santeModifier)
|
||||
if (!diceBase) return;
|
||||
let localModifier = 0
|
||||
if (rollData.isViser) {
|
||||
localModifier += 1
|
||||
}
|
||||
if (rollData.isMouvement) {
|
||||
localModifier -= 1
|
||||
}
|
||||
let diceBase = this.modifyDice(rollData.carac.dice, localModifier + Number(rollData.bonusMalus) + rollData.santeModifier)
|
||||
if (!diceBase) return;
|
||||
diceFormula = diceBase + "x + " + rollData.competence.system.score
|
||||
}
|
||||
if (rollData.enableProvidence) {
|
||||
@ -386,6 +393,52 @@ export class TeDeumUtility {
|
||||
return diceFormula
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getLocalisation(rollData) {
|
||||
let locRoll = await new Roll("1d20").roll()
|
||||
await this.showDiceSoNice(locRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.locRoll = foundry.utils.duplicate(locRoll)
|
||||
for (let key in game.system.tedeum.config.LOCALISATION) {
|
||||
let loc = game.system.tedeum.config.LOCALISATION[key]
|
||||
if (locRoll.total >= loc.score.min && locRoll.total <= loc.score.max) {
|
||||
rollData.loc = foundry.utils.duplicate(loc)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processAttaqueMelee(rollData) {
|
||||
if (rollData.arme?.system.typeArme != "melee") {
|
||||
return
|
||||
}
|
||||
if (rollData.isSuccess) {
|
||||
await this.getLocalisation(rollData)
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let bDegats = actor.getBonusDegats()
|
||||
let degatsRoll = await new Roll(rollData.arme.system.degats+"+"+bDegats.value ).roll()
|
||||
await this.showDiceSoNice(locRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.degatsRoll = foundry.utils.duplicate(degatsRoll)
|
||||
rollData.degats = degatsRoll.total
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processAttaqueDistance(rollData) {
|
||||
if (rollData.arme?.system.typeArme != "tir") {
|
||||
return
|
||||
}
|
||||
if (rollData.isSuccess) {
|
||||
// Roll the location
|
||||
await this.getLocalisation(rollData)
|
||||
// Now the degats
|
||||
let degatsRoll = await new Roll(rollData.arme.system.degats).roll()
|
||||
await this.showDiceSoNice(locRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.degatsRoll = foundry.utils.duplicate(degatsRoll)
|
||||
rollData.degats = degatsRoll.total
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollTeDeum(rollData) {
|
||||
|
||||
@ -397,7 +450,7 @@ export class TeDeumUtility {
|
||||
rollData.difficulty = game.system.tedeum.config.difficulte[rollData.difficulty].value
|
||||
let diceFormula = this.computeRollFormula(rollData, actor)
|
||||
if (!diceFormula) return;
|
||||
console.log("RollData", rollData, diceFormula )
|
||||
console.log("RollData", rollData, diceFormula)
|
||||
|
||||
// Performs roll
|
||||
let myRoll = await new Roll(diceFormula).roll()
|
||||
@ -409,6 +462,9 @@ export class TeDeumUtility {
|
||||
|
||||
await this.computeResults(rollData)
|
||||
|
||||
await this.processAttaqueDistance(rollData)
|
||||
await this.processAttaqueMelee(rollData)
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-te-deum/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
@ -423,6 +479,15 @@ export class TeDeumUtility {
|
||||
if (rollData.isReussiteCritique || rollData.isEchecCritique) {
|
||||
actor.modifyXP(rollData.carac.key, 1)
|
||||
}
|
||||
|
||||
// gestion degats automatique
|
||||
if (rollData.arme && rollData.defenderTokenId) {
|
||||
let defenderToken = canvas.tokens.placeables.find(t => t.id == rollData.defenderTokenId)
|
||||
if (defenderToken) {
|
||||
let actor = defenderToken.actor
|
||||
await actor.appliquerDegats(rollData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -489,7 +554,7 @@ export class TeDeumUtility {
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async createChatMessage(name, rollMode, chatOptions) {
|
||||
switch (rollMode) {
|
||||
@ -515,9 +580,9 @@ export class TeDeumUtility {
|
||||
type: "roll-data",
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
difficulty: "pardefaut",
|
||||
bonusMalus : "0",
|
||||
isReroll : false,
|
||||
enableProvidence : false,
|
||||
bonusMalus: "0",
|
||||
isReroll: false,
|
||||
enableProvidence: false,
|
||||
malusBlessures: 0,
|
||||
config: foundry.utils.duplicate(game.system.tedeum.config)
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ export class TeDeumArmeSchema extends foundry.abstract.TypeDataModel {
|
||||
|
||||
schema.initiativeBonus = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 });
|
||||
|
||||
schema.degats = new fields.StringField({ required: false, blank: true, initial: undefined });
|
||||
schema.degats = new fields.StringField({ required: false, blank: true, initial: "0" });
|
||||
schema.degatscrosse = new fields.StringField({ required: false, blank: true, initial: "0" });
|
||||
|
||||
let comp = []
|
||||
for (let key of Object.keys(game.system.tedeum.config.armeCompetences)) {
|
||||
comp.push(key);
|
||||
|
@ -6,6 +6,8 @@ export class TeDeumArmureSchema extends foundry.abstract.TypeDataModel {
|
||||
|
||||
const schema = {};
|
||||
|
||||
schema.typeArmure = new fields.StringField({required: true, choices: ["cuir", "maille", "plate"], initial: "cuir"});
|
||||
|
||||
schema.localisation = new fields.SchemaField(
|
||||
Object.values(game.system.tedeum.config.LOCALISATION).reduce((obj, loc) => {
|
||||
obj[loc.id] = new fields.SchemaField({
|
||||
@ -15,6 +17,12 @@ export class TeDeumArmureSchema extends foundry.abstract.TypeDataModel {
|
||||
}, {})
|
||||
);
|
||||
|
||||
schema.coutArmureLourde = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 });
|
||||
|
||||
schema.superposableCuir = new fields.BooleanField({initial: false});
|
||||
schema.superposableMaille = new fields.BooleanField({initial: false});
|
||||
schema.superposablePlate = new fields.BooleanField({initial: false});
|
||||
|
||||
schema.protection = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 });
|
||||
|
||||
schema.prix = new fields.NumberField({ ...requiredDouble, initial: 0, min: 0 });
|
||||
|
@ -69,6 +69,18 @@ export class TeDeumRollDialog extends Dialog {
|
||||
html.find('#roll-enable-providence').change((event) => {
|
||||
this.rollData.enableProvidence = event.currentTarget.checked
|
||||
})
|
||||
html.find('#roll-portee-tir').change((event) => {
|
||||
this.rollData.porteeTir = event.currentTarget.value
|
||||
this.rollData.difficulty = game.system.tedeum.config.ARME_PORTEES[this.rollData.porteeTir].difficulty
|
||||
this.rollData.porteeLabel = game.system.tedeum.config.ARME_PORTEES[this.rollData.porteeTir].label
|
||||
})
|
||||
html.find('#roll-tir-viser').change((event) => {
|
||||
this.rollData.isViser = event.currentTarget.checked
|
||||
})
|
||||
html.find('#roll-tir-mouvement').change((event) => {
|
||||
this.rollData.isMouvement = event.currentTarget.checked
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user