1
Fork 0

fsharp(ygosim): refactor: now using List.choose to remove a lot of complexity in the normal summoning stuff

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-15 02:26:52 +02:00 committed by prescientmoon
parent 4bfc7c050a
commit 6189917e92
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -179,9 +179,7 @@ module Summon =
elif level <= 6 then 1
else 2
let isNormalSummonable board maybeMonster =
match maybeMonster with
| Some monster ->
let isNormalSummonable board monster =
let requiredTributes = numberOfTributes monster
let possibleTributes =
@ -193,20 +191,14 @@ module Summon =
printfn "%i" freeZones
Some(requiredTributes <= possibleTributes && freeZones > 0)
| None -> None
requiredTributes <= possibleTributes && freeZones > 0
let hasNormalSummonableMonster board =
let hand = board ^. Board.currentPlayerHand
let monsters = List.choose monster hand
let result =
List.tryFind <| (monster
>> (isNormalSummonable board)
>> Option.isSome)
<| hand
Option.isSome result
List.exists <| isNormalSummonable board <| monsters
let canNormalSummon board =
hasNormalSummonableMonster board && board ^. Board.currentPlayerLastNormalSummon < board ^. Board.turn
@ -215,8 +207,6 @@ module Summon =
let free = freeMonsterZones <| board ^. Board.currentPlayer
let zone = chooseZone client free
let turn = board ^. Board.turn
board |> Board.currentPlayerLastNormalSummon .-> turn