some change on items
This commit is contained in:
@@ -31,7 +31,44 @@ export class ActorSheetL5r5e extends BaseSheetL5r5e {
|
||||
await new TwentyQuestionsDialog({}, this.actor).render(true);
|
||||
},
|
||||
});
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commons datas
|
||||
*/
|
||||
getData() {
|
||||
const sheetData = super.getData();
|
||||
|
||||
// Sort Items by rank 0->6 for advancements tab
|
||||
sheetData.items.sort((a, b) => {
|
||||
return (a.data.bought_at_rank || 0) - (b.data.bought_at_rank || 0);
|
||||
});
|
||||
|
||||
// Xp spent only in current rank
|
||||
sheetData.data.advancement.xp_spent_rank = this.getXpSpentInThisRank();
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current total xp spent for this rank
|
||||
*/
|
||||
getXpSpentInThisRank() {
|
||||
const currentRank = this.actor.data.data.identity.school_rank || 0;
|
||||
const spent = this.actor.items.reduce((tot, item) => {
|
||||
// TODO c'est bien par rang actuel +1 ?
|
||||
if (currentRank + 1 === item.data.data.rank) {
|
||||
let xp = item.data.data.xp_used || 0;
|
||||
|
||||
// if not in curriculum, xp spent /2 for this item
|
||||
if (!item.data.data.in_curriculum && xp > 0) {
|
||||
xp = Math.floor(xp / 2);
|
||||
}
|
||||
return tot + xp;
|
||||
}
|
||||
return tot;
|
||||
}, 0);
|
||||
return spent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
getData() {
|
||||
const sheetData = super.getData();
|
||||
|
||||
sheetData.data.dtypes = ["String", "Number", "Boolean"];
|
||||
sheetData.data.stances = CONFIG.L5r5e.stances;
|
||||
|
||||
return sheetData;
|
||||
@@ -48,41 +49,35 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
return;
|
||||
}
|
||||
|
||||
// *** Items / Inventory ***
|
||||
html.find(".item-edit").on("click", (ev) => {
|
||||
this._editSubItem(ev, "item");
|
||||
});
|
||||
html.find(".item-delete").on("click", (ev) => {
|
||||
this._deleteSubItem(ev, "item");
|
||||
// *** Items : edit, delete ***
|
||||
["item", "peculiarity", "technique", "advancement"].forEach((type) => {
|
||||
html.find(`.${type}-edit`).on("click", (ev) => {
|
||||
this._editSubItem(ev, type);
|
||||
});
|
||||
html.find(`.${type}-delete`).on("click", (ev) => {
|
||||
this._deleteSubItem(ev, type);
|
||||
});
|
||||
|
||||
if (type !== "item") {
|
||||
html.find(`.${type}-curriculum`).on("click", (ev) => {
|
||||
this._switchSubItemCurriculum(ev, type);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// *** Techniques ***
|
||||
// *** Items : add ***
|
||||
html.find(".technique-add").on("click", (ev) => {
|
||||
this._addSubItem({
|
||||
name: game.i18n.localize("l5r5e.techniques.title_new"),
|
||||
type: "technique",
|
||||
});
|
||||
});
|
||||
html.find(".technique-edit").on("click", (ev) => {
|
||||
this._editSubItem(ev, "technique");
|
||||
});
|
||||
html.find(".technique-delete").on("click", (ev) => {
|
||||
this._deleteSubItem(ev, "technique");
|
||||
});
|
||||
|
||||
// *** Advancement ***
|
||||
html.find(".advancement-add").on("click", (ev) => {
|
||||
this._addSubItem({
|
||||
name: game.i18n.localize("l5r5e.xp.advancements"),
|
||||
name: game.i18n.localize("l5r5e.advancements.title_new"),
|
||||
type: "advancement",
|
||||
});
|
||||
});
|
||||
html.find(".advancement-edit").on("click", (ev) => {
|
||||
this._editSubItem(ev, "advancement");
|
||||
});
|
||||
html.find(".advancement-delete").on("click", (ev) => {
|
||||
this._deleteSubItem(ev, "advancement");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,4 +110,19 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
const li = $(ev.currentTarget).parents("." + type);
|
||||
return this.actor.deleteOwnedItem(li.data(type + "Id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch "in_curriculum"
|
||||
* @private
|
||||
*/
|
||||
_switchSubItemCurriculum(ev, type) {
|
||||
const li = $(ev.currentTarget).parents("." + type);
|
||||
const itemId = li.data(type + "Id");
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
return item.update({
|
||||
data: {
|
||||
in_curriculum: !item.data.data.in_curriculum,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,21 +128,21 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(event.dataTransfer.getData("text/plain"));
|
||||
if (data.type !== "Item") return;
|
||||
|
||||
const item = game.items.get(data.id);
|
||||
|
||||
if (item.data.type !== type) {
|
||||
if (data.type !== "Item") {
|
||||
return;
|
||||
}
|
||||
|
||||
const item = game.items.get(data.id);
|
||||
if (item || item.data.type !== type) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO
|
||||
console.log("** OK ", item);
|
||||
// sub_type === 'peculiarity'
|
||||
} catch (err) {
|
||||
return false;
|
||||
console.warn(err);
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user