This commit is contained in:
@@ -66,6 +66,7 @@ export default class FTLNomadActorSheet extends HandlebarsApplicationMixin(found
|
||||
actor: this.document,
|
||||
system: this.document.system,
|
||||
source: this.document.toObject(),
|
||||
isEncumbered: this.document.system.isEncumbered(),
|
||||
enrichedDescription: await TextEditor.enrichHTML(this.document.system.description, { async: true }),
|
||||
isEditMode: this.isEditMode,
|
||||
isPlayMode: this.isPlayMode,
|
||||
|
||||
@@ -12,9 +12,14 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
contentClasses: ["character-content"],
|
||||
},
|
||||
actions: {
|
||||
createGear: FTLNomadCharacterSheet.#onCreateGear,
|
||||
createEquipment: FTLNomadCharacterSheet.#onCreateEquipment,
|
||||
createArmor: FTLNomadCharacterSheet.#onCreateArmor,
|
||||
createWeapon: FTLNomadCharacterSheet.#onCreateWeapon
|
||||
createWeapon: FTLNomadCharacterSheet.#onCreateWeapon,
|
||||
createTalent: FTLNomadCharacterSheet.#onCreateTalent,
|
||||
createImplant: FTLNomadCharacterSheet.#onCreateImplant,
|
||||
createPsionic: FTLNomadCharacterSheet.#onCreatePsionic,
|
||||
createLanguage: FTLNomadCharacterSheet.#onCreateLanguage
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
@@ -26,6 +31,9 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
tabs: {
|
||||
template: "templates/generic/tab-navigation.hbs",
|
||||
},
|
||||
talents: {
|
||||
template: "systems/fvtt-ftl-nomad/templates/character-talents.hbs",
|
||||
},
|
||||
equipment: {
|
||||
template: "systems/fvtt-ftl-nomad/templates/character-equipment.hbs",
|
||||
},
|
||||
@@ -36,7 +44,7 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
|
||||
/** @override */
|
||||
tabGroups = {
|
||||
sheet: "main",
|
||||
sheet: "talents",
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,6 +53,7 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
*/
|
||||
#getTabs() {
|
||||
const tabs = {
|
||||
talents: { id: "talents", group: "sheet", icon: "fa-solid fa-compass", label: "FTLNOMAD.Label.talents" },
|
||||
equipment: { id: "equipment", group: "sheet", icon: "fa-solid fa-shapes", label: "FTLNOMAD.Label.equipment" },
|
||||
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "FTLNOMAD.Label.biography" },
|
||||
}
|
||||
@@ -62,7 +71,7 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(this.document.system.notes, { async: true })
|
||||
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
@@ -72,6 +81,17 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
switch (partId) {
|
||||
case "main":
|
||||
break
|
||||
case "talents":
|
||||
context.tab = context.tabs.talents
|
||||
context.talents = doc.itemTypes.talent
|
||||
context.talents.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.implants = doc.itemTypes.implant
|
||||
context.implants.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.psionics = doc.itemTypes.psionic
|
||||
context.psionics.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.languages = doc.itemTypes.language
|
||||
context.languages.sort((a, b) => a.name.localeCompare(b.name))
|
||||
break
|
||||
case "equipment":
|
||||
context.tab = context.tabs.equipment
|
||||
context.weapons = doc.itemTypes.weapon
|
||||
@@ -90,8 +110,8 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
return context
|
||||
}
|
||||
|
||||
|
||||
static #onCreateGear(event, target) {
|
||||
|
||||
static #onCreateEquipment(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("FTLNOMAD.Label.newGear"), type: "gear" }])
|
||||
}
|
||||
|
||||
@@ -103,6 +123,22 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("FTLNOMAD.Label.newArmor"), type: "armor" }])
|
||||
}
|
||||
|
||||
static #onCreateTalent(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("FTLNOMAD.Label.newTalent"), type: "talent" }])
|
||||
}
|
||||
|
||||
static #onCreateImplant(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("FTLNOMAD.Label.newImplant"), type: "implant" }])
|
||||
}
|
||||
|
||||
static #onCreatePsionic(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("FTLNOMAD.Label.newPsionic"), type: "psionic" }])
|
||||
}
|
||||
|
||||
static #onCreateLanguage(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("FTLNOMAD.Label.newLanguage"), type: "language" }])
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles the roll action triggered by user interaction.
|
||||
@@ -122,35 +158,16 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
const rollType = $(event.currentTarget).data("roll-type")
|
||||
let item
|
||||
let li
|
||||
// Debug : console.log(">>>>", event, target, rollType)
|
||||
// Deprecated : if (this.isEditMode) return
|
||||
switch (rollType) {
|
||||
case "resource":
|
||||
item = foundry.utils.duplicate(this.actor.system.resources)
|
||||
item.name = game.i18n.localize(`FTLNOMAD.Label.Resources`)
|
||||
item.targetScore = item.permanentRating
|
||||
break
|
||||
case "char":
|
||||
let charId = $(event.currentTarget).data("char-id")
|
||||
item = foundry.utils.duplicate(this.actor.system.characteristics[charId])
|
||||
item.name = game.i18n.localize(`FTLNOMAD.Label.${charId}Long`)
|
||||
item.targetScore = item.value * 5
|
||||
break
|
||||
case "skill":
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
let skillId = $(event.currentTarget).data("skill-id");
|
||||
item = this.actor.system.skills[skillId];
|
||||
break
|
||||
case "weapon":
|
||||
case "damage":
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
item.damageBonus = this.actor.system.damageBonus
|
||||
break
|
||||
case "san":
|
||||
item = foundry.utils.duplicate(this.actor.system.san)
|
||||
item.name = game.i18n.localize("FTLNOMAD.Label.SAN")
|
||||
item.targetScore = item.value
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown roll type ${rollType}`)
|
||||
}
|
||||
|
||||
@@ -50,11 +50,26 @@ export const WEAPON_TYPES = {
|
||||
"grenade": { id: "grenade", label: "FTLNOMAD.Weapon.Types.Grenade" },
|
||||
"vehicle": { id: "vehicle", label: "FTLNOMAD.Weapon.Types.Vehicle" }
|
||||
}
|
||||
|
||||
export const WEAPON_RANGE = {
|
||||
"melee": { id: "melee", label: "FTLNOMAD.Weapon.Range.Melee" },
|
||||
"handgun": { id: "handgun", label: "FTLNOMAD.Weapon.Range.Handgun" },
|
||||
"rifle": { id: "rifle", label: "FTLNOMAD.Weapon.Range.Rifle" },
|
||||
"longrange": { id: "longrange", label: "FTLNOMAD.Weapon.Range.LongRange" }
|
||||
"handgun": { id: "handgun", label: "FTLNOMAD.Weapon.Range.Handgun", range: {close: 0, near:0, far:-2} },
|
||||
"assault": { id: "assault", label: "FTLNOMAD.Weapon.Range.Assault", range: {close: -2, near:0, far:-1, distant: -2} },
|
||||
"rifle": { id: "rifle", label: "FTLNOMAD.Weapon.Range.Rifle", range: {close: -3, near:0, far:0, distant: -1} },
|
||||
"melee": { id: "melee", label: "FTLNOMAD.Weapon.Range.Melee", range: {close: 0} },
|
||||
"heavyweapon": { id: "heavyweapon", label: "FTLNOMAD.Weapon.Range.HeavyWeapon", range: {near:-1, far:0, distant: 0} },
|
||||
"thrownweapon": { id: "thrownweapon", label: "FTLNOMAD.Weapon.Range.ThrownWeapon", range: {close: 0, near:-1} }
|
||||
}
|
||||
|
||||
export const ATTACK_MODIFIERS = {
|
||||
"two-attacks": -1,
|
||||
"aiming": 1,
|
||||
"dim": -1,
|
||||
"darkness": -2,
|
||||
"prone": -1,
|
||||
"cover": -2,
|
||||
"recoil-first": -1,
|
||||
"recoil-third": -2,
|
||||
"aware": -1
|
||||
}
|
||||
|
||||
export const TRIAGE_RESULTS = {
|
||||
@@ -98,12 +113,22 @@ export const CREATURE_SIZES = {
|
||||
"titanic": { id: "titanic", label: "FTLNOMAD.Creature.Size.Titanic" }
|
||||
}
|
||||
|
||||
export const MODIFIER_CHOICES = {
|
||||
"easy": { id: "easy", label: "FTLNOMAD.Label.Easy", value :"1" },
|
||||
"moderate": { id: "moderate", label: "FTLNOMAD.Label.Moderate", value: "0" },
|
||||
"difficult": { id: "difficult", label: "FTLNOMAD.Label.Difficult", value: "-1" },
|
||||
"formidable": { id: "formidable", label: "FTLNOMAD.Label.Formidable", value: "-2" },
|
||||
"impossible": { id: "impossible", label: "FTLNOMAD.Label.Impossible", value: "-4" }
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all constant definitions within the SYSTEM global export
|
||||
* @type {Object}
|
||||
*/
|
||||
export const SYSTEM = {
|
||||
id: SYSTEM_ID,
|
||||
MODIFIER_CHOICES,
|
||||
ATTACK_MODIFIERS,
|
||||
TECH_AGES,
|
||||
WEAPON_TYPES,
|
||||
WEAPON_RANGE,
|
||||
|
||||
@@ -40,14 +40,6 @@ export default class FTLNomadRoll extends Roll {
|
||||
return this.options.help
|
||||
}
|
||||
|
||||
get gene() {
|
||||
return this.options.gene
|
||||
}
|
||||
|
||||
get modifier() {
|
||||
return this.options.modifier
|
||||
}
|
||||
|
||||
get resultType() {
|
||||
return this.options.resultType
|
||||
}
|
||||
@@ -68,41 +60,15 @@ export default class FTLNomadRoll extends Roll {
|
||||
return this.options.weapon
|
||||
}
|
||||
|
||||
get isLowWP() {
|
||||
return this.options.isLowWP
|
||||
}
|
||||
|
||||
get isZeroWP() {
|
||||
return this.options.isZeroWP
|
||||
}
|
||||
|
||||
get isExhausted() {
|
||||
return this.options.isExhausted
|
||||
}
|
||||
|
||||
get isNudgedRoll() {
|
||||
return this.options.isNudgedRoll
|
||||
}
|
||||
|
||||
get wpCost() {
|
||||
return this.options.wpCost
|
||||
}
|
||||
|
||||
static updateResourceDialog(options) {
|
||||
let rating = 0
|
||||
if (options.rollItem.enableHand) {
|
||||
rating += options.rollItem.hand
|
||||
static updateFullFormula(options) {
|
||||
let fullFormula
|
||||
if ( options.numericModifier >= 0) {
|
||||
fullFormula = `${options.formula} + ${options.rollItem.value} + ${options.numericModifier}D`
|
||||
} else {
|
||||
fullFormula = `${options.formula} + ${options.rollItem.value} - ${Math.abs(options.numericModifier)}D`
|
||||
}
|
||||
if (options.rollItem.enableStowed) {
|
||||
rating += options.rollItem.stowed
|
||||
}
|
||||
if (options.rollItem.enableStorage) {
|
||||
rating += options.rollItem.storage
|
||||
}
|
||||
let multiplier = Number($(`.roll-skill-multiplier`).val())
|
||||
options.initialScore = rating
|
||||
options.percentScore = rating * multiplier
|
||||
$(".resource-score").text(`${rating} (${options.percentScore}%)`)
|
||||
$('#roll-dialog-full-formula').text(fullFormula)
|
||||
options.fullFormula = fullFormula
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,84 +86,25 @@ export default class FTLNomadRoll extends Roll {
|
||||
* @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled.
|
||||
*/
|
||||
static async prompt(options = {}) {
|
||||
let formula = "1d100"
|
||||
let hasModifier = true
|
||||
let hasMultiplier = false
|
||||
options.isNudge = true
|
||||
let formula = "2d6"
|
||||
|
||||
switch (options.rollType) {
|
||||
case "skill":
|
||||
console.log(options.rollItem)
|
||||
options.initialScore = options.rollItem.system.computeScore()
|
||||
break
|
||||
case "san":
|
||||
case "char":
|
||||
options.initialScore = options.rollItem.targetScore
|
||||
options.isNudge = (options.rollType !== "san")
|
||||
break
|
||||
case "resource":
|
||||
hasModifier = false
|
||||
hasMultiplier = true
|
||||
options.initialScore = options.rollItem.targetScore
|
||||
options.totalRating = options.rollItem.targetScore
|
||||
options.percentScore = options.rollItem.targetScore * 5
|
||||
options.rollItem.enableHand = true
|
||||
options.rollItem.enableStowed = true
|
||||
options.rollItem.enableStorage = true
|
||||
options.isNudge = false
|
||||
break
|
||||
case "damage":
|
||||
let formula = options.rollItem.system.damage
|
||||
if ( options.rollItem.system.weaponType === "melee" || options.rollItem.system.weaponType === "unarmed") {
|
||||
formula += ` + ${options.rollItem.damageBonus}`
|
||||
}
|
||||
let damageRoll = new Roll(formula)
|
||||
await damageRoll.evaluate()
|
||||
await damageRoll.toMessage({
|
||||
flavor: `${options.rollItem.name} - Damage Roll`
|
||||
});
|
||||
let isLethal = false
|
||||
options.isNudge = false
|
||||
if (options.rollItem.system.lethality > 0) {
|
||||
let lethalityRoll = new Roll("1d100")
|
||||
await lethalityRoll.evaluate()
|
||||
isLethal = (lethalityRoll.total <= options.rollItem.system.lethality)
|
||||
await lethalityRoll.toMessage({
|
||||
flavor: `${options.rollItem.name} - Lethality Roll : ${lethalityRoll.total} <= ${options.rollItem.system.lethality} => ${isLethal}`
|
||||
});
|
||||
}
|
||||
return
|
||||
case "weapon":
|
||||
let era = game.settings.get("fvtt-ftl-nomad", "settings-era")
|
||||
if (era !== options.rollItem.system.settings) {
|
||||
ui.notifications.error(game.i18n.localize("FTLNOMAD.Notifications.WrongEra"))
|
||||
console.log("WP Wrong Era", era, options.rollItem.system.weaponType)
|
||||
return
|
||||
}
|
||||
if (!SYSTEM.WEAPON_SKILL_MAPPING[era] || !SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType]) {
|
||||
ui.notifications.error(game.i18n.localize("FTLNOMAD.Notifications.NoWeaponType"))
|
||||
console.log("WP Not found", era, options.rollItem.system.weaponType)
|
||||
return
|
||||
}
|
||||
options.weapon = options.rollItem
|
||||
if (options.rollItem.system.hasDirectSkill) {
|
||||
let skillName = options.rollItem.name
|
||||
options.rollItem = {type: "skill", name: skillName, system: {base: 0, bonus: options.weapon.system.directSkillValue} }
|
||||
options.initialScore = options.weapon.system.directSkillValue
|
||||
} else {
|
||||
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
|
||||
let actor = game.actors.get(options.actorId)
|
||||
options.rollItem = actor.items.find(i => i.type === "skill" && i.name.toLowerCase() === skillName.toLowerCase())
|
||||
if (!options.rollItem) {
|
||||
ui.notifications.error(game.i18n.localize("FTLNOMAD.Notifications.NoWeaponSkill"))
|
||||
return
|
||||
}
|
||||
options.initialScore = options.rollItem.system.computeScore()
|
||||
console.log("WEAPON", skillName, era, options.rollItem)
|
||||
}
|
||||
let actor = game.actors.get(options.actorId)
|
||||
options.weapon = foundry.utils.duplicate(options.rollItem)
|
||||
options.rollItem = actor.system.skills.combat
|
||||
break
|
||||
default:
|
||||
options.initialScore = 50
|
||||
break
|
||||
}
|
||||
|
||||
@@ -209,37 +116,53 @@ export default class FTLNomadRoll extends Roll {
|
||||
})
|
||||
|
||||
const choiceModifier = SYSTEM.MODIFIER_CHOICES
|
||||
const choiceMultiplier = SYSTEM.MULTIPLIER_CHOICES
|
||||
let choiceRangeModifier = {}
|
||||
let rangeModifier = 0
|
||||
if ( options.weapon) {
|
||||
// Build the range modifiers
|
||||
let range = SYSTEM.WEAPON_RANGE[options.weapon.system.rangeType]
|
||||
for (let [key, value] of Object.entries(range.range)) {
|
||||
choiceRangeModifier[key] = { label: `${key} (${value}D)`, value: value }
|
||||
if (!rangeModifier && value) {
|
||||
rangeModifier = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let modifier = "+0"
|
||||
let multiplier = "5"
|
||||
let modifier = "0"
|
||||
options.numericModifier = rangeModifier
|
||||
let fullFormula = `${formula} + ${options.rollItem.value}`
|
||||
if (options.isEncumbered) {
|
||||
options.numericModifier += -1
|
||||
fullFormula += ` - ${options.numericModifier}D`
|
||||
} else {
|
||||
options.numericModifier += 0
|
||||
fullFormula += ` + ${options.numericModifier}D`
|
||||
}
|
||||
options.fullFormula = fullFormula
|
||||
options.formula = formula
|
||||
|
||||
let dialogContext = {
|
||||
actorId: options.actorId,
|
||||
actorName: options.actorName,
|
||||
rollType: options.rollType,
|
||||
rollItem: foundry.utils.duplicate(options.rollItem), // Object only, no class
|
||||
fullFormula,
|
||||
weapon: options?.weapon,
|
||||
initialScore: options.initialScore,
|
||||
targetScore: options.initialScore,
|
||||
isLowWP: options.isLowWP,
|
||||
isZeroWP: options.isZeroWP,
|
||||
isExhausted: options.isExhausted,
|
||||
enableHand: options.rollItem.enableHand,
|
||||
enableStowed: options.rollItem.enableStowed,
|
||||
enableStorage: options.rollItem.enableStorage,
|
||||
isEncumbered: options.isEncumbered,
|
||||
talents: options.talents,
|
||||
rollModes,
|
||||
fieldRollMode,
|
||||
choiceModifier,
|
||||
choiceMultiplier,
|
||||
choiceRangeModifier,
|
||||
rangeModifier,
|
||||
formula,
|
||||
hasTarget: options.hasTarget,
|
||||
hasModifier,
|
||||
hasMultiplier,
|
||||
modifier,
|
||||
multiplier
|
||||
}
|
||||
const content = await renderTemplate("systems/fvtt-ftl-nomad/templates/roll-dialog.hbs", dialogContext)
|
||||
|
||||
const title = CthulhuEternalRoll.createTitle(options.rollType, options.rollTarget)
|
||||
const title = FTLNomadRoll.createTitle(options.rollType, options.rollTarget)
|
||||
const label = game.i18n.localize("FTLNOMAD.Roll.roll")
|
||||
const rollContext = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: title },
|
||||
@@ -258,24 +181,27 @@ export default class FTLNomadRoll extends Roll {
|
||||
},
|
||||
],
|
||||
actions: {
|
||||
"selectHand": (event, button, dialog) => {
|
||||
options.rollItem.enableHand = !options.rollItem.enableHand
|
||||
this.updateResourceDialog(options)
|
||||
},
|
||||
"selectStowed": (event, button, dialog) => {
|
||||
options.rollItem.enableStowed = !options.rollItem.enableStowed
|
||||
this.updateResourceDialog(options)
|
||||
},
|
||||
"selectStorage": (event, button, dialog) => {
|
||||
options.rollItem.enableStorage = !options.rollItem.enableStorage
|
||||
this.updateResourceDialog(options)
|
||||
}
|
||||
},
|
||||
rejectClose: false, // Click on Close button will not launch an error
|
||||
render: (event, dialog) => {
|
||||
$(".roll-skill-multiplier").change(event => {
|
||||
options.multiplier = Number(event.target.value)
|
||||
this.updateResourceDialog(options)
|
||||
$(".roll-skill-modifier").change(event => {
|
||||
options.numericModifier += Number(event.target.value)
|
||||
FTLNomadRoll.updateFullFormula(options)
|
||||
})
|
||||
$(".roll-skill-range-modifier").change(event => {
|
||||
options.numericModifier += Number(event.target.value)
|
||||
FTLNomadRoll.updateFullFormula(options)
|
||||
})
|
||||
$(".select-combat-option").change(event => {
|
||||
console.log(event)
|
||||
let field = $(event.target).data("field")
|
||||
let modifier = SYSTEM.ATTACK_MODIFIERS[field]
|
||||
if ( event.target.checked) {
|
||||
options.numericModifier += modifier
|
||||
} else {
|
||||
options.numericModifier -= modifier
|
||||
}
|
||||
FTLNomadRoll.updateFullFormula(options)
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -285,25 +211,19 @@ export default class FTLNomadRoll extends Roll {
|
||||
|
||||
let rollData = foundry.utils.mergeObject(foundry.utils.duplicate(options), rollContext)
|
||||
rollData.rollMode = rollContext.visibility
|
||||
|
||||
// Update target score
|
||||
console.log("Rolldata", rollData, options)
|
||||
if (options.rollType === "resource") {
|
||||
rollData.targetScore = options.initialScore * Number(rollContext.multiplier)
|
||||
} else {
|
||||
rollData.targetScore = Math.min(Math.max(options.initialScore + Number(rollData.modifier), 0), 100)
|
||||
if (rollData.isLowWP || rollData.isExhausted) {
|
||||
rollData.targetScore -= 20
|
||||
}
|
||||
if (rollData.isZeroWP) {
|
||||
rollData.targetScore = 0
|
||||
}
|
||||
rollData.targetScore = Math.min(Math.max(rollData.targetScore, 0), 100)
|
||||
}
|
||||
rollData.targetScore = 8
|
||||
|
||||
if (Hooks.call("fvtt-ftl-nomad.preRoll", options, rollData) === false) return
|
||||
|
||||
let diceFormula = `${2+Math.abs(options.numericModifier)}D6`
|
||||
if ( options.numericModifier > 0 ) {
|
||||
diceFormula += `kh2 + ${options.rollItem.value}`
|
||||
} else {
|
||||
diceFormula += `kl2 + ${options.rollItem.value}`
|
||||
}
|
||||
|
||||
const roll = new this(formula, options.data, rollData)
|
||||
const roll = new this(diceFormula, options.data, rollData)
|
||||
await roll.evaluate()
|
||||
|
||||
roll.displayRollResult(roll, options, rollData)
|
||||
@@ -317,34 +237,15 @@ export default class FTLNomadRoll extends Roll {
|
||||
|
||||
// Compute the result quality
|
||||
let resultType = "failure"
|
||||
let dec = Math.floor(this.total / 10)
|
||||
let unit = this.total - (dec * 10)
|
||||
if (this.total <= rollData.targetScore) {
|
||||
if (this.total >= 8) {
|
||||
resultType = "success"
|
||||
// Detect if decimal == unit in the dire total result
|
||||
if (dec === unit || this.total === 1) {
|
||||
resultType = "successCritical"
|
||||
}
|
||||
} else {
|
||||
// Detect if decimal == unit in the dire total result
|
||||
if (dec === unit || this.total === 100) {
|
||||
resultType = "failureCritical"
|
||||
}
|
||||
}
|
||||
|
||||
this.options.resultType = resultType
|
||||
if (this.options.isNudgedRoll) {
|
||||
this.options.isSuccess = resultType === "success" || resultType === "successCritical"
|
||||
this.options.isFailure = resultType === "failure" || resultType === "failureCritical"
|
||||
this.options.isCritical = false
|
||||
} else {
|
||||
this.options.isSuccess = resultType === "success" || resultType === "successCritical"
|
||||
this.options.isFailure = resultType === "failure" || resultType === "failureCritical"
|
||||
this.options.isCritical = resultType === "successCritical" || resultType === "failureCritical"
|
||||
}
|
||||
this.options.isLowWP = rollData.isLowWP
|
||||
this.options.isZeroWP = rollData.isZeroWP
|
||||
this.options.isExhausted = rollData.isExhausted
|
||||
this.options.isSuccess = resultType === "success"
|
||||
this.options.isFailure = resultType === "failure"
|
||||
this.options.isEncumbered = rollData.isEncumbered
|
||||
this.options.rollData = foundry.utils.duplicate(rollData)
|
||||
}
|
||||
|
||||
@@ -361,10 +262,6 @@ export default class FTLNomadRoll extends Roll {
|
||||
return `${game.i18n.localize("FTLNOMAD.Label.titleSkill")}`
|
||||
case "weapon":
|
||||
return `${game.i18n.localize("FTLNOMAD.Label.titleWeapon")}`
|
||||
case "char":
|
||||
return `${game.i18n.localize("FTLNOMAD.Label.titleCharacteristic")}`
|
||||
case "san":
|
||||
return `${game.i18n.localize("FTLNOMAD.Label.titleSAN")}`
|
||||
default:
|
||||
return game.i18n.localize("FTLNOMAD.Label.titleStandard")
|
||||
}
|
||||
@@ -407,6 +304,8 @@ export default class FTLNomadRoll extends Roll {
|
||||
cardData.diceTotal = this.dice.reduce((t, d) => t + d.total, 0)
|
||||
cardData.isGM = game.user.isGM
|
||||
cardData.formula = this.formula
|
||||
cardData.fullFormula = this.options.fullFormula
|
||||
cardData.numericModifier = this.options.numericModifier
|
||||
cardData.total = this.total
|
||||
cardData.actorId = this.actorId
|
||||
cardData.actingCharName = this.actorName
|
||||
@@ -418,11 +317,7 @@ export default class FTLNomadRoll extends Roll {
|
||||
cardData.realDamage = this.realDamage
|
||||
cardData.isPrivate = isPrivate
|
||||
cardData.weapon = this.weapon
|
||||
cardData.isLowWP = this.isLowWP
|
||||
cardData.isZeroWP = this.isZeroWP
|
||||
cardData.isExhausted = this.isExhausted
|
||||
cardData.isNudgedRoll = this.isNudgedRoll
|
||||
cardData.wpCost = this.wpCost
|
||||
cardData.isEncumbered = this.isEncumbered
|
||||
|
||||
cardData.cssClass = cardData.css.join(" ")
|
||||
cardData.tooltip = isPrivate ? "" : await this.getTooltip()
|
||||
|
||||
@@ -18,6 +18,7 @@ export default class FTLNomadProtagonist extends foundry.abstract.TypeDataModel
|
||||
const skillField = (label) => {
|
||||
const schema = {
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 5 }),
|
||||
label: new fields.StringField({ required: true, nullable: false, initial: label })
|
||||
}
|
||||
return new fields.SchemaField(schema, { label })
|
||||
}
|
||||
@@ -43,6 +44,10 @@ export default class FTLNomadProtagonist extends foundry.abstract.TypeDataModel
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
|
||||
schema.armor = new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
|
||||
schema.credits = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
schema.rank = new fields.SchemaField({
|
||||
experienced: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 5 }),
|
||||
@@ -55,6 +60,7 @@ export default class FTLNomadProtagonist extends foundry.abstract.TypeDataModel
|
||||
schema.biodata = new fields.SchemaField({
|
||||
age: new fields.NumberField({ ...requiredInteger, initial: 15, min: 6 }),
|
||||
height: new fields.NumberField({ ...requiredInteger, initial: 170, min: 50 }),
|
||||
weight: new fields.NumberField({ ...requiredInteger, initial: 70, min: 1 }),
|
||||
gender: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
home: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
birthplace: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
@@ -70,9 +76,33 @@ export default class FTLNomadProtagonist extends foundry.abstract.TypeDataModel
|
||||
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
|
||||
|
||||
let encMax = 10 + (2*this.skills.physical.value)
|
||||
if (encMax !== this.enc.max) {
|
||||
this.enc.max = encMax
|
||||
}
|
||||
let enc = 0
|
||||
let armor = 0
|
||||
for (let i of this.parent.items) {
|
||||
if (i.system?.enc) {
|
||||
enc += i.system.enc
|
||||
}
|
||||
if ( i.system?.protection) {
|
||||
armor += i.system.protection
|
||||
}
|
||||
}
|
||||
if (enc !== this.enc.value) {
|
||||
this.enc.value = enc
|
||||
}
|
||||
if (armor !== this.armor.value) {
|
||||
this.armor.value = armor
|
||||
}
|
||||
}
|
||||
|
||||
isEncumbered() {
|
||||
return this.enc.value > this.enc.max
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* Rolls a dice for a character.
|
||||
@@ -84,12 +114,14 @@ export default class FTLNomadProtagonist extends foundry.abstract.TypeDataModel
|
||||
let opponentTarget
|
||||
const hasTarget = opponentTarget !== undefined
|
||||
|
||||
let roll = await CthulhuEternalRoll.prompt({
|
||||
let roll = await FTLNomadRoll.prompt({
|
||||
rollType,
|
||||
rollItem,
|
||||
actorId: this.parent.id,
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
talents: this.parent.items.filter(i => i.type === "talent" && i.system.isAdvantage),
|
||||
isEncumbered: this.isEncumbered(),
|
||||
hasTarget,
|
||||
target: opponentTarget
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user