Add resources management
This commit is contained in:
@ -89,6 +89,30 @@ export const RESOURCE_RATING = {
|
||||
}
|
||||
}
|
||||
|
||||
export const RESOURCE_BREAKDOWN = [
|
||||
{ value: 0, hand: 0, stowed: 0, storage: 0, checks: 0},
|
||||
{ value: 1, hand: 1, stowed: 0, storage: 0, checks: 1},
|
||||
{ value: 2, hand: 2, stowed: 0, storage: 0, checks: 1},
|
||||
{ value: 3, hand: 3, stowed: 0, storage: 0, checks: 1},
|
||||
{ value: 4, hand: 4, stowed: 0, storage: 0, checks: 1},
|
||||
{ value: 5, hand: 5, stowed: 0, storage: 0, checks: 1},
|
||||
{ value: 6, hand: 6, stowed: 0, storage: 0, checks: 1},
|
||||
{ value: 7, hand: 6, stowed: 1, storage: 0, checks: 2},
|
||||
{ value: 8, hand: 6, stowed: 2, storage: 0, checks: 2},
|
||||
{ value: 9, hand: 6, stowed: 3, storage: 0, checks: 2},
|
||||
{ value: 10, hand: 6, stowed: 4, storage: 0, checks: 2},
|
||||
{ value: 11, hand: 6, stowed: 5, storage: 0, checks: 2},
|
||||
{ value: 12, hand: 6, stowed: 6, storage: 0, checks: 2},
|
||||
{ value: 13, hand: 6, stowed: 6, storage: 1, checks: 3},
|
||||
{ value: 14, hand: 6, stowed: 6, storage: 2, checks: 3},
|
||||
{ value: 15, hand: 6, stowed: 6, storage: 3, checks: 3},
|
||||
{ value: 16, hand: 6, stowed: 6, storage: 4, checks: 3},
|
||||
{ value: 17, hand: 6, stowed: 6, storage: 5, checks: 3},
|
||||
{ value: 18, hand: 6, stowed: 6, storage: 6, checks: 3},
|
||||
{ value: 19, hand: 6, stowed: 6, storage: 7, checks: 3},
|
||||
{ value: 20, hand: 6, stowed: 6, storage: 8, checks: 3}
|
||||
]
|
||||
|
||||
export const MENTAL_ILLNESS_CURE_SKILL = {
|
||||
jazz: "CTHULHUETERNAL.Skill.Psychoanalyze",
|
||||
modern: "CTHULHUETERNAL.Skill.Psychoanalyze",
|
||||
@ -189,5 +213,6 @@ export const SYSTEM = {
|
||||
MENTAL_ILLNESS_CURE_SKILL,
|
||||
ERA_CSS,
|
||||
INSANITY,
|
||||
RESOURCE_BREAKDOWN,
|
||||
ASCII
|
||||
}
|
||||
|
@ -51,10 +51,16 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
schema.damageBonus = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
|
||||
schema.resources = new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), // Unused but kept for compatibility
|
||||
permanentRating: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
hand: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
currentHand: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
stowed: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
storage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
currentStowed: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
storage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
currentStorage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
checks: new fields.ArrayField(new fields.BooleanField(), { required: true, initial: [false, false, false], min:3, max:3 }),
|
||||
nbValidChecks: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
|
||||
schema.biodata = new fields.SchemaField({
|
||||
@ -140,6 +146,22 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
updates[`system.hp.value`] = this.hp.max
|
||||
}
|
||||
|
||||
if ( this.resources.permanentRating <= 20) {
|
||||
let breakdown = SYSTEM.RESOURCE_BREAKDOWN[this.resources.permanentRating]
|
||||
if (this.resources.hand !== breakdown.hand) {
|
||||
updates[`system.resources.hand`] = breakdown.hand
|
||||
}
|
||||
if (this.resources.stowed !== breakdown.stowed) {
|
||||
updates[`system.resources.stowed`] = breakdown.stowed
|
||||
}
|
||||
if (this.resources.storage !== breakdown.storage) {
|
||||
updates[`system.resources.storage`] = breakdown.storage
|
||||
}
|
||||
if (this.resources.nbValidChecks !== breakdown.checks) {
|
||||
updates[`system.resources.nbValidChecks`] = breakdown.checks
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(updates).length > 0) {
|
||||
this.parent.update(updates)
|
||||
}
|
||||
@ -157,7 +179,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
isExhausted() {
|
||||
return this.wp.exhausted
|
||||
}
|
||||
|
||||
|
||||
/** */
|
||||
/**
|
||||
* Rolls a dice for a character.
|
||||
|
Reference in New Issue
Block a user