Merge branch 'dev' into dev_gennpc
# Conflicts: # system/styles/l5r5e.css # system/templates/actors/character/identity.html
This commit is contained in:
@@ -113,6 +113,13 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
return;
|
||||
}
|
||||
|
||||
// Casualties/Panic +/-
|
||||
html.find(".addsub-control").on("click", this._modifyCasualtiesOrPanic.bind(this));
|
||||
|
||||
if (this.actor.data.data.soft_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete the linked Actor (warlord/commander)
|
||||
html.find(".actor-remove-control").on("click", this._removeLinkedActor.bind(this));
|
||||
}
|
||||
@@ -152,7 +159,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
*/
|
||||
async _onDrop(event) {
|
||||
// *** Everything below here is only needed if the sheet is editable ***
|
||||
if (!this.isEditable) {
|
||||
if (!this.isEditable || this.actor.data.data.soft_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,7 +191,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
*/
|
||||
async _onDropActors(type, event) {
|
||||
// *** Everything below here is only needed if the sheet is editable ***
|
||||
if (!this.isEditable) {
|
||||
if (!this.isEditable || this.actor.data.data.soft_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -270,4 +277,53 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
}
|
||||
return this.actor.update({ data: actorData });
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Subtract Casualties/Panic (+/- buttons)
|
||||
* @param {Event} event
|
||||
* @private
|
||||
*/
|
||||
async _modifyCasualtiesOrPanic(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const elmt = $(event.currentTarget);
|
||||
const type = elmt.data("type");
|
||||
let mod = elmt.data("value");
|
||||
if (!mod) {
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case "casualties":
|
||||
await this.actor.update({
|
||||
data: {
|
||||
battle_readiness: {
|
||||
casualties_strength: {
|
||||
value: Math.max(
|
||||
0,
|
||||
this.actor.data.data.battle_readiness.casualties_strength.value + mod
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
break;
|
||||
|
||||
case "panic":
|
||||
await this.actor.update({
|
||||
data: {
|
||||
battle_readiness: {
|
||||
panic_discipline: {
|
||||
value: Math.max(0, this.actor.data.data.battle_readiness.panic_discipline.value + mod),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn("L5R5E | Unsupported type", type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
*/
|
||||
async _onDrop(event) {
|
||||
// *** Everything below here is only needed if the sheet is editable ***
|
||||
if (!this.isEditable) {
|
||||
if (!this.isEditable || this.actor.data.data.soft_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -310,6 +310,9 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
|
||||
// Others Advancements
|
||||
html.find(".item-advancement-choose").on("click", this._showDialogAddSubItem.bind(this));
|
||||
|
||||
// Fatigue/Strife +/-
|
||||
html.find(".addsub-control").on("click", this._modifyFatigueOrStrife.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,6 +509,48 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Subtract Fatigue/Strife (+/- buttons)
|
||||
* @param {Event} event
|
||||
* @private
|
||||
*/
|
||||
async _modifyFatigueOrStrife(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const elmt = $(event.currentTarget);
|
||||
const type = elmt.data("type");
|
||||
let mod = elmt.data("value");
|
||||
if (!mod) {
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case "fatigue":
|
||||
await this.actor.update({
|
||||
data: {
|
||||
fatigue: {
|
||||
value: Math.max(0, this.actor.data.data.fatigue.value + mod),
|
||||
},
|
||||
},
|
||||
});
|
||||
break;
|
||||
|
||||
case "strife":
|
||||
await this.actor.update({
|
||||
data: {
|
||||
strife: {
|
||||
value: Math.max(0, this.actor.data.data.strife.value + mod),
|
||||
},
|
||||
},
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn("L5R5E | Unsupported type", type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch Readied state on a weapon
|
||||
* @param {Event} event
|
||||
|
||||
@@ -17,15 +17,40 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the SendToChat button on top of sheet
|
||||
* @override
|
||||
* Add buttons to L5R specific bar
|
||||
* @return {{label: string, class: string, icon: string, onclick: Function|null}[]}
|
||||
*/
|
||||
_getHeaderButtons() {
|
||||
let buttons = super._getHeaderButtons();
|
||||
_getL5rHeaderButtons() {
|
||||
/**
|
||||
* @var {{label: string, class: string, icon: string, onclick: Function|null}[]}
|
||||
*/
|
||||
const buttons = [];
|
||||
|
||||
if (this.isEditable && !this.actor.limited) {
|
||||
// Lock/Unlock
|
||||
buttons.unshift({
|
||||
label: `l5r5e.global.${this.actor.data.data.soft_locked ? "" : "un"}locked`,
|
||||
class: "l5r-softlock",
|
||||
icon: this.actor.data.data.soft_locked ? "fas fa-lock" : "fas fa-unlock",
|
||||
onclick: () =>
|
||||
game.l5r5e.HelpersL5r5e.debounce(
|
||||
"lock-" + this.object.id,
|
||||
() => {
|
||||
this.actor.update({
|
||||
data: {
|
||||
soft_locked: !this.actor.data.data.soft_locked,
|
||||
},
|
||||
});
|
||||
},
|
||||
500,
|
||||
true
|
||||
)(),
|
||||
});
|
||||
}
|
||||
|
||||
// Send To Chat
|
||||
buttons.unshift({
|
||||
label: game.i18n.localize("l5r5e.global.send_to_chat"),
|
||||
label: "l5r5e.global.send_to_chat",
|
||||
class: "send-to-chat",
|
||||
icon: "fas fa-comment-dots",
|
||||
onclick: () =>
|
||||
@@ -44,6 +69,9 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
getData(options = {}) {
|
||||
const sheetData = super.getData(options);
|
||||
|
||||
// System Header Buttons
|
||||
sheetData.l5rHeaderButtons = this._getL5rHeaderButtons();
|
||||
|
||||
sheetData.data.dtypes = ["String", "Number", "Boolean"];
|
||||
|
||||
// Sort Items by name
|
||||
@@ -51,6 +79,9 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
|
||||
// Shortcut for some tests
|
||||
sheetData.data.editable_not_soft_locked = sheetData.editable && !sheetData.data.data.soft_locked;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
@@ -106,6 +137,14 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
// Commons
|
||||
game.l5r5e.HelpersL5r5e.commonListeners(html, this.actor);
|
||||
|
||||
// System Header Buttons
|
||||
const l5rHeaderButtons = this._getL5rHeaderButtons();
|
||||
html.find(".l5r-header-button").click((event) => {
|
||||
event.preventDefault();
|
||||
const button = l5rHeaderButtons.find((b) => event.currentTarget.classList.contains(b.class));
|
||||
button.onclick(event);
|
||||
});
|
||||
|
||||
// *** Everything below here is only needed if the sheet is editable ***
|
||||
if (!this.isEditable) {
|
||||
return;
|
||||
|
||||
@@ -17,11 +17,12 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the TwentyQuestions button on top of sheet
|
||||
* Add the TwentyQuestions button in L5R specific bar
|
||||
* @override
|
||||
* @return {{label: string, class: string, icon: string, onclick: Function|null}[]}
|
||||
*/
|
||||
_getHeaderButtons() {
|
||||
let buttons = super._getHeaderButtons();
|
||||
_getL5rHeaderButtons() {
|
||||
const buttons = super._getL5rHeaderButtons();
|
||||
if (!this.isEditable || this.actor.limited) {
|
||||
return buttons;
|
||||
}
|
||||
@@ -151,17 +152,28 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
* @param formData
|
||||
*/
|
||||
_updateObject(event, formData) {
|
||||
// Store money in zeni
|
||||
formData["data.zeni"] = this._moneyToZeni(
|
||||
formData["data.money.koku"],
|
||||
formData["data.money.bu"],
|
||||
formData["data.money.zeni"]
|
||||
);
|
||||
// Store money in Zeni
|
||||
if (formData["data.money.koku"] || formData["data.money.bu"] || formData["data.money.zeni"]) {
|
||||
formData["data.zeni"] = this._moneyToZeni(
|
||||
formData["data.money.koku"] || 0,
|
||||
formData["data.money.bu"] || 0,
|
||||
formData["data.money.zeni"] || 0
|
||||
);
|
||||
// Remove fake money object
|
||||
delete formData["data.money.koku"];
|
||||
delete formData["data.money.bu"];
|
||||
delete formData["data.money.zeni"];
|
||||
}
|
||||
|
||||
// Remove fake money object
|
||||
delete formData["data.money.koku"];
|
||||
delete formData["data.money.bu"];
|
||||
delete formData["data.money.zeni"];
|
||||
// Save computed values
|
||||
const currentData = this.object.data.data;
|
||||
formData["data.focus"] = currentData.focus;
|
||||
formData["data.vigilance"] = currentData.vigilance;
|
||||
formData["data.endurance"] = currentData.endurance;
|
||||
formData["data.composure"] = currentData.composure;
|
||||
formData["data.fatigue.max"] = currentData.fatigue.max;
|
||||
formData["data.strife.max"] = currentData.strife.max;
|
||||
formData["data.void_points.max"] = currentData.void_points.max;
|
||||
|
||||
return super._updateObject(event, formData);
|
||||
}
|
||||
|
||||
@@ -245,6 +245,7 @@ export class TwentyQuestions {
|
||||
parseInt(formData.step18.heritage_add_honor);
|
||||
|
||||
// Update the actor
|
||||
actorDatas.soft_locked = true;
|
||||
actorDatas.template = formData.template;
|
||||
actorDatas.zeni = Math.floor(formData.step2.wealth * 50);
|
||||
actorDatas.identity = {
|
||||
|
||||
Reference in New Issue
Block a user