-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Logic wrt. ammo AC modifier and 10mm SMG!
- Loading branch information
Showing
4 changed files
with
335 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,157 @@ | ||
module LogicTest exposing (test) | ||
|
||
import Data.Fight.AttackStyle as AttackStyle | ||
import Data.Special as Special | ||
import Data.Fight.AttackStyle as AttackStyle exposing (AttackStyle(..)) | ||
import Data.Item as Item exposing (Kind(..)) | ||
import Data.Perk exposing (Perk) | ||
import Data.Skill exposing (Skill(..)) | ||
import Data.Special as Special exposing (Special) | ||
import Expect | ||
import Fuzz exposing (Fuzzer) | ||
import Logic | ||
import SeqDict | ||
import SeqDict exposing (SeqDict) | ||
import Test exposing (Test) | ||
import TestHelpers | ||
|
||
|
||
test : Test | ||
test = | ||
Test.describe "Logic" | ||
[ Test.describe "chanceToHit" | ||
[ Test.test "Unarmed + good range" <| | ||
\() -> | ||
[ Test.describe "chanceToHit" <| | ||
[ Test.fuzz chanceToHitArgsFuzzer "0..95" <| | ||
\args -> | ||
Logic.chanceToHit args | ||
|> Expect.all | ||
[ Expect.atLeast 0 | ||
, Expect.atMost 95 | ||
] | ||
, Test.fuzz2 chanceToHitArgsFuzzer (Fuzz.maybe TestHelpers.unarmedWeaponKindFuzzer) "Unarmed + good range: can hit" <| | ||
\args maybeWeapon -> | ||
Logic.chanceToHit | ||
{ attackerAddedSkillPercentages = SeqDict.empty | ||
, attackerPerks = SeqDict.empty | ||
, attackerSpecial = Special.init | ||
, distanceHexes = 1 | ||
, equippedWeapon = Nothing | ||
, equippedAmmo = Nothing | ||
, targetArmorClass = 0 | ||
, attackStyle = AttackStyle.UnarmedUnaimed | ||
{ args | ||
| attackStyle = AttackStyle.UnarmedUnaimed | ||
, equippedWeapon = maybeWeapon | ||
, distanceHexes = 1 | ||
, targetArmorClass = 0 | ||
} | ||
|> Expect.greaterThan 0 | ||
, Test.fuzz2 chanceToHitArgsFuzzer (Fuzz.maybe TestHelpers.unarmedWeaponKindFuzzer) "Unarmed outside range: cannot hit" <| | ||
\args maybeWeapon -> | ||
Logic.chanceToHit | ||
{ args | ||
| attackStyle = AttackStyle.UnarmedUnaimed | ||
, equippedWeapon = maybeWeapon | ||
, distanceHexes = args.distanceHexes + 1 | ||
} | ||
|> Expect.equal 0 | ||
, Test.fuzz2 chanceToHitArgsFuzzer TestHelpers.meleeWeaponKindFuzzer "Melee + good range: can hit" <| | ||
\args weapon -> | ||
Logic.chanceToHit | ||
{ args | ||
| attackStyle = AttackStyle.MeleeUnaimed | ||
, equippedWeapon = Just weapon | ||
, distanceHexes = 1 | ||
, targetArmorClass = 0 | ||
} | ||
|> Expect.greaterThan 0 | ||
, Test.fuzz2 chanceToHitArgsFuzzer TestHelpers.meleeWeaponKindFuzzer "Melee outside range: cannot hit" <| | ||
\args weapon -> | ||
Logic.chanceToHit | ||
{ args | ||
| attackStyle = AttackStyle.MeleeUnaimed | ||
, equippedWeapon = Just weapon | ||
, distanceHexes = args.distanceHexes + 1 | ||
} | ||
|> Expect.equal 0 | ||
, Test.fuzz2 chanceToHitArgsFuzzer TestHelpers.gunKindFuzzer "Ranged + good range: can hit" <| | ||
\args weapon -> | ||
Logic.chanceToHit | ||
{ args | ||
| attackStyle = AttackStyle.ShootSingleUnaimed | ||
, attackerSpecial = args.attackerSpecial |> Special.set Special.Strength 10 | ||
, equippedWeapon = Just weapon | ||
, distanceHexes = 1 | ||
, targetArmorClass = 0 | ||
} | ||
|> Expect.greaterThan 0 | ||
, Test.fuzz2 chanceToHitArgsFuzzer TestHelpers.gunKindFuzzer "Ranged outside range: cannot hit" <| | ||
\args weapon -> | ||
Logic.chanceToHit | ||
{ args | ||
| attackStyle = AttackStyle.ShootSingleUnaimed | ||
, equippedWeapon = Just weapon | ||
, distanceHexes = args.distanceHexes + 80 | ||
} | ||
|> Expect.equal 0 | ||
] | ||
] | ||
|
||
|
||
log : | ||
{ attackerAddedSkillPercentages : SeqDict Skill Int | ||
, attackerPerks : SeqDict Perk Int | ||
, attackerSpecial : Special | ||
, distanceHexes : Int | ||
, equippedWeapon : Maybe Item.Kind | ||
, equippedAmmo : Maybe Item.Kind | ||
, targetArmorClass : Int | ||
, attackStyle : AttackStyle | ||
} | ||
-> | ||
{ attackerAddedSkillPercentages : SeqDict Skill Int | ||
, attackerPerks : SeqDict Perk Int | ||
, attackerSpecial : Special | ||
, distanceHexes : Int | ||
, equippedWeapon : Maybe Item.Kind | ||
, equippedAmmo : Maybe Item.Kind | ||
, targetArmorClass : Int | ||
, attackStyle : AttackStyle | ||
} | ||
log args = | ||
let | ||
_ = | ||
{ attackerAddedSkillPercentages = SeqDict.toList args.attackerAddedSkillPercentages | ||
, attackerPerks = SeqDict.toList args.attackerPerks | ||
, attackerSpecial = args.attackerSpecial | ||
, distanceHexes = args.distanceHexes | ||
, equippedWeapon = args.equippedWeapon | ||
, equippedAmmo = args.equippedAmmo | ||
, targetArmorClass = args.targetArmorClass | ||
, attackStyle = args.attackStyle | ||
} | ||
|> Debug.log "chanceToHit args" | ||
in | ||
args | ||
|
||
|
||
chanceToHitArgsFuzzer : | ||
Fuzzer | ||
{ attackerAddedSkillPercentages : SeqDict Skill Int | ||
, attackerPerks : SeqDict Perk Int | ||
, attackerSpecial : Special | ||
, distanceHexes : Int | ||
, equippedWeapon : Maybe Item.Kind | ||
, equippedAmmo : Maybe Item.Kind | ||
, targetArmorClass : Int | ||
, attackStyle : AttackStyle | ||
} | ||
chanceToHitArgsFuzzer = | ||
Fuzz.map8 | ||
(\attackerAddedSkillPercentages attackerPerks attackerSpecial distanceHexes equippedWeapon equippedAmmo targetArmorClass attackStyle -> | ||
{ attackerAddedSkillPercentages = attackerAddedSkillPercentages | ||
, attackerPerks = attackerPerks | ||
, attackerSpecial = attackerSpecial | ||
, distanceHexes = distanceHexes | ||
, equippedWeapon = equippedWeapon | ||
, equippedAmmo = equippedAmmo | ||
, targetArmorClass = targetArmorClass | ||
, attackStyle = attackStyle | ||
} | ||
) | ||
TestHelpers.addedSkillPercentagesFuzzer | ||
TestHelpers.perksFuzzer | ||
TestHelpers.specialFuzzer | ||
TestHelpers.distanceFuzzer | ||
TestHelpers.equippedWeaponKindFuzzer | ||
TestHelpers.equippedAmmoKindFuzzer | ||
TestHelpers.armorClassFuzzer | ||
TestHelpers.attackStyleFuzzer |
Oops, something went wrong.