Add spells rolls and enhance CSS styling

This commit is contained in:
2026-01-12 10:45:20 +01:00
parent e75824cd20
commit 0bc6b43ffe
29 changed files with 2428 additions and 878 deletions
@@ -18,6 +18,10 @@ export default class PrismRPGCharacterSheet extends PrismRPGActorSheet {
rollInitiative: PrismRPGCharacterSheet.#onRollInitiative,
armorHitPointsPlus: PrismRPGCharacterSheet.#onArmorHitPointsPlus,
armorHitPointsMinus: PrismRPGCharacterSheet.#onArmorHitPointsMinus,
manaPointsPlus: PrismRPGCharacterSheet.#onManaPointsPlus,
manaPointsMinus: PrismRPGCharacterSheet.#onManaPointsMinus,
hpPlus: PrismRPGCharacterSheet.#onHpPlus,
hpMinus: PrismRPGCharacterSheet.#onHpMinus,
},
}
@@ -166,6 +170,30 @@ export default class PrismRPGCharacterSheet extends PrismRPGActorSheet {
this.actor.update({ "system.combat.armorHitPoints": Math.max(armorHP, 0) })
}
static #onManaPointsPlus(event, target) {
let mana = this.actor.system.manaPoints.value
mana += 1
this.actor.update({ "system.manaPoints.value": Math.min(mana, this.actor.system.manaPoints.max) })
}
static #onManaPointsMinus(event, target) {
let mana = this.actor.system.manaPoints.value
mana -= 1
this.actor.update({ "system.manaPoints.value": Math.max(mana, 0) })
}
static #onHpPlus(event, target) {
let hp = this.actor.system.hp.value
hp += 1
this.actor.update({ "system.hp.value": Math.min(hp, this.actor.system.hp.max) })
}
static #onHpMinus(event, target) {
let hp = this.actor.system.hp.value
hp -= 1
this.actor.update({ "system.hp.value": Math.max(hp, 0) })
}
static #onCreateEquipment(event, target) {
}
+75 -75
View File
@@ -9,7 +9,7 @@ export const TABLES = {
"damage": -7,
"attack": -4,
"challenge": -9,
"aether_points": -20,
"mana_points": -20,
"hp": -3,
"encumbered": 1,
"lift": 3,
@@ -20,7 +20,7 @@ export const TABLES = {
"damage": -6,
"attack": -4,
"challenge": -8,
"aether_points": -20,
"mana_points": -20,
"hp": -2,
"encumbered": 1,
"lift": 4,
@@ -31,7 +31,7 @@ export const TABLES = {
"damage": -5,
"attack": -3,
"challenge": -7,
"aether_points": -20,
"mana_points": -20,
"hp": -1,
"encumbered": 1,
"lift": 5,
@@ -42,7 +42,7 @@ export const TABLES = {
"damage": -4,
"attack": -3,
"challenge": -6,
"aether_points": -20,
"mana_points": -20,
"hp": -1,
"encumbered": 2,
"lift": 6,
@@ -53,7 +53,7 @@ export const TABLES = {
"damage": -3,
"attack": -2,
"challenge": -5,
"aether_points": -20,
"mana_points": -20,
"hp": 0,
"encumbered": 2,
"lift": 7,
@@ -64,7 +64,7 @@ export const TABLES = {
"damage": -2,
"attack": -1,
"challenge": -4,
"aether_points": -10,
"mana_points": -10,
"hp": 0,
"encumbered": 3,
"lift": 8,
@@ -75,7 +75,7 @@ export const TABLES = {
"damage": -2,
"attack": 0,
"challenge": -3,
"aether_points": -10,
"mana_points": -10,
"hp": 0,
"encumbered": 3,
"lift": 9,
@@ -86,7 +86,7 @@ export const TABLES = {
"damage": -1,
"attack": 0,
"challenge": -2,
"aether_points": 0,
"mana_points": 0,
"hp": 0,
"encumbered": 4,
"lift": 11,
@@ -97,7 +97,7 @@ export const TABLES = {
"damage": -1,
"attack": 0,
"challenge": -1,
"aether_points": 0,
"mana_points": 0,
"hp": 0,
"encumbered": 5,
"lift": 12,
@@ -108,7 +108,7 @@ export const TABLES = {
"damage": 0,
"attack": 0,
"challenge": 0,
"aether_points": 0,
"mana_points": 0,
"hp": 0,
"encumbered": 6,
"lift": 13,
@@ -119,7 +119,7 @@ export const TABLES = {
"damage": 0,
"attack": 0,
"challenge": 0,
"aether_points": 0,
"mana_points": 0,
"hp": 0,
"encumbered": 7,
"lift": 15,
@@ -130,7 +130,7 @@ export const TABLES = {
"damage": 1,
"attack": 0,
"challenge": 1,
"aether_points": 0,
"mana_points": 0,
"hp": 0,
"encumbered": 8,
"lift": 17,
@@ -141,7 +141,7 @@ export const TABLES = {
"damage": 1,
"attack": 0,
"challenge": 2,
"aether_points": 0,
"mana_points": 0,
"hp": 0,
"encumbered": 9,
"lift": 20,
@@ -152,7 +152,7 @@ export const TABLES = {
"damage": 2,
"attack": 1,
"challenge": 3,
"aether_points": 0,
"mana_points": 0,
"hp": 1,
"encumbered": 10,
"lift": 22,
@@ -163,7 +163,7 @@ export const TABLES = {
"damage": 3,
"attack": 1,
"challenge": 4,
"aether_points": 0,
"mana_points": 0,
"hp": 2,
"encumbered": 11,
"lift": 24,
@@ -174,7 +174,7 @@ export const TABLES = {
"damage": 4,
"attack": 2,
"challenge": 5,
"aether_points": 0,
"mana_points": 0,
"hp": 3,
"encumbered": 12,
"lift": 26,
@@ -185,7 +185,7 @@ export const TABLES = {
"damage": 5,
"attack": 2,
"challenge": 6,
"aether_points": 10,
"mana_points": 10,
"hp": 4,
"encumbered": 13,
"lift": 28,
@@ -196,7 +196,7 @@ export const TABLES = {
"damage": 6,
"attack": 3,
"challenge": 7,
"aether_points": 20,
"mana_points": 20,
"hp": 5,
"encumbered": 14,
"lift": 30,
@@ -207,7 +207,7 @@ export const TABLES = {
"damage": 7,
"attack": 3,
"challenge": 8,
"aether_points": 20,
"mana_points": 20,
"hp": 6,
"encumbered": 15,
"lift": 31,
@@ -218,7 +218,7 @@ export const TABLES = {
"damage": 8,
"attack": 4,
"challenge": 9,
"aether_points": 30,
"mana_points": 30,
"hp": 7,
"encumbered": 15,
"lift": 32,
@@ -229,7 +229,7 @@ export const TABLES = {
"damage": 9,
"attack": 4,
"challenge": 10,
"aether_points": 30,
"mana_points": 30,
"hp": 8,
"encumbered": 16,
"lift": 33,
@@ -240,7 +240,7 @@ export const TABLES = {
"damage": 10,
"attack": 5,
"challenge": 11,
"aether_points": 40,
"mana_points": 40,
"hp": 9,
"encumbered": 16,
"lift": 34,
@@ -251,7 +251,7 @@ export const TABLES = {
"damage": 12,
"attack": 5,
"challenge": 12,
"aether_points": 40,
"mana_points": 40,
"hp": 10,
"encumbered": 17,
"lift": 35,
@@ -262,7 +262,7 @@ export const TABLES = {
"damage": 14,
"attack": 5,
"challenge": 13,
"aether_points": 50,
"mana_points": 50,
"hp": 11,
"encumbered": 18,
"lift": 36,
@@ -273,7 +273,7 @@ export const TABLES = {
"damage": 16,
"attack": 6,
"challenge": 14,
"aether_points": 60,
"mana_points": 60,
"hp": 12,
"encumbered": 19,
"lift": 38,
@@ -286,7 +286,7 @@ export const TABLES = {
"attack": -5,
"defense": -3,
"development_points": 0,
"aether": -50,
"mana": -50,
"spell_cognition": 0,
"arkane_casting_mod": -4
},
@@ -295,7 +295,7 @@ export const TABLES = {
"attack": -4,
"defense": -3,
"development_points": 0,
"aether": -50,
"mana": -50,
"spell_cognition": 0,
"arkane_casting_mod": -4
},
@@ -304,7 +304,7 @@ export const TABLES = {
"attack": -3,
"defense": -3,
"development_points": 0,
"aether": -50,
"mana": -50,
"spell_cognition": 0.01,
"arkane_casting_mod": -3
},
@@ -313,7 +313,7 @@ export const TABLES = {
"attack": -2,
"defense": -2,
"development_points": 0,
"aether": -45,
"mana": -45,
"spell_cognition": 0.05,
"arkane_casting_mod": -3
},
@@ -322,7 +322,7 @@ export const TABLES = {
"attack": -2,
"defense": -2,
"development_points": 0,
"aether": -45,
"mana": -45,
"spell_cognition": 0.1,
"arkane_casting_mod": -2
},
@@ -331,7 +331,7 @@ export const TABLES = {
"attack": -2,
"defense": -2,
"development_points": 0,
"aether": -40,
"mana": -40,
"spell_cognition": 0.15,
"arkane_casting_mod": -2
},
@@ -340,7 +340,7 @@ export const TABLES = {
"attack": -1,
"defense": -1,
"development_points": 0,
"aether": -40,
"mana": -40,
"spell_cognition": 0.2,
"arkane_casting_mod": -1
},
@@ -349,7 +349,7 @@ export const TABLES = {
"attack": -1,
"defense": 0,
"development_points": 0,
"aether": -30,
"mana": -30,
"spell_cognition": 0.25,
"arkane_casting_mod": -1
},
@@ -358,7 +358,7 @@ export const TABLES = {
"attack": -1,
"defense": 0,
"development_points": 0,
"aether": -30,
"mana": -30,
"spell_cognition": 0.3,
"arkane_casting_mod": 0
},
@@ -367,7 +367,7 @@ export const TABLES = {
"attack": 0,
"defense": 0,
"development_points": 0,
"aether": -20,
"mana": -20,
"spell_cognition": 0.35,
"arkane_casting_mod": 0
},
@@ -376,7 +376,7 @@ export const TABLES = {
"attack": 0,
"defense": 0,
"development_points": 1,
"aether": -10,
"mana": -10,
"spell_cognition": 0.45,
"arkane_casting_mod": 0
},
@@ -385,7 +385,7 @@ export const TABLES = {
"attack": 1,
"defense": 0,
"development_points": 2,
"aether": 0,
"mana": 0,
"spell_cognition": 0.5,
"arkane_casting_mod": 1
},
@@ -394,7 +394,7 @@ export const TABLES = {
"attack": 1,
"defense": 0,
"development_points": 3,
"aether": 0,
"mana": 0,
"spell_cognition": 0.6,
"arkane_casting_mod": 1
},
@@ -403,7 +403,7 @@ export const TABLES = {
"attack": 1,
"defense": 1,
"development_points": 4,
"aether": 10,
"mana": 10,
"spell_cognition": 0.65,
"arkane_casting_mod": 2
},
@@ -412,7 +412,7 @@ export const TABLES = {
"attack": 2,
"defense": 1,
"development_points": 5,
"aether": 20,
"mana": 20,
"spell_cognition": 0.75,
"arkane_casting_mod": 2
},
@@ -421,7 +421,7 @@ export const TABLES = {
"attack": 2,
"defense": 1,
"development_points": 7,
"aether": 30,
"mana": 30,
"spell_cognition": 0.8,
"arkane_casting_mod": 3
},
@@ -430,7 +430,7 @@ export const TABLES = {
"attack": 2,
"defense": 1,
"development_points": 9,
"aether": 40,
"mana": 40,
"spell_cognition": 0.85,
"arkane_casting_mod": 3
},
@@ -439,7 +439,7 @@ export const TABLES = {
"attack": 3,
"defense": 2,
"development_points": 11,
"aether": 50,
"mana": 50,
"spell_cognition": 0.9,
"arkane_casting_mod": 4
},
@@ -448,7 +448,7 @@ export const TABLES = {
"attack": 3,
"defense": 2,
"development_points": 13,
"aether": 60,
"mana": 60,
"spell_cognition": 0.92,
"arkane_casting_mod": 5
},
@@ -457,7 +457,7 @@ export const TABLES = {
"attack": 3,
"defense": 2,
"development_points": 15,
"aether": 70,
"mana": 70,
"spell_cognition": 0.94,
"arkane_casting_mod": 6
},
@@ -466,7 +466,7 @@ export const TABLES = {
"attack": 4,
"defense": 2,
"development_points": 18,
"aether": 80,
"mana": 80,
"spell_cognition": 0.95,
"arkane_casting_mod": 7
},
@@ -475,7 +475,7 @@ export const TABLES = {
"attack": 4,
"defense": 3,
"development_points": 21,
"aether": 90,
"mana": 90,
"spell_cognition": 0.96,
"arkane_casting_mod": 7
},
@@ -484,7 +484,7 @@ export const TABLES = {
"attack": 4,
"defense": 3,
"development_points": 24,
"aether": 100,
"mana": 100,
"spell_cognition": 0.97,
"arkane_casting_mod": 8
},
@@ -493,7 +493,7 @@ export const TABLES = {
"attack": 5,
"defense": 3,
"development_points": 27,
"aether": 110,
"mana": 110,
"spell_cognition": 0.98,
"arkane_casting_mod": 8
},
@@ -502,7 +502,7 @@ export const TABLES = {
"attack": 5,
"defense": 4,
"development_points": 30,
"aether": 125,
"mana": 125,
"spell_cognition": 0.99,
"arkane_casting_mod": 9
}
@@ -688,7 +688,7 @@ export const TABLES = {
{
"value": 1,
"hp ": 1,
"aether_points": -50,
"mana_points": -50,
"pain_save": 1,
"toughness_save": -5,
"stabilization_dice": "D6",
@@ -698,7 +698,7 @@ export const TABLES = {
"value": 2,
"hp ": 2,
"aether_points": -40,
"mana_points": -40,
"pain_save": 2,
"toughness_saave": -4,
"stabilization_dice": "D6",
@@ -708,7 +708,7 @@ export const TABLES = {
"value": 3,
"hp ": 3,
"aether_points": -35,
"mana_points": -35,
"pain_save": 2,
"toughness_save": -3,
"stabilization_dice": "D6",
@@ -718,7 +718,7 @@ export const TABLES = {
"value": 4,
"hp ": 4,
"aether_points": -30,
"mana_points": -30,
"pain_save": 2,
"toughness_save": -3,
"stabilization_dice": "D6",
@@ -728,7 +728,7 @@ export const TABLES = {
"value": 5,
"hp ": 5,
"aether_points": -25,
"mana_points": -25,
"pain_save": 3,
"toughness_save": -2,
"stabilization_dice": "D6",
@@ -737,7 +737,7 @@ export const TABLES = {
{
"value": 6,
"hp ": 6,
"aether_points": -20,
"mana_points": -20,
"pain_save": 3,
"toughness_save": -2,
"stabilization_dice": "D6",
@@ -746,7 +746,7 @@ export const TABLES = {
{
"value": 7,
"hp ": 7,
"aether_points": -15,
"mana_points": -15,
"pain_save": 3,
"toughness_save": -1,
"stabilization_dice": "D6",
@@ -756,7 +756,7 @@ export const TABLES = {
"value": 8,
"hp ": 8,
"aether_points": -10,
"mana_points": -10,
"pain_save": 4,
"toughness_save": -1,
"stabilization_dice": "D8",
@@ -766,7 +766,7 @@ export const TABLES = {
"value": 9,
"hp ": 9,
"aether_points": -5,
"mana_points": -5,
"pain_save": 4,
"toughness_save": 0,
"stabilization_dice": "D8",
@@ -776,7 +776,7 @@ export const TABLES = {
"value": 10,
"hp ": 10,
"aether_points": 0,
"mana_points": 0,
"pain_save": 5,
"toughness_save": 0,
"stabilization_dice": "D8",
@@ -786,7 +786,7 @@ export const TABLES = {
"value": 11,
"hp ": 11,
"aether_points": 0,
"mana_points": 0,
"pain_save": 5,
"toughness_save": 0,
"stabilization_dice": "D8",
@@ -796,7 +796,7 @@ export const TABLES = {
"value": 12,
"hp ": 12,
"aether_points": 5,
"mana_points": 5,
"pain_save": 6,
"toughness_save": 0,
"stabilization_dice": "D10",
@@ -806,7 +806,7 @@ export const TABLES = {
"value": 13,
"hp ": 13,
"aether_points": 10,
"mana_points": 10,
"pain_save": 7,
"toughness_save": 1,
"stabilization_dice": "D10",
@@ -816,7 +816,7 @@ export const TABLES = {
"value": 14,
"hp ": 14,
"aether_points": 20,
"mana_points": 20,
"pain_save": 7,
"toughness_save": 2,
"stabilization_dice": "D10",
@@ -826,7 +826,7 @@ export const TABLES = {
"value": 15,
"hp ": 15,
"aether_points": 30,
"mana_points": 30,
"pain_save": 8,
"toughness_save": 3,
"stabilization_dice": "D12",
@@ -836,7 +836,7 @@ export const TABLES = {
"value": 16,
"hp ": 16,
"aether_points": 40,
"mana_points": 40,
"pain_save": 8,
"toughness_save": 4,
"stabilization_dice": "D12",
@@ -846,7 +846,7 @@ export const TABLES = {
"value": 17,
"hp ": 17,
"aether_points": 50,
"mana_points": 50,
"pain_save": 9,
"toughness_save": 5,
"stabilization_dice": "D12",
@@ -856,7 +856,7 @@ export const TABLES = {
"value": 18,
"hp ": 18,
"aether_points": 60,
"mana_points": 60,
"pain_save": 9,
"toughness_save": 6,
"stabilization_dice": "D12",
@@ -866,7 +866,7 @@ export const TABLES = {
"value": 19,
"hp ": 19,
"aether_points": 70,
"mana_points": 70,
"pain_save": 10,
"toughness_save": 7,
"stabilization_dice": "D12",
@@ -876,7 +876,7 @@ export const TABLES = {
"value": 20,
"hp ": 20,
"aether_points": 80,
"mana_points": 80,
"pain_save": 10,
"toughness_save": 8,
"stabilization_dice": "D12",
@@ -886,7 +886,7 @@ export const TABLES = {
"value": 21,
"hp ": 21,
"aether_points": 90,
"mana_points": 90,
"pain_save": 11,
"toughness_save": 9,
"stabilization_dice": "D20",
@@ -896,7 +896,7 @@ export const TABLES = {
"value": 22,
"hp ": 22,
"aether_points": 100,
"mana_points": 100,
"pain_save": 11,
"toughness_save": 10,
"stabilization_dice": "D20",
@@ -906,7 +906,7 @@ export const TABLES = {
"value": 23,
"hp ": 23,
"aether_points": 110,
"mana_points": 110,
"pain_save": 12,
"toughness_save": 11,
"stabilization_dice": "D20",
@@ -916,7 +916,7 @@ export const TABLES = {
"value": 24,
"hp ": 24,
"aether_points": 120,
"mana_points": 120,
"pain_save": 12,
"toughness_save": 12,
"stabilization_dice": "D20",
@@ -925,7 +925,7 @@ export const TABLES = {
{
"value": 25,
"hp ": 25,
"aether_points": 130,
"mana_points": 130,
"pain_save": 13,
"toughness_save": 13,
"stabilization_dice": "D20",
+23 -23
View File
@@ -14,35 +14,35 @@ export const SYSTEM_ID = "fvtt-prism-rpg"
export const DEV_MODE = false
export const MONEY = {
tinbit: {
id: "tinbit",
abbrev: "tb",
label: "PRISMRPG.Money.Tinbits",
coppercoin: {
id: "coppercoin",
abbrev: "cc",
label: "PRISMRPG.Money.CopperCoin",
valuetb: 1
},
copper: {
id: "copper",
abbrev: "cp",
label: "PRISMRPG.Money.Coppers",
silvercoin: {
id: "silvercoin",
abbrev: "sc",
label: "PRISMRPG.Money.SilverCoin",
valuetb: 5
},
goldcoin: {
id: "goldcoin",
abbrev: "gc",
label: "PRISMRPG.Money.GoldCoin",
valuetb: 10
},
silver: {
id: "silver",
abbrev: "sp",
label: "PRISMRPG.Money.Silvers",
note: {
id: "note",
abbrev: "nt",
label: "PRISMRPG.Money.Note",
valuetb: 100
},
gold: {
id: "gold",
abbrev: "gp",
label: "PRISMRPG.Money.Golds",
steam: {
id: "steam",
abbrev: "st",
label: "PRISMRPG.Money.Steam",
valuetb: 1000
},
platinum: {
id: "platinum",
abbrev: "pp",
label: "PRISMRPG.Money.Platinums",
valuetb: 10000
}
}
@@ -156,7 +156,7 @@ export const INITIATIVE_DICE_CHOICES_PER_CLASS = {
{ "name": "Aware and know exactly where the enemy is (1D4)", "value": "1D4" }*/
],
"magicuser": [
{ "name": "Sleeping to recover Aether Points (2D20)", "value": "2D20" },
{ "name": "Sleeping to recover Mana Points (2D20)", "value": "2D20" },
{ "name": "Asleep or totally distracted (1D20)", "value": "1D20" },
{ "name": "Awake but unsuspecting (1D12)", "value": "1D12" },
{ "name": "Declared Ready on Alert (1)", "value": "1" },
+18 -39
View File
@@ -1,4 +1,6 @@
import PrismRPGUtils from "../utils.mjs"
import PrismRPGRoll from "./roll.mjs"
export default class PrismRPGActor extends Actor {
static async create(data, options) {
@@ -42,31 +44,12 @@ export default class PrismRPGActor extends Actor {
}
/* *************************************************/
// This method is no longer needed in D&D 5e style system
// Weapon proficiency is handled through character class/race features
getBestWeaponClassSkill(skills, rollType, multiplier = 1.0) {
let maxValue = 0
let goodSkill = skills[0]
for (let s of skills) {
if (rollType === "weapon-attack") {
if (s.system.weaponBonus.attack > maxValue) {
maxValue = Number(s.system.weaponBonus.attack)
goodSkill = s
}
}
if (rollType === "weapon-defense") {
if (s.system.weaponBonus.defense > maxValue) {
maxValue = Number(s.system.weaponBonus.defense)
goodSkill = s
}
}
if (rollType.includes("weapon-damage")) {
if (s.system.weaponBonus.damage > maxValue) {
maxValue = Number(s.system.weaponBonus.damage)
goodSkill = s
}
}
}
goodSkill.weaponSkillModifier = maxValue * multiplier
return goodSkill
// In D&D 5e, we don't need weapon skills with bonuses
// Just return the first skill (or could be removed entirely)
return skills[0]
}
/* *************************************************/
@@ -150,6 +133,7 @@ export default class PrismRPGActor extends Actor {
break
case "spell-attack":
case "spell-power":
case "spell-cast":
case "miracle-attack":
case "miracle-power":
rollTarget = this.items.find((i) => (i.type === "miracle" || i.type === "spell") && i.id === rollKey)
@@ -164,8 +148,7 @@ export default class PrismRPGActor extends Actor {
break;
case "weapon-damage-small":
case "weapon-damage-medium":
case "weapon-attack":
case "weapon-defense": {
case "weapon-attack": {
let weapon = this.items.find((i) => i.type === "weapon" && i.id === rollKey)
let skill
let skills = this.items.filter((i) => i.type === "skill" && i.name.toLowerCase() === weapon.name.toLowerCase())
@@ -195,19 +178,15 @@ export default class PrismRPGActor extends Actor {
ui.notifications.warn(game.i18n.localize("PRISMRPG.Notifications.skillNotFound"))
return
}
rollTarget = skill
rollTarget.weapon = weapon
rollTarget.weaponSkillModifier = skill.weaponSkillModifier
rollTarget.rollKey = rollKey
rollTarget.combat = foundry.utils.duplicate(this.system.combat)
if (rollType === "weapon-damage-small" || rollType === "weapon-damage-medium") {
rollTarget.grantedDice = this.system.granted.damageDice
}
if (rollType === "weapon-attack") {
rollTarget.grantedDice = this.system.granted.attackDice
}
if (rollType === "weapon-defense") {
rollTarget.grantedDice = this.system.granted.defenseDice
// Create a plain object for rollTarget to ensure weapon data is preserved
rollTarget = {
...skill.toObject(),
weapon: weapon.toObject(),
rollKey: rollKey,
combat: foundry.utils.duplicate(this.system.combat),
strMod: PrismRPGRoll.getAbilityModifier(this.system.characteristics.str.value),
dexMod: PrismRPGRoll.getAbilityModifier(this.system.characteristics.dex.value)
}
}
break
+162 -27
View File
@@ -136,30 +136,40 @@ export default class PrismRPGRoll extends Roll {
case "weapon-attack":
options.rollName = options.rollTarget.name
// Default to STR for melee, DEX for ranged (will be updated by dialog choice)
if (options.rollTarget.weapon.system.weaponType === "melee") {
options.rollTarget.value = options.rollTarget.combat.attackModifier +
options.rollTarget.weaponSkillModifier +
options.rollTarget.value = options.rollTarget.strMod +
options.rollTarget.weapon.system.bonuses.attackBonus
} else {
options.rollTarget.value = options.rollTarget.combat.rangedAttackModifier +
options.rollTarget.weaponSkillModifier +
options.rollTarget.value = options.rollTarget.dexMod +
options.rollTarget.weapon.system.bonuses.attackBonus
}
break
case "weapon-defense":
options.rollName = options.rollTarget.name
options.rollTarget.value = options.rollTarget.combat.defenseModifier +
options.rollTarget.weaponSkillModifier +
options.rollTarget.weapon.system.bonuses.defenseBonus
break
case "spell":
case "spell-attack":
case "spell-power":
case "spell-cast":
options.rollName = options.rollTarget.name
options.rollTarget.value = options.rollTarget.actorModifiers.levelSpellModifier +
options.rollTarget.actorModifiers.intSpellModifier
// Find best mental characteristic (INT, WIS, CHA)
const actor = game.actors.get(options.actorId)
const intMod = this.getAbilityModifier(actor.system.characteristics.int.value)
const wisMod = this.getAbilityModifier(actor.system.characteristics.wis.value)
const chaMod = this.getAbilityModifier(actor.system.characteristics.cha.value)
const bestMentalMod = Math.max(intMod, wisMod, chaMod)
options.rollTarget.value = bestMentalMod
// Store which characteristic is being used
if (bestMentalMod === intMod) {
options.rollTarget.mentalCharacteristic = "INT"
options.rollTarget.mentalCharValue = actor.system.characteristics.int.value
} else if (bestMentalMod === wisMod) {
options.rollTarget.mentalCharacteristic = "WIS"
options.rollTarget.mentalCharValue = actor.system.characteristics.wis.value
} else {
options.rollTarget.mentalCharacteristic = "CHA"
options.rollTarget.mentalCharValue = actor.system.characteristics.cha.value
}
break
case "miracle":
@@ -188,17 +198,18 @@ export default class PrismRPGRoll extends Roll {
if (options.rollType.includes("weapon-damage")) {
isDamageRoll = true
hasAdvantage = false
options.rollName = options.rollTarget.name
let damageBonus = options.rollTarget.combat.damageModifier
options.rollTarget.value = damageBonus +
options.rollTarget.weaponSkillModifier +
options.rollTarget.weapon.system.bonuses.damageBonus
if (options.rollType.includes("small")) {
dice = options.rollTarget.weapon.system.damage.damageS
options.rollName = options.rollTarget.weapon.name
// Default to STR for melee, DEX for ranged (will be updated by dialog choice)
if (options.rollTarget.weapon.system.weaponType === "melee") {
options.rollTarget.value = options.rollTarget.strMod +
options.rollTarget.weapon.system.bonuses.damageBonus
} else {
dice = options.rollTarget.weapon.system.damage.damageM
options.rollTarget.value = options.rollTarget.dexMod +
options.rollTarget.weapon.system.bonuses.damageBonus
}
// Use the weapon's damage dice
dice = options.rollTarget.weapon.system.damage || "1d6"
dice = dice.replace(/E/gi, "")
} else if (options.rollType.includes("monster-damage")) {
isDamageRoll = true
@@ -218,6 +229,44 @@ export default class PrismRPGRoll extends Roll {
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes)
const choiceModifier = SYSTEM.CHOICE_MODIFIERS
const choiceAdvantage = SYSTEM.ADVANTAGE_CHOICES
const attackerAimChoices = SYSTEM.ATTACKER_AIM_CHOICES
// For weapon damage rolls, skip dialog and roll directly
if (options.rollType.includes("weapon-damage")) {
// Just roll the weapon's damage dice, no modifiers
const finalFormula = dice
const rollData = {
type: options.rollType,
rollType: options.rollType,
target: options.rollTarget,
rollName: options.rollName,
actorId: options.actorId,
actorName: options.actorName,
actorImage: options.actorImage,
rollMode: "publicroll",
hasTarget: options.hasTarget,
titleFormula: finalFormula
}
if (Hooks.call("fvtt-prism-rpg.preRoll", options, rollData) === false) return
// Execute the roll
let roll = new this(finalFormula, options.data, rollData)
await roll.evaluate()
// Store results
const duplicatedRollTarget = foundry.utils.duplicate(options.rollTarget)
roll.options.resultType = "success"
roll.options.rollTotal = roll.total
roll.options.rollTarget = duplicatedRollTarget
roll.options.titleFormula = finalFormula
roll.options.rollData = foundry.utils.duplicate(rollData)
if (Hooks.call("fvtt-prism-rpg.Roll", options, rollData, roll) === false) return
return roll
}
let dialogContext = {
rollType: options.rollType,
@@ -232,13 +281,14 @@ export default class PrismRPGRoll extends Roll {
dice,
choiceModifier,
choiceAdvantage,
attackerAimChoices,
hasTarget: options.hasTarget,
modifier: "+0",
advantage: "none"
}
const content = await foundry.applications.handlebars.renderTemplate(
"systems/fvtt-prism-rpg/templates/roll-dialog.hbs",
"systems/fvtt-prism-rpg/templates/roll-dialog-v2.hbs",
dialogContext
)
@@ -255,7 +305,13 @@ export default class PrismRPGRoll extends Roll {
callback: (event, button, dialog) => {
game.user.setFlag(SYSTEM.id, "roll-dialog-pos", foundry.utils.duplicate(dialog.position))
const output = Array.from(button.form.elements).reduce((obj, input) => {
if (input.name) obj[input.name] = input.value
if (input.name) {
if (input.type === "checkbox") {
obj[input.name] = input.checked
} else {
obj[input.name] = input.value
}
}
return obj
}, {})
return output
@@ -272,9 +328,29 @@ export default class PrismRPGRoll extends Roll {
if (hasModifier) {
let bonus = Number(options.rollTarget.value) || 0
let extraModifier = rollContext.modifier === "" ? 0 : parseInt(rollContext.modifier, 10)
// Recalculate bonus if player chose different attribute for weapon attack/damage
if (rollContext.attackAttribute && options.rollTarget.weapon) {
const chosenMod = rollContext.attackAttribute === "str" ? options.rollTarget.strMod : options.rollTarget.dexMod
const weaponBonus = options.rollTarget.weapon.system.bonuses.attackBonus || 0
const damageBonus = options.rollTarget.weapon.system.bonuses.damageBonus || 0
if (options.rollType === "weapon-attack") {
bonus = chosenMod + weaponBonus
} else if (options.rollType.includes("weapon-damage")) {
bonus = chosenMod + damageBonus
}
}
let extraModifier = rollContext.modifier === "" ? 0 : Number.parseInt(rollContext.modifier, 10)
totalModifier = bonus + extraModifier
// Apply aiming modifier for ranged attacks
if (rollContext.attackerAim && rollContext.attackerAim !== "0") {
const aimModifier = Number.parseInt(rollContext.attackerAim, 10)
totalModifier += aimModifier
}
if (totalModifier !== 0) {
finalFormula = totalModifier > 0 ?
`${dice} + ${totalModifier}` :
@@ -289,6 +365,35 @@ export default class PrismRPGRoll extends Roll {
finalFormula = finalFormula.replace(dice, `2${dice}kl`)
}
// Special ranged weapon modifiers
if (rollContext.letItFly) {
// Let it Fly: Pure D20E (replace with 1d20 if it was modified)
finalFormula = finalFormula.replace(/2d20k[hl]/, "1d20")
}
if (rollContext.pointBlank) {
// Point Blank: Add special advantage or bonus (implement based on your rules)
// This could add advantage or a flat bonus
}
// Handle spell upcast
let upcastLevel = 0
let totalManaCost = 0
let totalAPC = 0
let manaUpkeep = 0
let mentalCharacteristic = null
let mentalCharValue = null
if (options.rollType === "spell-cast") {
upcastLevel = rollContext.upcastLevel ? Number.parseInt(rollContext.upcastLevel, 10) : 0
totalManaCost = options.rollTarget.system.manaCost + upcastLevel
totalAPC = options.rollTarget.system.apc + upcastLevel
manaUpkeep = options.rollTarget.system.manaUpkeep
// Get mental characteristic info from rollTarget
mentalCharacteristic = options.rollTarget.mentalCharacteristic
mentalCharValue = options.rollTarget.mentalCharValue
}
const rollData = {
type: options.rollType,
rollType: options.rollType,
@@ -300,19 +405,49 @@ export default class PrismRPGRoll extends Roll {
rollMode: rollContext.visibility,
hasTarget: options.hasTarget,
titleFormula: finalFormula,
upcastLevel,
totalManaCost,
totalAPC,
manaUpkeep,
mentalCharacteristic,
mentalCharValue,
...rollContext,
}
if (Hooks.call("fvtt-prism-rpg.preRoll", options, rollData) === false) return
// Handle mana spending for spell-cast
if (options.rollType === "spell-cast" && totalManaCost > 0) {
const actor = game.actors.get(options.actorId)
const currentMana = actor.system.manaPoints.value
// Check if enough mana
if (currentMana < totalManaCost) {
ui.notifications.error(
`Not enough Mana! Need ${totalManaCost}, but only have ${currentMana} Mana points.`
)
return null
}
// Spend mana
await actor.update({
"system.manaPoints.value": currentMana - totalManaCost
})
ui.notifications.info(
`Spent ${totalManaCost} Mana (${currentMana}${currentMana - totalManaCost})`
)
}
// Execute the roll
let roll = new this(finalFormula, options.data, rollData)
await roll.evaluate()
// Store results
// Store results - duplicate rollTarget to properly serialize weapon Item
const duplicatedRollTarget = foundry.utils.duplicate(options.rollTarget)
roll.options.resultType = "success"
roll.options.rollTotal = roll.total
roll.options.rollTarget = options.rollTarget
roll.options.rollTarget = duplicatedRollTarget
roll.options.titleFormula = finalFormula
roll.options.rollData = foundry.utils.duplicate(rollData)
+1 -1
View File
@@ -24,7 +24,7 @@ export default class PrismRPGArmor extends foundry.abstract.TypeDataModel {
schema.isHelmet = new fields.BooleanField({ required: true, initial: false })
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
schema.money = new fields.StringField({ required: true, initial: "coppercoin", choices: SYSTEM.MONEY })
return schema
}
+1 -14
View File
@@ -84,11 +84,6 @@ export default class PrismRPGCharacter extends foundry.abstract.TypeDataModel {
temp: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.magicPoints = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.armorPoints = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
@@ -110,15 +105,7 @@ export default class PrismRPGCharacter extends foundry.abstract.TypeDataModel {
total: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
remaining: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.spellMiraclePoints = new fields.SchemaField({
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({
schema.manaPoints = new fields.SchemaField({
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
+27 -2
View File
@@ -7,11 +7,11 @@ export default class PrismRPGEquipment extends foundry.abstract.TypeDataModel {
const requiredInteger = { required: true, nullable: false, integer: true }
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.category = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.EQUIPMENT_CATEGORIES })
schema.category = new fields.StringField({ required: true, initial: "coppercoin", choices: SYSTEM.EQUIPMENT_CATEGORIES })
schema.encLoad = new fields.NumberField({ required: true, initial: 0, min: 0 })
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
schema.money = new fields.StringField({ required: true, initial: "coppercoin", choices: SYSTEM.MONEY })
// Kit properties
schema.isKit = new fields.BooleanField({
@@ -54,4 +54,29 @@ export default class PrismRPGEquipment extends foundry.abstract.TypeDataModel {
/** @override */
static LOCALIZATION_PREFIXES = ["PRISMRPG.Equipment"]
static migrateData(data) {
// Migrate old money types to new ones
if (data?.money) {
const moneyMigration = {
"tinbit": "coppercoin",
"copper": "coppercoin",
"silver": "silvercoin",
"gold": "goldcoin",
"platinum": "note"
}
if (moneyMigration[data.money]) {
data.money = moneyMigration[data.money]
}
// If still invalid, default to coppercoin
if (!SYSTEM.MONEY[data.money]) {
console.warn(`Prism RPG | Migrate equipment: Invalid money type "${data.money}", defaulting to coppercoin`)
data.money = "coppercoin"
}
}
return super.migrateData(data)
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ export default class PrismRPGShield extends foundry.abstract.TypeDataModel {
// Equipment properties
schema.encLoad = new fields.NumberField({ required: true, initial: 0, min: 0 })
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
schema.money = new fields.StringField({ required: true, initial: "coppercoin", choices: SYSTEM.MONEY })
schema.equipped = new fields.BooleanField({ required: true, initial: false })
return schema
+10 -9
View File
@@ -96,16 +96,17 @@ export default class PrismRPGWeapon extends foundry.abstract.TypeDataModel {
initial: ""
})
// Projectile-specific properties
schema.isProjectile = new fields.BooleanField({
required: true,
initial: false
// Range properties
schema.shortRange = new fields.NumberField({
...requiredInteger,
initial: 0,
min: 0
})
schema.range = new fields.SchemaField({
short: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
medium: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
long: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.longRange = new fields.NumberField({
...requiredInteger,
initial: 0,
min: 0
})
schema.reloadAPC = new fields.NumberField({
@@ -123,7 +124,7 @@ export default class PrismRPGWeapon extends foundry.abstract.TypeDataModel {
schema.encLoad = new fields.NumberField({ required: true, initial: 0, min: 0 })
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
schema.money = new fields.StringField({ required: true, initial: "coppercoin", choices: SYSTEM.MONEY })
schema.equipped = new fields.BooleanField({ required: true, initial: false })
schema.isImplement = new fields.BooleanField({ required: true, initial: false })