Manage selective fire
This commit is contained in:
@ -35,7 +35,9 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
schema.hp = new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
|
||||
stunned: new fields.BooleanField({ required: true, initial: false })
|
||||
stunned: new fields.BooleanField({ required: true, initial: false }),
|
||||
unconscious: new fields.BooleanField({ required: true, initial: false }),
|
||||
dead: new fields.BooleanField({ required: true, initial: false })
|
||||
})
|
||||
|
||||
schema.san = new fields.SchemaField({
|
||||
@ -130,6 +132,22 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
updates[`system.damageBonus`] = dmgBonus
|
||||
}
|
||||
|
||||
// Unconsciousness management
|
||||
if (!this.hp.unconscious && this.hp.value <= 2) {
|
||||
updates[`system.hp.unconscious`] = true
|
||||
}
|
||||
if (this.hp.unconscious && this.hp.value > 2) {
|
||||
updates[`system.hp.unconscious`] = false
|
||||
}
|
||||
|
||||
// Dead management
|
||||
if (!this.hp.dead && this.hp.value <= 0) {
|
||||
updates[`system.hp.dead`] = true
|
||||
}
|
||||
if (this.hp.dead && this.hp.value > 0) {
|
||||
updates[`system.hp.dead`] = false
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
if (this.san.value > this.san.max) {
|
||||
updates[`system.san.value`] = this.san.max
|
||||
@ -165,6 +183,10 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
}
|
||||
}
|
||||
|
||||
isStunned() {
|
||||
return this.hp.stunned
|
||||
}
|
||||
|
||||
isLowWP() {
|
||||
return this.wp.value <= 2
|
||||
}
|
||||
@ -207,6 +229,32 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
|
||||
*/
|
||||
async roll(rollType, rollItem) {
|
||||
|
||||
if (this.hp.dead ) {
|
||||
// Warn with chat message
|
||||
ChatMessage.create({
|
||||
content: `<p>${game.i18n.format("CTHULHUETERNAL.Label.deadWarning", {con: this.characteristics.con.value} )}</p>`,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent })
|
||||
})
|
||||
return null
|
||||
}
|
||||
if (this.hp.unconscious ) {
|
||||
// Warn with chat message
|
||||
ChatMessage.create({
|
||||
content: `<p>${game.i18n.localize("CTHULHUETERNAL.Label.unconsciousWarning")}</p>`,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent })
|
||||
})
|
||||
return null
|
||||
}
|
||||
if (this.hp.stunned && rollType === "skill") {
|
||||
// Warn with chat message
|
||||
ChatMessage.create({
|
||||
content: `<p>${game.i18n.localize("CTHULHUETERNAL.Label.stunnedWarning")}</p>`,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent })
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
let opponentTarget
|
||||
const hasTarget = opponentTarget !== undefined
|
||||
|
||||
|
@ -15,6 +15,8 @@ export default class CthulhuEternalSkill extends foundry.abstract.TypeDataModel
|
||||
schema.diceEvolved = new fields.BooleanField({ required: true, initial: true })
|
||||
schema.rollFailed = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.isAdversary = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.isHealing = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.healingFormula = new fields.StringField({ required: true, initial: "1d4" })
|
||||
|
||||
return schema
|
||||
}
|
||||
@ -36,11 +38,11 @@ export default class CthulhuEternalSkill extends foundry.abstract.TypeDataModel
|
||||
return `${this.base} + ${ String(this.bonus)}`;
|
||||
}
|
||||
|
||||
// Split the base value per stat :
|
||||
// Split the base value per stat :
|
||||
let base = this.base.toLowerCase();
|
||||
let char = actor.system.characteristics[base];
|
||||
if (!char) {
|
||||
ui.notifications.error(`The characteristic ${base} is wrong for actor ${actor.name}`);
|
||||
ui.notifications.error(`The characteristic ${base} is wrong for actor ${actor.name}`);
|
||||
return `${this.base } + ${ String(this.bonus)}`;
|
||||
}
|
||||
let charValue = char.value;
|
||||
|
@ -25,6 +25,10 @@ export default class CthulhuEternalWeapon extends foundry.abstract.TypeDataModel
|
||||
schema.armorPiercing = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.weaponSubtype = new fields.StringField({ required: true, initial: "basicfirearm", choices: SYSTEM.WEAPON_SUBTYPE })
|
||||
schema.state = new fields.StringField({ required: true, initial: "pristine", choices: SYSTEM.EQUIPMENT_STATES })
|
||||
schema.ammo = new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 6, min: 0 }),
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 6, min: 0 })
|
||||
})
|
||||
|
||||
schema.resourceLevel = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
|
||||
@ -37,4 +41,12 @@ export default class CthulhuEternalWeapon extends foundry.abstract.TypeDataModel
|
||||
get weaponCategory() {
|
||||
return game.i18n.localize(CATEGORY[this.category].label)
|
||||
}
|
||||
|
||||
isRanged() {
|
||||
return this.weaponType.includes("ranged")
|
||||
}
|
||||
|
||||
isFireArm() {
|
||||
return this.weaponType === "rangedfirearm"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user