Skip to content

Commit

Permalink
fix: double jersey/broom-wagon showing on cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliboy50 committed Feb 29, 2024
1 parent 5f72a65 commit c638d97
Showing 1 changed file with 6 additions and 40 deletions.
46 changes: 6 additions & 40 deletions velonimo.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,10 +946,7 @@ function (dojo, declare) {
}
dojo.toggleClass(DOM_ID_ACTION_BUTTON_GIVE_CARDS, DOM_CLASS_DISABLED_ACTION_BUTTON, (selectedCards.length === 0) || (selectedCards.length !== this.howManyCardsToGiveBack));
},
/**
* @param {number=} previousJerseyWearerId
*/
moveJerseyToCurrentWinner: function (previousJerseyWearerId) {
moveJerseyToCurrentWinner: function () {
const card = this.addSpecialCardsToCards([CARD_ID_JERSEY_PLUS_TEN], [])[0];
const tooltipTexts = this.getTooltipTextsForCard(card);
const position = this.getCardPositionInSpriteByColorAndValue(card.color, card.value);
Expand All @@ -965,6 +962,7 @@ function (dojo, declare) {
};
const removeJersey = (playerId) => {
dojo.removeClass(`player-table-${playerId}`, DOM_CLASS_PLAYER_HAS_JERSEY);
this.fadeOutAndDestroy(`player-table-${playerId}-jersey`);
this.fadeOutAndDestroy(`player-panel-${playerId}-jersey`);
};

Expand All @@ -984,10 +982,7 @@ function (dojo, declare) {
}
});
},
/**
* @param {number=} previousLegendsBroomWagonHolderId
*/
moveLegendsBroomWagonToLastLoser: function (previousLegendsBroomWagonHolderId) {
moveLegendsBroomWagonToLastLoser: function () {
if (!this.isExtensionLegendsEnabled) {
return;
}
Expand All @@ -1007,6 +1002,7 @@ function (dojo, declare) {
};
const removeLegendsBroomWagon = (playerId) => {
dojo.removeClass(`player-table-${playerId}`, DOM_CLASS_PLAYER_HAS_LEGENDS_BROOM_WAGON);
this.fadeOutAndDestroy(`player-table-${playerId}-legends-broom-wagon`);
this.fadeOutAndDestroy(`player-panel-${playerId}-legends-broom-wagon`);
};

Expand Down Expand Up @@ -1113,34 +1109,6 @@ function (dojo, declare) {
}
return undefined;
},
/**
* @returns {number|undefined}
*/
getCurrentJerseyOwnerIdIfExists: function () {
const players = Object.entries(this.players);
for (let i = 0; i < players.length; i++) {
const player = players[i][1];
if (player.isWearingJersey) {
return player.id;
}
}

return undefined;
},
/**
* @returns {number|undefined}
*/
getCurrentLegendsBroomWagonOwnerIdIfExists: function () {
const players = Object.entries(this.players);
for (let i = 0; i < players.length; i++) {
const player = players[i][1];
if (player.hasCardLegendsBroomWagon) {
return player.id;
}
}

return undefined;
},
/**
* @param {number} cardId
*/
Expand Down Expand Up @@ -3435,16 +3403,14 @@ function (dojo, declare) {
this.removeCardFromPlayerHand(CARD_ID_LEGENDS_BROOM_WAGON_PLUS_FIVE);
}

const previousJerseyWearerId = this.getCurrentJerseyOwnerIdIfExists();
const previousLegendsBroomWagonOwnerId = this.getCurrentLegendsBroomWagonOwnerIdIfExists();
this.players = data.args.players;
this.resetDisplayedNumberOfCardsByPlayerId();
this.setupPlayersHiddenCards();
data.args.specialCardIdsToRestore.forEach((cardId) => {
this.restoreSpecialCardForCurrentRound(cardId);
});
this.moveLegendsBroomWagonToLastLoser(previousLegendsBroomWagonOwnerId);
this.moveJerseyToCurrentWinner(previousJerseyWearerId);
this.moveJerseyToCurrentWinner();
this.moveLegendsBroomWagonToLastLoser();

this.setupPlayersScore();
},
Expand Down

0 comments on commit c638d97

Please sign in to comment.