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 Side =
|
||||
open Card
|
||||
open Card.Card
|
||||
|
||||
type Side =
|
||||
{ field: CardInstance option
|
||||
monsters: CardInstance list
|
||||
spells: CardInstance list
|
||||
graveyard: CardInstance list
|
||||
deck: CardInstance list }
|
||||
type Side<'s> =
|
||||
{ field: CardInstance<'s> option
|
||||
monsters: CardInstance<'s> list
|
||||
spells: CardInstance<'s> list
|
||||
graveyard: CardInstance<'s> list
|
||||
deck: CardInstance<'s> list }
|
||||
|
||||
let emptySide =
|
||||
{ field = None
|
||||
|
@ -20,27 +20,27 @@ module Side =
|
|||
|
||||
module Player =
|
||||
open Side
|
||||
open Card
|
||||
open Card.Card
|
||||
|
||||
type PlayerState =
|
||||
| InGame
|
||||
| Won
|
||||
| Lost of reason: string
|
||||
|
||||
type Player =
|
||||
type Player<'s> =
|
||||
{ lifePoints: int
|
||||
side: Side
|
||||
hand: CardInstance list
|
||||
side: Side<'s>
|
||||
hand: CardInstance<'s> list
|
||||
state: PlayerState }
|
||||
|
||||
let inflictDamage (player: Player) amount = { player with lifePoints = player.lifePoints - amount }
|
||||
|
||||
let initialPlayer lp =
|
||||
{ lifePoints = lp
|
||||
side = emptySide
|
||||
hand = []
|
||||
state = InGame }
|
||||
|
||||
// module Side =
|
||||
|
||||
module Turn =
|
||||
type Phase =
|
||||
| Draw
|
||||
|
@ -60,24 +60,45 @@ module Turn =
|
|||
| End -> (Draw, turn + 1)
|
||||
|
||||
module Board =
|
||||
open Player
|
||||
open Turn
|
||||
open Card
|
||||
|
||||
type Board =
|
||||
type Player = Player.Player<Board>
|
||||
|
||||
and Board =
|
||||
{ players: Player * Player
|
||||
turn: int
|
||||
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 =
|
||||
{ players = (initialPlayer 8000, initialPlayer 8000)
|
||||
{ players = (Player.initialPlayer 8000, Player.initialPlayer 8000)
|
||||
turn = 0
|
||||
phase = Turn.Draw }
|
||||
phase = Draw }
|
||||
|
||||
module Game =
|
||||
open Board
|
||||
open Turn
|
||||
open Player
|
||||
open Card
|
||||
|
||||
type PlayerAction =
|
||||
| Pass
|
||||
| NormalSummon
|
||||
| InitialDraw
|
||||
| Activate
|
||||
| Set
|
||||
|
||||
// let canDoInitialDraw (board: Board) =
|
||||
|
||||
|
||||
let draw (player: Player) =
|
||||
match player.side.deck with
|
||||
|
|
|
@ -1,11 +1,32 @@
|
|||
module Card
|
||||
|
||||
// TODO: actually implement it
|
||||
type BaseCard =
|
||||
{ name: string
|
||||
text: string }
|
||||
|
||||
type SpellCardType =
|
||||
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
|
||||
text: string
|
||||
effects: Effect<'s> list }
|
||||
|
||||
type SpellCardType =
|
||||
| NormalSpell
|
||||
| Field
|
||||
| Equip
|
||||
|
@ -13,12 +34,12 @@ type SpellCardType =
|
|||
| QuickPlay
|
||||
| Ritual
|
||||
|
||||
type TrapCardType =
|
||||
type TrapCardType =
|
||||
| NormalTrap
|
||||
| Counter
|
||||
| ContinuosTrap
|
||||
|
||||
type Attribute =
|
||||
type Attribute =
|
||||
| Dark
|
||||
| Light
|
||||
| Water
|
||||
|
@ -27,7 +48,7 @@ type Attribute =
|
|||
| Wind
|
||||
| Divine
|
||||
|
||||
type Race =
|
||||
type Race =
|
||||
| Aqua
|
||||
| Beast
|
||||
| BeastWarrior
|
||||
|
@ -54,24 +75,30 @@ type Race =
|
|||
| Wyrm
|
||||
| Zombie
|
||||
|
||||
type SpellCardDetails =
|
||||
type SpellCardDetails =
|
||||
{ spellType: SpellCardType }
|
||||
|
||||
type TrapCardDetails =
|
||||
type TrapCardDetails =
|
||||
{ trapType: TrapCardType }
|
||||
|
||||
|
||||
type MonsterCardDetails =
|
||||
type MonsterCardDetails =
|
||||
{ attack: int
|
||||
defense: int
|
||||
attribute: Attribute
|
||||
level: int }
|
||||
|
||||
|
||||
type Card =
|
||||
| Monster of BaseCard * MonsterCardDetails
|
||||
| Spell of BaseCard * SpellCardDetails
|
||||
| Trap of BaseCard * TrapCardDetails
|
||||
type Card<'s> =
|
||||
| Monster of BaseCard<'s> * MonsterCardDetails
|
||||
| Spell of BaseCard<'s> * SpellCardDetails
|
||||
| Trap of BaseCard<'s> * TrapCardDetails
|
||||
|
||||
// TODO: actually make this do what its supposed to
|
||||
type CardInstance = Card
|
||||
// TODO: actually make this do what its supposed to
|
||||
type CardInstance<'s> = Card<'s>
|
||||
|
||||
module Decklist =
|
||||
type Decklist =
|
||||
{ main: int list
|
||||
side: int list
|
||||
extra: int list }
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
open Game
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
let main _ =
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue