@@ -92,8 +92,7 @@ function* run(
92
92
! elements . includes ( 'web' )
93
93
)
94
94
}
95
- const warnAboutNeedlessMove = ( ) => {
96
- // @TODO : visualize to user
95
+ const markAsNeedlessMove = ( ) => {
97
96
performedNeedlessMove = true
98
97
}
99
98
@@ -165,18 +164,18 @@ function* run(
165
164
playerState . x ++
166
165
yield step ( 'goForward' )
167
166
} else {
168
- warnAboutNeedlessMove ( )
167
+ markAsNeedlessMove ( )
169
168
yield step ( 'invalidMove' )
170
169
}
171
170
} else if ( instruction . type === 'jump' ) {
172
171
if ( canStandAt ( playerState . x + 1 , playerState . y ) ) {
173
172
playerState . x ++
174
173
if ( ! elementsAt ( playerState . x + 1 , playerState . y ) . includes ( 'hole' ) ) {
175
- warnAboutNeedlessMove ( )
174
+ markAsNeedlessMove ( )
176
175
}
177
176
yield step ( 'jump' )
178
177
} else {
179
- warnAboutNeedlessMove ( )
178
+ markAsNeedlessMove ( )
180
179
yield step ( 'invalidMove' )
181
180
}
182
181
} else if ( instruction . type === 'pick' ) {
@@ -188,23 +187,23 @@ function* run(
188
187
yield step ( 'pickSword' )
189
188
removeElement ( playerState . x , playerState . y , 'sword' )
190
189
} else {
191
- warnAboutNeedlessMove ( )
190
+ markAsNeedlessMove ( )
192
191
yield step ( 'invalidMove' )
193
192
}
194
193
} else if ( instruction . type === 'up' ) {
195
194
if ( isConditionFulfilled . leaderUp ) {
196
195
playerState . y --
197
196
yield step ( 'goUp' )
198
197
} else {
199
- warnAboutNeedlessMove ( )
198
+ markAsNeedlessMove ( )
200
199
yield step ( 'invalidMove' )
201
200
}
202
201
} else if ( instruction . type === 'down' ) {
203
202
if ( isConditionFulfilled . leaderDown ) {
204
203
playerState . y ++
205
204
yield step ( 'goDown' )
206
205
} else {
207
- warnAboutNeedlessMove ( )
206
+ markAsNeedlessMove ( )
208
207
yield step ( 'invalidMove' )
209
208
}
210
209
} else if ( instruction . type === 'hit' ) {
@@ -214,16 +213,16 @@ function* run(
214
213
} else if ( isConditionFulfilled . web ) {
215
214
removeElement ( playerState . x + 1 , playerState . y , 'web' )
216
215
} else {
217
- warnAboutNeedlessMove ( )
216
+ markAsNeedlessMove ( )
218
217
}
219
218
yield step ( 'hit' )
220
219
} else {
221
- warnAboutNeedlessMove ( )
220
+ markAsNeedlessMove ( )
222
221
yield step ( 'invalidMove' )
223
222
}
224
223
} else if ( instruction . type === 'kiss' ) {
224
+ yield step ( 'kiss' ) // @TODO : allow air kisses into the air with needless move penalization
225
225
if ( elementsAt ( playerState . x + 1 , playerState . y ) . includes ( 'frog' ) ) {
226
- yield step ( 'kiss' ) // @TODO : allow air kisses into the air with needless move penalization
227
226
return {
228
227
type : 'final' ,
229
228
success : true ,
@@ -232,8 +231,7 @@ function* run(
232
231
playerState,
233
232
}
234
233
} else {
235
- warnAboutNeedlessMove ( )
236
- yield step ( 'invalidMove' )
234
+ markAsNeedlessMove ( )
237
235
}
238
236
} else if ( instruction . type === 'repeat' ) {
239
237
for ( let iteration = 1 ; iteration <= instruction . times ; iteration ++ ) {
@@ -270,7 +268,7 @@ function* run(
270
268
}
271
269
if ( value . performedNothing ) {
272
270
// Infinite loop detected
273
- warnAboutNeedlessMove ( )
271
+ markAsNeedlessMove ( )
274
272
yield step ( 'invalidMove' )
275
273
}
276
274
}
0 commit comments