Skip to content

Commit

Permalink
Fixed bug regarding resistances
Browse files Browse the repository at this point in the history
When guessing a boss with a singular weakness/resistance, that is part of the correct answer's weaknesses/resistances, it's added now only if not already included, instead of the same damage type being added multiple times for each guess.
  • Loading branch information
malthesers committed Jul 18, 2023
1 parent 607446b commit cf17d89
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/Game.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ function validateGuess(boss) {
known.value.weaknesses = boss.weaknesses
} else {
correct.value.weaknesses.forEach(weakness => {
if (boss.weaknesses.includes(weakness) && boss.weaknesses.length === 1) {
// If guessed boss has 1 weakness part of the answer, add it to known weaknesses if not already added
if (boss.weaknesses.includes(weakness) && boss.weaknesses.length === 1 && !known.value.weaknesses.includes(weakness)) {
known.value.weaknesses.push(weakness)
}
})
Expand All @@ -117,7 +118,8 @@ function validateGuess(boss) {
known.value.resistances = boss.resistances
} else {
correct.value.resistances.forEach(resistance => {
if (boss.resistances.includes(resistance) && boss.resistances.length === 1) {
// If guessed boss has 1 resistance part of the answer, add it to known resistances if not already added
if (boss.resistances.includes(resistance) && boss.resistances.length === 1 && !known.value.resistances.includes(resistance)) {
known.value.resistances.push(resistance)
}
})
Expand Down

0 comments on commit cf17d89

Please sign in to comment.