Enhance armes+armures
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user