v10 branch - Update manifest
This commit is contained in:
@ -81,16 +81,38 @@ export class PegasusUtility {
|
||||
rollData.dicePool = newDicePool
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static updateDamageDicePool(rollData) {
|
||||
if (rollData.isDamage) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "damage")
|
||||
if (rollData.damageDiceLevel > 0) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(rollData.damageDiceLevel)
|
||||
let diceList = diceKey.split(" ")
|
||||
for(let myDice of diceList) {
|
||||
let newDice = {
|
||||
name: "damage", key: myDice,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
|
||||
}
|
||||
newDicePool.push(newDice)
|
||||
}
|
||||
}
|
||||
rollData.dicePool = newDicePool
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static updateSpecDicePool(rollData) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "spec")
|
||||
if (rollData.specDicesLevel > 0) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(rollData.specDicesLevel)
|
||||
let newDice = {
|
||||
name: "spec", key: diceKey,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
|
||||
let diceList = diceKey.split(" ")
|
||||
for(let myDice of diceList) {
|
||||
let newDice = {
|
||||
name: "spec", key: myDice,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
|
||||
}
|
||||
newDicePool.push(newDice)
|
||||
}
|
||||
newDicePool.push(newDice)
|
||||
}
|
||||
rollData.dicePool = newDicePool
|
||||
}
|
||||
@ -107,8 +129,7 @@ export class PegasusUtility {
|
||||
/*-------------------------------------------- */
|
||||
static removeFromDicePool( rollData, diceIdx ) {
|
||||
let toRemove = rollData.dicePool[diceIdx]
|
||||
console.log("CLICK : ", rollData.dicePool, diceIdx)
|
||||
if (toRemove && toRemove.name != "spec" && toRemove.name != "stat") {
|
||||
if (toRemove && toRemove.name != "spec" && toRemove.name != "stat" && toRemove.name != "damage") {
|
||||
let newDicePool = []
|
||||
for (let i=0; i<rollData.dicePool.length; i++) {
|
||||
if ( i!=diceIdx) {
|
||||
@ -259,10 +280,17 @@ export class PegasusUtility {
|
||||
|
||||
html.on("click", '.chat-create-actor', event => {
|
||||
game.system.pegasus.creator.processChatEvent(event);
|
||||
});
|
||||
})
|
||||
html.on("click", '.view-item-from-chat', event => {
|
||||
game.system.pegasus.creator.openItemView(event)
|
||||
});
|
||||
})
|
||||
html.on("click", '.reroll-level-remaining', event => {
|
||||
let rollId = $(event.currentTarget).data("roll-id")
|
||||
let rollData = this.getRollData(rollId)
|
||||
rollData.reroll = true
|
||||
this.rollPegasus( rollData)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -347,7 +375,7 @@ export class PegasusUtility {
|
||||
static getDiceValue(level = 0) {
|
||||
let diceString = this.diceList[level]
|
||||
if (!diceString) {
|
||||
console.log("Level error", level)
|
||||
return __name2DiceValue[level]
|
||||
}
|
||||
let diceTab = diceString.split(" ")
|
||||
let diceValue = 0
|
||||
@ -554,6 +582,7 @@ export class PegasusUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async rollPegasus(rollData) {
|
||||
|
||||
/*
|
||||
let dicePool = [{ name: "stat", level: 0, statmod: 0 }, { name: "spec", level: 0 }, { name: "bonus", level: 0 }, { name: "hindrance", level: 0 }, { name: "other", level: 0 }];
|
||||
if (rollData.stat) {
|
||||
dicePool[0].level += Number(rollData.stat.value)
|
||||
@ -591,23 +620,34 @@ export class PegasusUtility {
|
||||
diceFormulaTab.push(this.getFoundryDiceFromLevel(diceGroup.level))
|
||||
}
|
||||
let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh';
|
||||
*/
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
|
||||
let diceFormulaTab = []
|
||||
for (let dice of rollData.dicePool) {
|
||||
diceFormulaTab.push(dice.key)
|
||||
}
|
||||
let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh + ' + (rollData.stat?.mod || 0)
|
||||
|
||||
// Performs roll
|
||||
let myRoll = rollData.roll;
|
||||
if (!myRoll) { // New rolls only of no rerolls
|
||||
myRoll = new Roll(diceFormula).roll({ async: false });
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"));
|
||||
let myRoll = rollData.roll
|
||||
if (!myRoll || rollData.reroll) { // 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
|
||||
}
|
||||
|
||||
if (rollData.reroll) {
|
||||
rollData.levelRemaining = actor.modifyHeroLevelRemaining(-1)
|
||||
}
|
||||
// Final score and keep data
|
||||
rollData.finalScore = myRoll.total + dicePool[0].statmod;
|
||||
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;
|
||||
let dmgRoll = new Roll(dmgFormula).roll({ async: false })
|
||||
await this.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.dmgResult = dmgRoll.total
|
||||
}
|
||||
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
@ -617,12 +657,11 @@ export class PegasusUtility {
|
||||
// Init stuf
|
||||
if (rollData.isInit) {
|
||||
let combat = game.combats.get(rollData.combatId)
|
||||
combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }]);
|
||||
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") {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.modifyStun(-1)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user