Step 5.2 fixes

This commit is contained in:
sladecraven 2022-07-20 23:53:37 +02:00
parent 8b6bfeb36c
commit aa4409be28
5 changed files with 97 additions and 44 deletions

View File

@ -477,24 +477,20 @@ export class PegasusActor extends Actor {
modifyMomentum(incDec) { modifyMomentum(incDec) {
let momentum = duplicate(this.data.data.momentum) let momentum = duplicate(this.data.data.momentum)
momentum.value += incDec momentum.value += incDec
if (momentum.value >= 0) { this.update({ 'data.momentum': momentum })
this.update({ 'data.momentum': momentum }) let chatData = {
let chatData = { user: game.user.id,
user: game.user.id, rollMode: game.settings.get("core", "rollMode"),
rollMode: game.settings.get("core", "rollMode"), whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM'))
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')) }
} if (incDec > 0) {
if (incDec > 0) { chatData.content = `<div>${this.name} has gained a Momentum</div`
chatData.content = `<div>${this.name} has gained a Momentum</div`
} else {
chatData.content = `<div>${this.name} has used a Momentum</div`
}
ChatMessage.create(chatData)
if (incDec < 0) {
PegasusUtility.showMomentumDialog(this.id)
}
} else { } else {
ui.notifications.warn("Momentum cannot go below 0") chatData.content = `<div>${this.name} has used a Momentum</div`
}
ChatMessage.create(chatData)
if (incDec < 0 && momentum.value >= 0) {
PegasusUtility.showMomentumDialog(this.id)
} }
} }
@ -539,27 +535,27 @@ export class PegasusActor extends Actor {
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
checkVirtue( virtue) { checkVirtue(virtue) {
let vices = this.getVices() let vices = this.getVices()
for (let vice of vices) { for (let vice of vices) {
let nonVirtues = vice.data.data.unavailablevirtue let nonVirtues = vice.data.data.unavailablevirtue
for (let blockedVirtue of nonVirtues) { for (let blockedVirtue of nonVirtues) {
if (blockedVirtue.name.toLowerCase() == virtue.name.toLowerCase()) { if (blockedVirtue.name.toLowerCase() == virtue.name.toLowerCase()) {
return false return false
} }
} }
} }
return true return true
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
checkVice( vice) { checkVice(vice) {
let virtues = this.getVirtues() let virtues = this.getVirtues()
for (let virtue of virtues) { for (let virtue of virtues) {
let nonVices = virtue.data.data.unavailablevice let nonVices = virtue.data.data.unavailablevice
for (let blockedVice of nonVices) { for (let blockedVice of nonVices) {
if (blockedVice.name.toLowerCase() == vice.name.toLowerCase()) { if (blockedVice.name.toLowerCase() == vice.name.toLowerCase()) {
return false return false
} }
} }
} }
return true return true
@ -582,17 +578,17 @@ export class PegasusActor extends Actor {
} }
} }
// Check virtue/vice validity // Check virtue/vice validity
if ( item.data.type == "virtue") { if (item.data.type == "virtue") {
if ( !this.checkVirtue(item) ) { if (!this.checkVirtue(item)) {
ui.notifications.info("Virtue is not allowed due to Vice.") ui.notifications.info("Virtue is not allowed due to Vice.")
return false return false
} }
} }
if ( item.data.type == "vice") { if (item.data.type == "vice") {
if ( !this.checkVice(item) ) { if (!this.checkVice(item)) {
ui.notifications.info("Vice is not allowed due to Virtue.") ui.notifications.info("Vice is not allowed due to Virtue.")
return false return false
} }
} }
let dropID = $(event.target).parents(".item").attr("data-item-id") // Only relevant if container drop let dropID = $(event.target).parents(".item").attr("data-item-id") // Only relevant if container drop
@ -811,6 +807,18 @@ export class PegasusActor extends Actor {
} }
} }
/* -------------------------------------------- */
async cleanupPerksIfTrauma() {
if ( this.getTraumaState == "severetrauma") {
for (let perk of this.data.items) {
if (perk.type == "perk") {
this.cleanPerkEffects(perk.id)
this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.used1': false, 'data.used2': false, 'data.used3': false }])
}
}
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async updatePerkStatus(itemId, status) { async updatePerkStatus(itemId, status) {
let item = this.items.get(itemId) let item = this.items.get(itemId)
@ -1036,7 +1044,7 @@ export class PegasusActor extends Actor {
// Update current hindrance level // Update current hindrance level
let hindrance = this.data.data.combat.hindrancedice let hindrance = this.data.data.combat.hindrancedice
if (this.data.data.secondary.health.value < 0) { if (this.data.data.secondary.health.value < 0) {
if (this.data.data.secondary.health.value < -Math.floor((this.data.data.secondary.health.value + 1) / 2)) { // Severe wounded if (this.data.data.secondary.health.value < -Math.floor((this.data.data.secondary.health.max + 1) / 2) ) { // Severe wounded
hindrance += 3 hindrance += 3
} else { } else {
hindrance += 1 hindrance += 1
@ -1045,6 +1053,7 @@ export class PegasusActor extends Actor {
} }
this.data.data.combat.hindrancedice = hindrance this.data.data.combat.hindrancedice = hindrance
this.getTraumaState() this.getTraumaState()
this.cleanupPerksIfTrauma()
} }
} }
@ -1214,20 +1223,20 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
addHindrancesList(effectsList) { addHindrancesList(effectsList) {
if (this.data.data.combat.stunlevel > 0) { if (this.data.data.combat.stunlevel > 0) {
effectsList.push({ label: "Stun Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.stunlevel }) effectsList.push({ label: "Stun Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: this.data.data.combat.stunlevel })
} }
if (this.data.data.combat.hindrancedice > 0) { if (this.data.data.combat.hindrancedice > 0) {
effectsList.push({ label: "Wounds Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.hindrancedice }) effectsList.push({ label: "Wounds Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: this.data.data.combat.hindrancedice })
} }
let overCapacity = Math.floor(this.encCurrent / this.getEncumbranceCapacity()) let overCapacity = Math.floor(this.encCurrent / this.getEncumbranceCapacity())
if (overCapacity > 0) { if (overCapacity > 0) {
effectsList.push({ label: "Encumbrance Hindrance", type: "hindrance", applied: false, value: overCapacity }) effectsList.push({ label: "Encumbrance Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: overCapacity })
} }
let effects = this.data.items.filter(item => item.type == 'effect') let effects = this.data.items.filter(item => item.type == 'effect')
for (let effect of effects) { for (let effect of effects) {
effect = duplicate(effect) effect = duplicate(effect)
if (effect.data.hindrance) { if (effect.data.hindrance) {
effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel }) effectsList.push({ label: effect.name, type: "effect", foreign: true, actorId: this.id, applied: false, effect: effect, value: effect.data.effectlevel })
} }
} }
} }
@ -1297,8 +1306,8 @@ export class PegasusActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getCommonRollData(statKey = undefined, useShield = false) { getCommonRollData(statKey = undefined, useShield = false, isInit = false) {
let rollData = PegasusUtility.getBasicRollData() let rollData = PegasusUtility.getBasicRollData(isInit)
rollData.alias = this.name rollData.alias = this.name
rollData.actorImg = this.img rollData.actorImg = this.img
rollData.actorId = this.id rollData.actorId = this.id
@ -1328,7 +1337,7 @@ export class PegasusActor extends Actor {
}) })
} }
this.addEffects(rollData) this.addEffects(rollData, isInit)
this.addArmorsShields(rollData, statKey, useShield) this.addArmorsShields(rollData, statKey, useShield)
this.addWeapons(rollData, statKey, useShield) this.addWeapons(rollData, statKey, useShield)
this.addEquipments(rollData, statKey) this.addEquipments(rollData, statKey)
@ -1440,7 +1449,7 @@ export class PegasusActor extends Actor {
if (mr) { if (mr) {
mr.dice = PegasusUtility.getDiceFromLevel(mr.value); mr.dice = PegasusUtility.getDiceFromLevel(mr.value);
let rollData = this.getCommonRollData("mr") let rollData = this.getCommonRollData("mr", false, isInit)
rollData.mode = "MR" rollData.mode = "MR"
rollData.img = "systems/fvtt-pegasus-rpg/images/icons/MR.webp" rollData.img = "systems/fvtt-pegasus-rpg/images/icons/MR.webp"
rollData.isInit = isInit rollData.isInit = isInit

View File

@ -85,6 +85,7 @@ export class PegasusRollDialog extends Dialog {
} }
//console.log("Effect", effect, toggled) //console.log("Effect", effect, toggled)
this.rollData.statDicesLevel = Number($('#statDicesLevel').val()) this.rollData.statDicesLevel = Number($('#statDicesLevel').val())
PegasusUtility.updateStatDicePool(this.rollData)
PegasusUtility.updateSpecDicePool(this.rollData) PegasusUtility.updateSpecDicePool(this.rollData)
PegasusUtility.updateDamageDicePool(this.rollData) PegasusUtility.updateDamageDicePool(this.rollData)
PegasusUtility.updateEffectsBonusDice(this.rollData) PegasusUtility.updateEffectsBonusDice(this.rollData)

View File

@ -85,9 +85,8 @@ export class PegasusUtility {
static updateHindranceBonusDice(rollData) { static updateHindranceBonusDice(rollData) {
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-hindrance") let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-hindrance")
for (let hindrance of rollData.effectsList) { for (let hindrance of rollData.effectsList) {
if (hindrance && hindrance.applied && hindrance.type == "hindrance") { if (hindrance && hindrance.applied && (hindrance.type == "hindrance" || (hindrance.type == "effect" && hindrance.effect?.data?.hindrance) ) ) {
console.log("Manage Hindrance", hindrance) let diceKey = PegasusUtility.getDiceFromLevel( (hindrance.value) ? hindrance.value : hindrance.effect.data.effectlevel)
let diceKey = PegasusUtility.getDiceFromLevel(hindrance.value)
let newDice = { let newDice = {
name: "effect-hindrance", key: diceKey, level: hindrance.value, effect: hindrance.name, name: "effect-hindrance", key: diceKey, level: hindrance.value, effect: hindrance.name,
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp` img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
@ -139,6 +138,24 @@ export class PegasusUtility {
} }
} }
/* -------------------------------------------- */
static updateStatDicePool( rollData) {
let newDicePool = rollData.dicePool.filter(dice => dice.name != "stat")
let statDice = rollData.dicePool.find(dice => dice.name == "stat")
if (rollData.statDicesLevel > 0) {
let diceKey = PegasusUtility.getDiceFromLevel(rollData.statDicesLevel)
let diceList = diceKey.split(" ")
for (let myDice of diceList) {
let newDice = {
name: "stat", key: myDice, level: rollData.statDicesLevel, mod: statDice.mod,
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
}
newDicePool.push(newDice)
}
}
rollData.dicePool = newDicePool
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static updateSpecDicePool(rollData) { static updateSpecDicePool(rollData) {
let newDicePool = rollData.dicePool.filter(dice => dice.name != "spec") let newDicePool = rollData.dicePool.filter(dice => dice.name != "spec")
@ -557,8 +574,20 @@ export class PegasusUtility {
if (msg.name == "msg_reroll_hero") { if (msg.name == "msg_reroll_hero") {
this.rerollHeroRemaining(msg.data.userId, msg.data.rollId) this.rerollHeroRemaining(msg.data.userId, msg.data.rollId)
} }
if (msg.name == "msg_gm_remove_effect") {
this.removeForeignEffect(msg.data)
}
} }
/* -------------------------------------------- */
static removeForeignEffect( effectData) {
if (game.user.isGM) {
console.log("Remote removal of effects", effectData)
let actor = game.actors.get(effectData.actorId)
actor.deleteEmbeddedDocuments('Item', [effectData.effect._id])
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static chatDataSetup(content, modeOverride, isRoll = false, forceWhisper) { static chatDataSetup(content, modeOverride, isRoll = false, forceWhisper) {
let chatData = { let chatData = {
@ -638,8 +667,16 @@ export class PegasusUtility {
let toRem = [] let toRem = []
for (let effect of rollData.effectsList) { for (let effect of rollData.effectsList) {
if (effect.effect && effect.effect.data.isUsed && effect.effect.data.oneuse) { if (effect.effect && effect.effect.data.isUsed && effect.effect.data.oneuse) {
toRem.push(effect.effect._id) if (effect.foreign) {
ChatMessage.create({ content: `One used effect ${effect.effect.name} has been auto-deleted.` }) if (game.user.isGM) {
this.removeForeignEffect(effect)
} else {
game.socket.emit("system.fvtt-pegasus-rgp", { msg: "msg_gm_remove_effect", data: effect })
}
} else {
toRem.push(effect.effect._id)
ChatMessage.create({ content: `One used effect ${effect.effect.name} has been auto-deleted.` })
}
} }
} }
if (toRem.length > 0) { if (toRem.length > 0) {
@ -874,7 +911,7 @@ export class PegasusUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getBasicRollData() { static getBasicRollData(isInit) {
let rollData = { let rollData = {
rollId: randomID(16), rollId: randomID(16),
rollMode: game.settings.get("core", "rollMode"), rollMode: game.settings.get("core", "rollMode"),
@ -893,7 +930,9 @@ export class PegasusUtility {
equipmentsList: [], equipmentsList: [],
optionsDiceList: PegasusUtility.getOptionsDiceList() optionsDiceList: PegasusUtility.getOptionsDiceList()
} }
PegasusUtility.updateWithTarget(rollData) if ( !isInit) { // For init, do not display target hindrances
PegasusUtility.updateWithTarget(rollData)
}
return rollData return rollData
} }

View File

@ -183,6 +183,6 @@
"templateVersion": 95, "templateVersion": 95,
"title": "Pegasus RPG", "title": "Pegasus RPG",
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
"version": "0.6.1", "version": "0.6.2",
"background" : "./images/ui/pegasus_welcome_page.webp" "background" : "./images/ui/pegasus_welcome_page.webp"
} }

View File

@ -1002,6 +1002,10 @@
<label class="short-label">Character Development Points Total (CDP total) : </label> <label class="short-label">Character Development Points Total (CDP total) : </label>
<input type="text" class="" name="data.biodata.cdp" value="{{data.biodata.cdp}}" data-dtype="Number" /> <input type="text" class="" name="data.biodata.cdp" value="{{data.biodata.cdp}}" data-dtype="Number" />
</li> </li>
<li class="flexrow">
<label class="short-label">Corruption : </label>
<input type="text" class="" name="data.biodata.corruption" value="{{data.biodata.corruption}}" data-dtype="Number" />
</li>
<li class="flexrow"> <li class="flexrow">
<label class="short-label">Hero Level (max) : </label> <label class="short-label">Hero Level (max) : </label>
<input type="text" class="" name="data.biodata.maxlevelremaining" value="{{data.biodata.maxlevelremaining}}" data-dtype="Number" /> <input type="text" class="" name="data.biodata.maxlevelremaining" value="{{data.biodata.maxlevelremaining}}" data-dtype="Number" />