Specific case for school_ability and mastery_ability on drop

This commit is contained in:
Vlyan
2021-01-02 14:09:34 +01:00
parent 331872e84f
commit 5afb766ee2
2 changed files with 15 additions and 6 deletions

View File

@@ -133,6 +133,11 @@ export class BaseSheetL5r5e extends ActorSheet {
}).render(true);
return;
}
// No cost for schools
item.data.data.xp_cost = 0;
item.data.data.xp_used = 0;
item.data.data.in_curriculum = true;
} else {
// Check if technique is allowed for this character
if (!game.user.isGM && !this.actor.data.data.techniques[item.data.data.technique_type]) {
@@ -148,15 +153,15 @@ export class BaseSheetL5r5e extends ActorSheet {
}).render(true);
return;
}
// Verify cost
item.data.data.xp_cost =
item.data.data.xp_cost > 0 ? item.data.data.xp_cost : CONFIG.l5r5e.xp.techniqueCost;
item.data.data.xp_used = item.data.data.xp_cost;
}
// Modify the bought at rank to the current actor rank
item.data.data.bought_at_rank = this.actor.data.data.identity.school_rank;
// Verify cost
item.data.data.xp_cost =
item.data.data.xp_cost > 0 ? item.data.data.xp_cost : CONFIG.l5r5e.xp.techniqueCost;
item.data.data.xp_used = item.data.data.xp_cost;
break;
}

View File

@@ -55,7 +55,11 @@ export class HelpersL5r5e {
* Return the target object on a drag n drop event, or null if not found
*/
static async getDragnDropTargetObject(event) {
const data = JSON.parse(event.dataTransfer.getData("text/plain"));
const json = event.dataTransfer.getData("text/plain");
if (!json) {
return null;
}
const data = JSON.parse(json);
return await HelpersL5r5e.getObjectGameOrPack(data.id, data.type, data.pack);
}