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:
parent
4bfc7c050a
commit
6189917e92
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue