BeziqueCardGame.SDK
1.5.0
dotnet add package BeziqueCardGame.SDK --version 1.5.0
NuGet\Install-Package BeziqueCardGame.SDK -Version 1.5.0
<PackageReference Include="BeziqueCardGame.SDK" Version="1.5.0" />
<PackageVersion Include="BeziqueCardGame.SDK" Version="1.5.0" />
<PackageReference Include="BeziqueCardGame.SDK" />
paket add BeziqueCardGame.SDK --version 1.5.0
#r "nuget: BeziqueCardGame.SDK, 1.5.0"
#:package BeziqueCardGame.SDK@1.5.0
#addin nuget:?package=BeziqueCardGame.SDK&version=1.5.0
#tool nuget:?package=BeziqueCardGame.SDK&version=1.5.0
Bezique Card Game SDK
A comprehensive C# SDK for implementing the Bezique card game in Unity and .NET applications. The SDK provides complete game logic, rule enforcement, AI opponents, and online multiplayer capabilities through a server-authoritative architecture.
Features
- Complete Game Rules - Full implementation of Bezique rules including melds, tricks, trump mechanics, and scoring
- Server-Authoritative - All game logic resides server-side; clients are pure presentation layers
- Unity Compatible - Targets
netstandard2.1for Unity 2021.3+ compatibility - AI Opponents - Built-in AI bot controllers for single-player scenarios
- Online Multiplayer - SignalR-based real-time multiplayer with matchmaking
- Authentication - Built-in authentication (guest, email/password, Google OAuth)
- Event-Driven API - Clean event system for UI updates and game state changes
Installation
.NET Projects
Install the SDK via NuGet Package Manager or .NET CLI:
dotnet add package BeziqueCardGame.SDK
Unity Projects
Using NuGetForUnity (recommended):
- Install NuGetForUnity
- Search for
BeziqueCardGame.SDKin the NuGet window - Click Install
The SDK will automatically include all required dependencies:
BeziqueCardGame.SDK.Core- Data models and typesBeziqueCardGame.SDK.Local- Local gameplay and AIBeziqueCardGame.SDK.MatchMaker- Online multiplayer clientBeziqueCardGame.Sdk.Auth- Authentication
Quick Start
Single-Player Game (Human vs AI)
using BeziqueCardGame.SDK.Core;
using BeziqueCardGame.SDK.Local;
// Configure the match
var config = new MatchConfig(
GameMode.Standard, // Standard or Advanced
targetScore: 750,
playerCount: 2
);
// Set up controllers: Human vs AI
var controllers = new IPlayerController[]
{
new HumanController(),
new AiBotController(new LocalRandom())
};
// Create and start the game
var client = new LocalGameClient(config, controllers);
// Subscribe to game events
client.OnTrumpRevealed += (suit, card) => {
Console.WriteLine($"Trump card: {card.ToCardString()}");
};
client.OnTrickEvaluated += (winner, cards) => {
Console.WriteLine($"Player {winner} won the trick!");
};
client.OnRoundEnded += (scores) => {
Console.WriteLine($"Final scores: {scores[0]} - {scores[1]}");
};
// Start the game
if (client.TryStartSinglePlayerGame(out string error))
{
// Game is running - call RunUntilHumanInput() after each human action
client.RunUntilHumanInput();
}
else
{
Console.WriteLine($"Failed to start: {error}");
}
Playing Cards
// Human player plays a card
byte playerId = 0;
byte cardToPlay = hand[0]; // Card byte from player's hand
if (client.TryPlayCard(playerId, cardToPlay, out string error))
{
// Card accepted - let AI play until next human input needed
client.RunUntilHumanInput();
}
else
{
Console.WriteLine($"Invalid play: {error}");
}
Declaring Melds
// After winning a trick, declare a meld
var meldCards = new List<byte> { card1, card2, card3, card4, card5 };
if (client.TryDeclareMeld(playerId, meldCards, out string error))
{
Console.WriteLine("Meld accepted!");
}
else
{
Console.WriteLine($"Invalid meld: {error}");
}
API Reference
LocalGameClient
The main class for managing local games.
Constructor
LocalGameClient(MatchConfig config, IPlayerController[] controllers)
Key Methods
| Method | Description |
|---|---|
TryStartSinglePlayerGame(out string error) |
Starts the game and auto-plays bot turns |
RunUntilHumanInput() |
Advances game state until human input is required |
TryPlayCard(playerId, card, out error) |
Play a card from hand |
TryDeclareMeld(playerId, cards, out error) |
Declare a meld after winning a trick |
TrySkipMeld(out error) |
Skip meld declaration |
TrySwapTrump7(out error) |
Swap trump 7 with face-up trump card |
TrySkipSwap(out error) |
Skip trump 7 swap |
HasAnyMelds(playerId) |
Check if player has any valid melds available |
TryAutoSkipMeldIfNoValidMelds(playerId, out error) |
Auto-skip if no melds available |
TryRematch(out error) |
Start a new match |
State Queries
| Property | Type | Description |
|---|---|---|
CurrentPhase |
GamePhase |
Current game phase (Playing, MeldDecision, Trump7Swap, GameOver, Processing) |
CurrentPlayerId |
byte |
Whose turn it is |
LeadPlayerId |
byte |
Who leads the current trick |
TrumpSuit |
byte |
Trump suit byte |
TrumpCard |
byte |
Face-up trump card byte |
DeckCount |
int |
Cards remaining in deck |
PlayerCount |
int |
Number of players |
IsGameOver |
bool |
Match has concluded |
WinnerIndex |
byte |
Winning player index |
HasTrump7Option |
bool |
Current player can swap trump 7 |
IsWaitingForInput |
bool |
Game is waiting for player input |
TableCards |
IReadOnlyList<byte> |
Cards on the table |
Events
| Event | Signature | Description |
|---|---|---|
OnCardsDealt |
Action<byte, IReadOnlyList<byte>> |
Fired when cards are dealt |
OnTrumpRevealed |
Action<byte, byte> |
Fired when trump card is revealed |
OnCardDrawn |
Action<byte, byte> |
Fired when a player draws a card |
OnTrickEvaluated |
Action<byte, IReadOnlyList<byte>> |
Fired when a trick is won |
OnRoundEnded |
Action<ushort[]> |
Fired when round ends (all scores) |
OnMeldScored |
Action<byte, List<byte>, ushort> |
Fired when a meld is scored |
MatchConfig
Game configuration settings.
public struct MatchConfig
{
public readonly GameMode GameMode; // Standard or Advanced
public readonly ushort TargetScore; // 750, 1000, or 1500
public readonly byte PlayerCount; // 2 or 4 players
public readonly byte AceTenThreshold; // Calculated based on player count
}
IPlayerController
Interface for player input controllers.
public interface IPlayerController
{
byte ChooseCard(IReadOnlyList<byte> hand, GameStateView state);
List<byte> ChooseMeld(IReadOnlyList<byte> hand, byte trumpSuit, GameStateView state);
bool ChooseTrump7Swap(GameStateView state);
}
Unity Integration
MonoBehaviour Example
using UnityEngine;
using BeziqueCardGame.SDK.Core;
using BeziqueCardGame.SDK.Local;
public class BeziqueGameManager : MonoBehaviour
{
private LocalGameClient _client;
private byte _humanPlayerId = 0;
void Start()
{
var config = new MatchConfig(GameMode.Standard, 750, 2);
var controllers = new IPlayerController[]
{
new HumanController(),
new AiBotController(new LocalRandom())
};
_client = new LocalGameClient(config, controllers);
SubscribeToEvents();
if (!_client.TryStartSinglePlayerGame(out string error))
{
Debug.LogError($"Failed to start: {error}");
return;
}
RefreshUI();
}
// Called from UI when player taps a card
public void OnCardTapped(byte cardByte)
{
if (_client.CurrentPlayerId != _humanPlayerId) return;
if (!_client.TryPlayCard(_humanPlayerId, cardByte, out string error))
{
ShowErrorToast(error);
return;
}
_client.RunUntilHumanInput();
RefreshUI();
}
void RefreshUI()
{
if (_client.TryGetPlayerHand(_humanPlayerId, out var hand, out _))
{
UpdateHandDisplay(hand);
}
ushort[] scores = _client.GetAllScores();
UpdateScoreDisplay(scores);
// Update UI based on current game phase
switch (_client.CurrentPhase)
{
case GamePhase.Playing:
ShowPlayCardUI();
break;
case GamePhase.MeldDecision:
ShowMeldUI();
break;
case GamePhase.Trump7Swap:
ShowTrump7SwapUI();
break;
case GamePhase.GameOver:
ShowGameOverScreen();
break;
}
}
void SubscribeToEvents()
{
_client.OnTrumpRevealed += (suit, card) => {
UpdateTrumpIndicator(card);
};
_client.OnTrickEvaluated += (winner, cards) => {
AnimateTrickWin(winner, cards);
};
_client.OnRoundEnded += (scores) => {
ShowRoundSummary(scores);
};
}
}
For detailed Unity integration instructions, see the Consumer Guide.
Online Multiplayer
For online multiplayer functionality, use the AuthClient and GameClient classes from the included MatchMaker SDK.
using BeziqueCardGame.Sdk.Auth;
using BeziqueCardGame.SDK.MatchMaker;
// Authenticate
var authClient = new AuthClient("https://your-server.com");
var loginResult = await authClient.GuestLoginAsync();
// Connect to game hub
var gameClient = await loginResult.Session.ConnectToGameAsync();
// Create or join a room
var roomResult = await gameClient.CreateOrJoinRoomAsync("Bezique");
// Listen for game events
gameClient.OnGameState += (state) => {
// Update UI with server state
};
Game Rules Overview
Bezique is a trick-taking card game for 2-4 players using 4 standard decks plus 4 jokers (132 cards total).
Objective
First player to reach the target score (750, 1,000, or 1,500 points) wins.
Scoring
| Meld | Points |
|---|---|
| Trump Run (A, 10, K, Q, J) | 250 |
| Double Bezique | 500 |
| Four Aces | 100 |
| Four Kings | 80 |
| Four Queens | 60 |
| Four Jacks / Bezique | 40 |
| Trump Marriage (K, Q) | 40 |
| Non-Trump Marriage (K, Q) | 20 |
| Trump 7 | 10 |
| Each Ace/10 in tricks | 10 |
Card Ranking
Ace > 10 > King > Queen > Jack > 9 > 8 > 7
For complete rules, see the Game Rules Documentation.
Requirements
- .NET 10.0 or .NET Standard 2.1 (for Unity compatibility)
- Unity 2021.3+ (for Unity projects)
Documentation
Consumer Documentation (SDK Users)
| Document | Description |
|---|---|
| Game Rules | Complete Bezique card game rules with meld reusability |
| Game Story | Narrative guide to the game flow |
| Game Design | Game design document |
| Test Scenarios | 88 test scenarios for validation |
| Architecture | System architecture diagrams |
| Game Flow | State machine flow diagrams |
| Consumer Guide | Integration guide for Unity/Web |
| Web Implementation | Web-specific implementation |
Developer Documentation
| Document | Description |
|---|---|
| CLAUDE.md | Project instructions for AI development |
| AGENTS.md | Agent system documentation |
| agent/SKILL.md | Web client integration skill guide |
| UnityIntegrationGuide | Unity/Web integration patterns |
License
This project is licensed under the MIT License.
Package ID: BeziqueCardGame.SDK
Version: 1.0.5
Authors: CoreLoopStudio
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.5.0 | 123 | 9/8/2026 |
| 1.4.9 | 123 | 9/5/2026 |
| 1.4.8 | 129 | 8/6/2026 |
| 1.4.7 | 123 | 8/6/2026 |
| 1.4.6 | 130 | 7/15/2026 |
| 1.4.5 | 125 | 7/4/2026 |
| 1.4.4 | 130 | 6/30/2026 |
| 1.4.3 | 130 | 6/17/2026 |
| 1.4.2 | 143 | 6/17/2026 |
| 1.4.1 | 128 | 6/9/2026 |
| 1.4.0 | 130 | 6/9/2026 |
| 1.3.1 | 125 | 5/23/2026 |
| 1.3.0 | 120 | 5/23/2026 |
| 1.2.0 | 120 | 5/23/2026 |
| 1.1.1 | 122 | 5/23/2026 |
| 1.1.0 | 134 | 5/15/2026 |
| 1.0.6 | 121 | 5/15/2026 |
| 1.0.5 | 122 | 5/15/2026 |
| 1.0.4 | 119 | 5/7/2026 |
| 1.0.3 | 128 | 5/6/2026 |