Working on 0.8.x
- Working on title - Added property update/delete for item patterns
This commit is contained in:
@@ -324,6 +324,10 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
event.stopPropagation();
|
||||
|
||||
const type = $(event.currentTarget).data("item-type");
|
||||
if (!type) {
|
||||
return;
|
||||
}
|
||||
|
||||
const titles = {
|
||||
item: "ITEM.TypeItem",
|
||||
armor: "ITEM.TypeArmor",
|
||||
@@ -336,6 +340,10 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
item_pattern: "ITEM.TypeItem_pattern",
|
||||
signature_scroll: "ITEM.TypeSignature_scroll",
|
||||
};
|
||||
if (!titles[type]) {
|
||||
return;
|
||||
}
|
||||
|
||||
const created = await this.actor.createEmbeddedDocuments("Item", [
|
||||
{
|
||||
name: game.i18n.localize(titles[type]),
|
||||
@@ -343,6 +351,9 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
img: `${CONFIG.l5r5e.paths.assets}icons/items/${type}.svg`,
|
||||
},
|
||||
]);
|
||||
if (created?.length > 0) {
|
||||
return;
|
||||
}
|
||||
const item = this.actor.items.get(created[0].id);
|
||||
|
||||
// assign current school rank to the new adv/tech
|
||||
@@ -385,7 +396,14 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
event.stopPropagation();
|
||||
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
if (!itemId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const item = this.actor.items.get(itemId);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
item.sheet.render(true);
|
||||
}
|
||||
|
||||
@@ -399,6 +417,9 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
event.stopPropagation();
|
||||
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
if (!itemId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove 1 qty if possible
|
||||
const tmpItem = this.actor.items.get(itemId);
|
||||
|
||||
@@ -334,7 +334,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
|
||||
if (this.object.data.step13.advantage.length > 0) {
|
||||
formData["step13.skill"] = "none";
|
||||
setProperty(this.object.data, "step13.disadvantage", []);
|
||||
foundry.utils.setProperty(this.object.data, "step13.disadvantage", []);
|
||||
}
|
||||
|
||||
// Update 20Q object data
|
||||
@@ -364,14 +364,14 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
this.cache = {};
|
||||
for (const stepName of TwentyQuestions.itemsList) {
|
||||
// Check if current step value is a array
|
||||
let step = getProperty(this.object.data, stepName);
|
||||
let step = foundry.utils.getProperty(this.object.data, stepName);
|
||||
if (!step || !Array.isArray(step)) {
|
||||
step = [];
|
||||
}
|
||||
|
||||
// Init cache if not exist
|
||||
if (!hasProperty(this.cache, stepName)) {
|
||||
setProperty(this.cache, stepName, []);
|
||||
if (!foundry.utils.hasProperty(this.cache, stepName)) {
|
||||
foundry.utils.setProperty(this.cache, stepName, []);
|
||||
}
|
||||
|
||||
// Get linked Item, and store it in cache (delete null value and old items)
|
||||
@@ -385,9 +385,9 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
continue;
|
||||
}
|
||||
newStep.push(id);
|
||||
getProperty(this.cache, stepName).push(item);
|
||||
foundry.utils.getProperty(this.cache, stepName).push(item);
|
||||
}
|
||||
setProperty(this.object.data, stepName, newStep);
|
||||
foundry.utils.setProperty(this.object.data, stepName, newStep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
roll.actor = this._actor;
|
||||
|
||||
await roll.roll();
|
||||
setProperty(this.object.data, stepName, roll.result);
|
||||
foundry.utils.setProperty(this.object.data, stepName, roll.result);
|
||||
return roll.toMessage({ flavor: flavor });
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
*/
|
||||
_addOwnedItem(item, stepName) {
|
||||
// Add to Step (uniq id only)
|
||||
let step = getProperty(this.object.data, stepName);
|
||||
let step = foundry.utils.getProperty(this.object.data, stepName);
|
||||
if (!step) {
|
||||
step = [];
|
||||
}
|
||||
@@ -420,7 +420,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
step.push(item.id);
|
||||
|
||||
// Add to cache
|
||||
getProperty(this.cache, stepName).push(item);
|
||||
foundry.utils.getProperty(this.cache, stepName).push(item);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,14 +429,14 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
*/
|
||||
_deleteOwnedItem(stepName, itemId) {
|
||||
// Delete from current step
|
||||
let step = getProperty(this.object.data, stepName);
|
||||
let step = foundry.utils.getProperty(this.object.data, stepName);
|
||||
step = step.filter((e) => !!e && e !== itemId);
|
||||
setProperty(this.object.data, stepName, step);
|
||||
foundry.utils.setProperty(this.object.data, stepName, step);
|
||||
|
||||
// Delete from cache
|
||||
let cache = getProperty(this.cache, stepName);
|
||||
let cache = foundry.utils.getProperty(this.cache, stepName);
|
||||
cache = cache.filter((e) => !!e && e.id !== itemId);
|
||||
setProperty(this.cache, stepName, cache);
|
||||
foundry.utils.setProperty(this.cache, stepName, cache);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,7 +444,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
* @private
|
||||
*/
|
||||
_getSkillZero(skillsList, skillsPoints, stepName) {
|
||||
const stepSkillId = getProperty(this.object.data, stepName);
|
||||
const stepSkillId = foundry.utils.getProperty(this.object.data, stepName);
|
||||
const out = {};
|
||||
Object.entries(skillsList).forEach(([cat, val]) => {
|
||||
out[cat] = val.filter(
|
||||
|
||||
@@ -267,7 +267,7 @@ export class TwentyQuestions {
|
||||
// Rings - Reset to 1, and apply modifiers
|
||||
CONFIG.l5r5e.stances.forEach((ring) => (actorDatas.rings[ring] = 1));
|
||||
TwentyQuestions.ringList.forEach((formName) => {
|
||||
const ring = getProperty(this.data, formName);
|
||||
const ring = foundry.utils.getProperty(this.data, formName);
|
||||
if (ring !== "none") {
|
||||
actorDatas.rings[ring] = actorDatas.rings[ring] + 1;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ export class TwentyQuestions {
|
||||
actorDatas.skills[skillCat][skillId] = 0;
|
||||
});
|
||||
TwentyQuestions.skillList.forEach((formName) => {
|
||||
const skillId = getProperty(this.data, formName);
|
||||
const skillId = foundry.utils.getProperty(this.data, formName);
|
||||
const skillCat = CONFIG.l5r5e.skills.get(skillId);
|
||||
if (skillId !== "none") {
|
||||
actorDatas.skills[skillCat][skillId] = actorDatas.skills[skillCat][skillId] + 1;
|
||||
@@ -292,7 +292,7 @@ export class TwentyQuestions {
|
||||
// Add items in 20Q to actor
|
||||
for (const types of Object.values(itemsCache)) {
|
||||
for (const item of types) {
|
||||
const itemData = duplicate(item.data);
|
||||
const itemData = foundry.utils.duplicate(item.data);
|
||||
if (itemData.data?.bought_at_rank) {
|
||||
itemData.data.bought_at_rank = 0;
|
||||
}
|
||||
@@ -377,7 +377,7 @@ export class TwentyQuestions {
|
||||
summariesRingsOrSkills(listName) {
|
||||
const store = {};
|
||||
TwentyQuestions[listName].forEach((formName) => {
|
||||
const id = getProperty(this.data, formName);
|
||||
const id = foundry.utils.getProperty(this.data, formName);
|
||||
if (!id || id === "none") {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user