Step 5.2 fixes
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user