From ab4bd21306c24595718a99e99b532adfb57d7530 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Wed, 18 Dec 2019 21:21:53 +0200 Subject: [PATCH] fsharp(ygosim): feat: tribtues are now sent to the graveyard Signed-off-by: prescientmoon --- fsharp/ygosim/src/Board.fs | 15 ++++++++++----- fsharp/ygosim/src/Program.fs | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fsharp/ygosim/src/Board.fs b/fsharp/ygosim/src/Board.fs index 61820e9..5a1d5c7 100644 --- a/fsharp/ygosim/src/Board.fs +++ b/fsharp/ygosim/src/Board.fs @@ -58,6 +58,7 @@ module Player = let inline deck f player = (side << Side.deck) f player let inline monsters f player = (side << Side.monsters) f player + let inline graveyard f player = (side << Side.graveyard) f player let initialPlayer lp id = { lifePoints = lp @@ -217,6 +218,9 @@ module Zone = let hasFreeMonsterZones = (>=) << freeMonsterZoneCount let hasFreeMonsterZone player = hasFreeMonsterZones player 1 + module Movement = + let toDeckBottom (card: CardInstance) = over Player.deck (fun deck -> deck @ [ card ]) + let toGraveyard cards = over Player.graveyard (fun deck -> cards @ deck) module Summon = open Card.Card @@ -226,6 +230,7 @@ module Summon = open Card open Board open Zone + open Zone.Movement open Client open Utils @@ -285,10 +290,12 @@ module Summon = let replaceTributes = map <| Option.bind replaceInstance // Tribute monsters - let boardWithoutTributes = board |> over Board.currentPlayerMonsters replaceTributes - let free = freeMonsterZones <| boardWithoutTributes ^. Board.currentPlayer + let boardWithoutTributes = + board + |> over Board.currentPlayerMonsters replaceTributes + |> over Board.currentPlayer (tributes |>> toCardInstance |> toGraveyard) - // TODO: move tributes to graveyard + let free = freeMonsterZones <| boardWithoutTributes ^. Board.currentPlayer // Choose a zone to summon the monster let zone = chooseZone client free @@ -334,8 +341,6 @@ module Game = |> Board.currentPlayerHand .-> hand |> Board.currentPlayerDeck .-> deck - let toDeckBottom (card: CardInstance) (player: Player) = over Player.deck (fun d -> rev <| card :: rev d) player - let handleMainPhase client board = if canNormalSummon board then performNormalSummon client board else board diff --git a/fsharp/ygosim/src/Program.fs b/fsharp/ygosim/src/Program.fs index ee6fdfa..5cf0439 100644 --- a/fsharp/ygosim/src/Program.fs +++ b/fsharp/ygosim/src/Program.fs @@ -7,6 +7,7 @@ open Card.Card open Card.MonsterTypes open Card.BaseCard + open Board.Zone.Movement let printState state = match state with