slight refactoring to help with extensibility of adding enemy variants later
This commit is contained in:
@@ -21,19 +21,26 @@ struct
|
||||
| W_X_AXIS of GameType.x_axis
|
||||
| W_Y_AXIS of GameType.y_axis
|
||||
|
||||
fun mkEnemy (id, health, x, y, xAxis, yAxis) =
|
||||
{id = id, health = health, x = x, y = y, xAxis = xAxis, yAxis = yAxis}
|
||||
fun mkEnemy (id, health, x, y, xAxis, yAxis, variant) =
|
||||
{ id = id
|
||||
, health = health
|
||||
, x = x
|
||||
, y = y
|
||||
, xAxis = xAxis
|
||||
, yAxis = yAxis
|
||||
, variant = variant
|
||||
}
|
||||
|
||||
fun withPatch (enemy, patch) =
|
||||
let
|
||||
val {id, health, x, y, xAxis, yAxis} = enemy
|
||||
val {id, health, x, y, xAxis, yAxis, variant} = enemy
|
||||
in
|
||||
case patch of
|
||||
W_HEALTH health => mkEnemy (id, health, x, y, xAxis, yAxis)
|
||||
| W_X x => mkEnemy (id, health, x, y, xAxis, yAxis)
|
||||
| W_X_AXIS xAxis => mkEnemy (id, health, x, y, xAxis, yAxis)
|
||||
| W_Y y => mkEnemy (id, health, x, y, xAxis, yAxis)
|
||||
| W_Y_AXIS yAxis => mkEnemy (id, health, x, y, xAxis, yAxis)
|
||||
W_HEALTH health => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
|
||||
| W_X x => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
|
||||
| W_X_AXIS xAxis => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
|
||||
| W_Y y => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
|
||||
| W_Y_AXIS yAxis => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
|
||||
end
|
||||
|
||||
fun withPatches (enemy, lst) =
|
||||
|
||||
Reference in New Issue
Block a user