Init/progression dice
This commit is contained in:
@ -59,7 +59,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
|
||||
)
|
||||
const woundFieldSchema = {
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
duration: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
description: new fields.StringField({ initial: "", required: false, nullable: true }),
|
||||
}
|
||||
@ -68,9 +68,11 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
|
||||
painDamage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
wounds: new fields.ArrayField(new fields.SchemaField(woundFieldSchema ) , { initial: [{description:"", value:0, duration:0},{description:"", value:0, duration:0},
|
||||
{description:"", value:0, duration:0},{description:"", value:0, duration:0},{description:"", value:0, duration:0},{description:"", value:0, duration:0},
|
||||
{description:"", value:0, duration:0},{description:"", value:0, duration:0}], min:8} ),
|
||||
wounds: new fields.ArrayField(new fields.SchemaField(woundFieldSchema), {
|
||||
initial: [{ description: "", value: 0, duration: 0 }, { description: "", value: 0, duration: 0 },
|
||||
{ description: "", value: 0, duration: 0 }, { description: "", value: 0, duration: 0 }, { description: "", value: 0, duration: 0 }, { description: "", value: 0, duration: 0 },
|
||||
{ description: "", value: 0, duration: 0 }, { description: "", value: 0, duration: 0 }], min: 8
|
||||
}),
|
||||
})
|
||||
|
||||
schema.perception = new fields.SchemaField({
|
||||
@ -99,7 +101,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
vertical: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
})
|
||||
schema.biodata = new fields.SchemaField({
|
||||
class: new fields.StringField({required: true, initial: "untrained", choices: SYSTEM.CHAR_CLASSES}),
|
||||
class: new fields.StringField({ required: true, initial: "untrained", choices: SYSTEM.CHAR_CLASSES }),
|
||||
level: new fields.NumberField({ ...requiredInteger, initial: 1, min: 1 }),
|
||||
mortal: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
alignment: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
@ -110,13 +112,13 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
magicUser: new fields.BooleanField({ initial: false }),
|
||||
clericUser: new fields.BooleanField({ initial: false }),
|
||||
})
|
||||
|
||||
|
||||
schema.modifiers = new fields.SchemaField({
|
||||
levelSpellModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
saveModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
levelMiracleModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
intSpellModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
chaMiracleModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
chaMiracleModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
})
|
||||
|
||||
schema.developmentPoints = new fields.SchemaField({
|
||||
@ -127,6 +129,14 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
total: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
used: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
schema.aetherPoints = new fields.SchemaField({
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
schema.divinityPoints = new fields.SchemaField({
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
schema.combat = new fields.SchemaField({
|
||||
attackModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
defenseModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
@ -187,7 +197,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
let conDef = SYSTEM.CHARACTERISTICS_TABLES.con.find(s => s.value === this.characteristics.con.value)
|
||||
this.saves.pain.value = conDef.pain_save + this.modifiers.saveModifier
|
||||
this.saves.toughness.value = conDef.toughness_save + this.modifiers.saveModifier
|
||||
this.challenges.dying.value = conDef.stabilization_dice
|
||||
this.challenges.dying.value = conDef.stabilization_dice
|
||||
|
||||
this.saves.contagion.value = this.characteristics.con.value + this.modifiers.saveModifier
|
||||
this.saves.poison.value = this.characteristics.con.value + this.modifiers.saveModifier
|
||||
@ -209,7 +219,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
let chaDef = SYSTEM.CHARACTERISTICS_TABLES[chaKey].find(s => s.value === this.characteristics[chaKey].value)
|
||||
this.combat.damageModifier += chaDef.damage
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -234,4 +244,46 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
async rollInitiative(combatId = undefined, combatantId = undefined) {
|
||||
const hasTarget = false
|
||||
let actorClass = this.biodata.class;
|
||||
|
||||
let wisDef = SYSTEM.CHARACTERISTICS_TABLES.wis.find((c) => c.value === this.characteristics.wis.value)
|
||||
let maxInit = Number(wisDef.init_cap) || 1000
|
||||
console.log("Rolling initiative for", this)
|
||||
|
||||
let roll = await LethalFantasyRoll.promptInitiative({
|
||||
actorId: this.parent.id,
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
combatId,
|
||||
combatantId ,
|
||||
actorClass,
|
||||
maxInit,
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
async rollProgressionDice(combatId, combatantId, rollProgressionCount) {
|
||||
|
||||
// Get all weapons from the actor
|
||||
let weapons = this.parent.items.filter(i => i.type === "weapon")
|
||||
let weaponsChoices = weapons.map(w => { return { id: w.id, name: `${w.name} (${w.system.combatProgressionDice})`, combatProgressionDice: w.system.combatProgressionDice } })
|
||||
|
||||
let roll = await LethalFantasyRoll.promptProgressionDice({
|
||||
actorId: this.parent.id,
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
weaponsChoices,
|
||||
combatId,
|
||||
combatantId,
|
||||
rollProgressionCount,
|
||||
type: "progression",
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
attackModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
defenseModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
damageDice: new fields.StringField({ required: true, nullable: false, initial: "1D6" }),
|
||||
damageModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
}
|
||||
return new fields.SchemaField(schema, { label })
|
||||
}
|
||||
@ -104,7 +105,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
height: new fields.NumberField({ ...requiredInteger, initial: 170, min: 50 }),
|
||||
length: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
weight: new fields.NumberField({ ...requiredInteger, initial: 70, min: 0 })
|
||||
})
|
||||
})
|
||||
schema.combat = new fields.SchemaField({
|
||||
attackModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
defenseModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
@ -141,4 +142,59 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
async rollInitiative(combatId = undefined, combatantId = undefined) {
|
||||
const hasTarget = false
|
||||
|
||||
let maxInit = 100
|
||||
|
||||
let roll = await LethalFantasyRoll.promptInitiative({
|
||||
actorId: this.parent.id,
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
combatId,
|
||||
combatantId,
|
||||
maxInit,
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
async rollProgressionDice(combatId, combatantId, rollProgressionCount) {
|
||||
|
||||
const rollModes = Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
default: "public",
|
||||
})
|
||||
|
||||
let roll = new Roll("1D8")
|
||||
await roll.evaluate()
|
||||
let max = rollProgressionCount
|
||||
let msg = await roll.toMessage({ flavor: `Progression Roll for ${this.parent.name}, progression count : ${rollProgressionCount}/${max}` } )
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
|
||||
|
||||
let hasAttack = false
|
||||
for (let key in this.attacks) {
|
||||
let attack = this.attacks[key]
|
||||
if (attack.attackScore > 0 && attack.attackScore === roll.total) {
|
||||
hasAttack = true
|
||||
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOK", { name: this.parent.name, weapon: attack.name, roll: roll.total })
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
|
||||
// Update the combatant progression count
|
||||
let combat = game.combats.get(combatId)
|
||||
let combatant = combat.combatants.get(combatantId)
|
||||
combatant.update({ 'system.progressionCount': 0 })
|
||||
}
|
||||
}
|
||||
if (!hasAttack) {
|
||||
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionKO", { name: this.parent.name, roll: roll.total })
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user