Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue where multiple weapons of same type was not showing #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/files
1 change: 0 additions & 1 deletion .gitignore/.gitignore

This file was deleted.

12 changes: 6 additions & 6 deletions bin/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ module.exports = class Model {
this.rules.push(ruleName);
}

addWeaponData (weaponData, selection) {
addWeaponData (weaponData, selection, numberOfModelsInUnit) {
let newMatch = weaponData.$.name.match(weaponNameWithoutNumberRegex).groups,
selectionNumber = selection.$.name.match(weaponNameWithoutNumberRegex).groups.number,
newNumber = newMatch.number ? parseInt(newMatch.number, 10) : selectionNumber ? parseInt(selectionNumber, 10) : 1;
newNumber = parseInt(selection.$.number, 10) / numberOfModelsInUnit;

for (const weapon of this.weapons) {
if (weapon.name === newMatch.weaponName) {
Expand All @@ -37,7 +37,7 @@ module.exports = class Model {
this.weapons.push({ name: newMatch.weaponName, number: newNumber });
}

handleSelectionDataRecursive (selectionData) {
handleSelectionDataRecursive (selectionData, numberOfModelsInUnit) {
for (const selection of selectionData[0].selection) {
if (selection.profiles && selection.profiles[0] !== "")
for (const profile of selection.profiles[0].profile)
Expand All @@ -55,15 +55,15 @@ module.exports = class Model {

if (0 < ignore) continue;

this.addWeaponData(profile, selection);
this.addWeaponData(profile, selection, numberOfModelsInUnit);
break;
case "abilities":
this.addAbilityData(profile);
break;
}

if (selection.selections && selection.selections[0] !== "")
this.handleSelectionDataRecursive(selection.selections);
this.handleSelectionDataRecursive(selection.selections, numberOfModelsInUnit);
}
}

Expand Down Expand Up @@ -101,4 +101,4 @@ module.exports = class Model {

return true;
}
}
}
4 changes: 2 additions & 2 deletions bin/ModelCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = class ModelCollection {
//console.log("selections: " + selectionData);

if (selectionData && selectionData[0] !== "" && selectionData[0].selection)
newModel.handleSelectionDataRecursive(selectionData);
newModel.handleSelectionDataRecursive(selectionData, newModel.number);

this.add(newModel);
}
Expand Down Expand Up @@ -137,4 +137,4 @@ module.exports = class ModelCollection {
delete this.models[name];
}
}
}
}
2 changes: 1 addition & 1 deletion lua_modules/MatchedPlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function hideCard(player, card)
if element.attributes ~= nil and
element.attributes.id ~= nil and
(element.attributes.id:find("^ymc%-")) ~= nil and -- if we find a card
element.attributes.active = true then
element.attributes.active == true then
return -- we found a card that is still visible, so we dont want to reset the UI
end

Expand Down