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

@@ -13,6 +13,7 @@ __! Be certain to carefully back up any critical user data before installing thi
- To change the linked property, drop any property on the item pattern sheet.
- Added an optional "Specificity" technique type to serve as a catch-all (by request).
- Added Mantis Clan compendium entries.
- Added a "Description" in PC/NPC sheet: this field is used in limited view (public description, "notes" are private).
- Fix : rnkMessage not passing on actor object for NPCs (thanks to Bragma).
- Fix : The "Crescent Moon Style" technique rank from 4 to 2.
- Fix : Drop an advancement on a PC/NPC sheet now correctly add the bonus to the Actor (ex Air +1).

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 *****

View File

@@ -21,6 +21,8 @@
}
},
"social": {
"notes": "",
"description": "",
"social": {
"honor": 0,
"glory": 0,
@@ -109,14 +111,12 @@
"character": {
"templates": ["identity", "rings", "social", "skills", "techniques", "conflict", "advancement"],
"zeni": 0,
"notes": "",
"twenty_questions": {}
},
"npc": {
"templates": ["rings", "social", "techniques", "conflict"],
"type": "minion",
"attitude": "",
"notes": "",
"conflict_rank": {
"martial": 0,
"social": 0

View File

@@ -55,7 +55,15 @@
</ul>
</fieldset>
</div>
{{!-- Description (npc have it on header) --}}
{{#ifCond data.type '==' "character"}}
<fieldset class="narrative-description">
<legend class="text-block-header">{{localize 'l5r5e.description' }}</legend>
{{editor content=data.data.description target="data.description" button=true editable=options.editable}}
</fieldset>
{{/ifCond}}
{{!-- Notes (private) --}}
<fieldset class="narrative-note">
<legend class="text-block-header">{{localize 'l5r5e.notes' }}</legend>
{{editor content=data.data.notes.value target="data.notes.value" button=true editable=options.editable}}
{{editor content=data.data.notes target="data.notes" button=true editable=options.editable}}
</fieldset>

View File

@@ -3,38 +3,6 @@
{{!-- Sheet Header --}}
<div class="sheet-header">
<h1 class="charname"><input name="name" type="text" value="{{data.name}}" placeholder="Name"/></h1>
{{!-- Sheet identity --}}
<ul class="identity-content">
<li>
<label class="attribute-label">
{{localize 'l5r5e.clan'}}
<input type="text" name="data.identity.clan" value="{{data.data.identity.clan}}"/>
</label>
</li>
<li>
<label class="attribute-label">
{{localize 'l5r5e.family'}}
<input type="text" name="data.identity.family" value="{{data.data.identity.family}}"/>
</label>
</li>
<li>
<label class="attribute-label">
{{localize 'l5r5e.schoolrank'}}
<input type="number" name="data.identity.school_rank" value="{{data.data.identity.school_rank}}" class="select-on-focus" data-dtype="Number" min="1" placeholder="1"/>
</label>
</li>
<li>
<label class="attribute-label">
{{localize 'l5r5e.school'}}
<input type="text" name="data.identity.school" value="{{data.data.identity.school}}"/>
</label>
</li>
<li>
<label class="attribute-label">
{{localize 'l5r5e.roles'}}
<input type="text" name="data.identity.roles" value="{{data.data.identity.roles}}"/>
</label>
</li>
</ul>
{{{data.data.description}}}
</div>
</form>

View File

@@ -7,8 +7,8 @@
{{> 'systems/l5r5e/templates/actors/npc/identity.html'}}
</div>
<fieldset class="npc-note">
<legend class="text-block-header">{{localize 'l5r5e.notes'}}</legend>
{{editor content=data.data.notes.value target="data.notes.value" button=true editable=options.editable}}
<legend class="text-block-header">{{localize 'l5r5e.description'}}</legend>
{{editor content=data.data.description target="data.description" button=true editable=options.editable}}
</fieldset>
<div class="header-fields">
<h2>{{localize 'l5r5e.social.title'}}</h2>