v2 changes

This commit is contained in:
2022-07-10 10:22:04 +02:00
parent 55efa32739
commit f66b9c1913
32 changed files with 836 additions and 460 deletions

View File

@ -55,11 +55,78 @@ export class PegasusUtility {
/* -------------------------------------------- */
static pushInitiativeOptions(html, options) {
console.log('Option pushed....')
options.push({ name: "Apply -10", condition: true, icon: '<i class="fas fa-plus"></i>', callback: target => { PegasusCombat.decInitBy10(target.data('combatant-id'), -10); } })
}
/* -------------------------------------------- */
static getDiceList() {
return [{ key: "d4", img: "systems/fvtt-pegasus-rpg/images/dice/d4.webp" }, { key: "d6", img: "systems/fvtt-pegasus-rpg/images/dice/d6.webp" },
{ key: "d8", img: "systems/fvtt-pegasus-rpg/images/dice/d8.webp" }, { key: "d10", img: "systems/fvtt-pegasus-rpg/images/dice/d10.webp" },
{ key: "d12", img: "systems/fvtt-pegasus-rpg/images/dice/d12.webp" }]
}
/* -------------------------------------------- */
static updateEffectsBonusDice( rollData) {
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-bonus-dice")
for (let effect of rollData.effectsList) {
if (effect && effect.applied && effect.effect.data.bonusdice) {
let diceKey = PegasusUtility.getDiceFromLevel(effect.effect.data.effectlevel)
let newDice = {
name: "effect-bonus-dice", key: diceKey, effect: effect.effect.name,
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.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`
}
newDicePool.push(newDice)
}
rollData.dicePool = newDicePool
}
/* -------------------------------------------- */
static addDicePool(rollData, diceKey) {
let newDice = {
name: "dice-click", key: diceKey,
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
}
rollData.dicePool.push(newDice)
}
/*-------------------------------------------- */
static removeFromDicePool( rollData, diceIdx ) {
let toRemove = rollData.dicePool[diceIdx]
console.log("CLICK : ", rollData.dicePool, diceIdx)
if (toRemove && toRemove.name != "spec" && toRemove.name != "stat") {
let newDicePool = []
for (let i=0; i<rollData.dicePool.length; i++) {
if ( i!=diceIdx) {
newDicePool.push( rollData.dicePool[i])
}
}
rollData.dicePool = newDicePool
if (toRemove.name == "effect-bonus-dice") {
for (let effect of rollData.effectsList) {
if ( effect.effect.name == toRemove.effect && effect.applied) {
effect.applied = false //Remove the effect
}
}
}
}
}
/*-------------------------------------------- */
static getSpecs() {
return this.specs;
}
@ -279,7 +346,7 @@ export class PegasusUtility {
/* -------------------------------------------- */
static getDiceValue(level = 0) {
let diceString = this.diceList[level]
if ( !diceString) {
if (!diceString) {
console.log("Level error", level)
}
let diceTab = diceString.split(" ")
@ -384,14 +451,14 @@ export class PegasusUtility {
this.updateRollData(msg.data)
}
if (msg.name == "msg_gm_item_drop" && game.user.isGM) {
let actor = game.actors.get( msg.data.actorId )
let actor = game.actors.get(msg.data.actorId)
let item
if (msg.data.isPack) {
item = await fromUuid("Compendium." + msg.data.isPack + "." + msg.data.itemId)
} else {
item = game.items.get(msg.data.itemId)
}
this.addItemDropToActor( actor, item )
this.addItemDropToActor(actor, item)
}
}
@ -468,6 +535,22 @@ export class PegasusUtility {
}
}
/* -------------------------------------------- */
static removeOneUseEffects(rollData) {
// De-actived used effects from perks
let toRem = []
for (let effect of rollData.effectsList) {
if (effect.effect.data.isUsed && effect.effect.data.oneuse) {
toRem.push(effect.effect._id)
}
}
if (toRem.length > 0) {
console.log("Going to remove one use effects", toRem)
let actor = game.actors.get(rollData.actorId)
actor.deleteEmbeddedDocuments('Item', toRem)
}
}
/* -------------------------------------------- */
static async rollPegasus(rollData) {
@ -489,11 +572,15 @@ export class PegasusUtility {
if (rollData.specDicesLevel) {
dicePool[1].level = rollData.specDicesLevel
}
if (rollData.bonusDicesLevel) {
dicePool[2].level += Number(rollData.bonusDicesLevel)
if (rollData.traumaState == "none") {
if (rollData.bonusDicesLevel) {
dicePool[2].level += Number(rollData.bonusDicesLevel)
}
}
if (rollData.hindranceDicesLevel) {
dicePool[3].level += Number(rollData.hindranceDicesLevel)
if (!rollData.isInit) { // No Hindrance dice for Init
if (rollData.hindranceDicesLevel) {
dicePool[3].level += Number(rollData.hindranceDicesLevel)
}
}
if (rollData.otherDicesLevel) {
dicePool[4].level += Number(rollData.otherDicesLevel)
@ -509,7 +596,6 @@ export class PegasusUtility {
let myRoll = rollData.roll;
if (!myRoll) { // New rolls only of no rerolls
myRoll = new Roll(diceFormula).roll({ async: false });
console.log("ROLL : ", diceFormula)
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"));
rollData.roll = myRoll
}
@ -534,7 +620,14 @@ export class PegasusUtility {
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)
}
//this.removeUsedPerkEffects( rollData) // Unused for now
this.removeOneUseEffects(rollData) // Unused for now
// And save the roll
this.saveRollData(rollData);
@ -631,7 +724,7 @@ export class PegasusUtility {
item = await fromUuid("Compendium." + dataItem.pack + "." + dataItem.id)
} else {
item = game.items.get(dataItem.id)
}
}
return item
}