Step 5.2 fixes
This commit is contained in:
parent
8b6bfeb36c
commit
aa4409be28
@ -477,24 +477,20 @@ export class PegasusActor extends Actor {
|
||||
modifyMomentum(incDec) {
|
||||
let momentum = duplicate(this.data.data.momentum)
|
||||
momentum.value += incDec
|
||||
if (momentum.value >= 0) {
|
||||
this.update({ 'data.momentum': momentum })
|
||||
let chatData = {
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM'))
|
||||
}
|
||||
if (incDec > 0) {
|
||||
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)
|
||||
}
|
||||
this.update({ 'data.momentum': momentum })
|
||||
let chatData = {
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM'))
|
||||
}
|
||||
if (incDec > 0) {
|
||||
chatData.content = `<div>${this.name} has gained a Momentum</div`
|
||||
} 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()
|
||||
for (let vice of vices) {
|
||||
let nonVirtues = vice.data.data.unavailablevirtue
|
||||
for (let blockedVirtue of nonVirtues) {
|
||||
if (blockedVirtue.name.toLowerCase() == virtue.name.toLowerCase()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
checkVice( vice) {
|
||||
checkVice(vice) {
|
||||
let virtues = this.getVirtues()
|
||||
for (let virtue of virtues) {
|
||||
let nonVices = virtue.data.data.unavailablevice
|
||||
for (let blockedVice of nonVices) {
|
||||
if (blockedVice.name.toLowerCase() == vice.name.toLowerCase()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
@ -582,17 +578,17 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
}
|
||||
// Check virtue/vice validity
|
||||
if ( item.data.type == "virtue") {
|
||||
if ( !this.checkVirtue(item) ) {
|
||||
if (item.data.type == "virtue") {
|
||||
if (!this.checkVirtue(item)) {
|
||||
ui.notifications.info("Virtue is not allowed due to Vice.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( item.data.type == "vice") {
|
||||
if ( !this.checkVice(item) ) {
|
||||
if (item.data.type == "vice") {
|
||||
if (!this.checkVice(item)) {
|
||||
ui.notifications.info("Vice is not allowed due to Virtue.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
let item = this.items.get(itemId)
|
||||
@ -1036,7 +1044,7 @@ export class PegasusActor extends Actor {
|
||||
// Update current hindrance level
|
||||
let hindrance = this.data.data.combat.hindrancedice
|
||||
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
|
||||
} else {
|
||||
hindrance += 1
|
||||
@ -1045,6 +1053,7 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
this.data.data.combat.hindrancedice = hindrance
|
||||
this.getTraumaState()
|
||||
this.cleanupPerksIfTrauma()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1214,20 +1223,20 @@ export class PegasusActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
addHindrancesList(effectsList) {
|
||||
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) {
|
||||
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())
|
||||
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')
|
||||
for (let effect of effects) {
|
||||
effect = duplicate(effect)
|
||||
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) {
|
||||
let rollData = PegasusUtility.getBasicRollData()
|
||||
getCommonRollData(statKey = undefined, useShield = false, isInit = false) {
|
||||
let rollData = PegasusUtility.getBasicRollData(isInit)
|
||||
rollData.alias = this.name
|
||||
rollData.actorImg = this.img
|
||||
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.addWeapons(rollData, statKey, useShield)
|
||||
this.addEquipments(rollData, statKey)
|
||||
@ -1440,7 +1449,7 @@ export class PegasusActor extends Actor {
|
||||
if (mr) {
|
||||
mr.dice = PegasusUtility.getDiceFromLevel(mr.value);
|
||||
|
||||
let rollData = this.getCommonRollData("mr")
|
||||
let rollData = this.getCommonRollData("mr", false, isInit)
|
||||
rollData.mode = "MR"
|
||||
rollData.img = "systems/fvtt-pegasus-rpg/images/icons/MR.webp"
|
||||
rollData.isInit = isInit
|
||||
|
@ -85,6 +85,7 @@ export class PegasusRollDialog extends Dialog {
|
||||
}
|
||||
//console.log("Effect", effect, toggled)
|
||||
this.rollData.statDicesLevel = Number($('#statDicesLevel').val())
|
||||
PegasusUtility.updateStatDicePool(this.rollData)
|
||||
PegasusUtility.updateSpecDicePool(this.rollData)
|
||||
PegasusUtility.updateDamageDicePool(this.rollData)
|
||||
PegasusUtility.updateEffectsBonusDice(this.rollData)
|
||||
|
@ -85,9 +85,8 @@ export class PegasusUtility {
|
||||
static updateHindranceBonusDice(rollData) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-hindrance")
|
||||
for (let hindrance of rollData.effectsList) {
|
||||
if (hindrance && hindrance.applied && hindrance.type == "hindrance") {
|
||||
console.log("Manage Hindrance", hindrance)
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(hindrance.value)
|
||||
if (hindrance && hindrance.applied && (hindrance.type == "hindrance" || (hindrance.type == "effect" && hindrance.effect?.data?.hindrance) ) ) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel( (hindrance.value) ? hindrance.value : hindrance.effect.data.effectlevel)
|
||||
let newDice = {
|
||||
name: "effect-hindrance", key: diceKey, level: hindrance.value, effect: hindrance.name,
|
||||
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) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "spec")
|
||||
@ -557,8 +574,20 @@ export class PegasusUtility {
|
||||
if (msg.name == "msg_reroll_hero") {
|
||||
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) {
|
||||
let chatData = {
|
||||
@ -638,8 +667,16 @@ export class PegasusUtility {
|
||||
let toRem = []
|
||||
for (let effect of rollData.effectsList) {
|
||||
if (effect.effect && effect.effect.data.isUsed && effect.effect.data.oneuse) {
|
||||
toRem.push(effect.effect._id)
|
||||
ChatMessage.create({ content: `One used effect ${effect.effect.name} has been auto-deleted.` })
|
||||
if (effect.foreign) {
|
||||
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) {
|
||||
@ -874,7 +911,7 @@ export class PegasusUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getBasicRollData() {
|
||||
static getBasicRollData(isInit) {
|
||||
let rollData = {
|
||||
rollId: randomID(16),
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
@ -893,7 +930,9 @@ export class PegasusUtility {
|
||||
equipmentsList: [],
|
||||
optionsDiceList: PegasusUtility.getOptionsDiceList()
|
||||
}
|
||||
PegasusUtility.updateWithTarget(rollData)
|
||||
if ( !isInit) { // For init, do not display target hindrances
|
||||
PegasusUtility.updateWithTarget(rollData)
|
||||
}
|
||||
return rollData
|
||||
}
|
||||
|
||||
|
@ -183,6 +183,6 @@
|
||||
"templateVersion": 95,
|
||||
"title": "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"
|
||||
}
|
||||
|
@ -1002,6 +1002,10 @@
|
||||
<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" />
|
||||
</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">
|
||||
<label class="short-label">Hero Level (max) : </label>
|
||||
<input type="text" class="" name="data.biodata.maxlevelremaining" value="{{data.biodata.maxlevelremaining}}" data-dtype="Number" />
|
||||
|
Loading…
Reference in New Issue
Block a user