Data model change

This commit is contained in:
2022-07-25 21:33:00 +02:00
parent 1de5086efa
commit 732d51b8b3
7 changed files with 73 additions and 533 deletions

View File

@@ -262,50 +262,24 @@ export class CrucibleUtility {
let actor = game.actors.get(rollData.actorId)
let diceFormulaTab = []
for (let dice of rollData.dicePool) {
let level = dice.level
if (dice.name == "stat") {
level += rollData.statLevelBonus
}
diceFormulaTab.push(this.getFoundryDiceFromLevel(level))
let diceFormula = String(rollData.ability.value) + "d6cs>=5"
if (rollData.skill) {
diceFormula += "+" + String(rollData.skill.data.level) + "d8cs>=5"
}
let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh + ' + (rollData.stat?.mod || 0)
// Performs roll
let myRoll = rollData.roll
if (!myRoll || rollData.rerollHero || rollData.rerollMomentum) { // New rolls only of no rerolls
if (!myRoll) { // New rolls only of no rerolls
myRoll = new Roll(diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = myRoll
}
// Final score and keep data
rollData.finalScore = myRoll.total
if (rollData.damages) {
let dmgFormula = this.getFoundryDiceFromLevel(rollData.damages.value)
let dmgRoll = new Roll(dmgFormula).roll({ async: false })
await this.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode"))
rollData.dmgResult = dmgRoll.total
}
rollData.nbSuccess = myRoll.total
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-generic-result.html`, rollData)
});
// Init stuf
if (rollData.isInit) {
let combat = game.combats.get(rollData.combatId)
combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }])
}
// Stun specific -> Suffere a stun level when dmg-res
if (rollData.subKey && rollData.subKey == "dmg-res") {
actor.modifyStun(+1)
}
//this.removeUsedPerkEffects( rollData) // Unused for now
this.removeOneUseEffects(rollData) // Unused for now
})
console.log("Rolldata result", rollData)
// And save the roll
this.saveRollData(rollData)