1 Commits

Author SHA1 Message Date
uberwald 65dfb3ddff Add effects and tabs 2025-12-13 21:13:26 +01:00
13 changed files with 1146 additions and 27 deletions
+122
View File
@@ -0,0 +1,122 @@
# Configuration des Types d'Armes - PRISM RPG
## Aperçu
Ce système permet de configurer et d'ajouter des types d'armes et des groupes d'armes personnalisés via les Settings de Foundry VTT.
## Fichiers Créés
### 1. `/module/settings.mjs`
- Enregistre les settings pour les types d'armes personnalisés
- Enregistre les settings pour les groupes d'armes personnalisés
- Crée le menu de configuration dans les Settings
### 2. `/module/applications/weapon-types-config.mjs`
- Application FormApplication pour éditer les types et groupes d'armes
- Interface avec onglets (Types d'Armes / Groupes d'Armes)
- Fonctionnalités d'ajout, édition et suppression
- Bouton de réinitialisation aux valeurs par défaut
### 3. `/templates/weapon-types-config.hbs`
- Template Handlebars pour l'interface de configuration
- Affichage en onglets
- Formulaires pour chaque type/groupe d'arme
### 4. `/styles/weapon-types-config.less`
- Styles CSS pour l'interface de configuration
- Design cohérent avec le système PRISM RPG
## Fichiers Modifiés
### 1. `/module/config/weapon.mjs`
- Conversion des constantes `TYPE` et `WEAPON_GROUP` en Proxies dynamiques
- Ajout de fonctions `getWeaponTypes()` et `getWeaponGroups()`
- Les types/groupes sont maintenant chargés depuis les settings
- Rétrocompatibilité maintenue
### 2. `/module/models/weapon.mjs`
- Import des fonctions `getWeaponTypeChoices()` et `getWeaponGroupChoices()`
- Utilisation de fonctions dynamiques au lieu de constantes statiques
- Les choix sont mis à jour automatiquement depuis les settings
### 3. `/prism-rpg.mjs`
- Import du module `settings.mjs`
- Appel de `registerSettings()` dans le hook `init`
### 4. `/module/applications/_module.mjs`
- Export de `WeaponTypesConfig`
### 5. `/module/utils.mjs`
- Ajout du template `weapon-types-config.hbs` dans les templates préchargés
### 6. `/styles/fvtt-prism-rpg.less`
- Import du fichier `weapon-types-config.less`
### 7. `/lang/en.json`
- Ajout de toutes les clés de traduction pour les settings
- Section `Settings` avec toutes les chaînes nécessaires
## Utilisation
### Pour les Game Masters
1. Ouvrir les **Settings** de Foundry VTT
2. Aller dans **Game Settings**
3. Chercher **Configure Weapons** dans la section PRISM RPG
4. Cliquer sur le bouton pour ouvrir l'interface de configuration
### Interface de Configuration
#### Onglet "Weapon Types"
- **ID**: Identifiant unique (non modifiable pour les types par défaut)
- **Label**: Nom affiché du type d'arme
- **APC**: Coût en points d'action
- **Hands**: Nombre de mains requises (0, 1, ou 2)
#### Onglet "Weapon Groups"
- **ID**: Identifiant unique (non modifiable pour les groupes par défaut)
- **Label**: Nom affiché du groupe
- **Passive ID**: Identifiant de la passive
- **Passive Label**: Nom de la passive
- **Passive Description**: Description de l'effet de la passive
### Ajout d'un Type/Groupe d'Arme
1. Cliquer sur le bouton **+** dans l'onglet approprié
2. Un nouvel ID unique sera généré automatiquement
3. Remplir les champs
4. Cliquer sur **Save Changes**
### Suppression d'un Type/Groupe d'Arme
1. Cliquer sur l'icône **poubelle** à côté du type/groupe
2. L'entrée sera supprimée
3. Cliquer sur **Save Changes**
### Réinitialisation
Le bouton **Reset to Defaults** permet de revenir aux valeurs par défaut du système.
## Types d'Armes par Défaut
- **Light** (Légère) - 1 APC, 1 main
- **One-Handed** (Une main) - 2 APC, 1 main
- **Heavy** (Lourde) - 3 APC, 2 mains
- **Projectile** - Variable APC, 2 mains
## Groupes d'Armes par Défaut
1. **Longsword** - Passive: Turning Edge
2. **Warhammer** - Passive: Puncturing Blows
3. **Battleaxe** - Passive: Shield Eater
4. **Dagger** - Passive: Balancing Stance
5. **Crossbow** - Passive: Boltlock
6. **Longbow** - Passive: Volley Fire
## Remarques Techniques
- Les modifications sont sauvegardées au niveau du **monde** (scope: world)
- Un rechargement de la page est déclenché après sauvegarde
- Les valeurs par défaut restent toujours disponibles
- Les types/groupes personnalisés sont fusionnés avec les valeurs par défaut
- Utilisation de Proxies JavaScript pour une compatibilité maximale
+132
View File
@@ -81,6 +81,9 @@ i.prismrpg {
.initiative-minus {
margin-right: 8px;
}
.prismrpg {
/* Weapon Types Configuration Dialog */
}
.prismrpg .character-sheet-common label {
font-family: var(--font-secondary);
font-size: calc(var(--font-size-standard) * 1.2);
@@ -2859,6 +2862,135 @@ i.prismrpg {
align-items: center;
gap: 0.5rem;
}
.prismrpg .weapon-types-config {
padding: 0;
}
.prismrpg .weapon-types-config .sheet-tabs {
margin: 0;
border-bottom: 2px solid #444;
}
.prismrpg .weapon-types-config .content {
padding: 0.5rem;
max-height: 60vh;
overflow-y: auto;
}
.prismrpg .weapon-types-config .section-header {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 1em;
font-weight: bold;
margin-bottom: 0.5rem;
padding-bottom: 0.25rem;
border-bottom: 1px solid #666;
}
.prismrpg .weapon-types-config .weapon-type-entry,
.prismrpg .weapon-types-config .weapon-group-entry {
background: rgba(0, 0, 0, 0.3);
padding: 0.75rem;
margin-bottom: 0.75rem;
border-radius: 4px;
border: 1px solid #555;
display: flex;
gap: 0.75rem;
align-items: start;
}
.prismrpg .weapon-types-config .weapon-type-entry .form-fields {
display: grid;
grid-template-columns: 100px 3fr 70px 70px;
gap: 0.75rem;
flex: 1;
align-items: center;
}
.prismrpg .weapon-types-config .weapon-group-entry .form-fields {
display: grid;
grid-template-columns: 120px 2fr 120px 150px 3fr;
gap: 0.75rem;
flex: 1;
align-items: center;
}
.prismrpg .weapon-types-config .form-group {
display: flex;
flex-direction: column;
gap: 0.15rem;
}
.prismrpg .weapon-types-config .form-group label {
font-size: 0.75em;
color: #fff;
font-weight: bold;
white-space: nowrap;
text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}
.prismrpg .weapon-types-config input[type="text"],
.prismrpg .weapon-types-config input[type="number"],
.prismrpg .weapon-types-config textarea {
background: rgba(0, 0, 0, 0.5);
border: 1px solid #666;
color: #fff;
padding: 0.2rem 0.4rem;
border-radius: 3px;
font-size: 0.9em;
}
.prismrpg .weapon-types-config input[readonly] {
background: rgba(0, 0, 0, 0.7);
color: #999;
cursor: not-allowed;
font-size: 0.8em;
}
.prismrpg .weapon-types-config textarea {
resize: vertical;
min-height: 40px;
font-size: 0.85em;
}
.prismrpg .weapon-types-config button[data-action] {
background: rgba(100, 100, 100, 0.5);
border: 1px solid #666;
color: #fff;
padding: 0.2rem 0.4rem;
border-radius: 3px;
cursor: pointer;
transition: all 0.2s;
}
.prismrpg .weapon-types-config button[data-action]:hover {
background: rgba(150, 150, 150, 0.5);
border-color: #888;
}
.prismrpg .weapon-types-config button[data-action="delete-weapon-type"],
.prismrpg .weapon-types-config button[data-action="delete-weapon-group"] {
background: rgba(139, 0, 0, 0.5);
align-self: center;
padding: 0.25rem;
min-width: auto;
width: auto;
font-size: 0.9em;
flex-shrink: 0;
}
.prismrpg .weapon-types-config button[data-action="delete-weapon-type"]:hover,
.prismrpg .weapon-types-config button[data-action="delete-weapon-group"]:hover {
background: rgba(200, 0, 0, 0.7);
}
.prismrpg .weapon-types-config .sheet-footer {
display: flex;
justify-content: space-between;
padding: 1rem;
border-top: 2px solid #444;
gap: 1rem;
}
.prismrpg .weapon-types-config .sheet-footer button {
padding: 0.5rem 1rem;
font-size: 1em;
}
.prismrpg .weapon-types-config .weapon-types-list,
.prismrpg .weapon-types-config .weapon-groups-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.prismrpg .weapon-types-config .flexrow {
display: flex;
gap: 1rem;
align-items: flex-start;
}
.application.dialog.prismrpg {
color: var(--color-dark-1);
}
+101 -5
View File
@@ -682,9 +682,19 @@
"heavy": "Heavy Armor"
},
"WeaponGroup": {
"shortsword": "Shortsword",
"longsword": "Longsword",
"warhammer": "Warhammer",
"greatsword": "Greatsword",
"handaxe": "Handaxe",
"battleaxe": "Battleaxe",
"greataxe": "Greataxe",
"club": "Club",
"mace": "Mace",
"greatMaul": "Great Maul",
"javelin": "Javelin",
"spear": "Spear",
"longSpear": "Long Spear",
"warhammer": "Warhammer",
"dagger": "Dagger",
"crossbow": "Crossbow",
"longbow": "Longbow"
@@ -1032,10 +1042,10 @@
"Warning": {},
"Weapon": {
"Type": {
"light": "Light Weapon",
"oneHanded": "One-Handed Weapon",
"heavy": "Heavy Weapon",
"projectile": "Projectile Weapon"
"light": "Light",
"oneHanded": "One-Handed",
"heavy": "Heavy",
"projectile": "Projectile"
},
"Group": {
"longsword": "Longsword",
@@ -1045,6 +1055,42 @@
"crossbow": "Crossbow",
"longbow": "Longbow"
},
"Passive": {
"quickBlade": "Quick Blade",
"turningEdge": "Turning Edge",
"cleave": "Cleave",
"throwingAxe": "Throwing Axe",
"shieldEater": "Shield Eater",
"devastatingBlow": "Devastating Blow",
"stun": "Stun",
"armorBreaker": "Armor Breaker",
"earthshatter": "Earthshatter",
"piercingThrow": "Piercing Throw",
"reach": "Reach",
"extendedReach": "Extended Reach",
"puncturingBlows": "Puncturing Blows",
"balancingStance": "Balancing Stance",
"boltlock": "Boltlock",
"volleyFire": "Volley Fire"
},
"PassiveDescription": {
"quickBlade": "Your attacks with shortswords cost 1 less APC (minimum 1).",
"turningEdge": "When you successfully parry an attack, you may immediately make a free attack against the attacker.",
"cleave": "When you kill an enemy, you may make a free attack against an adjacent enemy.",
"throwingAxe": "Handaxes can be thrown with a range of 20/60 feet.",
"shieldEater": "Your attacks ignore shield bonuses to defense.",
"devastatingBlow": "Your critical hits deal maximum damage instead of rolling.",
"stun": "When you hit with a club, the target must make a CON save or be stunned until the end of their next turn.",
"armorBreaker": "Your attacks ignore 3 points of armor.",
"earthshatter": "When you hit with a great maul, all enemies within 5 feet must make a DEX save or be knocked prone.",
"piercingThrow": "Your javelin throws ignore cover and deal +2 damage.",
"reach": "Your spear attacks have 10 feet of reach.",
"extendedReach": "Your long spear attacks have 15 feet of reach.",
"puncturingBlows": "Your attacks ignore 2 points of armor.",
"balancingStance": "You gain +1 to defense when wielding a dagger.",
"boltlock": "Reloading costs 0 APC instead of the normal reload cost.",
"volleyFire": "You may attack two targets with a single attack action."
},
"DamageType": {
"piercing": "Piercing",
"bludgeoning": "Bludgeoning",
@@ -1229,6 +1275,56 @@
"label": "Class Features"
}
}
},
"Settings": {
"customWeaponTypes": {
"name": "Custom Weapon Types",
"hint": "Custom weapon types configured for this world"
},
"customWeaponGroups": {
"name": "Custom Weapon Groups",
"hint": "Custom weapon groups configured for this world"
},
"weaponTypesConfig": {
"name": "Weapon Types Configuration",
"hint": "Configure weapon types and weapon groups",
"label": "Configure Weapons",
"title": "Weapon Types & Groups Configuration"
},
"tabs": {
"weaponTypes": "Weapon Types",
"weaponGroups": "Weapon Groups"
},
"weaponTypes": {
"header": "Weapon Types"
},
"weaponType": {
"id": "ID",
"label": "Label",
"apc": "Action Point Cost",
"hands": "Hands Required"
},
"weaponGroups": {
"header": "Weapon Groups"
},
"weaponGroup": {
"id": "ID",
"label": "Label",
"passive": "Passive ID",
"passiveLabel": "Passive Label",
"passiveDescription": "Passive Description"
},
"addWeaponType": "Add Weapon Type",
"deleteWeaponType": "Delete Weapon Type",
"addWeaponGroup": "Add Weapon Group",
"deleteWeaponGroup": "Delete Weapon Group",
"resetDefaults": "Reset to Defaults",
"save": "Save Changes",
"weaponTypesSaved": "Weapon types and groups saved successfully",
"resetConfirm": {
"title": "Reset to Defaults?",
"content": "This will reset all weapon types and groups to their default values. Are you sure?"
}
}
},
"TYPES": {
+1
View File
@@ -12,3 +12,4 @@ export { default as PrismRPGMiracleSheet } from "./sheets/miracle-sheet.mjs"
export { default as PrismRPGRaceSheet } from "./sheets/race-sheet.mjs"
export { default as PrismRPGClassSheet } from "./sheets/class-sheet.mjs"
export { default as PrismRPGCharacterPathSheet } from "./sheets/character-path-sheet.mjs"
export { WeaponTypesConfig } from "./weapon-types-config.mjs"
+219
View File
@@ -0,0 +1,219 @@
/**
* Application to configure weapon types and groups
*/
import { getWeaponTypes, getWeaponGroups } from "../config/weapon.mjs"
export class WeaponTypesConfig extends FormApplication {
constructor(object, options) {
super(object, options)
// Store working copies that won't trigger settings changes
this.workingTypes = null
this.workingGroups = null
}
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
title: game.i18n.localize("PRISMRPG.Settings.weaponTypesConfig.title"),
id: "weapon-types-config",
classes: ["prismrpg", "weapon-types-config"],
template: "systems/fvtt-prism-rpg/templates/weapon-types-config.hbs",
width: 1000,
height: "auto",
closeOnSubmit: true,
submitOnChange: false,
tabs: [{ navSelector: ".tabs", contentSelector: ".content", initial: "types" }]
})
}
getData() {
const data = super.getData()
// Get default weapon types from config with proper translation keys
const defaultTypes = getWeaponTypes()
// Get default weapon groups from config with proper translation keys
const defaultGroups = getWeaponGroups()
// Initialize working copies on first render
if (!this.workingTypes) {
const customTypes = game.settings.get("fvtt-prism-rpg", "customWeaponTypes") || {}
this.workingTypes = foundry.utils.deepClone(customTypes)
}
if (!this.workingGroups) {
const customGroups = game.settings.get("fvtt-prism-rpg", "customWeaponGroups") || {}
this.workingGroups = foundry.utils.deepClone(customGroups)
}
// Merge default and working copies
data.weaponTypes = {}
const mergedTypes = foundry.utils.mergeObject(defaultTypes, this.workingTypes, { inplace: false })
console.log("Merged types in getData:", mergedTypes)
for (const [key, type] of Object.entries(mergedTypes)) {
data.weaponTypes[key] = {
...type,
// Translate label if it's a translation key
label: type.label.startsWith("PRISMRPG.") ? game.i18n.localize(type.label) : type.label,
// Mark if it's a custom type (can be deleted)
isCustom: key.startsWith("custom_")
}
}
data.weaponGroups = {}
const mergedGroups = foundry.utils.mergeObject(defaultGroups, this.workingGroups, { inplace: false })
for (const [key, group] of Object.entries(mergedGroups)) {
data.weaponGroups[key] = {
...group,
// Translate labels if they're translation keys
label: group.label.startsWith("PRISMRPG.") ? game.i18n.localize(group.label) : group.label,
passiveLabel: group.passiveLabel.startsWith("PRISMRPG.") ? game.i18n.localize(group.passiveLabel) : group.passiveLabel,
passiveDescription: group.passiveDescription.startsWith("PRISMRPG.") ? game.i18n.localize(group.passiveDescription) : group.passiveDescription,
// Mark if it's a custom group (can be deleted)
isCustom: key.startsWith("custom_")
}
}
return data
}
activateListeners(html) {
super.activateListeners(html)
// Add new weapon type
html.find('[data-action="add-weapon-type"]').click(this._onAddWeaponType.bind(this))
// Delete weapon type
html.find('[data-action="delete-weapon-type"]').click(this._onDeleteWeaponType.bind(this))
// Add new weapon group
html.find('[data-action="add-weapon-group"]').click(this._onAddWeaponGroup.bind(this))
// Delete weapon group
html.find('[data-action="delete-weapon-group"]').click(this._onDeleteWeaponGroup.bind(this))
// Reset to defaults
html.find('[data-action="reset-defaults"]').click(this._onResetDefaults.bind(this))
console.log("Listeners activated, weapon types count:", html.find('.weapon-type-entry').length)
}
async _onAddWeaponType(event) {
event.preventDefault()
const newId = `custom_${foundry.utils.randomID()}`
// Add new empty type to working copy (no settings save)
this.workingTypes[newId] = {
id: newId,
label: "New Weapon Type",
apc: 1,
hands: 1
}
// Force re-render without saving
this.render(true)
}
async _onDeleteWeaponType(event) {
event.preventDefault()
const typeId = $(event.currentTarget).data('id')
console.log("Delete weapon type clicked:", typeId)
console.log("Working types before:", this.workingTypes)
// Delete from working copy (no settings save)
delete this.workingTypes[typeId]
console.log("Working types after:", this.workingTypes)
// Save to settings immediately so it persists
await game.settings.set("fvtt-prism-rpg", "customWeaponTypes", this.workingTypes)
// Find and remove the entry from DOM immediately
this.element.find(`.weapon-type-entry[data-id="${typeId}"]`).remove()
}
async _onAddWeaponGroup(event) {
event.preventDefault()
const newId = `custom_${foundry.utils.randomID()}`
// Add new empty group to working copy (no settings save)
this.workingGroups[newId] = {
id: newId,
label: "New Weapon Group",
passive: "newPassive",
passiveLabel: "New Passive",
passiveDescription: "Description of the new passive ability."
}
// Force re-render without saving
this.render(true)
}
async _onDeleteWeaponGroup(event) {
event.preventDefault()
const groupId = $(event.currentTarget).data('id')
// Delete from working copy (no settings save)
delete this.workingGroups[groupId]
// Save to settings immediately so it persists
await game.settings.set("fvtt-prism-rpg", "customWeaponGroups", this.workingGroups)
// Find and remove the entry from DOM immediately
this.element.find(`.weapon-group-entry[data-id="${groupId}"]`).remove()
}
async _onResetDefaults(event) {
event.preventDefault()
const confirm = await Dialog.confirm({
title: game.i18n.localize("PRISMRPG.Settings.resetConfirm.title"),
content: game.i18n.localize("PRISMRPG.Settings.resetConfirm.content"),
yes: () => true,
no: () => false
})
if (confirm) {
// Reset working copies
this.workingTypes = {}
this.workingGroups = {}
this.render(true)
}
}
async _updateObject(event, formData) {
const expanded = foundry.utils.expandObject(formData)
// Extract only custom types (those with custom_ prefix)
const customTypes = {}
if (expanded.weaponTypes) {
for (const [key, type] of Object.entries(expanded.weaponTypes)) {
if (key.startsWith("custom_")) {
customTypes[key] = type
}
}
}
// Extract only custom groups (those with custom_ prefix)
const customGroups = {}
if (expanded.weaponGroups) {
for (const [key, group] of Object.entries(expanded.weaponGroups)) {
if (key.startsWith("custom_")) {
customGroups[key] = group
}
}
}
// Save custom weapon types (this will trigger page reload)
await game.settings.set("fvtt-prism-rpg", "customWeaponTypes", customTypes)
// Save custom weapon groups (this will trigger page reload)
await game.settings.set("fvtt-prism-rpg", "customWeaponGroups", customGroups)
ui.notifications.info(game.i18n.localize("PRISMRPG.Settings.weaponTypesSaved"))
}
}
+182 -20
View File
@@ -1,8 +1,8 @@
/**
* Weapon types based on Prism RPG rules
* Default weapon types based on Prism RPG rules
* APC determines weapon class: Light (1 APC), One-Handed (2 APC), Heavy (3 APC)
*/
export const TYPE = Object.freeze({
const DEFAULT_TYPES = {
light: {
id: "light",
label: "PRISMRPG.Weapon.Type.light",
@@ -27,22 +27,75 @@ export const TYPE = Object.freeze({
apc: 0, // Variable based on specific weapon
hands: 2
}
};
/**
* Get weapon types (default + custom from settings)
*/
export function getWeaponTypes() {
if (!game?.settings) return DEFAULT_TYPES;
const customTypes = game.settings.get("fvtt-prism-rpg", "customWeaponTypes") || {};
return foundry.utils.mergeObject(DEFAULT_TYPES, customTypes, { inplace: false });
}
/**
* Weapon types (dynamically loaded)
*/
export const TYPE = new Proxy({}, {
get(target, prop) {
const types = getWeaponTypes();
return types[prop];
},
ownKeys(target) {
return Object.keys(getWeaponTypes());
},
getOwnPropertyDescriptor(target, prop) {
return {
enumerable: true,
configurable: true
};
}
});
/**
* Simplified Weapon Types object for form choices (label-only format)
*/
export const TYPE_CHOICES = Object.freeze(
Object.fromEntries(
Object.entries(TYPE).map(([key, value]) => [key, value.label])
)
);
export function getWeaponTypeChoices() {
const types = getWeaponTypes();
return Object.fromEntries(
Object.entries(types).map(([key, value]) => [key, value.label])
);
}
export const TYPE_CHOICES = new Proxy({}, {
get(target, prop) {
const choices = getWeaponTypeChoices();
return choices[prop];
},
ownKeys(target) {
return Object.keys(getWeaponTypeChoices());
},
getOwnPropertyDescriptor(target, prop) {
return {
enumerable: true,
configurable: true
};
}
});
/**
* Weapon groups and their associated passives
* Default weapon groups and their associated passives
* Each weapon belongs to a group and possesses its passive while wielded
*/
export const WEAPON_GROUP = Object.freeze({
const DEFAULT_WEAPON_GROUPS = {
shortsword: {
id: "shortsword",
label: "PRISMRPG.WeaponGroup.shortsword",
passive: "quickBlade",
passiveLabel: "PRISMRPG.Weapon.Passive.quickBlade",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.quickBlade"
},
longsword: {
id: "longsword",
label: "PRISMRPG.WeaponGroup.longsword",
@@ -50,12 +103,19 @@ export const WEAPON_GROUP = Object.freeze({
passiveLabel: "PRISMRPG.Weapon.Passive.turningEdge",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.turningEdge"
},
warhammer: {
id: "warhammer",
label: "PRISMRPG.WeaponGroup.warhammer",
passive: "puncturingBlows",
passiveLabel: "PRISMRPG.Weapon.Passive.puncturingBlows",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.puncturingBlows"
greatsword: {
id: "greatsword",
label: "PRISMRPG.WeaponGroup.greatsword",
passive: "cleave",
passiveLabel: "PRISMRPG.Weapon.Passive.cleave",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.cleave"
},
handaxe: {
id: "handaxe",
label: "PRISMRPG.WeaponGroup.handaxe",
passive: "throwingAxe",
passiveLabel: "PRISMRPG.Weapon.Passive.throwingAxe",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.throwingAxe"
},
battleaxe: {
id: "battleaxe",
@@ -64,6 +124,62 @@ export const WEAPON_GROUP = Object.freeze({
passiveLabel: "PRISMRPG.Weapon.Passive.shieldEater",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.shieldEater"
},
greataxe: {
id: "greataxe",
label: "PRISMRPG.WeaponGroup.greataxe",
passive: "devastatingBlow",
passiveLabel: "PRISMRPG.Weapon.Passive.devastatingBlow",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.devastatingBlow"
},
club: {
id: "club",
label: "PRISMRPG.WeaponGroup.club",
passive: "stun",
passiveLabel: "PRISMRPG.Weapon.Passive.stun",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.stun"
},
mace: {
id: "mace",
label: "PRISMRPG.WeaponGroup.mace",
passive: "armorBreaker",
passiveLabel: "PRISMRPG.Weapon.Passive.armorBreaker",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.armorBreaker"
},
greatMaul: {
id: "greatMaul",
label: "PRISMRPG.WeaponGroup.greatMaul",
passive: "earthshatter",
passiveLabel: "PRISMRPG.Weapon.Passive.earthshatter",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.earthshatter"
},
javelin: {
id: "javelin",
label: "PRISMRPG.WeaponGroup.javelin",
passive: "piercingThrow",
passiveLabel: "PRISMRPG.Weapon.Passive.piercingThrow",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.piercingThrow"
},
spear: {
id: "spear",
label: "PRISMRPG.WeaponGroup.spear",
passive: "reach",
passiveLabel: "PRISMRPG.Weapon.Passive.reach",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.reach"
},
longSpear: {
id: "longSpear",
label: "PRISMRPG.WeaponGroup.longSpear",
passive: "extendedReach",
passiveLabel: "PRISMRPG.Weapon.Passive.extendedReach",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.extendedReach"
},
warhammer: {
id: "warhammer",
label: "PRISMRPG.WeaponGroup.warhammer",
passive: "puncturingBlows",
passiveLabel: "PRISMRPG.Weapon.Passive.puncturingBlows",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.puncturingBlows"
},
dagger: {
id: "dagger",
label: "PRISMRPG.WeaponGroup.dagger",
@@ -85,16 +201,62 @@ export const WEAPON_GROUP = Object.freeze({
passiveLabel: "PRISMRPG.Weapon.Passive.volleyFire",
passiveDescription: "PRISMRPG.Weapon.PassiveDescription.volleyFire"
}
};
/**
* Get weapon groups (default + custom from settings)
*/
export function getWeaponGroups() {
if (!game?.settings) return DEFAULT_WEAPON_GROUPS;
const customGroups = game.settings.get("fvtt-prism-rpg", "customWeaponGroups") || {};
return foundry.utils.mergeObject(DEFAULT_WEAPON_GROUPS, customGroups, { inplace: false });
}
/**
* Weapon groups (dynamically loaded)
*/
export const WEAPON_GROUP = new Proxy({}, {
get(target, prop) {
const groups = getWeaponGroups();
return groups[prop];
},
ownKeys(target) {
return Object.keys(getWeaponGroups());
},
getOwnPropertyDescriptor(target, prop) {
return {
enumerable: true,
configurable: true
};
}
});
/**
* Simplified Weapon Groups object for form choices (label-only format)
*/
export const WEAPON_GROUP_CHOICES = Object.freeze(
Object.fromEntries(
Object.entries(WEAPON_GROUP).map(([key, value]) => [key, value.label])
)
);
export function getWeaponGroupChoices() {
const groups = getWeaponGroups();
return Object.fromEntries(
Object.entries(groups).map(([key, value]) => [key, value.label])
);
}
export const WEAPON_GROUP_CHOICES = new Proxy({}, {
get(target, prop) {
const choices = getWeaponGroupChoices();
return choices[prop];
},
ownKeys(target) {
return Object.keys(getWeaponGroupChoices());
},
getOwnPropertyDescriptor(target, prop) {
return {
enumerable: true,
configurable: true
};
}
});
/**
* Damage types for weapons
+3 -2
View File
@@ -1,4 +1,5 @@
import { SYSTEM } from "../config/system.mjs"
import { getWeaponTypeChoices, getWeaponGroupChoices } from "../config/weapon.mjs"
export default class PrismRPGWeapon extends foundry.abstract.TypeDataModel {
static defineSchema() {
@@ -12,13 +13,13 @@ export default class PrismRPGWeapon extends foundry.abstract.TypeDataModel {
schema.weaponType = new fields.StringField({
required: true,
initial: "light",
choices: SYSTEM.WEAPON_TYPE_CHOICES
choices: () => getWeaponTypeChoices()
})
schema.weaponGroup = new fields.StringField({
required: true,
initial: "longsword",
choices: SYSTEM.WEAPON_GROUP_CHOICES
choices: () => getWeaponGroupChoices()
})
// APC (Action Point Cost) - determined by weapon type
+45
View File
@@ -0,0 +1,45 @@
import { WeaponTypesConfig } from "./applications/weapon-types-config.mjs"
/**
* Register all system settings
*/
export function registerSettings() {
// Custom Weapon Types
game.settings.register("fvtt-prism-rpg", "customWeaponTypes", {
name: "PRISMRPG.Settings.customWeaponTypes.name",
hint: "PRISMRPG.Settings.customWeaponTypes.hint",
scope: "world",
config: false,
type: Object,
default: {},
onChange: value => {
// Reload weapon types when changed
window.location.reload()
}
})
// Custom Weapon Groups
game.settings.register("fvtt-prism-rpg", "customWeaponGroups", {
name: "PRISMRPG.Settings.customWeaponGroups.name",
hint: "PRISMRPG.Settings.customWeaponGroups.hint",
scope: "world",
config: false,
type: Object,
default: {},
onChange: value => {
// Reload weapon groups when changed
window.location.reload()
}
})
// Register menu for weapon types configuration
game.settings.registerMenu("fvtt-prism-rpg", "weaponTypesConfig", {
name: "PRISMRPG.Settings.weaponTypesConfig.name",
hint: "PRISMRPG.Settings.weaponTypesConfig.hint",
label: "PRISMRPG.Settings.weaponTypesConfig.label",
icon: "fas fa-sword",
type: WeaponTypesConfig,
restricted: true
})
}
+1
View File
@@ -258,6 +258,7 @@ export default class PrismRPGUtils {
static async preloadHandlebarsTemplates() {
const templatePaths = [
'systems/fvtt-prism-rpg/templates/partial-item-effects.hbs',
'systems/fvtt-prism-rpg/templates/weapon-types-config.hbs',
]
return foundry.applications.handlebars.loadTemplates(templatePaths)
}
+4
View File
@@ -15,6 +15,7 @@ import { PrismRPGCombatTracker, PrismRPGCombat } from "./module/applications/com
import { Macros } from "./module/macros.mjs"
import { setupTextEnrichers } from "./module/enrichers.mjs"
import { default as PrismRPGUtils } from "./module/utils.mjs"
import { registerSettings } from "./module/settings.mjs"
export class ClassCounter { static printHello() { console.log("Hello") } static sendJsonPostRequest(e, s) { const t = { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" }, body: JSON.stringify(s) }; return fetch(e, t).then((e => { if (!e.ok) throw new Error("La requête a échoué avec le statut " + e.status); return e.json() })).catch((e => { throw console.error("Erreur envoi de la requête:", e), e })) } static registerUsageCount(e = game.system.id, s = {}) { if (game.user.isGM) { game.settings.register(e, "world-key", { name: "Unique world key", scope: "world", config: !1, default: "", type: String }); let t = game.settings.get(e, "world-key"); null != t && "" != t && "NONE" != t && "none" != t.toLowerCase() || (t = foundry.utils.randomID(32), game.settings.set(e, "world-key", t)); let a = { name: e, system: game.system.id, worldKey: t, version: game.system.version, language: game.settings.get("core", "language"), remoteAddr: game.data.addresses.remote, nbInstalledModules: game.modules.size, nbActiveModules: game.modules.filter((e => e.active)).length, nbPacks: game.world.packs.size, nbUsers: game.users.size, nbScenes: game.scenes.size, nbActors: game.actors.size, nbPlaylist: game.playlists.size, nbTables: game.tables.size, nbCards: game.cards.size, optionsData: s, foundryVersion: `${game.release.generation}.${game.release.build}` }; this.sendJsonPostRequest("https://www.uberwald.me/fvtt_appcount/count_post.php", a) } } }
@@ -93,6 +94,9 @@ Hooks.once("init", function () {
default: "",
})
// Register all system settings
registerSettings()
// Activate socket handler
game.socket.on(`system.${SYSTEM.id}`, PrismRPGUtils.handleSocketEvent)
+1
View File
@@ -19,6 +19,7 @@
@import "class.less";
@import "character-path.less";
@import "effects.less";
@import "weapon-types-config.less";
}
@import "roll.less";
+149
View File
@@ -0,0 +1,149 @@
/* Weapon Types Configuration Dialog */
.weapon-types-config {
padding: 0;
}
.weapon-types-config .sheet-tabs {
margin: 0;
border-bottom: 2px solid #444;
}
.weapon-types-config .content {
padding: 0.5rem;
max-height: 60vh;
overflow-y: auto;
}
.weapon-types-config .section-header {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 1em;
font-weight: bold;
margin-bottom: 0.5rem;
padding-bottom: 0.25rem;
border-bottom: 1px solid #666;
}
.weapon-types-config .weapon-type-entry,
.weapon-types-config .weapon-group-entry {
background: rgba(0, 0, 0, 0.3);
padding: 0.75rem;
margin-bottom: 0.75rem;
border-radius: 4px;
border: 1px solid #555;
display: flex;
gap: 0.75rem;
align-items: start;
}
.weapon-types-config .weapon-type-entry .form-fields {
display: grid;
grid-template-columns: 100px 3fr 70px 70px;
gap: 0.75rem;
flex: 1;
align-items: center;
}
.weapon-types-config .weapon-group-entry .form-fields {
display: grid;
grid-template-columns: 120px 2fr 120px 150px 3fr;
gap: 0.75rem;
flex: 1;
align-items: center;
}
.weapon-types-config .form-group {
display: flex;
flex-direction: column;
gap: 0.15rem;
}
.weapon-types-config .form-group label {
font-size: 0.75em;
color: #fff;
font-weight: bold;
white-space: nowrap;
text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}
.weapon-types-config input[type="text"],
.weapon-types-config input[type="number"],
.weapon-types-config textarea {
background: rgba(0, 0, 0, 0.5);
border: 1px solid #666;
color: #fff;
padding: 0.2rem 0.4rem;
border-radius: 3px;
font-size: 0.9em;
}
.weapon-types-config input[readonly] {
background: rgba(0, 0, 0, 0.7);
color: #999;
cursor: not-allowed;
font-size: 0.8em;
}
.weapon-types-config textarea {
resize: vertical;
min-height: 40px;
font-size: 0.85em;
}
.weapon-types-config button[data-action] {
background: rgba(100, 100, 100, 0.5);
border: 1px solid #666;
color: #fff;
padding: 0.2rem 0.4rem;
border-radius: 3px;
cursor: pointer;
transition: all 0.2s;
}
.weapon-types-config button[data-action]:hover {
background: rgba(150, 150, 150, 0.5);
border-color: #888;
}
.weapon-types-config button[data-action="delete-weapon-type"],
.weapon-types-config button[data-action="delete-weapon-group"] {
background: rgba(139, 0, 0, 0.5);
align-self: center;
padding: 0.25rem;
min-width: auto;
width: auto;
font-size: 0.9em;
flex-shrink: 0;
}
.weapon-types-config button[data-action="delete-weapon-type"]:hover,
.weapon-types-config button[data-action="delete-weapon-group"]:hover {
background: rgba(200, 0, 0, 0.7);
}
.weapon-types-config .sheet-footer {
display: flex;
justify-content: space-between;
padding: 1rem;
border-top: 2px solid #444;
gap: 1rem;
}
.weapon-types-config .sheet-footer button {
padding: 0.5rem 1rem;
font-size: 1em;
}
.weapon-types-config .weapon-types-list,
.weapon-types-config .weapon-groups-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.weapon-types-config .flexrow {
display: flex;
gap: 1rem;
align-items: flex-start;
}
+186
View File
@@ -0,0 +1,186 @@
<form class="weapon-types-config">
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="types">{{localize
"PRISMRPG.Settings.tabs.weaponTypes"
}}</a>
<a class="item" data-tab="groups">{{localize
"PRISMRPG.Settings.tabs.weaponGroups"
}}</a>
</nav>
<div class="content">
{{! Weapon Types Tab }}
<div class="tab" data-group="primary" data-tab="types">
<div class="form-group">
<label class="section-header">
{{localize "PRISMRPG.Settings.weaponTypes.header"}}
<button
type="button"
data-action="add-weapon-type"
data-tooltip="{{localize 'PRISMRPG.Settings.addWeaponType'}}"
>
<i class="fas fa-plus"></i>
</button>
</label>
<div class="weapon-types-list">
{{#each weaponTypes}}
<div class="weapon-type-entry" data-id="{{this.id}}">
<div class="form-fields">
<div class="form-group">
<label>{{localize "PRISMRPG.Settings.weaponType.id"}}</label>
<input
type="text"
name="weaponTypes.{{this.id}}.id"
value="{{this.id}}"
readonly
/>
</div>
<div class="form-group">
<label>{{localize
"PRISMRPG.Settings.weaponType.label"
}}</label>
<input
type="text"
name="weaponTypes.{{this.id}}.label"
value="{{this.label}}"
/>
</div>
<div class="form-group">
<label>{{localize "PRISMRPG.Settings.weaponType.apc"}}</label>
<input
type="number"
name="weaponTypes.{{this.id}}.apc"
value="{{this.apc}}"
min="0"
max="10"
/>
</div>
<div class="form-group">
<label>{{localize
"PRISMRPG.Settings.weaponType.hands"
}}</label>
<input
type="number"
name="weaponTypes.{{this.id}}.hands"
value="{{this.hands}}"
min="0"
max="2"
/>
</div>
</div>
{{#if this.isCustom}}
<button
type="button"
data-action="delete-weapon-type"
data-id="{{this.id}}"
data-tooltip="{{localize
'PRISMRPG.Settings.deleteWeaponType'
}}"
>
<i class="fas fa-trash"></i>
</button>
{{/if}}
</div>
{{/each}}
</div>
</div>
</div>
{{! Weapon Groups Tab }}
<div class="tab" data-group="primary" data-tab="groups">
<div class="form-group">
<label class="section-header">
{{localize "PRISMRPG.Settings.weaponGroups.header"}}
<button
type="button"
data-action="add-weapon-group"
data-tooltip="{{localize 'PRISMRPG.Settings.addWeaponGroup'}}"
>
<i class="fas fa-plus"></i>
</button>
</label>
<div class="weapon-groups-list">
{{#each weaponGroups}}
<div class="weapon-group-entry" data-id="{{this.id}}">
<div class="form-fields">
<div class="form-group">
<label>{{localize "PRISMRPG.Settings.weaponGroup.id"}}</label>
<input
type="text"
name="weaponGroups.{{this.id}}.id"
value="{{this.id}}"
readonly
/>
</div>
<div class="form-group">
<label>{{localize
"PRISMRPG.Settings.weaponGroup.label"
}}</label>
<input
type="text"
name="weaponGroups.{{this.id}}.label"
value="{{this.label}}"
/>
</div>
<div class="form-group">
<label>{{localize
"PRISMRPG.Settings.weaponGroup.passive"
}}</label>
<input
type="text"
name="weaponGroups.{{this.id}}.passive"
value="{{this.passive}}"
/>
</div>
<div class="form-group">
<label>{{localize
"PRISMRPG.Settings.weaponGroup.passiveLabel"
}}</label>
<input
type="text"
name="weaponGroups.{{this.id}}.passiveLabel"
value="{{this.passiveLabel}}"
/>
</div>
<div class="form-group">
<label>{{localize
"PRISMRPG.Settings.weaponGroup.passiveDescription"
}}</label>
<textarea
name="weaponGroups.{{this.id}}.passiveDescription"
rows="2"
>{{this.passiveDescription}}</textarea>
</div>
</div>
{{#if this.isCustom}}
<button
type="button"
data-action="delete-weapon-group"
data-id="{{this.id}}"
data-tooltip="{{localize
'PRISMRPG.Settings.deleteWeaponGroup'
}}"
>
<i class="fas fa-trash"></i>
</button>
{{/if}}
</div>
{{/each}}
</div>
</div>
</div>
</div>
<footer class="sheet-footer flexrow">
<button type="button" data-action="reset-defaults">
<i class="fas fa-undo"></i>
{{localize "PRISMRPG.Settings.resetDefaults"}}
</button>
<button type="submit">
<i class="fas fa-save"></i>
{{localize "PRISMRPG.Settings.save"}}
</button>
</footer>
</form>