Merge branch 'dev' into dev_skillslist

# Conflicts:
#	CHANGELOG.md
#	system/lang/en-en.json
#	system/lang/fr-fr.json
#	system/scripts/actor.js
#	system/scripts/actors/base-character-sheet.js
#	system/scripts/combat.js
#	system/scripts/config.js
#	system/scripts/dice/dice-picker-dialog.js
#	system/scripts/dice/roll-n-keep-dialog.js
#	system/scripts/gm/gm-monitor.js
#	system/scripts/gm/gm-toolbox.js
#	system/scripts/hooks.js
#	system/scripts/items/technique-sheet.js
#	system/scripts/main-l5r5e.js
#	system/scripts/migration.js
#	system/scripts/preloadTemplates.js
#	system/scripts/settings.js
#	system/scripts/socket-handler.js
#	system/styles/l5r5e.css
#	system/system.json
#	system/templates/actors/character-sheet.html
This commit is contained in:
Vlyan
2023-12-14 10:08:41 +01:00
54 changed files with 9442 additions and 393 deletions

View File

@@ -146,7 +146,7 @@ export class ActorL5r5e extends Actor {
// Now using updateDocuments
return Actor.updateDocuments([docData], context).then(() => {
// Notify the "Gm Monitor" if this actor is watched
if (game.settings.get(CONFIG.l5r5e.systemName, "gm-monitor-actors").find((e) => e === this.id)) {
if (game.settings.get(CONFIG.l5r5e.namespace, "gm-monitor-actors").some((uuid) => uuid === this.uuid)) {
game.l5r5e.HelpersL5r5e.refreshLocalAndSocket("l5r5e-gm-monitor");
}
});
@@ -384,9 +384,9 @@ export class ActorL5r5e extends Actor {
}
const cfg = {
character: game.settings.get(CONFIG.l5r5e.systemName, "initiative-prepared-character"),
adversary: game.settings.get(CONFIG.l5r5e.systemName, "initiative-prepared-adversary"),
minion: game.settings.get(CONFIG.l5r5e.systemName, "initiative-prepared-minion"),
character: game.settings.get(CONFIG.l5r5e.namespace, "initiative-prepared-character"),
adversary: game.settings.get(CONFIG.l5r5e.namespace, "initiative-prepared-adversary"),
minion: game.settings.get(CONFIG.l5r5e.namespace, "initiative-prepared-minion"),
};
// Prepared is a boolean or if null we get the info in the actor

View File

@@ -161,7 +161,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
if (!item || item.documentName !== "Item" || !["army_cohort", "army_fortification"].includes(item.type)) {
// actor dual trigger...
if (item?.documentName !== "Actor") {
console.warn("L5R5E | Characters items are not allowed", item?.type, item);
console.warn("L5R5E | AS | Characters items are not allowed", item?.type, item);
}
return;
}
@@ -221,7 +221,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
*/
async _updateLinkedActorData(type, actor, isInit = false) {
if (!actor || actor.documentName !== "Actor" || !actor.isCharacterType) {
console.warn("L5R5E | Wrong actor type", actor?.type, actor);
console.warn("L5R5E | AS | Wrong actor type", actor?.type, actor);
return;
}
@@ -252,7 +252,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
break;
default:
console.warn("L5R5E | Unknown type", type);
console.warn("L5R5E | AS | Unknown type", type);
return;
}
return this.actor.update(actorData);
@@ -276,7 +276,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
break;
default:
console.warn("L5R5E | Unknown type", type);
console.warn("L5R5E | AS | Unknown type", type);
return;
}
return this.actor.update({ system: actorData });
@@ -323,7 +323,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
break;
default:
console.warn("L5R5E | Unsupported type", type);
console.warn("L5R5E | AS | Unsupported type", type);
break;
}
}

View File

