Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Server Documentation

Codex04 edited this page Nov 12, 2017 · 1 revision

Servers

Program Core
Game Referee

Program

Entry point of the server project

Core

Core class of the server

Constructor

Default constructor of the Core

Instance

Getter and Setter of the singleton instance of the Core

Locker

Getter and Setter for the locker state of the Core

Start

Start the server's dependencies like the Network and loop infinitly the execution.

Game

Game Logic for the Belote card Game used by Referee

Constructor

Default constructor for Game

AIEntryPoint(name, p)

Main entry point for all the AI actions

Name Description
name System.String
Define the name of the player which the AI will play for.
p CardGameResources.Net.Packet
The packet transmission that the AI will use

AIPlayCard(name)

Logic for AI on CardGameResources.Net.EnvInfos.S_SET_TOUR event.

Name Description
name System.String
The name of the player who must play

AITakeTrump(data)

Logic for AI on CardGameResources.Net.GameAction.S_REQUEST_TRUMP_FROM event.

Name Description
data System.Collections.Generic.KeyValuePair{System.Int32,System.String}
A pair of value which contains the lap number and the name of the player who must play

AssignTrump(name, color)

Assign a name and a color to the Game.TrumpInfos

Name Description
name System.String
The name of the owner
color System.String
The name of the real color of the tump

CheckDeckWinner

This method check who's the winner for the current round, update the scores and notify the users about it

Returns

The name of the winner

FillUserDeck

This method will randomly fill the CardGameResources.Game.Deck of all the connected users with a limit of 8 CardGameResources.Game.Card per user.

GamePlayCheckMove(userDeck, playedCard, board, color, powerCheck)

Utility method mainly used by Game.PlayCard_callback(System.String,CardGameResources.Game.Card) to check if a user can play a specific CardGameResources.Game.Card

Name Description
userDeck CardGameResources.Game.Deck
The deck from which "playedCard" is issued
playedCard CardGameResources.Game.Card
The CardGameResources.Game.Card played
board CardGameResources.Game.Deck
The current CardGameResources.Game.Deck on the board
color System.String
The current board main color
powerCheck System.Boolean
If set to true, the method will also check if the user have a better card in he's CardGameResources.Game.Deck

Returns

GetCardPoints(card)

Get the amount of point for a specific CardGameResources.Game.Card. This method take in consideration the actual trump.

Name Description
card CardGameResources.Game.Card

Returns

The amount of point for card

GetCardValue(card)

Return the real value for the paramaeter card. This method allow the user to do some arithmetics and comparaison with the cards.

Name Description
card CardGameResources.Game.Card

Returns

The value of the card as an integer

GetUserListFrom(begin)

Generate a new list of user which indicate the order of the plays

Name Description
begin System.String
The username which will play first

Returns

The ordered list of players

GiveCards

This method distribute randomly 5 CardGameResources.Game.Card per user

Init

This method will initialize each component of the game logic

InitMasterDeck

Initialize the master deck, which is a constant CardGameResources.Game.Deck of all the 32 avalaible cards.

InitUsersDeck

Initialize the user CardGameResources.Game.Decks with 5 CardGameResources.Game.Card

IsColorInDeck(deck, color)

This method will check if there is at least one CardGameResources.Game.Card with the color color in the deck

Name Description
deck CardGameResources.Game.Deck
The CardGameResources.Game.Deck of card which will be the object of the search.
color System.String
The color which will be used for the search.

Returns

The number of CardGameResources.Game.Card which match the color

PlayCard_callback(name, card)

Entry point of the main rules method. It will be called when the server receive a request of type CardGameResources.Net.GameAction.C_PLAY_CARD This function act also as a referee by checking if the user movement does not break any rules.

Name Description
name System.String
The name of the user who sent the command
card CardGameResources.Game.Card
The card that the user want to play

PlayCard(name, card)

This function will play a specific CardGameResources.Game.Card for name. It'll also update all the needed variables and trigger all the changes to the users.

Name Description
name System.String
The name of the user who sent the command
card CardGameResources.Game.Card
The card that the user want to play

PlayPhase

Entry point for the main gameplay phase. Manage the core of the game.

Reconnect(name)

Reconnect a player who's been previously disconnect from the server.

Name Description
name System.String
The name of the player who just registered

Reset

This method is designed to totally reset the game logic.

Run

Start the GamePlay phases: TrumpPhase, PlayPhase ; then end the game

Send(type, data)

Send some data of type "type" to all registered users.

Name Description
type CardGameResources.Net.PacketType
The type of data which will be send
data System.Object
The data which will be send

Returns

Send(name, type, data)

Send some data of type "type" to name.

Name Description
name System.String
The username who will receive the request
type CardGameResources.Net.PacketType
The type of the data which will be send
data System.Object
The data which will be send

StartGame

Entry point of the game. Called by the referee when 4 players are connected

TakeTrump_callback(name, ans)

Callback method when the server receive a CardGameResources.Net.GameAction.C_TAKE_TRUMP request

Name Description
name System.String
The name of the user who sent the request
ans System.Boolean
The answer of the user

TakeTrumpAs_callback(name, color)

Callback method when the server receive a CardGameResources.Net.GameAction.C_TAKE_TRUMP_AS request

Name Description
name System.String
The name of the user who sent the request
color System.String
A string containing the color of the trump, or nothing

TrumpDecision

This method will chose a card for the trump randomly and will then notify all the clients about it

TrumpPhase

Manage the trump phase: init, request, chose, assign and notify

Returns

TrumpPhaseInitLock(phase)

Manage the locks for the trump phase

Name Description
phase System.Int32

TrumpPhaseWait(phase)

Lock the actions for trump phase

Name Description
phase System.Int32

Referee

The mission of the referee is to regulate the flow of request handled by the Network.Server. It also act as a router and can interact directly with the Referee.Game.

CheckRegisterValidity(name)

Check if the client can register to the server

Name Description
name System.String
The name of the client

EntryPoint(obj)

This method is triggered when the server receive an object. It Will redirect the object trhough the different routes

Name Description
obj System.Object
The CardGameResources.Net.Packet object serialized as an System.Object

GameEntryPoint(p)

GAME FUNCTIONS This function is called by the main entry point when the received object is of type CardGameResources.Net.PacketType.GAME

Name Description
p CardGameResources.Net.Packet
The CardGameResources.Net.Packet received from the server

Instance

A getter and a setter for the Referee singleton instance

PokeHandling(key, name)

This method is used to handle synchronous events. It will unlock the Network.Lock.Locker associated to the key of the CardGameResources.Net.Packet

Name Description
key System.UInt32
The key of the Network.Lock.Locker
name System.String
The name of the client who try to unlock the Network.Lock.Locker

Register(name, evt)

Try to register a user into the server. If the server went full, it'll start the game.

Name Description
name System.String
The name of the client who try to register
evt CardGameResources.Net.Syscall
The content of the CardGameResources.Net.Syscall event contained in the received CardGameResources.Net.Packet

SysEntryPoint(p)

SYS FUNCTIONS This function is called by the main entry point when the received object is of type CardGameResources.Net.PacketType.SYS

Name Description
p CardGameResources.Net.Packet
The CardGameResources.Net.Packet received from the server