fsharp(ygosim): feat: added basic effect types
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
6e0c6dbf5b
commit
6ea2d71082
|
@ -1,14 +1,14 @@
|
||||||
module Board
|
module Board
|
||||||
|
|
||||||
module Side =
|
module Side =
|
||||||
open Card
|
open Card.Card
|
||||||
|
|
||||||
type Side =
|
type Side<'s> =
|
||||||
{ field: CardInstance option
|
{ field: CardInstance<'s> option
|
||||||
monsters: CardInstance list
|
monsters: CardInstance<'s> list
|
||||||
spells: CardInstance list
|
spells: CardInstance<'s> list
|
||||||
graveyard: CardInstance list
|
graveyard: CardInstance<'s> list
|
||||||
deck: CardInstance list }
|
deck: CardInstance<'s> list }
|
||||||
|
|
||||||
let emptySide =
|
let emptySide =
|
||||||
{ field = None
|
{ field = None
|
||||||
|
@ -20,27 +20,27 @@ module Side =
|
||||||
|
|
||||||
module Player =
|
module Player =
|
||||||
open Side
|
open Side
|
||||||
open Card
|
open Card.Card
|
||||||
|
|
||||||
type PlayerState =
|
type PlayerState =
|
||||||
| InGame
|
| InGame
|
||||||
| Won
|
| Won
|
||||||
| Lost of reason: string
|
| Lost of reason: string
|
||||||
|
|
||||||
type Player =
|
type Player<'s> =
|
||||||
{ lifePoints: int
|
{ lifePoints: int
|
||||||
side: Side
|
side: Side<'s>
|
||||||
hand: CardInstance list
|
hand: CardInstance<'s> list
|
||||||
state: PlayerState }
|
state: PlayerState }
|
||||||
|
|
||||||
let inflictDamage (player: Player) amount = { player with lifePoints = player.lifePoints - amount }
|
|
||||||
|
|
||||||
let initialPlayer lp =
|
let initialPlayer lp =
|
||||||
{ lifePoints = lp
|
{ lifePoints = lp
|
||||||
side = emptySide
|
side = emptySide
|
||||||
hand = []
|
hand = []
|
||||||
state = InGame }
|
state = InGame }
|
||||||
|
|
||||||
|
// module Side =
|
||||||
|
|
||||||
module Turn =
|
module Turn =
|
||||||
type Phase =
|
type Phase =
|
||||||
| Draw
|
| Draw
|
||||||
|
@ -60,24 +60,45 @@ module Turn =
|
||||||
| End -> (Draw, turn + 1)
|
| End -> (Draw, turn + 1)
|
||||||
|
|
||||||
module Board =
|
module Board =
|
||||||
open Player
|
|
||||||
open Turn
|
open Turn
|
||||||
|
open Card
|
||||||
|
|
||||||
type Board =
|
type Player = Player.Player<Board>
|
||||||
|
|
||||||
|
and Board =
|
||||||
{ players: Player * Player
|
{ players: Player * Player
|
||||||
turn: int
|
turn: int
|
||||||
phase: Phase }
|
phase: Phase }
|
||||||
|
|
||||||
|
type Card = Card.Card<Board>
|
||||||
|
|
||||||
|
type CardInstance = Card.CardInstance<Board>
|
||||||
|
|
||||||
|
type Effect = Effect.Effect<Board>
|
||||||
|
|
||||||
|
type Condition = Effect.Condition<Board>
|
||||||
|
|
||||||
|
type Action = Effect.Action<Board>
|
||||||
|
|
||||||
let emptyBoard =
|
let emptyBoard =
|
||||||
{ players = (initialPlayer 8000, initialPlayer 8000)
|
{ players = (Player.initialPlayer 8000, Player.initialPlayer 8000)
|
||||||
turn = 0
|
turn = 0
|
||||||
phase = Turn.Draw }
|
phase = Draw }
|
||||||
|
|
||||||
module Game =
|
module Game =
|
||||||
open Board
|
open Board
|
||||||
open Turn
|
open Turn
|
||||||
open Player
|
open Player
|
||||||
open Card
|
|
||||||
|
type PlayerAction =
|
||||||
|
| Pass
|
||||||
|
| NormalSummon
|
||||||
|
| InitialDraw
|
||||||
|
| Activate
|
||||||
|
| Set
|
||||||
|
|
||||||
|
// let canDoInitialDraw (board: Board) =
|
||||||
|
|
||||||
|
|
||||||
let draw (player: Player) =
|
let draw (player: Player) =
|
||||||
match player.side.deck with
|
match player.side.deck with
|
||||||
|
|
|
@ -1,9 +1,30 @@
|
||||||
module Card
|
module Card
|
||||||
|
|
||||||
// TODO: actually implement it
|
|
||||||
type BaseCard =
|
module Effect =
|
||||||
|
type Condition<'s> = 's -> bool
|
||||||
|
|
||||||
|
type Action<'s> =
|
||||||
|
{ condition: Condition<'s>
|
||||||
|
resolution: 's -> 's }
|
||||||
|
|
||||||
|
type EffectType =
|
||||||
|
| Trigger
|
||||||
|
| Ignition
|
||||||
|
|
||||||
|
type Effect<'s> =
|
||||||
|
{ cost: Action<'s>
|
||||||
|
resolve: Action<'s>
|
||||||
|
_type: EffectType }
|
||||||
|
|
||||||
|
|
||||||
|
module Card =
|
||||||
|
open Effect
|
||||||
|
|
||||||
|
type BaseCard<'s> =
|
||||||
{ name: string
|
{ name: string
|
||||||
text: string }
|
text: string
|
||||||
|
effects: Effect<'s> list }
|
||||||
|
|
||||||
type SpellCardType =
|
type SpellCardType =
|
||||||
| NormalSpell
|
| NormalSpell
|
||||||
|
@ -68,10 +89,16 @@ type MonsterCardDetails =
|
||||||
level: int }
|
level: int }
|
||||||
|
|
||||||
|
|
||||||
type Card =
|
type Card<'s> =
|
||||||
| Monster of BaseCard * MonsterCardDetails
|
| Monster of BaseCard<'s> * MonsterCardDetails
|
||||||
| Spell of BaseCard * SpellCardDetails
|
| Spell of BaseCard<'s> * SpellCardDetails
|
||||||
| Trap of BaseCard * TrapCardDetails
|
| Trap of BaseCard<'s> * TrapCardDetails
|
||||||
|
|
||||||
// TODO: actually make this do what its supposed to
|
// TODO: actually make this do what its supposed to
|
||||||
type CardInstance = Card
|
type CardInstance<'s> = Card<'s>
|
||||||
|
|
||||||
|
module Decklist =
|
||||||
|
type Decklist =
|
||||||
|
{ main: int list
|
||||||
|
side: int list
|
||||||
|
extra: int list }
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
open Game
|
open Game
|
||||||
|
|
||||||
[<EntryPoint>]
|
[<EntryPoint>]
|
||||||
let main argv =
|
let main _ =
|
||||||
let board = Board.emptyBoard
|
let board = Board.emptyBoard
|
||||||
let sampleCard = Spell ({name= "sampleCard"; text="something"}, {spellType = Card.ContinuosSpell})
|
let sampleCard = Card.Spell ({name= "sampleCard"; text="something"; effects = []}, {spellType = Card.ContinuosSpell})
|
||||||
|
|
||||||
let secondBoard = withCurrentPlayer <| Game.toDeckBottom sampleCard <| board
|
let secondBoard = withCurrentPlayer <| Game.toDeckBottom sampleCard <| board
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue