Added a "description" field on the PC/NPC sheet, displayed in limited view

This commit is contained in:
Vlyan
2021-05-26 13:55:39 +02:00
parent c82a3324d8
commit b883689b63
8 changed files with 60 additions and 68 deletions

View File

@@ -134,7 +134,7 @@ export class BaseSheetL5r5e extends ActorSheet {
* @override
*/
activateEditor(name, options = {}, initialContent = "") {
if (name === "data.notes.value" && initialContent) {
if (["data.notes", "data.description"].includes(name) && initialContent) {
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
}
super.activateEditor(name, options, initialContent);
@@ -148,8 +148,11 @@ export class BaseSheetL5r5e extends ActorSheet {
* @override
*/
async _updateObject(event, formData) {
if (formData["data.notes.value"]) {
formData["data.notes.value"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.notes.value"], true);
if (formData["data.notes"]) {
formData["data.notes"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.notes"], true);
}
if (formData["data.description"]) {
formData["data.description"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.description"], true);
}
return super._updateObject(event, formData);
}

View File

@@ -22,7 +22,7 @@ export default class HooksL5r5e {
*/
static async ready() {
// Migration stuff
if (game.l5r5e.migrations.needUpdate()) {
if (game.l5r5e.migrations.needUpdate(game.l5r5e.migrations.NEEDED_VERSION)) {
game.l5r5e.migrations.migrateWorld();
}

View File

@@ -9,12 +9,13 @@ export class MigrationL5r5e {
static NEEDED_VERSION = "1.3.0";
/**
* Return true if the current world need some updates
* @returns {boolean}
* Return true if the version need some updates
* @param {string} version
* @return {boolean}
*/
static needUpdate() {
static needUpdate(version) {
const currentVersion = game.settings.get("l5r5e", "systemMigrationVersion");
return currentVersion && foundry.utils.isNewerVersion(MigrationL5r5e.NEEDED_VERSION, currentVersion);
return currentVersion && foundry.utils.isNewerVersion(version, currentVersion);
}
/**
@@ -26,6 +27,10 @@ export class MigrationL5r5e {
return;
}
// if (MigrationL5r5e.needUpdate("1.3.0")) {
// ChatMessage.create({"content": "<strong>L5R5E v1.3.0 :</strong><br>"});
// }
// Warn the users
ui.notifications.info(
`Applying L5R5e System Migration for version ${game.system.data.version}.` +
@@ -190,35 +195,42 @@ export class MigrationL5r5e {
const actorData = actor.data;
// ***** Start of 1.1.0 *****
// Add "Prepared" in actor
if (actorData.prepared === undefined) {
updateData["data.prepared"] = true;
}
if (MigrationL5r5e.needUpdate("1.1.0")) {
// Add "Prepared" in actor
if (actorData.prepared === undefined) {
updateData["data.prepared"] = true;
}
// NPC are now without autostats, we need to save the value
if (actor.type === "npc") {
if (actorData.endurance < 1) {
updateData["data.endurance"] = (Number(actorData.rings.earth) + Number(actorData.rings.fire)) * 2;
updateData["data.composure"] = (Number(actorData.rings.earth) + Number(actorData.rings.water)) * 2;
updateData["data.focus"] = Number(actorData.rings.air) + Number(actorData.rings.fire);
updateData["data.vigilance"] = Math.ceil(
(Number(actorData.rings.air) + Number(actorData.rings.water)) / 2
);
// NPC are now without autostats, we need to save the value
if (actor.type === "npc") {
if (actorData.endurance < 1) {
updateData["data.endurance"] = (Number(actorData.rings.earth) + Number(actorData.rings.fire)) * 2;
updateData["data.composure"] = (Number(actorData.rings.earth) + Number(actorData.rings.water)) * 2;
updateData["data.focus"] = Number(actorData.rings.air) + Number(actorData.rings.fire);
updateData["data.vigilance"] = Math.ceil(
(Number(actorData.rings.air) + Number(actorData.rings.water)) / 2
);
}
}
}
// ***** End of 1.1.0 *****
// ***** Start of 1.3.0 *****
// NPC have now more thant a Strength and a Weakness
if (actor.type === "npc" && actorData.rings_affinities) {
updateData["data.rings_affinities." + actorData.rings_affinities.strength.ring] =
actorData.rings_affinities.strength.value;
updateData["data.rings_affinities." + actorData.rings_affinities.weakness.ring] =
actorData.rings_affinities.weakness.value;
if (MigrationL5r5e.needUpdate("1.3.0")) {
// PC/NPC removed notes useless props "value"
updateData["data.notes"] = actorData.notes.value;
// Delete old keys : not working :'(
updateData["-=data.rings_affinities.strength"] = null;
updateData["-=data.rings_affinities.weakness"] = null;
// NPC have now more thant a Strength and a Weakness
if (actor.type === "npc" && actorData.rings_affinities) {
updateData["data.rings_affinities." + actorData.rings_affinities.strength.ring] =
actorData.rings_affinities.strength.value;
updateData["data.rings_affinities." + actorData.rings_affinities.weakness.ring] =
actorData.rings_affinities.weakness.value;
// Delete old keys : not working :'(
updateData["-=data.rings_affinities.strength"] = null;
updateData["-=data.rings_affinities.weakness"] = null;
}
}
// ***** End of 1.3.0 *****