v10 branch - Update manifest

This commit is contained in:
2022-07-13 22:47:07 +02:00
parent f66b9c1913
commit bf52b61a0d
12 changed files with 268 additions and 85 deletions

View File

@@ -58,6 +58,7 @@ export class PegasusActorSheet extends ActorSheet {
effects: duplicate(this.actor.getEffects()),
moneys: duplicate(this.actor.getMoneys()),
encCapacity: this.actor.getEncumbranceCapacity(),
levelRemainingList: this.actor.getLevelRemainingList(),
containersTree: this.actor.containersTree,
encCurrent: this.actor.encCurrent,
encHindrance: this.actor.encHindrance,
@@ -79,6 +80,10 @@ export class PegasusActorSheet extends ActorSheet {
rollData.mode = "generic"
rollData.title = `Dice Pool Roll`
rollData.img = "icons/dice/d12black.svg"
rollData.isGeneric = true
rollData.traumaState = this.actor.getTraumaState()
rollData.diceList = PegasusUtility.getDiceList()
rollData.dicePool = []
let rollDialog = await PegasusRollDialog.create( this.actor, rollData);
rollDialog.render( true );

View File

@@ -857,6 +857,18 @@ export class PegasusActor extends Actor {
return this.traumaState
}
/* -------------------------------------------- */
getLevelRemaining() {
return this.data.data.biodata.currentlevelremaining
}
/* -------------------------------------------- */
modifyHeroLevelRemaining( incDec) {
let biodata = duplicate(this.data.data.biodata)
biodata.currentlevelremaining = Math.max(biodata.currentlevelremaining+incDec, 0)
this.update( {"data.biodata": biodata} )
return biodata.currentlevelremaining
}
/* -------------------------------------------- */
async computeNRGHealth() {
if (this.isToken) return
@@ -1205,6 +1217,7 @@ export class PegasusActor extends Actor {
rollData.actorId = this.id
rollData.img = this.img
rollData.traumaState = this.getTraumaState()
rollData.levelRemaining = this.getLevelRemaining()
rollData.activePerks = duplicate(this.getActivePerks())
rollData.diceList = PegasusUtility.getDiceList()
rollData.dicePool = []
@@ -1223,7 +1236,7 @@ export class PegasusActor extends Actor {
}
let diceKey = PegasusUtility.getDiceFromLevel(rollData.stat.value)
rollData.dicePool.push({
name: "stat", key: diceKey,
name: "stat", key: diceKey, mod: rollData.stat.mod,
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
})
}
@@ -1236,6 +1249,15 @@ export class PegasusActor extends Actor {
return rollData
}
/* -------------------------------------------- */
getLevelRemainingList( ) {
let options = []
for (let i=0; i<=this.data.data.biodata.maxlevelremaining; i++) {
options.push( `<option value="${i}">${i}</option>`)
}
return options.join("\n")
}
/* -------------------------------------------- */
async startRoll(rollData) {
this.syncRoll(rollData);
@@ -1251,7 +1273,7 @@ export class PegasusActor extends Actor {
let power = this.data.items.get(itemId)
if (power) {
power = duplicate(power)
this.rollPool(power.data.dmgstatistic)
this.rollPool(power.data.dmgstatistic, false, "power-dmg")
}
}
@@ -1264,7 +1286,9 @@ export class PegasusActor extends Actor {
rollData.subKey = subKey
rollData.title = `Roll : ${stat.label} `
rollData.img = "icons/dice/d12black.svg"
if (subKey == "melee-dmg" || subKey == "ranged-dmg" || subKey == "power-dmg") {
rollData.isDamage = true
}
this.startRoll(rollData)
} else {
ui.notifications.warn("Statistic not found !");
@@ -1312,6 +1336,7 @@ export class PegasusActor extends Actor {
rollData.specName = spec.name
rollData.img = spec.img
rollData.specDicesLevel = spec.data.level
PegasusUtility.updateSpecDicePool(rollData)
this.startRoll(rollData)
} else {
ui.notifications.warn("Specialisation not found !");
@@ -1355,7 +1380,7 @@ export class PegasusActor extends Actor {
rollData.title = `Armor : ${armor.name}`
rollData.isResistance = true;
rollData.img = armor.img
rollData.otherDicesLevel = armor.data.resistance
rollData.damageDiceLevel = armor.data.resistance
this.startRoll(rollData);
} else {

View File

@@ -5,7 +5,7 @@ export class PegasusRollDialog extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData) {
let options = { classes: ["PegasusDialog"], width: 620, height: 380, 'z-index': 99999 };
let options = { classes: ["PegasusDialog"], width: 620, height: 480, 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-generic.html', rollData);
return new PegasusRollDialog(actor, rollData, html, options);
@@ -63,7 +63,7 @@ export class PegasusRollDialog extends Dialog {
idVal = "#statDicesLevel"
}
if (effectData.data.otherdice) {
idVal = "#otherDicesLevel"
idVal = "#damageDiceLevel"
}
if (effectData.data.hindrance) {
idVal = "#hindranceDicesLevel"
@@ -96,8 +96,9 @@ export class PegasusRollDialog extends Dialog {
this.rollData.specDicesLevel = Number($('#specDicesLevel').val())
//this.rollData.bonusDicesLevel = Number($('#bonusDicesLevel').val())
//this.rollData.hindranceDicesLevel = Number($('#hindranceDicesLevel').val())
this.rollData.otherDicesLevel = Number($('#otherDicesLevel').val())
this.rollData.damageDiceLevel = Number($('#damageDiceLevel').val())
PegasusUtility.updateSpecDicePool(this.rollData)
PegasusUtility.updateDamageDicePool(this.rollData)
PegasusUtility.updateEffectsBonusDice(this.rollData)
}
@@ -148,7 +149,7 @@ export class PegasusRollDialog extends Dialog {
let equip = this.rollData.equipmentsList[equipIdx]
if (equip) {
equip.applied = toggled
let idVal = "#otherDicesLevel" // Default
let idVal = "#damageDiceLevel" // Default
if (equip.equip.data.bonusdice) {
idVal = "#bonusDicesLevel"
}
@@ -156,7 +157,7 @@ export class PegasusRollDialog extends Dialog {
idVal = "#statDicesLevel"
}
if (equip.equip.data.otherdice) {
idVal = "#otherDicesLevel"
idVal = "#damageDiceLevel"
}
let newLevel = Number($(idVal).val())
if (toggled) {
@@ -171,7 +172,7 @@ export class PegasusRollDialog extends Dialog {
this.rollData.specDicesLevel = Number($('#specDicesLevel').val())
this.rollData.bonusDicesLevel = Number($('#bonusDicesLevel').val())
this.rollData.hindranceDicesLevel = Number($('#hindranceDicesLevel').val())
this.rollData.otherDicesLevel = Number($('#otherDicesLevel').val())
this.rollData.damageDiceLevel = Number($('#damageDiceLevel').val())
}
}
@@ -214,14 +215,10 @@ export class PegasusRollDialog extends Dialog {
PegasusUtility.updateSpecDicePool(this.rollData)
this.refreshDialog()
});
html.find('#bonusDicesLevel').change((event) => {
this.rollData.bonusDicesLevel = Number(event.currentTarget.value)
});
html.find('#hindranceDicesLevel').change((event) => {
this.rollData.hindranceDicesLevel = Number(event.currentTarget.value)
});
html.find('#otherDicesLevel').change((event) => {
this.rollData.otherDicesLevel = Number(event.currentTarget.value)
html.find('#damageDiceLevel').change(async (event) => {
this.rollData.damageDiceLevel = Number(event.currentTarget.value)
PegasusUtility.updateDamageDicePool(this.rollData)
this.refreshDialog()
});
html.find('.effect-clicked').change(async (event) => {
let toggled = event.currentTarget.checked

View File

@@ -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)
}