Skip to content

Commit

Permalink
fix: wheel bugs (#2417)
Browse files Browse the repository at this point in the history
Added some missing wheel modifiers.
Fixed some wrong wheel slots.
  • Loading branch information
dudantas authored Mar 18, 2024
1 parent 0346955 commit 39d0d84
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 7 deletions.
51 changes: 50 additions & 1 deletion src/creatures/players/wheel/player_wheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,47 @@ const static std::vector<WheelGemBasicModifier_t> wheelGemBasicSlot1Allowed = {
WheelGemBasicModifier_t::Vocation_Health_IceResistance,
WheelGemBasicModifier_t::Vocation_Health_EnergyResistance,
WheelGemBasicModifier_t::Vocation_Health_EarthResistance,
WheelGemBasicModifier_t::Vocation_Mana_FireResistance,
WheelGemBasicModifier_t::Vocation_Mana_EnergyResistance,
WheelGemBasicModifier_t::Vocation_Mana_Earth_Resistance,
WheelGemBasicModifier_t::Vocation_Mana_Ice_Resistance,
WheelGemBasicModifier_t::Vocation_Capacity_FireResistance,
WheelGemBasicModifier_t::Vocation_Capacity_EnergyResistance,
WheelGemBasicModifier_t::Vocation_Capacity_EarthResistance,
WheelGemBasicModifier_t::Vocation_Capacity_IceResistance,
};

const static std::vector<WheelGemBasicModifier_t> wheelGemBasicSlot2Allowed = {
WheelGemBasicModifier_t::General_FireResistance,
WheelGemBasicModifier_t::General_IceResistance,
WheelGemBasicModifier_t::General_EnergyResistance,
WheelGemBasicModifier_t::General_EarthResistance,
WheelGemBasicModifier_t::General_PhysicalResistance,
WheelGemBasicModifier_t::General_HolyResistance,
WheelGemBasicModifier_t::General_HolyResistance_DeathWeakness,
WheelGemBasicModifier_t::General_DeathResistance_HolyWeakness,
WheelGemBasicModifier_t::General_FireResistance_EarthResistance,
WheelGemBasicModifier_t::General_FireResistance_IceResistance,
WheelGemBasicModifier_t::General_FireResistance_EnergyResistance,
WheelGemBasicModifier_t::General_EarthResistance_IceResistance,
WheelGemBasicModifier_t::General_EarthResistance_EnergyResistance,
WheelGemBasicModifier_t::General_IceResistance_EnergyResistance,
WheelGemBasicModifier_t::General_FireResistance_EarthWeakness,
WheelGemBasicModifier_t::General_FireResistance_IceWeakness,
WheelGemBasicModifier_t::General_FireResistance_EnergyWeakness,
WheelGemBasicModifier_t::General_EarthResistance_FireWeakness,
WheelGemBasicModifier_t::General_EarthResistance_IceWeakness,
WheelGemBasicModifier_t::General_EarthResistance_EnergyWeakness,
WheelGemBasicModifier_t::General_IceResistance_EarthWeakness,
WheelGemBasicModifier_t::General_IceResistance_FireWeakness,
WheelGemBasicModifier_t::General_IceResistance_EnergyWeakness,
WheelGemBasicModifier_t::General_EnergyResistance_EarthWeakness,
WheelGemBasicModifier_t::General_EnergyResistance_IceWeakness,
WheelGemBasicModifier_t::General_EnergyResistance_FireWeakness,
WheelGemBasicModifier_t::General_ManaDrainResistance,
WheelGemBasicModifier_t::General_LifeDrainResistance,
WheelGemBasicModifier_t::General_ManaDrainResistance_LifeDrainResistance,
WheelGemBasicModifier_t::General_MitigationMultiplier,
};

// To avoid conflict in other files that might use a function with the same name
Expand Down Expand Up @@ -835,7 +876,7 @@ void PlayerWheel::revealGem(WheelGemQuality_t quality) {
gem.basicModifier2 = {};
gem.supremeModifier = {};
if (quality >= WheelGemQuality_t::Regular) {
gem.basicModifier2 = static_cast<WheelGemBasicModifier_t>(uniform_random(0, magic_enum::enum_count<WheelGemBasicModifier_t>() - 1));
gem.basicModifier2 = selectBasicModifier2(gem.basicModifier1);
}
if (quality >= WheelGemQuality_t::Greater && !supremeModifiers.empty()) {
gem.supremeModifier = supremeModifiers[uniform_random(0, supremeModifiers.size() - 1)];
Expand Down Expand Up @@ -3106,3 +3147,11 @@ float PlayerWheel::calculateMitigation() const {
mitigation += (mitigation * (float)getMitigationMultiplier()) / 100.f;
return mitigation;
}

WheelGemBasicModifier_t PlayerWheel::selectBasicModifier2(WheelGemBasicModifier_t modifier1) const {
WheelGemBasicModifier_t modifier = modifier1;
while (modifier == modifier1) {
modifier = wheelGemBasicSlot2Allowed[uniform_random(0, wheelGemBasicSlot2Allowed.size() - 1)];
}
return modifier;
}
2 changes: 2 additions & 0 deletions src/creatures/players/wheel/player_wheel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ class PlayerWheel {
}
}

WheelGemBasicModifier_t selectBasicModifier2(WheelGemBasicModifier_t modifier1) const;

private:
friend class Player;
// Reference to the player
Expand Down
12 changes: 6 additions & 6 deletions src/io/io_wheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void IOWheel::slotGreen200(const std::shared_ptr<Player> &player, uint16_t point
// SLOT_GREEN_TOP_150 = 2
void IOWheel::slotGreenTop150(const std::shared_ptr<Player> &player, uint16_t points, uint8_t, PlayerWheelMethodsBonusData &bonusData) const {
bonusData.mitigation += MITIGATION_INCREASE * points;
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_GREEN_BOTTOM_150)) {
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_GREEN_TOP_150)) {
bonusData.leech.manaLeech += MANA_LEECH_INCREASE;
}
}
Expand Down Expand Up @@ -522,7 +522,7 @@ void IOWheel::slotGreenTop75(const std::shared_ptr<Player> &player, uint16_t poi
} else {
bonusData.stats.mana += 6 * points;
}
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_GREEN_TOP_100)) {
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_GREEN_TOP_75)) {
bonusData.leech.lifeLeech += HEALTH_LEECH_INCREASE;
}
}
Expand Down Expand Up @@ -566,7 +566,7 @@ void IOWheel::slotRedBottom150(const std::shared_ptr<Player> &player, uint16_t p
} else {
bonusData.stats.health += 1 * points;
}
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_RED_TOP_150)) {
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_RED_BOTTOM_150)) {
bonusData.leech.manaLeech += MANA_LEECH_INCREASE;
}
}
Expand Down Expand Up @@ -760,7 +760,7 @@ void IOWheel::slotBlueTop150(const std::shared_ptr<Player> &player, uint16_t poi
} else {
bonusData.stats.capacity += 2 * points;
}
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_BLUE_BOTTOM_150)) {
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_BLUE_TOP_150)) {
bonusData.leech.lifeLeech += HEALTH_LEECH_INCREASE;
}
}
Expand Down Expand Up @@ -796,7 +796,7 @@ void IOWheel::slotBlueBottom75(const std::shared_ptr<Player> &player, uint16_t p
// SLOT_PURPLE_BOTTOM_75 = 28
void IOWheel::slotPurpleBottom75(const std::shared_ptr<Player> &player, uint16_t points, uint8_t, PlayerWheelMethodsBonusData &bonusData) const {
bonusData.mitigation += MITIGATION_INCREASE * points;
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_PURPLE_BOTTOM_100)) {
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_PURPLE_BOTTOM_75)) {
bonusData.leech.manaLeech += MANA_LEECH_INCREASE;
}
}
Expand Down Expand Up @@ -898,7 +898,7 @@ void IOWheel::slotPurpleBottom150(const std::shared_ptr<Player> &player, uint16_
} else {
bonusData.stats.mana += 6 * points;
}
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_PURPLE_TOP_150)) {
if (isMaxPointAddedToSlot(player, points, WheelSlots_t::SLOT_PURPLE_BOTTOM_150)) {
bonusData.leech.lifeLeech += HEALTH_LEECH_INCREASE;
}
}
Expand Down

0 comments on commit 39d0d84

Please sign in to comment.