Skip to content

Commit

Permalink
Fix HthEvade only working when nothing's equipped
Browse files Browse the repository at this point in the history
  • Loading branch information
Janiczek committed Nov 4, 2024
1 parent 957c226 commit e658d9e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/Data/Fight/Generator.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ chanceToHit who ongoing attackStyle =
Logic.armorClass
{ naturalArmorClass = otherOpponent.naturalArmorClass
, equippedArmor = otherOpponent.equippedArmor
, equippedWeapon = otherOpponent.equippedWeapon
, hasHthEvadePerk = Perk.rank Perk.HthEvade otherOpponent.perks > 0
, unarmedSkill = Skill.get otherOpponent.special otherOpponent.addedSkillPercentages Skill.Unarmed
, apFromPreviousTurn = apFromPreviousTurn other ongoing
Expand Down Expand Up @@ -1705,6 +1706,7 @@ evalValue who state value =
Logic.armorClass
{ naturalArmorClass = state.them.naturalArmorClass
, equippedArmor = state.them.equippedArmor
, equippedWeapon = state.them.equippedWeapon
, hasHthEvadePerk = Perk.rank Perk.HthEvade state.them.perks > 0
, unarmedSkill = Skill.get state.them.special state.them.addedSkillPercentages Skill.Unarmed
, apFromPreviousTurn = apFromPreviousTurn state.themWho state.ongoingFight
Expand Down
3 changes: 1 addition & 2 deletions src/Data/Perk.elm
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,7 @@ description perk =
"With this Perk you immediately gain one experience level."

HthEvade ->
-- TODO perhaps in future change to only work if hands are empty?
"Each unused action point gives you a +2 instead of +1 towards your Armor Class at the end of your turn, plus 1/12 of your unarmed skill."
"If your hands are empty (no equipped weapon), each unused action point gives you a +2 instead of +1 towards your Armor Class at the end of your turn, plus 1/12 of your unarmed skill."

Lifegiver ->
"With each level of this Perk, you gain an additional 4 Hit Points every time you advance a level. This is in addition to the Hit Points you already gain per level based off of your Endurance. This also applies retroactively to all the levels you already gained."
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Version.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module Data.Version exposing (version)

version : String
version =
"2024.11.04::004"
"2024.11.04::005"
1 change: 1 addition & 0 deletions src/Frontend.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3908,6 +3908,7 @@ inventoryView _ player =
, hasDodgerPerk = Perk.rank Perk.Dodger player.perks > 0
}
, equippedArmor = player.equippedArmor |> Maybe.map .kind
, equippedWeapon = player.equippedWeapon |> Maybe.map .kind
, apFromPreviousTurn = 0
, hasHthEvadePerk = Perk.rank Perk.HthEvade player.perks > 0
, unarmedSkill = Skill.get player.special player.addedSkillPercentages Skill.Unarmed
Expand Down
5 changes: 2 additions & 3 deletions src/Frontend/News.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type alias Item =

items : List Item
items =
[ { date = 1730730862
[ { date = 1730747519
, title = "TODOs before release"
, text =
"""
Expand All @@ -32,7 +32,7 @@ announcement!
Current TODOs:
- HtH Evade perk to only work if hands are empty
- perk - show max number of ranks
Next up:
Expand All @@ -51,7 +51,6 @@ Later:
- new char / char screen: show Sequence and other stats in derived stats
- gecko skinning - is it doing anything?
- skynet and k9 - doing anything?
- perk - show max number of ranks
- perk - show all perks, some grayed out, show the requirements?
- music in the bg (opt-in)
Expand Down
9 changes: 7 additions & 2 deletions src/Logic.elm
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,25 @@ naturalArmorClass r =
armorClass :
{ naturalArmorClass : Int
, equippedArmor : Maybe ItemKind.Kind
, equippedWeapon : Maybe ItemKind.Kind
, hasHthEvadePerk : Bool
, unarmedSkill : Int
, apFromPreviousTurn : Int
}
-> Int
armorClass r =
let
hthEvadeBonusesApply : Bool
hthEvadeBonusesApply =
r.hasHthEvadePerk && r.equippedWeapon == Nothing

fromArmor =
r.equippedArmor
|> Maybe.map ItemKind.armorClass
|> Maybe.withDefault 0

unusedApMultiplier =
if r.hasHthEvadePerk then
if hthEvadeBonusesApply then
2

else
Expand All @@ -307,7 +312,7 @@ armorClass r =
r.apFromPreviousTurn * unusedApMultiplier

fromUnarmedSkill =
if r.hasHthEvadePerk then
if hthEvadeBonusesApply then
r.unarmedSkill // 12

else
Expand Down
4 changes: 2 additions & 2 deletions tests/Data/Fight/GeneratorTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ damageNeverNegative : Test
damageNeverNegative =
Test.fuzz randomFightFuzzer "Damage in fight should never be negative" <|
\fight ->
fight.fightInfo.log
fight.fightInfoForAttacker.log
|> List.map (Tuple.second >> Fight.attackDamage)
|> List.filter (\damage -> damage < 0)
|> List.isEmpty
Expand Down Expand Up @@ -163,7 +163,7 @@ meleeUnaimedStrategyResultsInMeleeUnaimedAttacks =
(Random.initialSeed 3)
|> Tuple.first
in
fight.fightInfo.log
fight.fightInfoForAttacker.log
|> List.all
(\( _, action ) ->
case action of
Expand Down

0 comments on commit e658d9e

Please sign in to comment.