diff --git a/CHANGELOG.md b/CHANGELOG.md index addaa1bc..4231f252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ * Purchasing Signature Abilities now takes these links into account, if defined * Purchasing Force Powers now checks the required force rating * Sheets now default to the v2 version (they can still be manually changed back to v1) + * Species can now have starting XP defined + * Dragging a species onto a player character grants the starting XP + * The importer has been updated to import starting XP * Fixes: * Sending a signature ability to chat now includes purchased upgrades * Granting XP to the entire group now updates the XP logs diff --git a/lang/en.json b/lang/en.json index 3cec955b..8a06d11b 100644 --- a/lang/en.json +++ b/lang/en.json @@ -283,6 +283,8 @@ "SWFFG.GrantXP": "Grant XP", "SWFFG.GrantXPTo": "Grant XP to", "SWFFG.GrantXPToAllCharacters": "Grant XP to all characters", + "SWFFG.GrantXPSpecies": "received species {species}", + "SWFFG.StartingXP": "Starting XP", "SWFFG.ObligationTable": "Obligation Table", "SWFFG.DutyTable": "Duty Table", "SWFFG.Range": "Range", diff --git a/modules/actors/actor-sheet-ffg.js b/modules/actors/actor-sheet-ffg.js index 111a18e7..c4c22009 100644 --- a/modules/actors/actor-sheet-ffg.js +++ b/modules/actors/actor-sheet-ffg.js @@ -7,7 +7,7 @@ import DiceHelpers from "../helpers/dice-helpers.js"; import ActorOptions from "./actor-ffg-options.js"; import ImportHelpers from "../importer/import-helpers.js"; import ModifierHelpers from "../helpers/modifiers.js"; -import ActorHelpers, {xpLogSpend} from "../helpers/actor-helpers.js"; +import ActorHelpers, {xpLogEarn, xpLogSpend} from "../helpers/actor-helpers.js"; import ItemHelpers from "../helpers/item-helpers.js"; import EmbeddedItemHelpers from "../helpers/embeddeditem-helpers.js"; import {change_role, deregister_crew, build_crew_roll} from "../helpers/crew.js"; @@ -58,6 +58,24 @@ export class ActorSheetFFG extends ActorSheet { // Handle item sorting within the same Actor if ( this.actor.uuid === item.parent?.uuid ) return this._onSortItem(event, itemData); + if (this.actor.type === "character" && itemData.type === "species") { + // add starting XP from species + const curAvailable = parseInt(this.actor.system?.experience?.available); + const curTotal = parseInt(this.actor.system?.experience?.total); + const startingXP = parseInt(itemData.system?.startingXP); + await this.actor.update( + { + system: { + experience: { + available: curAvailable + startingXP, + total: curTotal + startingXP, + } + } + } + ); + await xpLogEarn(this.actor, startingXP, curAvailable + startingXP, curTotal + startingXP, game.i18n.format("SWFFG.GrantXPSpecies", {species: itemData.name}) ); + } + // Create the owned item return this._onDropItemCreate(itemData); } else { @@ -1435,11 +1453,11 @@ export class ActorSheetFFG extends ActorSheet { let sameActor = data.actorId === this.actor.id; if (!sameActor) { try { - this.actor.createEmbeddedDocuments("Item", [duplicate(data.data)]); // Create a new Item + this.actor.createEmbeddedDocuments("Item", [foundry.utils.duplicate(data.data)]); // Create a new Item const actor = game.actors.get(data.actorId); await actor.items.get(data.data._id)?.delete(); // Delete originating item from other actor } catch (err) { - CONFIG.logger.error(`Error transfering item between actors.`, err); + CONFIG.logger.error(`Error transferring item between actors.`, err); } } } diff --git a/modules/importer/oggdude/importers/species.js b/modules/importer/oggdude/importers/species.js index 66a4822a..7bc95949 100644 --- a/modules/importer/oggdude/importers/species.js +++ b/modules/importer/oggdude/importers/species.js @@ -27,6 +27,7 @@ export default class Species { attributes: {}, description: item.Description, talents: {}, + startingXP: item.StartingAttrs.Experience ? parseInt(item.StartingAttrs.Experience, 10) : 0, }; // populate starting characteristics diff --git a/template.json b/template.json index fef26337..8abfa473 100644 --- a/template.json +++ b/template.json @@ -764,7 +764,8 @@ }, "species": { "templates": ["core"], - "talents": {} + "talents": {}, + "startingXP": 0 }, "criticalinjury": { "templates": ["core"], diff --git a/templates/items/ffg-species-sheet.html b/templates/items/ffg-species-sheet.html index bcd8b28d..bab93127 100644 --- a/templates/items/ffg-species-sheet.html +++ b/templates/items/ffg-species-sheet.html @@ -38,6 +38,9 @@