feat: add Blackjack example
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace Blackjack;
|
||||
|
||||
/// <summary>
|
||||
/// A playing card with a suit and rank.
|
||||
/// One entity per card.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public struct Card
|
||||
{
|
||||
[Key(0)] public Suit Suit;
|
||||
[Key(1)] public Rank Rank;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace Blackjack;
|
||||
|
||||
/// <summary>
|
||||
/// Tag component marking the dealer's hand entity.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public struct DealerHand { }
|
||||
@@ -0,0 +1,9 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace Blackjack;
|
||||
|
||||
/// <summary>
|
||||
/// Tag component marking the deck entity.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public struct Deck { }
|
||||
@@ -0,0 +1,15 @@
|
||||
using MessagePack;
|
||||
using OECS;
|
||||
|
||||
namespace Blackjack;
|
||||
|
||||
/// <summary>
|
||||
/// Relationship from a hand entity to a card entity,
|
||||
/// representing that the hand holds this card.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public struct Holds : IRelationship
|
||||
{
|
||||
[Key(0)] public Entity Source { get; set; }
|
||||
[Key(1)] public Entity Target { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using MessagePack;
|
||||
using OECS;
|
||||
|
||||
namespace Blackjack;
|
||||
|
||||
/// <summary>
|
||||
/// Relationship from a card entity to the deck entity,
|
||||
/// representing that the card is in the deck.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public struct InDeck : IRelationship
|
||||
{
|
||||
[Key(0)] public Entity Source { get; set; }
|
||||
[Key(1)] public Entity Target { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace Blackjack;
|
||||
|
||||
/// <summary>
|
||||
/// Tag component marking the player's hand entity.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public struct PlayerHand { }
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Blackjack;
|
||||
|
||||
public enum Rank : byte
|
||||
{
|
||||
Ace = 1,
|
||||
Two = 2,
|
||||
Three = 3,
|
||||
Four = 4,
|
||||
Five = 5,
|
||||
Six = 6,
|
||||
Seven = 7,
|
||||
Eight = 8,
|
||||
Nine = 9,
|
||||
Ten = 10,
|
||||
Jack = 11,
|
||||
Queen = 12,
|
||||
King = 13
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Blackjack;
|
||||
|
||||
public enum Suit : byte
|
||||
{
|
||||
Clubs = 0,
|
||||
Diamonds = 1,
|
||||
Hearts = 2,
|
||||
Spades = 3
|
||||
}
|
||||
Reference in New Issue
Block a user