Skip to content

Commit

Permalink
fix super troops issue (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
csuvajit committed Feb 27, 2024
1 parent b711b64 commit ad9dd00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clashofclans.js",
"version": "3.3.3",
"version": "3.3.4",
"description": "JavaScript library for interacting with the Clash of Clans API",
"author": "https://clashofclans.js.org",
"license": "MIT",
Expand Down
15 changes: 8 additions & 7 deletions src/struct/Unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ export class Unit {
this.dps = rawUnit!.dps[this.level - 1] ?? 0;
this.trainingTime = Number(rawUnit!.trainingTime);

const origin = data.troops.find((troop) => troop.village === 'home' && troop.name === original.name)!;
this.level = origin.level;
this.maxLevel = origin.maxLevel;
this.boostable = data.townHallLevel >= 11 && origin.level >= rawSuperUnit.minOriginalLevel;

this.upgradeCost = original.upgrade.cost[origin.level - 1] || 0;
const origin = data.troops.find((troop) => troop.village === 'home' && troop.name === original.name);
if (origin) {
this.level = origin.level;
this.maxLevel = origin.maxLevel;
this.boostable = data.townHallLevel >= 11 && origin.level >= rawSuperUnit.minOriginalLevel;
this.upgradeCost = original.upgrade.cost[origin.level - 1] || 0;
this.upgradeTime = original.upgrade.time[origin.level - 1] || 0;
}
this.upgradeResource = original.upgrade.resource;
this.upgradeTime = original.upgrade.time[origin.level - 1] || 0;
this.hallMaxLevel = original.levels[data.townHallLevel - 1] ?? this.maxLevel;
} else if (rawUnit) {
// special case for the builder base
Expand Down

1 comment on commit ad9dd00

@csuvajit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for clashofclans-js ready!

✅ Preview
https://clashofclans-m41ss43m5-csuvajit.vercel.app

Built with commit ad9dd00.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.