summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2023-01-08 20:11:30 +0800
committerFrederick Yin <fkfd@fkfd.me>2023-01-08 20:11:30 +0800
commitc50c43698af9b4291f1e63154d19123ed89b8f10 (patch)
tree76a2b30bd23c888903310d944e3ba0d002560629
parent1e336424e1c661303fed2a4d4e58915bf267bb55 (diff)
beginRounds and beginTurn are better names
-rw-r--r--Game.hs14
-rw-r--r--Main.hs4
2 files changed, 9 insertions, 9 deletions
diff --git a/Game.hs b/Game.hs
index 7c5c8ba..816a65c 100644
--- a/Game.hs
+++ b/Game.hs
@@ -17,17 +17,17 @@ data Game = Game { players :: [Player]
}
-- | Begin new round of game.
-nextRound :: Int -> Game -> IO Game
-nextRound n game = do
+beginRounds :: Int -> Game -> IO Game
+beginRounds n game = do
if n == 0
then return game
else do
- game' <- nextTurn game
- nextRound (n - 1) game'
+ game' <- beginTurn game
+ beginRounds (n - 1) game'
-- | Let current player take their turn.
-nextTurn :: Game -> IO Game
-nextTurn game@(Game plyrs pidx att dir stock disc) = do
+beginTurn :: Game -> IO Game
+beginTurn game@(Game plyrs pidx att dir stock disc) = do
putStrLn $ replicate 80 '-'
putStrLn $ "Current attack: " ++ show att
decision <- prompt game
@@ -66,7 +66,7 @@ nextTurn game@(Game plyrs pidx att dir stock disc) = do
if null $ P.cards player'
then return game'
- else nextTurn game'
+ else beginTurn game'
-- | Prompt player to play a card (or draw card and skip turn).
prompt :: Game -> IO (Maybe Card)
diff --git a/Main.hs b/Main.hs
index 1992399..7e66efa 100644
--- a/Main.hs
+++ b/Main.hs
@@ -9,7 +9,7 @@ import Game (Game(..),
discardPile,
prompt,
dealCards,
- nextRound,
+ beginRounds,
)
import Player (Player(..))
import qualified Player as P
@@ -33,5 +33,5 @@ main = do
, discardPile = discard
}
- nextRound 1 $ dealCards 6 game
+ beginRounds 1 $ dealCards 6 game
print ()