1
Fork 0

fsharp(ygosim): feat: deckouting

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-07 19:56:20 +02:00 committed by prescientmoon
parent eab212c039
commit 6e0c6dbf5b
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
2 changed files with 15 additions and 5 deletions

View file

@ -22,17 +22,24 @@ module Player =
open Side
open Card
type PlayerState =
| InGame
| Won
| Lost of reason: string
type Player =
{ lifePoints: int
side: Side
hand: CardInstance list }
hand: CardInstance list
state: PlayerState }
let inflictDamage (player: Player) amount = { player with lifePoints = player.lifePoints - amount }
let initialPlayer lp =
{ lifePoints = lp
side = emptySide
hand = [] }
hand = []
state = InGame }
module Turn =
type Phase =
@ -64,7 +71,7 @@ module Board =
let emptyBoard =
{ players = (initialPlayer 8000, initialPlayer 8000)
turn = 0
phase = Draw }
phase = Turn.Draw }
module Game =
open Board
@ -74,7 +81,7 @@ module Game =
let draw (player: Player) =
match player.side.deck with
| [] -> player // TODO: makes this end the game
| [] -> { player with state = Lost "deckout" }
| card :: deck ->
{ player with
hand = card :: player.hand

View file

@ -8,7 +8,6 @@
let board = Board.emptyBoard
let sampleCard = Spell ({name= "sampleCard"; text="something"}, {spellType = Card.ContinuosSpell})
let (first, second) = board.players
let secondBoard = withCurrentPlayer <| Game.toDeckBottom sampleCard <| board
printfn "%A" secondBoard
@ -17,4 +16,8 @@
printfn "%A" thirdBoard
let lastBoard = List.fold (fun b _ -> doTurn b) thirdBoard [0..5]
printf "%A" lastBoard
0