Some automatisations on advancements
Added xp cost for technique
This commit is contained in:
@@ -199,8 +199,9 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
});
|
||||
const item = this.actor.getOwnedItem(created._id);
|
||||
|
||||
// assign current school rank to the new tech
|
||||
if (item.data.type === "advancement") {
|
||||
// assign current school rank to the new adv/tech
|
||||
if (["advancement", "technique"].includes(item.data.type)) {
|
||||
item.data.data.rank = this.actor.data.data.identity.school_rank;
|
||||
item.data.data.bought_at_rank = this.actor.data.data.identity.school_rank;
|
||||
}
|
||||
|
||||
@@ -230,6 +231,25 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
return;
|
||||
}
|
||||
|
||||
// Specific advancements, remove 1 to selected ring/skill
|
||||
if (tmpItem.type === "advancement") {
|
||||
const actor = duplicate(this.actor.data.data);
|
||||
const itmData = tmpItem.data.data;
|
||||
if (itmData.advancement_type === "ring") {
|
||||
// Ring
|
||||
actor.rings[itmData.ring] = Math.max(1, actor.rings[itmData.ring] - 1);
|
||||
} else {
|
||||
// Skill
|
||||
const skillCatId = CONFIG.l5r5e.skills.get(itmData.skill);
|
||||
actor.skills[skillCatId][itmData.skill] = Math.max(0, actor.skills[skillCatId][itmData.skill] - 1);
|
||||
}
|
||||
|
||||
// Update Actor
|
||||
this.actor.update({
|
||||
data: diffObject(this.actor.data.data, actor),
|
||||
});
|
||||
}
|
||||
|
||||
return this.actor.deleteOwnedItem(itemId);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
sheetData.data.xp_spent_rank = totalXp.rank;
|
||||
sheetData.data.xp_spent = totalXp.total;
|
||||
sheetData.data.xp_saved = sheetData.data.xp_total - sheetData.data.xp_spent;
|
||||
sheetData.data.xp_goal = CONFIG.l5r5e.xpPerRank[this.actor.data.data.identity.school_rank - 1] || null;
|
||||
sheetData.data.xp_goal = CONFIG.l5r5e.xp.costPerRank[this.actor.data.data.identity.school_rank - 1] || null;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
}
|
||||
const stepKey = $(event.target).data("step");
|
||||
if (!stepKey) {
|
||||
console.log("event stepKey is undefined");
|
||||
console.warn("event stepKey is undefined");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
(type !== "item" && item.data.type !== type) ||
|
||||
(type === "item" && !["item", "weapon", "armor"].includes(item.data.type))
|
||||
) {
|
||||
console.log("forbidden item for this drop zone", type, item.data.type);
|
||||
console.warn("forbidden item for this drop zone", type, item.data.type);
|
||||
return;
|
||||
}
|
||||
// Add the item (step and cache)
|
||||
|
||||
@@ -208,7 +208,7 @@ export class TwentyQuestions {
|
||||
* Fill a actor data from this object
|
||||
*/
|
||||
async toActor(actor, itemsCache) {
|
||||
const actorDatas = actor.data.data;
|
||||
const actorDatas = duplicate(actor.data.data);
|
||||
const formData = this.data;
|
||||
|
||||
// Update the actor real datas
|
||||
@@ -280,7 +280,7 @@ export class TwentyQuestions {
|
||||
// Update actor
|
||||
actor.update({
|
||||
name: (formData.step2.family + " " + formData.step19.firstname).trim(),
|
||||
data: actorDatas,
|
||||
data: diffObject(actor.data.data, actorDatas),
|
||||
});
|
||||
|
||||
// TODO Tmp
|
||||
|
||||
Reference in New Issue
Block a user