1
1
module Data.Fight.GeneratorTest exposing (suite )
2
2
3
- import Data.Fight as Fight exposing (Action , Opponent , Who )
3
+ import Data.Fight as Fight exposing (Opponent )
4
4
import Data.Fight.AttackStyle as AttackStyle
5
5
import Data.Fight.Generator exposing (Fight )
6
6
import Data.FightStrategy exposing (..)
@@ -15,14 +15,14 @@ import SeqDict
15
15
import SeqSet
16
16
import Test exposing (Test )
17
17
import TestHelpers exposing (..)
18
- import Time
19
18
20
19
21
20
suite : Test
22
21
suite =
23
22
Test . describe " Data.Fight.Generator"
24
23
[ damageNeverNegative
25
24
, meleeAttackAtDistance2WithRange2
25
+ , meleeAttackAtDistance2WithRange1
26
26
]
27
27
28
28
@@ -53,7 +53,25 @@ meleeAttackAtDistance2WithRange2 =
53
53
\ () ->
54
54
let
55
55
opponent =
56
- { type_ = Fight . Player { name = " Opponent" , xp = 0 }, hp = 100 , maxHp = 100 , maxAp = 10 , sequence = 5 , traits = SeqSet . empty, perks = SeqDict . empty, caps = 50 , items = Dict . empty, drops = [], equippedArmor = Nothing , equippedWeapon = Just Item . SuperSledge , equippedAmmo = Nothing , naturalArmorClass = 5 , attackStats = Logic . unarmedAttackStats { special = Special . init, unarmedSkill = 50 , traits = SeqSet . empty, perks = SeqDict . empty, level = 1 , npcExtraBonus = 0 }, addedSkillPercentages = SeqDict . empty, special = Special . init, fightStrategy = strategy }
56
+ { type_ = Fight . Player { name = " Opponent" , xp = 0 }
57
+ , hp = 100
58
+ , maxHp = 100
59
+ , maxAp = 10
60
+ , sequence = 5
61
+ , traits = SeqSet . empty
62
+ , perks = SeqDict . empty
63
+ , caps = 50
64
+ , items = Dict . empty
65
+ , drops = []
66
+ , equippedArmor = Nothing
67
+ , equippedWeapon = Just Item . SuperSledge
68
+ , equippedAmmo = Nothing
69
+ , naturalArmorClass = 5
70
+ , attackStats = Logic . unarmedAttackStats { special = Special . init, unarmedSkill = 50 , traits = SeqSet . empty, perks = SeqDict . empty, level = 1 , npcExtraBonus = 0 }
71
+ , addedSkillPercentages = SeqDict . empty
72
+ , special = Special . init
73
+ , fightStrategy = strategy
74
+ }
57
75
58
76
result =
59
77
Random . step
@@ -80,6 +98,70 @@ meleeAttackAtDistance2WithRange2 =
80
98
|> Expect . onFail " Expected the attack to succeed"
81
99
82
100
101
+ meleeAttackAtDistance2WithRange1 : Test
102
+ meleeAttackAtDistance2WithRange1 =
103
+ let
104
+ strategy : FightStrategy
105
+ strategy =
106
+ If
107
+ { condition = Operator { lhs = Distance , op = GT_ , rhs = Number 2 }
108
+ , then_ = Command MoveForward
109
+ , else_ = Command AttackRandomly
110
+ }
111
+ in
112
+ Test . test " Melee combat at distance 2 with weapon with range 1 shouldn't work" <|
113
+ \ () ->
114
+ let
115
+ opponent =
116
+ { type_ =
117
+ Fight . Player
118
+ { name = " Opponent"
119
+ , xp = 0
120
+ }
121
+ , hp = 100
122
+ , maxHp = 100
123
+ , maxAp = 10
124
+ , sequence = 5
125
+ , traits = SeqSet . empty
126
+ , perks = SeqDict . empty
127
+ , caps = 50
128
+ , items = Dict . empty
129
+ , drops = []
130
+ , equippedArmor = Nothing
131
+ , equippedWeapon = Just Item . Wakizashi
132
+ , equippedAmmo = Nothing
133
+ , naturalArmorClass = 5
134
+ , attackStats = Logic . unarmedAttackStats { special = Special . init, unarmedSkill = 50 , traits = SeqSet . empty, perks = SeqDict . empty, level = 1 , npcExtraBonus = 0 }
135
+ , addedSkillPercentages = SeqDict . empty
136
+ , special = Special . init
137
+ , fightStrategy = strategy
138
+ }
139
+
140
+ result =
141
+ Random . step
142
+ ( Data . Fight . Generator . attack_
143
+ Fight . Attacker
144
+ { distanceHexes = 2
145
+ , attacker = opponent
146
+ , attackerAp = 10
147
+ , attackerItemsUsed = SeqDict . empty
148
+ , target = opponent
149
+ , targetAp = 10
150
+ , targetItemsUsed = SeqDict . empty
151
+ , reverseLog = []
152
+ , actionsTaken = 0
153
+ }
154
+ AttackStyle . MeleeUnaimed
155
+ 4
156
+ )
157
+ ( Random . initialSeed 3 )
158
+ |> Tuple . first
159
+ in
160
+ result. ranCommandSuccessfully
161
+ |> Expect . equal False
162
+ |> Expect . onFail " Expected the attack to fail"
163
+
164
+
83
165
fightFuzzer :
84
166
{ attacker : Fuzzer Opponent
85
167
, target : Fuzzer Opponent
0 commit comments