also indicate conditions and skills in the spritesheet

This commit is contained in:
thmsn
2023-11-23 02:05:13 +00:00
parent 3758596a87
commit c1f67881c8
+41 -10
View File
@@ -25,7 +25,9 @@
border-color: yellow; border-color: yellow;
} }
.has-item { .has-item,
.has-condition,
.has-skill {
border-color: red; border-color: red;
} }
</style> </style>
@@ -35,19 +37,26 @@
// TODO: prepare / show a little items.py snippet for easy copy paste? // TODO: prepare / show a little items.py snippet for easy copy paste?
const current_itemset = "{{name}}"; const current_itemset = "{{name}}";
const itemsBySkin = {}; function mapBySkin(dictionary) {
for (const itemKey in G.items) { const bySkin = {};
const item = G.items[itemKey]; for (const key in dictionary) {
if (!item.skin) continue; const value = dictionary[key];
item.id = itemKey; if (!value.skin) continue;
value.id = key;
if (!itemsBySkin[item.skin]) { if (!bySkin[value.skin]) {
itemsBySkin[item.skin] = []; bySkin[value.skin] = [];
}
bySkin[value.skin].push(value);
} }
return bySkin;
itemsBySkin[item.skin].push(item);
} }
const itemsBySkin = mapBySkin(G.items);
const conditionsBySkin = mapBySkin(G.conditions);
const skillsBySkin = mapBySkin(G.skills);
// lookup table to look up skin name in G.positions by x,y coordinates // lookup table to look up skin name in G.positions by x,y coordinates
const skinByXY = {}; const skinByXY = {};
for (const skin in G.positions) { for (const skin in G.positions) {
@@ -80,6 +89,8 @@
let hasPosition = false; let hasPosition = false;
let hasItem = false; let hasItem = false;
let hasCondition = false;
let hasSkill = false;
let title = [`${x},${y}`]; let title = [`${x},${y}`];
for (const skin of skins) { for (const skin of skins) {
const position = G.positions[skin]; const position = G.positions[skin];
@@ -95,6 +106,18 @@
hasItem = true; hasItem = true;
} }
const conditions = conditionsBySkin[skin] ?? [];
for (const item of conditions) {
title.push(`G.conditions.${item.id} = ${item.name}`);
hasCondition = true;
}
const skills = skillsBySkin[skin] ?? [];
for (const item of skills) {
title.push(`G.skills.${item.id} = ${item.name}`);
hasSkill = true;
}
title.push(""); title.push("");
} }
@@ -106,6 +129,14 @@
$(element).addClass("has-item"); $(element).addClass("has-item");
} }
if (hasCondition) {
$(element).addClass("has-condition");
}
if (hasSkill) {
$(element).addClass("has-skill");
}
$(element).attr("title", title.join("\n")); $(element).attr("title", title.join("\n"));
} }