@@ -49,7 +49,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
// Build the list order
Array.from(CONFIG.l5r5e.techniques)
.filter(([id, cfg]) => cfg.type !== "custom" || game.settings.get(CONFIG.l5r5e.systemName, "techniques-customs"))
.filter(([id, cfg]) => cfg.type !== "custom" || game.settings.get(CONFIG.l5r5e.namespace, "techniques-customs"))
.forEach(([id, cfg]) => {
out[id] = [];
});
@@ -60,7 +60,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
case "technique":
if (!out[item.system.technique_type]) {
console.warn(
`L5R5E | Empty or unknown technique type[${item.system.technique_type}] forced to "kata" in item id[${item._id}], name[${item.name}]`
`L5R5E | BCS | Empty or unknown technique type[${item.system.technique_type}] forced to "kata" in item id[${item._id}], name[${item.name}]`
);
item.system.technique_type = "kata";
}
@@ -73,7 +73,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
if (embedItem.type === "technique") {
if (!out[embedItem.system.technique_type]) {
console.warn(
`L5R5E | Empty or unknown technique type[${embedItem.system.technique_type}] forced to "kata" in item id[${id}], name[${embedItem.name}], parent: id[${item._id}], name[${item.name}]`
`L5R5E | BCS | Empty or unknown technique type[${embedItem.system.technique_type}] forced to "kata" in item id[${id}], name[${embedItem.name}], parent: id[${item._id}], name[${item.name}]`
);
embedItem.system.technique_type = "kata";
}
@@ -136,14 +136,14 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
try {
// *** Everything below here is only needed if the sheet is editable ***
if (!this.isEditable || this.actor.system.soft_locked) {
console.log("L5R5E | This sheet is not editable");
console.log("L5R5E | BCS | This sheet is not editable");
return;
}
// Check item type and subtype
const item = await game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event);
if (!item || !["Item", "JournalEntry"].includes(item.documentName) || item.type === "property") {
console.log(`L5R5E | Wrong subtype ${item?.type}`, item);
console.log(`L5R5E | BCS | Wrong subtype ${item?.type}`, item);
return;
}
@@ -151,7 +151,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
if (item.documentName === "JournalEntry") {
// npc does not have this
if (!this.actor.system.identity?.school_curriculum_journal) {
console.log("L5R5E | NPC won't go to school :'(");
console.log("L5R5E | BCS | NPC won't go to school :'(");
return;
}
this.actor.system.identity.school_curriculum_journal = {
@@ -181,7 +181,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
return embedItem._id === item._id;
})
) {
console.log("L5R5E | This element has been ignored because it already exists in this actor", item.uuid);
console.log("L5R5E | BCS | This element has been ignored because it already exists in this actor", item.uuid);
return;
}
@@ -208,7 +208,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
switch (itemData.type) {
case "army_cohort":
case "army_fortification":
console.warn("L5R5E | Army items are not allowed", item?.type, item);
console.warn("L5R5E | BCS | Army items are not allowed", item?.type, item);
return;
case "advancement":
@@ -364,7 +364,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
const created = await this.actor.createEmbeddedDocuments("Item", [
{
name: game.i18n.localize(`ITEM.Type${type.capitalize()}`),
name: game.i18n.localize(`TYPES.Item.${type.toLowerCase()}`),
type: type,
img: `${CONFIG.l5r5e.paths.assets}icons/items/${type}.svg`,
},
@@ -566,7 +566,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
break;
default:
console.warn("L5R5E | Unsupported type", type);
console.warn("L5R5E | BCS | Unsupported type", type);
break;
}
}

View File

@@ -182,7 +182,7 @@ export class BaseSheetL5r5e extends ActorSheet {
const created = await this.actor.createEmbeddedDocuments("Item", [
{
name: game.i18n.localize(`ITEM.Type${type.capitalize()}`),
name: game.i18n.localize(`TYPES.Item.${type.toLowerCase()}`),
type: type,
img: `${CONFIG.l5r5e.paths.assets}icons/items/${type}.svg`,
},

View File

@@ -90,7 +90,7 @@ export class CharacterGenerator {
static async _getItemFromPack(packName, id = null) {
const comp = await game.packs.get(packName);
if (!comp) {
console.log(`L5R5E | Pack not found[${packName}]`);
console.log(`L5R5E | CG | Pack not found[${packName}]`);
return;
}
let document;

View File

@@ -104,19 +104,19 @@ export class TwentyQuestionsDialog extends FormApplication {
new DragDrop({
dragSelector: ".item",
dropSelector: ".items",
permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
permissions: { dragstart: this.isEditable, drop: this.isEditable },
callbacks: { dragstart: this._onDragStart.bind(this), drop: this._onDropItem.bind(this, "item") },
}),
new DragDrop({
dragSelector: ".technique",
dropSelector: ".techniques",
permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
permissions: { dragstart: this.isEditable, drop: this.isEditable },
callbacks: { dragstart: this._onDragStart.bind(this), drop: this._onDropItem.bind(this, "technique") },
}),
new DragDrop({
dragSelector: ".peculiarity",
dropSelector: ".peculiarities",
permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
permissions: { dragstart: this.isEditable, drop: this.isEditable },
callbacks: {
dragstart: this._onDragStart.bind(this),
drop: this._onDropItem.bind(this, "peculiarity"),
@@ -125,7 +125,7 @@ export class TwentyQuestionsDialog extends FormApplication {
new DragDrop({
dragSelector: ".bond",
dropSelector: ".bonds",
permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
permissions: { dragstart: this.isEditable, drop: this.isEditable },
callbacks: {
dragstart: this._onDragStart.bind(this),
drop: this._onDropItem.bind(this, "bond"),
@@ -251,16 +251,16 @@ export class TwentyQuestionsDialog extends FormApplication {
if (!["item", "technique", "peculiarity", "bond"].includes(type)) {
return;
}
const stepKey = $(event.target).data("step");
const stepKey = $(event.currentTarget).data("step");
if (!stepKey) {
console.warn("L5R5E | Event stepKey is undefined");
console.warn("L5R5E | 20Q | Event stepKey is undefined");
return;
}
try {
// Get item
const item = await game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event);
if (item.documentName !== "Item" || !item) {
console.warn(`L5R5E | Forbidden item for this drop zone ${type} : ${item.type}`);
console.warn(`L5R5E | 20Q | Forbidden item for this drop zone ${type} : ${item.type}`);
return;
}
@@ -273,7 +273,7 @@ export class TwentyQuestionsDialog extends FormApplication {
(type !== "item" && item.type !== type) ||
(type === "item" && !["item", "weapon", "armor"].includes(item.type))
) {
console.warn(`L5R5E | Forbidden item for this drop zone ${type} : ${item.type}`);
console.warn(`L5R5E | 20Q | Forbidden item for this drop zone ${type} : ${item.type}`);
return;
}
@@ -286,7 +286,7 @@ export class TwentyQuestionsDialog extends FormApplication {
if (stepKey === "step3.school_ability") {
if (item.system.technique_type !== "school_ability") {
console.warn(
`L5R5E | This technique is not a school ability : ${item.system.technique_type}`
`L5R5E | 20Q | This technique is not a school ability : ${item.system.technique_type}`
);
return;
}
@@ -301,37 +301,37 @@ export class TwentyQuestionsDialog extends FormApplication {
switch (stepKey) {
case "step9.distinction":
if (item.system.peculiarity_type !== "distinction") {
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
console.warn(`L5R5E | 20Q | Wrong type given "${item.system.peculiarity_type}" instead of "distinction"`);
return;
}
break;
case "step10.adversity":
if (item.system.peculiarity_type !== "adversity") {
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
console.warn(`L5R5E | 20Q | Wrong type given "${item.system.peculiarity_type}" instead of "adversity"`);
return;
}
break;
case "step11.passion":
if (item.system.peculiarity_type !== "passion") {
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
console.warn(`L5R5E | 20Q | Wrong type given "${item.system.peculiarity_type}" instead of "passion"`);
return;
}
break;
case "step12.anxiety":
if (item.system.peculiarity_type !== "anxiety") {
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
console.warn(`L5R5E | 20Q | Wrong type given "${item.system.peculiarity_type}" instead of "anxiety"`);
return;
}
break;
case "step13.advantage":
if (!["distinction", "passion"].includes(item.system.peculiarity_type)) {
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
console.warn(`L5R5E | 20Q | Wrong type given "${item.system.peculiarity_type}" instead of "distinction" or "passion"`);
return;
}
break;
case "step13.disadvantage":
if (!["adversity", "anxiety"].includes(item.system.peculiarity_type)) {
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
console.warn(`L5R5E | 20Q | Wrong type given "${item.system.peculiarity_type}" instead of "adversity" or "anxiety"`);
return;
}
break;
@@ -344,7 +344,7 @@ export class TwentyQuestionsDialog extends FormApplication {
this.submit();
} catch (err) {
console.warn("L5R5E | ", err);
console.warn("L5R5E | 20Q | ", err);
}
return false;
}
@@ -430,7 +430,7 @@ export class TwentyQuestionsDialog extends FormApplication {
}
const item = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack({ id: id, type: "Item" });
if (!item) {
console.warn(`L5R5E | Unknown item id[${id}]`);
console.warn(`L5R5E | 20Q | Unknown item id[${id}]`);
continue;
}
newStep.push(id);

View File

@@ -24,15 +24,15 @@ export class CombatL5r5e extends Combat {
// Get global modifiers
const cfg = {
difficulty: game.settings.get(CONFIG.l5r5e.systemName, "initiative-difficulty-value"),
difficultyHidden: game.settings.get(CONFIG.l5r5e.systemName, "initiative-difficulty-hidden"),
difficulty: game.settings.get(CONFIG.l5r5e.namespace, "initiative-difficulty-value"),
difficultyHidden: game.settings.get(CONFIG.l5r5e.namespace, "initiative-difficulty-hidden"),
};
// SkillId from DicePicker or global
const skillId = messageOptions.skillId
? messageOptions.skillId
: CONFIG.l5r5e.initiativeSkills[game.settings.get(CONFIG.l5r5e.systemName, "initiative-encounter")];
const skillCat = CONFIG.l5r5e.skills.get(skillId);// TODO refacto avec les skill items
: CONFIG.l5r5e.initiativeSkills[game.settings.get(CONFIG.l5r5e.namespace, "initiative-encounter")];
const skillCat = CONFIG.l5r5e.skills.get(skillId); // TODO refacto with skill items
// Get score for each combatant
const networkActors = [];

View File

@@ -1,8 +1,8 @@
export const L5R5E = {
systemName: "l5r5e", // System namespace, same as "id" in system.json
namespace: "l5r5e",
paths: {
assets: `systems/l5r5e/assets/`,
templates: `systems/l5r5e/templates/`,
assets: "systems/l5r5e/assets/",
templates: "systems/l5r5e/templates/",
},
money: [50, 10],
stances: ["earth", "air", "water", "fire", "void"],

View File

@@ -176,7 +176,7 @@ export class DicePickerDialog extends FormApplication {
// Difficulty
if (!options.difficulty || !this.parseDifficulty(options.difficulty)) {
this.difficulty = game.settings.get(CONFIG.l5r5e.systemName, "initiative-difficulty-value");
this.difficulty = game.settings.get(CONFIG.l5r5e.namespace, "initiative-difficulty-value");
}
// DifficultyHidden
@@ -201,7 +201,7 @@ export class DicePickerDialog extends FormApplication {
*/
async refresh() {
if (this._difficultyHiddenIsLock.option) {
this.difficulty = game.settings.get(CONFIG.l5r5e.systemName, "initiative-difficulty-value");
this.difficulty = game.settings.get(CONFIG.l5r5e.namespace, "initiative-difficulty-value");
this.difficultyHidden = false;
}
this.render(false);
@@ -246,11 +246,8 @@ export class DicePickerDialog extends FormApplication {
if (!targetToken) {
return;
}
if (!(targetToken instanceof TokenDocument) || !targetToken.isOwner) {
console.warn(
"L5R5E | DP | target rejected : Not a valid TokenDocument instance or permission was denied",
targetToken
);
if (!(targetToken instanceof TokenDocument)) {
console.warn("L5R5E | DP | target rejected : Not a valid TokenDocument instance", targetToken);
return;
}
this._target = targetToken;
@@ -308,7 +305,7 @@ export class DicePickerDialog extends FormApplication {
name: "",
};
this.skillCatId = CONFIG.l5r5e.skills.get(skillId);// TODO refacto avec les skill items
this.skillCatId = CONFIG.l5r5e.skills.get(skillId); // TODO refacto with skill items
}
/**
@@ -365,7 +362,7 @@ export class DicePickerDialog extends FormApplication {
*/
set difficultyHidden(isHidden) {
// If GM hide, then player choice don't matter
this._difficultyHiddenIsLock.gm = game.settings.get(CONFIG.l5r5e.systemName, "initiative-difficulty-hidden");
this._difficultyHiddenIsLock.gm = game.settings.get(CONFIG.l5r5e.namespace, "initiative-difficulty-hidden");
if (this._difficultyHiddenIsLock.gm || this._difficultyHiddenIsLock.option) {
isHidden = true;
}

View File

@@ -196,21 +196,12 @@ export class RollnKeepDialog extends FormApplication {
new DragDrop({
dragSelector: ".dice.draggable",
dropSelector: ".dropbox",
permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
permissions: { dragstart: this.isEditable, drop: this.isEditable },
callbacks: { dragstart: this._onDragStart.bind(this), drop: this._onDropItem.bind(this) },
}),
];
}
/**
* Define whether a user is able to begin a dragstart workflow for a given drag selector
* @param selector The candidate HTML selector for dragging
* @return Can the current user drag this selector?
*/
_canDragStart(selector) {
return this.options.editable;
}
/**
* Callback actions which occur at the beginning of a drag start workflow.
* @param {DragEvent} event The originating DragEvent
@@ -544,7 +535,7 @@ export class RollnKeepDialog extends FormApplication {
// Show DsN dice for the new roll
if (game.dice3d !== undefined) {
game.dice3d.showForRoll(
await game.dice3d.showForRoll(
roll,
game.user,
true,
@@ -683,7 +674,7 @@ export class RollnKeepDialog extends FormApplication {
}
// Delete old chat message related to this series
if (game.settings.get(CONFIG.l5r5e.systemName, "rnk-deleteOldMessage")) {
if (game.settings.get(CONFIG.l5r5e.namespace, "rnk-deleteOldMessage")) {
if (game.user.isFirstGM) {
const message = game.messages.get(msgOldId);
if (message) {

View File

@@ -42,7 +42,7 @@ export class GmMonitor extends FormApplication {
buttons.unshift({
label: game.i18n.localize("l5r5e.gm.monitor.switch_view"),
class: "switch-view",
icon: "fas fa-users",
icon: "fas fa-repeat",
onclick: () =>
game.l5r5e.HelpersL5r5e.debounce(
"SwitchView-" + this.object.id,
@@ -50,7 +50,21 @@ export class GmMonitor extends FormApplication {
this.object.view = this.object.view === "armies" ? "characters" : "armies";
this.render(false);
},
1000,
500,
true
)(),
});
// Add selected tokens
buttons.unshift({
label: game.i18n.localize("l5r5e.gm.monitor.add_selected_tokens"),
class: "add-selected-token",
icon: "fas fa-users",
onclick: () =>
game.l5r5e.HelpersL5r5e.debounce(
"AddSelectedToken-" + this.object.id,
() => this.#addSelectedTokens(),
500,
true
)(),
});
@@ -84,11 +98,19 @@ export class GmMonitor extends FormApplication {
*/
_initialize() {
let actors;
const ids = game.settings.get(CONFIG.l5r5e.systemName, "gm-monitor-actors");
const uuidList = game.settings.get(CONFIG.l5r5e.namespace, "gm-monitor-actors");
if (uuidList.length > 0) {
// Get actors from stored uuids
actors = uuidList
.map(uuid => {
const doc = fromUuidSync(uuid);
if (doc instanceof TokenDocument) {
return doc.actor;
}
return doc;
})
.filter(a => !!a); // skip null
if (ids.length > 0) {
// get actors with stored ids
actors = game.actors.filter((e) => ids.includes(e.id));
} else {
// If empty add pc with owner
actors = game.actors.filter((actor) => actor.isCharacter && actor.hasPlayerOwnerActive);
@@ -103,6 +125,27 @@ export class GmMonitor extends FormApplication {
this.object.actors = actors;
}
/**
* Add selected token on monitor if not already present
*/
#addSelectedTokens() {
if (canvas.tokens.controlled.length > 0) {
const actors2Add = canvas.tokens.controlled
.map(t => t.actor)
.filter(t => !!t && !this.object.actors.find((a) => a.uuid === t.uuid));
if (actors2Add.length < 1) {
return;
}
this.object.actors = [
...this.object.actors,
...actors2Add
];
this._saveActorsIds().then(() => this.render(false));
}
}
/**
* Prevent non GM to render this windows
* @override
@@ -161,11 +204,11 @@ export class GmMonitor extends FormApplication {
return $(event.currentTarget).data("text");
}
const id = $(event.currentTarget).data("actor-id");
if (!id) {
const uuid = $(event.currentTarget).data("actor-uuid");
if (!uuid) {
return;
}
const actor = this.object.actors.find((e) => e.id === id);
const actor = this.object.actors.find((a) => a.uuid === uuid);
if (!actor) {
return;
}
@@ -201,11 +244,14 @@ export class GmMonitor extends FormApplication {
return;
}
const actor = game.actors.find((a) => a.uuid === data.uuid);
const actor = fromUuidSync(data.uuid);
if (!actor) {
return;
}
// Switch view to current character type
this.object.view = actor.isArmy ? "armies" : "characters";
this.object.actors.push(actor);
return this._saveActorsIds();
@@ -218,9 +264,9 @@ export class GmMonitor extends FormApplication {
*/
async _saveActorsIds() {
return game.settings.set(
CONFIG.l5r5e.systemName,
CONFIG.l5r5e.namespace,
"gm-monitor-actors",
this.object.actors.map((e) => e.id)
this.object.actors.map((a) => a.uuid)
);
}
@@ -234,12 +280,12 @@ export class GmMonitor extends FormApplication {
event.preventDefault();
event.stopPropagation();
const id = $(event.currentTarget).data("actor-id");
if (!id) {
const uuid = $(event.currentTarget).data("actor-uuid");
if (!uuid) {
return;
}
this.object.actors = this.object.actors.filter((e) => e.id !== id);
this.object.actors = this.object.actors.filter((a) => a.uuid !== uuid);
return this._saveActorsIds();
}
@@ -256,17 +302,17 @@ export class GmMonitor extends FormApplication {
const type = $(event.currentTarget).data("type");
if (!type) {
console.warn("L5R5E | type not set", type);
console.warn("L5R5E | GMM | type not set", type);
return;
}
const id = $(event.currentTarget).data("actor-id");
if (!id) {
console.warn("L5R5E | actor id not set", type);
const uuid = $(event.currentTarget).data("actor-uuid");
if (!uuid) {
console.warn("L5R5E | GMM | actor uuid not set", type);
return;
}
const actor = game.actors.get(id);
const actor = fromUuidSync(uuid);
if (!actor) {
console.warn("L5R5E | Actor not found", type);
console.warn("L5R5E | GMM | Actor not found", type);
return;
}
@@ -323,7 +369,7 @@ export class GmMonitor extends FormApplication {
break;
default:
console.warn("L5R5E | Unsupported type", type);
console.warn("L5R5E | GMM | Unsupported type", type);
break;
}
if (!foundry.utils.isEmpty(updateData)) {

View File

@@ -55,8 +55,8 @@ export class GmToolbox extends FormApplication {
*/
_initialize() {
this.object = {
difficulty: game.settings.get(CONFIG.l5r5e.systemName, "initiative-difficulty-value"),
difficultyHidden: game.settings.get(CONFIG.l5r5e.systemName, "initiative-difficulty-hidden"),
difficulty: game.settings.get(CONFIG.l5r5e.namespace, "initiative-difficulty-value"),
difficultyHidden: game.settings.get(CONFIG.l5r5e.namespace, "initiative-difficulty-hidden"),
};
}
@@ -128,7 +128,7 @@ export class GmToolbox extends FormApplication {
event.stopPropagation();
this.object.difficultyHidden = !this.object.difficultyHidden;
game.settings
.set(CONFIG.l5r5e.systemName, "initiative-difficulty-hidden", this.object.difficultyHidden)
.set(CONFIG.l5r5e.namespace, "initiative-difficulty-hidden", this.object.difficultyHidden)
.then(() => this.submit());
});
@@ -150,7 +150,7 @@ export class GmToolbox extends FormApplication {
this.object.difficulty = Math.max(0, this.object.difficulty - 1);
break;
}
game.settings.set("l5r5e", "initiative-difficulty-value", this.object.difficulty).then(() => this.submit());
game.settings.set(CONFIG.l5r5e.namespace, "initiative-difficulty-value", this.object.difficulty).then(() => this.submit());
});
// Scene End, Sleep, Void Pts

View File

@@ -274,7 +274,7 @@ export class HelpersL5r5e {
document.prepareData();
}
} catch (err) {
console.warn("L5R5E | ", err);
console.warn("L5R5E | Helpers | ", err);
}
return document;
}
@@ -306,7 +306,7 @@ export class HelpersL5r5e {
break;
default:
console.log(`L5R5E | createObjectFromCompendium - Unmanaged type ${type}`);
console.log(`L5R5E | Helpers | createObjectFromCompendium - Unmanaged type ${type}`);
break;
} // swi
@@ -330,7 +330,7 @@ export class HelpersL5r5e {
if (gameProp) {
return { id: gameProp.id, name: gameProp.name };
} else {
console.warn(`L5R5E | Unknown property id[${property.id}]`);
console.warn(`L5R5E | Helpers | Unknown property id[${property.id}]`);
}
return property;
})
@@ -825,14 +825,14 @@ export class HelpersL5r5e {
static async drawManyFromPack(pack, tableName, retrieve = 5, opt = { rollMode: "selfroll" }) {
const comp = game.packs.get(pack);
if (!comp) {
console.log(`L5R5E | Pack not found[${pack}]`);
console.log(`L5R5E | Helpers | Pack not found[${pack}]`);
return;
}
await comp.getDocuments();
const table = await (/^[a-zA-Z0-9]{16}$/.test(tableName) ? comp.get(tableName) : comp.getName(tableName));
if (!table) {
console.log(`L5R5E | Table not found[${tableName}]`, comp, table);
console.log(`L5R5E | Helpers | Table not found[${tableName}]`, comp, table);
return;
}
return await table.drawMany(retrieve, opt);
@@ -953,7 +953,7 @@ export class HelpersL5r5e {
)}`;
choiceDiv.addEventListener("click", (clickEvent) => {
const selectedIndex = clickEvent.target.attributes["data-id"].value;
const selectedIndex = clickEvent.target.attributes["data-id"]?.value;
if (!list[selectedIndex]) {
return;
}

View File

@@ -6,7 +6,7 @@ export default class HooksL5r5e {
// Enable embed Babele compendiums only if custom compendium is not found or disabled
if (
typeof Babele !== "undefined" &&
Babele.get().modules.every((module) => module.module !== "l5r5e-custom-compendiums")
Babele.get().modules.every((module) => module.module !== game.settings.get(CONFIG.l5r5e.namespace, "custom-compendium-name"))
) {
Babele.get().setSystemTranslationsDir("babele"); // Since Babele v2.0.7
}
@@ -30,9 +30,9 @@ export default class HooksL5r5e {
// Prepare values are sometimes null
["character", "adversary", "minion"].forEach(preparedId => {
const prepVal = game.settings.get(CONFIG.l5r5e.systemName, `initiative-prepared-${preparedId}`);
const prepVal = game.settings.get(CONFIG.l5r5e.namespace, `initiative-prepared-${preparedId}`);
if (prepVal === null || prepVal === "null") {
game.settings.set(CONFIG.l5r5e.systemName, `initiative-prepared-${preparedId}`, "actor");
game.settings.set(CONFIG.l5r5e.namespace, `initiative-prepared-${preparedId}`, "actor");
}
});
@@ -103,14 +103,10 @@ export default class HooksL5r5e {
case "settings":
// Add Changelog link
html.find("#game-details .system").append(
`<p><a href="${game.system.changelog}" target="_blank">Changelog</a>` +
` <a href="${game.i18n.localize(
"l5r5e.settings.wiki.link"
)}" target="_blank">${game.i18n.localize("l5r5e.settings.wiki.title")}</a>` +
` <a href="${game.i18n.localize(
"l5r5e.settings.custom-compendiums.link"
)}" target="_blank">${game.i18n.localize("l5r5e.settings.custom-compendiums.title")}</a>` +
`</p>`
`<span><a href="${game.system.changelog}" target="_blank">Changelog</a>`
+ ` <a href="${game.i18n.localize("l5r5e.settings.wiki.link")}" target="_blank">${game.i18n.localize("l5r5e.settings.wiki.title")}</a>`
+ ` <a href="${game.i18n.localize("l5r5e.settings.custom-compendiums.link")}" target="_blank">${game.i18n.localize("l5r5e.settings.custom-compendiums.title")}</a>`
+ `</span>`
);
break;
}
@@ -166,14 +162,14 @@ export default class HooksL5r5e {
// *** Conf ***
const encounterTypeList = Object.keys(CONFIG.l5r5e.initiativeSkills);
const prepared = {
character: game.settings.get(CONFIG.l5r5e.systemName, "initiative-prepared-character"),
adversary: game.settings.get(CONFIG.l5r5e.systemName, "initiative-prepared-adversary"),
minion: game.settings.get(CONFIG.l5r5e.systemName, "initiative-prepared-minion"),
character: game.settings.get(CONFIG.l5r5e.namespace, "initiative-prepared-character"),
adversary: game.settings.get(CONFIG.l5r5e.namespace, "initiative-prepared-adversary"),
minion: game.settings.get(CONFIG.l5r5e.namespace, "initiative-prepared-minion"),
};
// *** Template ***
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}gm/combat-tracker-bar.html`, {
encounterType: game.settings.get(CONFIG.l5r5e.systemName, "initiative-encounter"),
encounterType: game.settings.get(CONFIG.l5r5e.namespace, "initiative-encounter"),
encounterTypeList,
prepared,
});
@@ -194,7 +190,7 @@ export default class HooksL5r5e {
if (!encounterTypeList.includes(encounter)) {
return;
}
game.settings.set(CONFIG.l5r5e.systemName, "initiative-encounter", encounter);
game.settings.set(CONFIG.l5r5e.namespace, "initiative-encounter", encounter);
});
html.find(".prepared-control").on("mousedown", (event) => {
@@ -210,7 +206,7 @@ export default class HooksL5r5e {
true: rev ? "actor" : "false",
actor: rev ? "false" : "true",
};
game.settings.set(CONFIG.l5r5e.systemName, `initiative-prepared-${preparedId}`, nextValue[prepared[preparedId]]);
game.settings.set(CONFIG.l5r5e.namespace, `initiative-prepared-${preparedId}`, nextValue[prepared[preparedId]]);
});
}

View File

@@ -43,16 +43,13 @@ export class ItemL5r5e extends Item {
* TODO probably useless if we can add "items" in metadata.embedded, but no clue how to.
*
* @param {string} embeddedName The name of the embedded Document type
* @return {Collection} The Collection instance of embedded Documents of the requested type
* @return {DocumentCollection} The Collection instance of embedded Documents of the requested type
*/
getEmbeddedCollection(embeddedName) {
const collectionName = embeddedName === "Item" ? "items" : this.constructor.metadata.embedded[embeddedName];
if (!collectionName) {
throw new Error(
`${embeddedName} is not a valid embedded Document within the ${this.documentName} Document`
);
if (embeddedName === "Item") {
return this.items;
}
return this[collectionName];
return super.getEmbeddedCollection(embeddedName);
}
/**
@@ -86,7 +83,7 @@ export class ItemL5r5e extends Item {
// **** Embed Items, need to get the parents ****
const parentItem = this.getItemFromParentId();
if (!parentItem) {
console.warn(`L5R5E | Embed parentItem not found`);
console.warn(`L5R5E | Helpers | Embed parentItem not found`);
return;
}
@@ -202,7 +199,7 @@ export class ItemL5r5e extends Item {
}
/**
* Add a Embed Item
* Add an Embed Item
* @param {ItemL5r5e} item Object to add
* @param {boolean} save if we save in db or not (used internally)
* @param {boolean} newId if we change the id
@@ -257,7 +254,7 @@ export class ItemL5r5e extends Item {
}
/**
* Update a Embed Item
* Update an Embed Item
* @param {ItemL5r5e} item Object to add
* @param {boolean} save if we save in db or not (used internally)
* @return {Promise<string>}

View File

@@ -111,7 +111,7 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e {
*/
async _updateLinkedActorData(actor) {
if (!actor || actor.documentName !== "Actor" || !actor.isCharacterType) {
console.warn("L5R5E | Wrong actor type", actor?.type, actor);
console.warn("L5R5E | Army Cohort | Wrong actor type", actor?.type, actor);
return;
}

View File

@@ -101,7 +101,7 @@ export class BaseItemSheetL5r5e extends ItemSheet {
event.preventDefault();
event.stopPropagation();
const itemId = $(event.currentTarget).data("item-id");
console.warn("L5R5E | TODO ItemSheetL5r5e._addSubItem()", itemId); // TODO _addSubItem Currently not used, title override it
console.warn("L5R5E | BIS | TODO ItemSheetL5r5e._addSubItem()", itemId); // TODO _addSubItem Currently not used, title override it
}
/**

View File

@@ -51,7 +51,7 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
props.push({ id: gameProp.id, name: gameProp.name });
} else {
// Item not found
console.warn(`L5R5E | Unknown property id[${property.id}], name[${property.name}]`);
console.warn(`L5R5E | IS | Unknown property id[${property.id}], name[${property.name}]`);
sheetData.data.propertiesList.push({
id: property.id,
name: property.name,
@@ -87,11 +87,13 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
* @return {DragDrop[]} An array of DragDrop handlers
*/
_createDragDropHandlers() {
// "this.isEditable" fail for tooltips (undefined "this.document")
const isEditable = this.options.editable;
return [
new DragDrop({
dragSelector: ".property",
dropSelector: null,
permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
permissions: { dragstart: isEditable, drop: isEditable },
callbacks: { dragstart: this._onDragStart.bind(this), drop: this._onDrop.bind(this) },
}),
];

View File

@@ -21,7 +21,7 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
// List all available techniques type
const types = ["core", "school", "title"];
if (game.settings.get(CONFIG.l5r5e.systemName, "techniques-customs")) {
if (game.settings.get(CONFIG.l5r5e.namespace, "techniques-customs")) {
types.push("custom");
}
sheetData.data.techniquesList = game.l5r5e.HelpersL5r5e.getTechniquesList({ types });

View File

@@ -116,7 +116,7 @@ export class TitleSheetL5r5e extends ItemSheetL5r5e {
// Create the new Item
const itemId = await this.document.addEmbedItem(
new game.l5r5e.ItemL5r5e({
name: game.i18n.localize(`ITEM.Type${selectedType.capitalize()}`),
name: game.i18n.localize(`TYPES.Item.${selectedType.toLowerCase()}`),
type: selectedType,
img: `${CONFIG.l5r5e.paths.assets}icons/items/${selectedType}.svg`,
})

View File

@@ -112,99 +112,99 @@ Hooks.once("init", async () => {
// ***** Register custom sheets *****
// Actors
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet(L5R5E.systemName, CharacterSheetL5r5e, {
Actors.registerSheet(L5R5E.namespace, CharacterSheetL5r5e, {
types: ["character"],
label: "ACTOR.TypeCharacter",
label: "TYPES.Actor.character",
makeDefault: true,
});
Actors.registerSheet(L5R5E.systemName, NpcSheetL5r5e, {
Actors.registerSheet(L5R5E.namespace, NpcSheetL5r5e, {
types: ["npc"],
label: "ACTOR.TypeNpc",
label: "TYPES.Actor.npc",
makeDefault: true,
});
Actors.registerSheet(L5R5E.systemName, ArmySheetL5r5e, {
Actors.registerSheet(L5R5E.namespace, ArmySheetL5r5e, {
types: ["army"],
label: "ACTOR.TypeArmy",
label: "TYPES.Actor.army",
makeDefault: true,
});
// Items
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet(L5R5E.systemName, ItemSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, ItemSheetL5r5e, {
types: ["item"],
label: "ITEM.TypeItem",
label: "TYPES.Item.item",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, SkillSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, SkillSheetL5r5e, {
types: ["skill"],
label: "ITEM.TypeSkill",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, ArmorSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, ArmorSheetL5r5e, {
types: ["armor"],
label: "ITEM.TypeArmor",
label: "TYPES.Item.armor",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, WeaponSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, WeaponSheetL5r5e, {
types: ["weapon"],
label: "ITEM.TypeWeapon",
label: "TYPES.Item.weapon",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, TechniqueSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, TechniqueSheetL5r5e, {
types: ["technique"],
label: "ITEM.TypeTechnique",
label: "TYPES.Item.technique",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, PropertySheetL5r5e, {
Items.registerSheet(L5R5E.namespace, PropertySheetL5r5e, {
types: ["property"],
label: "ITEM.TypeProperty",
label: "TYPES.Item.property",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, PeculiaritySheetL5r5e, {
Items.registerSheet(L5R5E.namespace, PeculiaritySheetL5r5e, {
types: ["peculiarity"],
label: "ITEM.TypePeculiarity",
label: "TYPES.Item.peculiarity",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, AdvancementSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, AdvancementSheetL5r5e, {
types: ["advancement"],
label: "ITEM.TypeAdvancement",
label: "TYPES.Item.advancement",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, TitleSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, TitleSheetL5r5e, {
types: ["title"],
label: "ITEM.TypeTitle",
label: "TYPES.Item.title",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, BondSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, BondSheetL5r5e, {
types: ["bond"],
label: "ITEM.TypeBond",
label: "TYPES.Item.bond",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, SignatureScrollSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, SignatureScrollSheetL5r5e, {
types: ["signature_scroll"],
label: "ITEM.TypeSignature_scroll",
label: "TYPES.Item.signature_scroll",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, ItemPatternSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, ItemPatternSheetL5r5e, {
types: ["item_pattern"],
label: "ITEM.TypeItem_pattern",
label: "TYPES.Item.item_pattern",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, ArmyCohortSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, ArmyCohortSheetL5r5e, {
types: ["army_cohort"],
label: "ITEM.TypeArmy_cohort",
label: "TYPES.Item.army_cohort",
makeDefault: true,
});
Items.registerSheet(L5R5E.systemName, ArmyFortificationSheetL5r5e, {
Items.registerSheet(L5R5E.namespace, ArmyFortificationSheetL5r5e, {
types: ["army_fortification"],
label: "ITEM.TypeArmy_fortification",
label: "TYPES.Item.army_fortification",
makeDefault: true,
});
// Journal
Journal.unregisterSheet("core", JournalSheet);
Journal.registerSheet(L5R5E.systemName, BaseJournalSheetL5r5e, {
label: "JOURNAL.TypeJournal",
Journal.registerSheet(L5R5E.namespace, BaseJournalSheetL5r5e, {
label: "TYPES.Journal.journal",
makeDefault: true,
});
@@ -216,7 +216,7 @@ Hooks.once("init", async () => {
// Override the default Token _drawBar function to allow fatigue bar reversing.
Token.prototype._drawBar = function (number, bar, data) {
const reverseBar = data.attribute === "fatigue" && game.settings.get(L5R5E.systemName, "token-reverseFatigueBar");
const reverseBar = data.attribute === "fatigue" && game.settings.get(L5R5E.namespace, "token-reverseFatigueBar");
// Bar value
const pct = Math.clamped(Number(data.value), 0, data.max) / data.max;

View File

@@ -14,7 +14,7 @@ export class MigrationL5r5e {
* @return {boolean}
*/
static needUpdate(version) {
const currentVersion = game.settings.get(CONFIG.l5r5e.systemName, "systemMigrationVersion");
const currentVersion = game.settings.get(CONFIG.l5r5e.namespace, "systemMigrationVersion");
return !currentVersion || foundry.utils.isNewerVersion(version, currentVersion);
}
@@ -49,11 +49,11 @@ export class MigrationL5r5e {
try {
const updateData = await MigrationL5r5e._migrateActorData(actor, options);
if (!foundry.utils.isEmpty(updateData)) {
console.log(`L5R5E | Migrating Actor document ${actor.name}[${actor._id}]`);
console.log(`L5R5E | Migration | Migrating Actor document ${actor.name}[${actor._id}]`);
await actor.update(updateData);
}
} catch (err) {
err.message = `L5R5E | Failed L5R5e system migration for Actor ${actor.name}[${actor._id}]: ${err.message}`;
err.message = `L5R5E | Migration | Failed L5R5e system migration for Actor ${actor.name}[${actor._id}]: ${err.message}`;
console.error(err);
}
}
@@ -63,11 +63,11 @@ export class MigrationL5r5e {
try {
const updateData = MigrationL5r5e._migrateItemData(item, options);
if (!foundry.utils.isEmpty(updateData)) {
console.log(`L5R5E | Migrating Item document ${item.name}[${item._id}]`);
console.log(`L5R5E | Migration | Migrating Item document ${item.name}[${item._id}]`);
await item.update(updateData);
}
} catch (err) {
err.message = `L5R5E | Failed L5R5e system migration for Item ${item.name}[${item._id}]: ${err.message}`;
err.message = `L5R5E | Migration | Failed L5R5e system migration for Item ${item.name}[${item._id}]: ${err.message}`;
console.error(err);
}
}
@@ -77,14 +77,14 @@ export class MigrationL5r5e {
try {
const updateData = MigrationL5r5e._migrateSceneData(scene, options);
if (!foundry.utils.isEmpty(updateData)) {
console.log(`L5R5E | Migrating Scene document ${scene.name}[${scene._id}]`);
console.log(`L5R5E | Migration | Migrating Scene document ${scene.name}[${scene._id}]`);
await scene.update(updateData);
// If we do not do this, then synthetic token actors remain in cache
// with the un-updated actorData.
scene.tokens.contents.forEach((t) => (t._actor = null));
}
} catch (err) {
err.message = `L5R5E | Failed L5R5e system migration for Scene ${scene.name}[${scene._id}]: ${err.message}`;
err.message = `L5R5E | Migration | Failed L5R5e system migration for Scene ${scene.name}[${scene._id}]: ${err.message}`;
console.error(err);
}
}
@@ -109,16 +109,16 @@ export class MigrationL5r5e {
}
// Save all the modified entries at once
if (updatedChatList.length > 0) {
console.log(`L5R5E | Migrating ${updatedChatList.length} ChatMessage documents`);
console.log(`L5R5E | Migration | Migrating ${updatedChatList.length} ChatMessage documents`);
await ChatMessage.updateDocuments(updatedChatList);
}
} catch (err) {
err.message = `L5R5E | Failed L5R5e system migration for ChatMessage`;
err.message = `L5R5E | Migration | Failed L5R5e system migration for ChatMessage`;
console.error(err);
}
// Set the migration as complete
await game.settings.set(CONFIG.l5r5e.systemName, "systemMigrationVersion", game.system.version);
await game.settings.set(CONFIG.l5r5e.namespace, "systemMigrationVersion", game.system.version);
ui.notifications.info(`L5R5e System Migration to version ${game.system.version} completed!`, {
permanent: true,
});
@@ -165,9 +165,7 @@ export class MigrationL5r5e {
updateData["_id"] = doc._id;
updateDatasList.push(updateData);
console.log(
`L5R5E | Migrating ${docType} document ${doc.name}[${doc._id}] in Compendium ${pack.collection}`
);
console.log(`L5R5E | Migration | Migrating ${docType} document ${doc.name}[${doc._id}] in Compendium ${pack.collection}`);
}
// Save the modified entries
@@ -176,13 +174,13 @@ export class MigrationL5r5e {
}
} catch (err) {
// Handle migration failures
err.message = `L5R5E | Failed system migration for documents ${docType} in pack ${pack.collection}: ${err.message}`;
err.message = `L5R5E | Migration | Failed system migration for documents ${docType} in pack ${pack.collection}: ${err.message}`;
console.error(err);
}
// Apply the original locked status for the pack
await pack.configure({ locked: wasLocked });
console.log(`L5R5E | Migrated all ${docType} contents from Compendium ${pack.collection}`);
console.log(`L5R5E | Migration | Migrated all ${docType} contents from Compendium ${pack.collection}`);
}
/**
@@ -196,12 +194,12 @@ export class MigrationL5r5e {
const tokens = scene.tokens.map((token) => {
const t = token.toJSON();
if (!t.actorId || t.actorLink) {
t.actorData = {};
t.delta = {};
} else if (!game.actors.has(t.actorId)) {
t.actorId = null;
t.actorData = {};
t.delta = {};
} else if (!t.actorLink) {
const actorData = foundry.utils.duplicate(t.actorData);
const actorData = foundry.utils.duplicate(t.delta);
actorData.type = token.actor?.type;
const update = MigrationL5r5e._migrateActorData(actorData, options);
["items", "effects"].forEach((embeddedName) => {
@@ -209,7 +207,7 @@ export class MigrationL5r5e {
return;
}
const updates = new Map(update[embeddedName].map((u) => [u._id, u]));
t.actorData[embeddedName].forEach((original) => {
t.delta[embeddedName].forEach((original) => {
const update = updates.get(original._id);
if (update) {
foundry.utils.mergeObject(original, update);
@@ -218,7 +216,7 @@ export class MigrationL5r5e {
delete update[embeddedName];
});
foundry.utils.mergeObject(t.actorData, update);
foundry.utils.mergeObject(t.delta, update);
}
return t;
});
@@ -228,7 +226,7 @@ export class MigrationL5r5e {
/**
* Migrate a single Actor document to incorporate latest data model changes
* Return an Object of updateData to be applied
* @param {ActorL5r5e|Object} actor The actor, or the TokenDocument.actorData to Update
* @param {ActorL5r5e|Object} actor The actor, or the TokenDocument.delta to Update
* @param options
* @return {Object} The updateData to apply
*/

View File

@@ -13,6 +13,7 @@ export const PreloadTemplates = async function () {
`${tpl}actors/character/inventory.html`,
`${tpl}actors/character/narrative.html`,
`${tpl}actors/character/rings.html`,
`${tpl}actors/character/effects.html`,
`${tpl}actors/character/social.html`,
`${tpl}actors/character/stance.html`,
`${tpl}actors/character/techniques.html`,
@@ -24,6 +25,7 @@ export const PreloadTemplates = async function () {
`${tpl}actors/npc/inventory.html`,
`${tpl}actors/npc/narrative.html`,
`${tpl}actors/npc/rings.html`,
`${tpl}actors/npc/effects.html`,
`${tpl}actors/npc/social.html`,
`${tpl}actors/npc/skill.html`,
`${tpl}actors/npc/techniques.html`,

View File

@@ -2,10 +2,12 @@
* Custom system settings register
*/
export const RegisterSettings = function () {
const isBabeleRegistered = (typeof Babele !== "undefined");
/* ------------------------------------ */
/* User settings */
/* ------------------------------------ */
game.settings.registerMenu(CONFIG.l5r5e.systemName, "defaultSkillsListMenu", {
game.settings.registerMenu(CONFIG.l5r5e.namespace, "defaultSkillsListMenu", {
name: "SETTINGS.DefaultSkillsList.Title",
label: "SETTINGS.DefaultSkillsList.Label",
hint: "SETTINGS.DefaultSkillsList.Hint",
@@ -13,7 +15,7 @@ export const RegisterSettings = function () {
type: game.l5r5e.DefaultSkillsDialogL5r5e,
restricted: true, // GameMaster only
});
game.settings.register(CONFIG.l5r5e.systemName, "defaultSkillsList", {
game.settings.register(CONFIG.l5r5e.namespace, "defaultSkillsList", {
name: "System Migration Version",
scope: "world",
config: false,
@@ -21,7 +23,7 @@ export const RegisterSettings = function () {
default: game.l5r5e.HelpersL5r5e.getDefaultSkillsUuidFromPack(),
});
game.settings.register(CONFIG.l5r5e.systemName, "rnk-deleteOldMessage", {
game.settings.register(CONFIG.l5r5e.namespace, "rnk-deleteOldMessage", {
name: "SETTINGS.RollNKeep.DeleteOldMessage",
hint: "SETTINGS.RollNKeep.DeleteOldMessageHint",
scope: "world",
@@ -29,7 +31,7 @@ export const RegisterSettings = function () {
default: true,
type: Boolean,
});
game.settings.register(CONFIG.l5r5e.systemName, "initiative-setTn1OnTypeChange", {
game.settings.register(CONFIG.l5r5e.namespace, "initiative-setTn1OnTypeChange", {
name: "SETTINGS.Initiative.SetTn1OnTypeChange",
hint: "SETTINGS.Initiative.SetTn1OnTypeChangeHint",
scope: "world",
@@ -37,14 +39,14 @@ export const RegisterSettings = function () {
type: Boolean,
default: true,
});
game.settings.register(CONFIG.l5r5e.systemName, "token-reverseFatigueBar", {
game.settings.register(CONFIG.l5r5e.namespace, "token-reverseFatigueBar", {
name: "SETTINGS.ReverseFatigueBar",
scope: "world",
config: true,
type: Boolean,
default: false,
});
game.settings.register(CONFIG.l5r5e.systemName, "techniques-customs", {
game.settings.register(CONFIG.l5r5e.namespace, "techniques-customs", {
name: "SETTINGS.CustomTechniques.Title",
hint: "SETTINGS.CustomTechniques.Hint",
scope: "world",
@@ -52,11 +54,25 @@ export const RegisterSettings = function () {
type: Boolean,
default: false,
});
game.settings.register(CONFIG.l5r5e.namespace, "custom-compendium-name", {
name: "SETTINGS.CustomCompendiumName.Title",
hint: "SETTINGS.CustomCompendiumName.Hint",
scope: "world",
config: isBabeleRegistered,
requiresReload: true,
type: String,
default: "l5r5e-custom-compendiums",
onChange: (name) => {
if (!Babele.get().modules.find((module) => module.module === name)) {
ui.notifications.warn(game.i18n.format("SETTINGS.CustomCompendiumName.Notification", { name }), { permanent: true });
}
}
});
/* ------------------------------------ */
/* Update */
/* ------------------------------------ */
game.settings.register(CONFIG.l5r5e.systemName, "systemMigrationVersion", {
game.settings.register(CONFIG.l5r5e.namespace, "systemMigrationVersion", {
name: "System Migration Version",
scope: "world",
config: false,
@@ -67,7 +83,7 @@ export const RegisterSettings = function () {
/* ------------------------------------ */
/* Initiative Roll Dialog (GM only) */
/* ------------------------------------ */
game.settings.register(CONFIG.l5r5e.systemName, "initiative-difficulty-hidden", {
game.settings.register(CONFIG.l5r5e.namespace, "initiative-difficulty-hidden", {
name: "Initiative difficulty is hidden",
scope: "world",
config: false,
@@ -75,7 +91,7 @@ export const RegisterSettings = function () {
default: false,
onChange: () => game.l5r5e.HelpersL5r5e.notifyDifficultyChange(),
});
game.settings.register(CONFIG.l5r5e.systemName, "initiative-difficulty-value", {
game.settings.register(CONFIG.l5r5e.namespace, "initiative-difficulty-value", {
name: "Initiative difficulty value",
scope: "world",
config: false,
@@ -83,20 +99,20 @@ export const RegisterSettings = function () {
default: 2,
onChange: () => game.l5r5e.HelpersL5r5e.notifyDifficultyChange(),
});
game.settings.register(CONFIG.l5r5e.systemName, "initiative-encounter", {
game.settings.register(CONFIG.l5r5e.namespace, "initiative-encounter", {
name: "Initiative encounter type",
scope: "world",
config: false,
type: String,
default: "skirmish",
onChange: () => {
if (game.settings.get(CONFIG.l5r5e.systemName, "initiative-setTn1OnTypeChange")) {
game.settings.set(CONFIG.l5r5e.systemName, "initiative-difficulty-value", 1);
if (game.settings.get(CONFIG.l5r5e.namespace, "initiative-setTn1OnTypeChange")) {
game.settings.set(CONFIG.l5r5e.namespace, "initiative-difficulty-value", 1);
}
ui.combat.render(true);
},
});
game.settings.register(CONFIG.l5r5e.systemName, "initiative-prepared-character", {
game.settings.register(CONFIG.l5r5e.namespace, "initiative-prepared-character", {
name: "Initiative PC prepared or not",
scope: "world",
config: false,
@@ -107,7 +123,7 @@ export const RegisterSettings = function () {
ui.combat.render(true);
},
});
game.settings.register(CONFIG.l5r5e.systemName, "initiative-prepared-adversary", {
game.settings.register(CONFIG.l5r5e.namespace, "initiative-prepared-adversary", {
name: "Initiative NPC adversary are prepared or not",
scope: "world",
config: false,
@@ -118,7 +134,7 @@ export const RegisterSettings = function () {
ui.combat.render(true);
},
});
game.settings.register(CONFIG.l5r5e.systemName, "initiative-prepared-minion", {
game.settings.register(CONFIG.l5r5e.namespace, "initiative-prepared-minion", {
name: "Initiative NPC minion are prepared or not",
scope: "world",
config: false,
@@ -133,7 +149,7 @@ export const RegisterSettings = function () {
/* ------------------------------------ */
/* GM Monitor windows (GM only) */
/* ------------------------------------ */
game.settings.register(CONFIG.l5r5e.systemName, "gm-monitor-actors", {
game.settings.register(CONFIG.l5r5e.namespace, "gm-monitor-actors", {
name: "Gm Monitor",
scope: "world",
config: false,

View File

@@ -34,7 +34,7 @@ export class SocketHandlerL5r5e {
break;
default:
console.warn(new Error("L5R5E | This socket event is not supported"), payload);
console.warn(new Error("L5R5E | SH | This socket event is not supported"), payload);
break;
}
});
@@ -54,7 +54,7 @@ export class SocketHandlerL5r5e {
_onDeleteChatMessage(payload) {
// Only delete the message if the user is a GM (otherwise it has no real effect)
// Currently only used in RnK
if (!game.user.isFirstGM || !game.settings.get(CONFIG.l5r5e.systemName, "rnk-deleteOldMessage")) {
if (!game.user.isFirstGM || !game.settings.get(CONFIG.l5r5e.namespace, "rnk-deleteOldMessage")) {
return;
}
game.messages.get(payload.messageId)?.delete();
@@ -118,27 +118,27 @@ export class SocketHandlerL5r5e {
* }
* });
*
* @param {User[]} users Users list to trigger the DP (will be reduced to id for network perf.)
* @param {ActorL5r5e[]} actors Actors list to trigger the DP (will be reduced to uuid for network perf.)
* @param {Object} dpOptions Any DicePickerDialog.options
* @param {User[]} users Users list to trigger the DP (will be reduced to id for network perf.)
* @param {Actor[]} actors Actors list to trigger the DP (will be reduced to uuid for network perf.)
* @param {Object} dpOptions Any DicePickerDialog.options
*/
openDicePicker({ users = [], actors = [], dpOptions = {} }) {
// At least one user or one actor
if (foundry.utils.isEmpty(users) && foundry.utils.isEmpty(actors)) {
console.error("L5R5E | openDicePicker - 'users' and 'actors' are both empty, use at least one.");
console.error("L5R5E | SH | openDicePicker - 'users' and 'actors' are both empty, use at least one.");
return;
}
// Fail if dpOptions.actor* provided
if (!foundry.utils.isEmpty(dpOptions?.actorName)) {
console.error("L5R5E | openDicePicker - Do not use 'dpOptions.actorName', use 'actors' list instead.");
console.error("L5R5E | SH | openDicePicker - Do not use 'dpOptions.actorName', use 'actors' list instead.");
return;
}
if (!foundry.utils.isEmpty(dpOptions?.actorId)) {
console.error("L5R5E | openDicePicker - Do not use 'dpOptions.actorId', use 'actors' list instead.");
console.error("L5R5E | SH | openDicePicker - Do not use 'dpOptions.actorId', use 'actors' list instead.");
return;
}
if (!foundry.utils.isEmpty(dpOptions?.actor)) {
console.error("L5R5E | openDicePicker - Do not use 'dpOptions.actor', use 'actors' list instead.");
console.error("L5R5E | SH | openDicePicker - Do not use 'dpOptions.actor', use 'actors' list instead.");
return;
}