optics and stuff
This commit is contained in:
parent
a26149c242
commit
75e1b62dfb
3 changed files with 135 additions and 3 deletions
108
numbersquare.cabal
Normal file
108
numbersquare.cabal
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
cabal-version: 1.12
|
||||||
|
|
||||||
|
-- This file has been generated from package.yaml by hpack version 0.38.3.
|
||||||
|
--
|
||||||
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
|
name: numbersquare
|
||||||
|
version: 0.1.0
|
||||||
|
synopsis: a game where you number square
|
||||||
|
description: a game where you number square
|
||||||
|
category: Games
|
||||||
|
author: skulk
|
||||||
|
maintainer: skulk
|
||||||
|
license: BSD3
|
||||||
|
license-file: LICENSE
|
||||||
|
build-type: Simple
|
||||||
|
|
||||||
|
library
|
||||||
|
exposed-modules:
|
||||||
|
Game
|
||||||
|
Types.BoardPosition
|
||||||
|
Types.GameBoard
|
||||||
|
Types.GameMode
|
||||||
|
Types.GameState
|
||||||
|
Types.Player
|
||||||
|
other-modules:
|
||||||
|
Paths_numbersquare
|
||||||
|
hs-source-dirs:
|
||||||
|
src
|
||||||
|
default-extensions:
|
||||||
|
ImportQualifiedPost
|
||||||
|
DataKinds
|
||||||
|
FlexibleInstances
|
||||||
|
MultiParamTypeClasses
|
||||||
|
TypeFamilies
|
||||||
|
UndecidableInstances
|
||||||
|
ghc-options: -Wall
|
||||||
|
build-depends:
|
||||||
|
array
|
||||||
|
, base ==4.*
|
||||||
|
, binary
|
||||||
|
, containers
|
||||||
|
, display
|
||||||
|
, extra
|
||||||
|
, mtl
|
||||||
|
, optics
|
||||||
|
, random
|
||||||
|
, text
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
executable numbersquare
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_numbersquare
|
||||||
|
hs-source-dirs:
|
||||||
|
app
|
||||||
|
default-extensions:
|
||||||
|
ImportQualifiedPost
|
||||||
|
DataKinds
|
||||||
|
FlexibleInstances
|
||||||
|
MultiParamTypeClasses
|
||||||
|
TypeFamilies
|
||||||
|
UndecidableInstances
|
||||||
|
ghc-options: -Wall
|
||||||
|
build-depends:
|
||||||
|
array
|
||||||
|
, base ==4.*
|
||||||
|
, binary
|
||||||
|
, containers
|
||||||
|
, display
|
||||||
|
, extra
|
||||||
|
, mtl
|
||||||
|
, optics
|
||||||
|
, random
|
||||||
|
, text
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
test-suite numberspec-test
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Spec
|
||||||
|
Paths_numbersquare
|
||||||
|
hs-source-dirs:
|
||||||
|
test
|
||||||
|
default-extensions:
|
||||||
|
ImportQualifiedPost
|
||||||
|
DataKinds
|
||||||
|
FlexibleInstances
|
||||||
|
MultiParamTypeClasses
|
||||||
|
TypeFamilies
|
||||||
|
UndecidableInstances
|
||||||
|
ghc-options: -Wall -threaded -O0
|
||||||
|
build-depends:
|
||||||
|
QuickCheck
|
||||||
|
, array
|
||||||
|
, base ==4.*
|
||||||
|
, binary
|
||||||
|
, containers
|
||||||
|
, display
|
||||||
|
, extra
|
||||||
|
, hspec >=2.1.8
|
||||||
|
, mtl
|
||||||
|
, numbersquare
|
||||||
|
, optics
|
||||||
|
, random
|
||||||
|
, text
|
||||||
|
default-language: Haskell2010
|
||||||
10
package.yaml
10
package.yaml
|
|
@ -17,6 +17,16 @@ dependencies:
|
||||||
- extra
|
- extra
|
||||||
- display
|
- display
|
||||||
- binary
|
- binary
|
||||||
|
- containers
|
||||||
|
- optics
|
||||||
|
|
||||||
|
default-extensions:
|
||||||
|
- ImportQualifiedPost
|
||||||
|
- DataKinds
|
||||||
|
- FlexibleInstances
|
||||||
|
- MultiParamTypeClasses
|
||||||
|
- TypeFamilies
|
||||||
|
- UndecidableInstances
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs:
|
source-dirs:
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,27 @@
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
module Types.GameState where
|
module Types.GameState where
|
||||||
|
|
||||||
|
import Data.Sequence (Seq)
|
||||||
|
import Data.Sequence qualified as S
|
||||||
|
import Optics (makeFieldLabels)
|
||||||
|
import System.Random
|
||||||
import Types.GameBoard
|
import Types.GameBoard
|
||||||
import Types.GameMode (GameMode)
|
import Types.GameMode (GameMode)
|
||||||
import Types.Player
|
import Types.Player
|
||||||
|
|
||||||
data GameState mode = MkGameState
|
data GameState mode = MkGameState
|
||||||
{ board :: GameBoard mode
|
{ board :: GameBoard mode
|
||||||
, players :: [PlayerState]
|
, players :: Seq PlayerState
|
||||||
}
|
}
|
||||||
|
|
||||||
newGame :: (GameMode mode) => mode -> [PlayerName] -> IO (GameState mode)
|
makeFieldLabels ''GameState
|
||||||
newGame = undefined
|
|
||||||
|
newtype PlayerIndex = MkPlayerIndex Int
|
||||||
|
deriving (Show, Eq)
|
||||||
|
|
||||||
|
newGame :: (GameMode mode, RandomGen g) => mode -> [PlayerName] -> g -> ((GameState mode), g)
|
||||||
|
newGame gmode playerInfos rng =
|
||||||
|
let (initialBoard, nextRng) = newRandomBoard gmode 10 10 rng
|
||||||
|
playerStates = S.fromList $ map (\n -> MkPlayerState{name = n, score = 0}) playerInfos
|
||||||
|
in (MkGameState initialBoard playerStates, nextRng)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue