Skip to content

Commit

Permalink
DEVBUG (mercs): fix incorrect level computation from experience
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastientromp committed Oct 13, 2021
1 parent 933bd95 commit 5eac935
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
27 changes: 16 additions & 11 deletions core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@firestone-hs/retrieve-users-duels-runs": "^1.0.3",
"@firestone-hs/save-dungeon-loot-info": "^1.0.8",
"@firestone-hs/simulate-bgs-battle": "^1.1.120",
"@firestone-hs/trigger-process-mercenaries-review": "^1.0.3",
"@firestone-hs/trigger-process-mercenaries-review": "^1.0.4",
"@firestone-hs/user-bgs-post-match-stats": "^1.0.3",
"@ng-select/ng-select": "^6.1.0",
"@sebastientromp/ngx-charts": "^19.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CardsFacadeService } from '../../../../services/cards-facade.service';
<div class="role-icon" *ngIf="roleIcon"><img [src]="roleIcon" /></div>
<div class="name">
<span>{{ name }}</span>
<span class="level" *ngIf="level">({{ level }})</span>
<span class="level" *ngIf="level" helpTooltip="Current mercenary level">({{ level }})</span>
</div>
</div>
<div
Expand Down
3 changes: 3 additions & 0 deletions core/src/js/services/game-events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ export class GameEvents {
}

public async dispatchGameEvent(gameEvent) {
if (!gameEvent) {
return;
}
// if (gameEvent.Type !== 'GAME_STATE_UPDATE') {
// console.debug('[debug] game event', gameEvent.Type, gameEvent);
// }
Expand Down
11 changes: 2 additions & 9 deletions core/src/js/services/mercenaries/mercenaries-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,13 @@ export const getMercCardLevel = (cardId: string): number => {
};

export const getMercLevelFromExperience = (totalXp: number, referenceData: MercenariesReferenceData): number => {
if (totalXp <= 0) {
return null;
}

let currentLevel = 1;
let xpToAttribute = totalXp;
let currentLevel = 0;
for (const levelMapping of referenceData.mercenaryLevels) {
if (xpToAttribute < levelMapping.xpToNext) {
if (levelMapping.xpToNext > totalXp) {
break;
}
currentLevel++;
xpToAttribute -= levelMapping.xpToNext;
}

return currentLevel;
};

Expand Down

0 comments on commit 5eac935

Please sign in to comment.