diff --git a/lang/en.json b/lang/en.json index 49ecfba..f56d630 100644 --- a/lang/en.json +++ b/lang/en.json @@ -56,6 +56,7 @@ } }, "Skill": { + "Unnatural": "Unnatural", "FIELDS": { "settings": { "label": "Settings era" @@ -212,7 +213,13 @@ "individual": "Individual", "community": "Community" }, + "Harshness": { + "normal": "Normal", + "harsh": "Harsh", + "veryHarsh": "Very Harsh" + }, "Label": { + "biodata": "Biodata", "skill": "Skill", "modifier": "Modifier", "rollView": "Roll View", @@ -225,6 +232,12 @@ "powShort": "POW", "conShort": "CON", "chaShort": "CHA", + "strLong": "Strength", + "dexLong": "Dexterity", + "intLong": "Intelligence", + "powLong": "Power", + "conLong": "Constitution", + "chaLong": "Charisma", "total": "Total", "skills": "Skills", "gear": "Gear", @@ -252,11 +265,14 @@ "totalScore": "Total Score", "exhausted": "Exhausted", "skillRoll": "Skill Roll", + "charRoll": "Characteristic Roll", "finalScore": "Final Score", "failure": "Failure", "success": "Success", "criticalSuccess": "Critical Success", - "criticalFailure": "Critical Failure" + "criticalFailure": "Critical Failure", + "Characteristic": "Characteristic", + "targetScore": "Target Score" }, "Edit": "Edit", "Delete": "Delete", diff --git a/module/applications/sheets/protagonist-sheet.mjs b/module/applications/sheets/protagonist-sheet.mjs index 5b00abf..64d73c5 100644 --- a/module/applications/sheets/protagonist-sheet.mjs +++ b/module/applications/sheets/protagonist-sheet.mjs @@ -148,9 +148,19 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS let item // Debug : console.log(">>>>", event, target, rollType) // Deprecated : if (this.isEditMode) return - if (rollType === "skill") { - const li = $(event.currentTarget).parents(".item"); - item = this.actor.items.get(li.data("item-id")); + switch(rollType) { + case "char": + let charId = $(event.currentTarget).data("char-id") + item = foundry.utils.duplicate(this.actor.system.characteristics[charId]) + item.name = game.i18n.localize("CTHULHUETERNAL.Label." + charId + "Long") + item.targetScore = item.value * 5 + break + case "skill": + const li = $(event.currentTarget).parents(".item"); + item = this.actor.items.get(li.data("item-id")); + break + default: + throw new Error(`Unknown roll type ${rollType}`) } await this.document.system.roll(rollType, item) } diff --git a/module/config/protagonist.mjs b/module/config/protagonist.mjs index 677f225..ce33d15 100644 --- a/module/config/protagonist.mjs +++ b/module/config/protagonist.mjs @@ -25,3 +25,9 @@ export const CHARACTERISTICS = Object.freeze({ } }) +export const HARSHNESS = Object.freeze({ + "normal": "CTHULHUETERNAL.Harshness.normal", + "harsh": "CTHULHUETERNAL.Harshness.harsh", + "veryharsh": "CTHULHUETERNAL.Harshness.veryHarsh" +}) + diff --git a/module/config/system.mjs b/module/config/system.mjs index 0aa6bc8..aab0e9a 100644 --- a/module/config/system.mjs +++ b/module/config/system.mjs @@ -42,6 +42,7 @@ export const ASCII = ` export const SYSTEM = { id: SYSTEM_ID, CHARACTERISTICS: PROTAGONIST.CHARACTERISTICS, + HARSHNESS: PROTAGONIST.HARSHNESS, WEAPON_TYPE: WEAPON.WEAPON_TYPE, WEAPON_SUBTYPE: WEAPON.WEAPON_SUBTYPE, BOND_TYPE: BOND.BOND_TYPE, diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index 49a4088..8fe0092 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -1,4 +1,5 @@ export default class CthulhuEternalActor extends Actor { + async _preCreate(data, options, user) { await super._preCreate(data, options, user) diff --git a/module/documents/roll.mjs b/module/documents/roll.mjs index bec6669..23f2132 100644 --- a/module/documents/roll.mjs +++ b/module/documents/roll.mjs @@ -95,8 +95,8 @@ export default class CthulhuEternalRoll extends Roll { console.log(options.rollItem) options.initialScore = options.rollItem.system.computeScore() break - case "characteristic": - options.initialScore = options.rollItem.value * 5 + case "char": + options.initialScore = options.rollItem.targetScore break default: options.initialScore = 50 diff --git a/module/models/protagonist.mjs b/module/models/protagonist.mjs index 1e3f10e..750b956 100644 --- a/module/models/protagonist.mjs +++ b/module/models/protagonist.mjs @@ -28,7 +28,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData schema.wp = new fields.SchemaField({ value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), - max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), + max: new fields.NumberField({ ...requiredInteger, initial: 3, min: 0 }), exhausted: new fields.BooleanField({ required: true, initial: false }) }) @@ -44,7 +44,6 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData recovery: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), violence: new fields.ArrayField(new fields.BooleanField(), { required: true, initial: [false, false, false], min:3, max:3}), helplessness: new fields.ArrayField(new fields.BooleanField(), { required: true, initial: [false, false, false], min:3, max:3 }), - breakingPoint: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }) }) @@ -65,7 +64,8 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData home: new fields.StringField({ required: true, nullable: false, initial: "" }), birthplace: new fields.StringField({ required: true, nullable: false, initial: "" }), eyes: new fields.StringField({ required: true, nullable: false, initial: "" }), - hair: new fields.StringField({ required: true, nullable: false, initial: "" }) + hair: new fields.StringField({ required: true, nullable: false, initial: "" }), + harshness: new fields.StringField({ required: true, nullable: false, initial: "normal", choices:SYSTEM.HARSHNESS }), }) return schema @@ -74,6 +74,75 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData /** @override */ static LOCALIZATION_PREFIXES = ["CTHULHUETERNAL.Protagonist"] + prepareDerivedData() { + super.prepareDerivedData(); + + let updates = {} + if ( this.wp.max !== this.characteristics.pow.value) { + updates[`system.wp.max`] = this.characteristics.pow.value + } + let hpMax = Math.round((this.characteristics.con.value + this.characteristics.str.value) / 2) + if ( this.hp.max !== hpMax) { + updates[`system.hp.max`] = hpMax + } + + // Get Unnatural skill for MAX SAN + let unnatural = this.parent.items.find(i => i.type === "skill" && i.name.toLowerCase() === game.i18n.localize("CTHULHUETERNAL.Skill.Unnatural").toLowerCase()) + let minus = 0 + if (unnatural) { + minus = unnatural.data.skillTotal + } + let maxSan = Math.max(99 - minus, 0) + if ( this.san.max !== maxSan) { + updates[`system.san.max`] = maxSan + } + + let bp = Math.max(this.san.value - this.characteristics.pow.value, 0) + if ( this.san.breakingPoint !== bp) { + updates[`system.san.breakingPoint`] = bp + } + + let recoverySan = this.characteristics.pow.value * 5 + if (recoverySan > this.san.max) { + recoverySan = this.san.max + } + if ( this.san.recovery !== recoverySan) { + updates[`system.san.recovery`] = recoverySan + } + + let dmgBonus = 0 + if (this.characteristics.str.value <= 4) { + dmgBonus = -2 + } else if (this.characteristics.str.value <= 8) { + dmgBonus = -1 + } else if (this.characteristics.str.value <= 12) { + dmgBonus = 0 + } else if (this.characteristics.str.value <= 16) { + dmgBonus = 1 + } else if (this.characteristics.str.value <= 20) { + dmgBonus = 2 + } + if ( this.damageBonus !== dmgBonus) { + updates[`system.damageBonus`] = dmgBonus + } + + // Sanity check + if (this.san.value > this.san.max) { + updates[`system.san.value`] = this.san.max + } + if (this.wp.value > this.wp.max) { + updates[`system.wp.value`] = this.wp.max + } + if (this.hp.value > this.hp.max) { + updates[`system.hp.value`] = this.hp.max + } + + if (Object.keys(updates).length > 0) { + this.parent.update(updates) + } + } + + /** */ /** * Rolls a dice for a character. * @param {("save"|"resource|damage")} rollType The type of the roll. diff --git a/module/models/skill.mjs b/module/models/skill.mjs index b0e592d..d37fc43 100644 --- a/module/models/skill.mjs +++ b/module/models/skill.mjs @@ -34,7 +34,7 @@ export default class CthulhuEternalSkill extends foundry.abstract.TypeDataModel return `${this.base} + ${ String(this.bonus)}`; } - // Split the base value per stat : WIS,DEX,STR,INT,CHA (example) + // Split the base value per stat : let base = this.base.toLowerCase(); let char = actor.system.characteristics[base]; if (!char) { diff --git a/templates/chat-message.hbs b/templates/chat-message.hbs index b516b1d..4ba4065 100644 --- a/templates/chat-message.hbs +++ b/templates/chat-message.hbs @@ -6,11 +6,15 @@