-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
252 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
system/src/apps/CompendiumItemSelectors/BackgroundSelector.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import CompendiumItemSelector from "../CompendiumItemSelector"; | ||
|
||
export default class BackgroundSelector extends CompendiumItemSelector { | ||
|
||
closeOnSelection = true; | ||
|
||
maxChoices = 1; | ||
|
||
get prompt() { | ||
return game.i18n.localize("SHADOWDARK.dialog.select_background.prompt"); | ||
} | ||
|
||
get title() { | ||
return game.i18n.localize("SHADOWDARK.dialog.select_background.title"); | ||
} | ||
|
||
async getAvailableItems() { | ||
return await shadowdark.compendiums.backgrounds(); | ||
} | ||
|
||
async getUuids() { | ||
const uuid = this.object?.system?.background; | ||
|
||
return uuid !== "" ? [uuid] : []; | ||
} | ||
|
||
async saveUuids(uuids) { | ||
const uuid = uuids[0] ?? ""; | ||
|
||
return this.object.update({ | ||
"system.background": uuid, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export {default as AncestrySelector} from "./AncestrySelector.mjs"; | ||
export {default as ArmorPropertySelector} from "./ArmorPropertySelector.mjs"; | ||
export {default as BackgroundSelector} from "./BackgroundSelector.mjs"; | ||
export {default as ClassSelector} from "./ClassSelector.mjs"; | ||
export {default as LanguageSelector} from "./LanguageSelector.mjs"; | ||
export {default as WeaponPropertySelector} from "./WeaponPropertySelector.mjs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { UpdateBaseSD } from "../UpdateBaseSD.mjs"; | ||
|
||
export default class Update_230922_1 extends UpdateBaseSD { | ||
static version = 230922.1; | ||
|
||
async updateActor(actorData) { | ||
if (actorData.type !== "Player") return; | ||
|
||
return {"system.-=title": null}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { UpdateBaseSD } from "../UpdateBaseSD.mjs"; | ||
|
||
// Migrates a character actor's Ancesty from a free text field to a uuid | ||
// compendium link | ||
// | ||
// Attempts to match any current value to a uuid compendium link if there is | ||
// a match on the slugified names | ||
|
||
export default class Update_230923_1 extends UpdateBaseSD { | ||
static version = 230923.1; | ||
|
||
async updateActor(actorData) { | ||
if (actorData.type !== "Player") return; | ||
|
||
const updateData = { | ||
"system.background": "", | ||
}; | ||
|
||
const currentValue = actorData.system?.background ?? ""; | ||
|
||
if (currentValue !== "") { | ||
const itemLut = {}; | ||
(await shadowdark.compendiums.backgrounds()).forEach( | ||
item => itemLut[item.name.slugify()] = item.uuid | ||
); | ||
|
||
const matchingItem = itemLut[currentValue.slugify()]; | ||
|
||
if (matchingItem) { | ||
updateData["system.background"] = matchingItem; | ||
} | ||
else { | ||
ui.notifications.warn( | ||
game.i18n.format( | ||
"Background '{itemName}' for Character '{name}' does not exist in a compendium; you will need to create this Item and update the Character manually.", | ||
{ | ||
itemName: currentValue, | ||
name: actorData.name, | ||
} | ||
), | ||
{permanent: true} | ||
); | ||
} | ||
} | ||
|
||
return updateData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.