Skip to content

Commit

Permalink
changed model to board
Browse files Browse the repository at this point in the history
  • Loading branch information
tkshill committed Nov 1, 2020
1 parent 32f4293 commit b02e90a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Game/Model.elm → src/Game/Board.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Game.Model exposing
module Game.Board exposing
( BoardState
, Cellname(..)
, ChosenPiece
Expand All @@ -16,6 +16,7 @@ module Game.Model exposing
, isWin
, playedPieces
, unPlayedPieces
, updateBoard
)

import Dict exposing (Dict)
Expand Down Expand Up @@ -427,5 +428,19 @@ initialModel =
}


updateBoard : Cellname -> Gamepiece -> BoardState -> BoardState
updateBoard name gamepiece board =
if
List.any ((==) { status = Unplayed, gamepiece = gamepiece }) board
&& not (List.any (\ps -> ps.status == Played name) board)
then
board
|> List.filter ((/=) { status = Unplayed, gamepiece = gamepiece })
|> (::) { status = Played name, gamepiece = gamepiece }

else
board



--

0 comments on commit b02e90a

Please sign in to comment.