@@ -125,13 +125,8 @@ func TestPlayer_FlashDurationTimeRemaining_Fallback(t *testing.T) {
125
125
}
126
126
127
127
func TestPlayer_IsSpottedBy_HasSpotted_True (t * testing.T ) {
128
- pl := newPlayer (0 )
129
- entity := new (fake.Entity )
130
- pl .Entity = entity
128
+ pl := playerWithProperty ("m_bSpottedByMask.000" , sendtables.PropertyValue {IntVal : 2 })
131
129
pl .EntityID = 1
132
- prop := new (fake.Property )
133
- prop .On ("Value" ).Return (sendtables.PropertyValue {IntVal : 2 })
134
- entity .On ("FindPropertyI" , "m_bSpottedByMask.000" ).Return (prop )
135
130
136
131
other := newPlayer (0 )
137
132
other .EntityID = 2
@@ -141,13 +136,8 @@ func TestPlayer_IsSpottedBy_HasSpotted_True(t *testing.T) {
141
136
}
142
137
143
138
func TestPlayer_IsSpottedBy_HasSpotted_False (t * testing.T ) {
144
- pl := newPlayer (0 )
145
- entity := new (fake.Entity )
146
- pl .Entity = entity
139
+ pl := playerWithProperty ("m_bSpottedByMask.000" , sendtables.PropertyValue {IntVal : 0 })
147
140
pl .EntityID = 1
148
- prop := new (fake.Property )
149
- prop .On ("Value" ).Return (sendtables.PropertyValue {IntVal : 0 })
150
- entity .On ("FindPropertyI" , "m_bSpottedByMask.000" ).Return (prop )
151
141
152
142
other := newPlayer (0 )
153
143
other .EntityID = 2
@@ -157,12 +147,7 @@ func TestPlayer_IsSpottedBy_HasSpotted_False(t *testing.T) {
157
147
}
158
148
159
149
func TestPlayer_IsSpottedBy_HasSpotted_BitOver32 (t * testing.T ) {
160
- pl := newPlayer (0 )
161
- entity := new (fake.Entity )
162
- prop := new (fake.Property )
163
- prop .On ("Value" ).Return (sendtables.PropertyValue {IntVal : 1 })
164
- entity .On ("FindPropertyI" , "m_bSpottedByMask.001" ).Return (prop )
165
- pl .Entity = entity
150
+ pl := playerWithProperty ("m_bSpottedByMask.001" , sendtables.PropertyValue {IntVal : 1 })
166
151
pl .EntityID = 1
167
152
168
153
other := newPlayer (0 )
@@ -182,10 +167,55 @@ func TestPlayer_IsSpottedBy_EntityNull(t *testing.T) {
182
167
assert .False (t , other .HasSpotted (pl ))
183
168
}
184
169
170
+ func TestPlayer_IsInBombZone (t * testing.T ) {
171
+ pl := playerWithProperty ("m_bInBombZone" , sendtables.PropertyValue {IntVal : 1 })
172
+
173
+ assert .True (t , pl .IsInBombZone ())
174
+ }
175
+
176
+ func TestPlayer_IsInBuyZone (t * testing.T ) {
177
+ pl := playerWithProperty ("m_bInBuyZone" , sendtables.PropertyValue {IntVal : 1 })
178
+
179
+ assert .True (t , pl .IsInBuyZone ())
180
+ }
181
+
182
+ func TestPlayer_IsWalking (t * testing.T ) {
183
+ pl := playerWithProperty ("m_bIsWalking" , sendtables.PropertyValue {IntVal : 1 })
184
+
185
+ assert .True (t , pl .IsWalking ())
186
+ }
187
+
188
+ func TestPlayer_IsScoped (t * testing.T ) {
189
+ pl := playerWithProperty ("m_bIsScoped" , sendtables.PropertyValue {IntVal : 1 })
190
+
191
+ assert .True (t , pl .IsScoped ())
192
+ }
193
+
194
+ func TestPlayer_CashSpentThisRound (t * testing.T ) {
195
+ pl := playerWithProperty ("m_iCashSpentThisRound" , sendtables.PropertyValue {IntVal : 500 })
196
+
197
+ assert .Equal (t , 500 , pl .CashSpentThisRound ())
198
+ }
199
+
200
+ func TestPlayer_CashSpentTotal (t * testing.T ) {
201
+ pl := playerWithProperty ("m_iTotalCashSpent" , sendtables.PropertyValue {IntVal : 500 })
202
+
203
+ assert .Equal (t , 500 , pl .CashSpentTotal ())
204
+ }
205
+
185
206
func newPlayer (tick int ) * Player {
186
207
return NewPlayer (128 , tickProvider (tick ))
187
208
}
188
209
189
210
func tickProvider (tick int ) ingameTickProvider {
190
211
return func () int { return tick }
191
212
}
213
+
214
+ func playerWithProperty (propName string , value sendtables.PropertyValue ) * Player {
215
+ entity := new (fake.Entity )
216
+ prop := new (fake.Property )
217
+ prop .On ("Value" ).Return (value )
218
+ entity .On ("FindPropertyI" , propName ).Return (prop )
219
+ pl := & Player {Entity : entity }
220
+ return pl
221
+ }
0 commit comments