Back to help index

Game Class

The Game class must implement the following method:

response = Game.send(message)

Message

An Object with these properties:

Property name Type Value
command String One of the following:
  • "start"
  • "info"
  • "human_play"
  • "next"
data Object Dependant on the command property. See the table below.

The allowed pairs of command and data properties are the following:

command data Description
"start" Array of Array of Player objects Ask to start a new game with the teams specified in the data property
"info" undefined Require infos about the game
"human_play" HumanPlay Play the specified human card
"next" undefined Ask for the next event

Player

An Object with these properties:

Property name Type Value
type String One of the following:
  • "human"
  • "cpu"
name String Player's name

HumanPlay

An Object with these properties:

Property name Type Value
player String The name of the human player who is moving
card String The id of the card which is playing
take Number The index of the cards to take. take property is optional: if there is more than one possible take, a choice info is returned inside the Response object.

Response

An Object with these properties:

Property name Type Value
infos Array of Info objects A list of Informations about the current response
moves Array of Move objects A list of Objects representing the cards to move
cards Array of CardsGroup objects A list of CardsGroups to be updated (before cards movements)

Info

An Object with these properties:

Property name Type Value
info String One of the following:
  • "first_player"
  • "winner"
  • "waiting"
  • "summary"
  • "choice"
  • "info"
  • "cards_definition"
  • "scopa"
  • "cards_value_lt_10"
  • "2_equal_cards"
  • "3_equal_cards"
data Object Dependant on the info property. See the table below.

The allowed pairs of info and data properties are the following:

info data Description
"first_player" String data is the name of the first player of the match
"winner" Array of String List of the players who won the game
"waiting" String Waiting for move from human player with name data
"summary" Array of Summary objects Match summary
"choice" Choice List of possible takes
"info" GameInfo Informations about the game class
"cards_definition" Array of CardsGroup objects Define all cards groups on match start
"scopa" String data is the name of the player who made scopa
"cards_value_lt_10" String data is the name of the player with cards of values less than 10
"2_equal_cards" String data is the name of the player with 2 equal cards
"3_equal_cards" String data is the name of the player with 3 equal cards

Summary

An Object with these properties:

Property name Type Value
players Array of String List of players of the team
primiera Number Primiera value
cards Number Cards count (between 0 and 40)
seven_of_coins Number 1 if the team took the seven of coins, else 0
coins Number Number of coins (between 0 and 10)
scopa Number Number of scopa
re_bello Number 1 if the team took the king of coins, else 0
partial Number Points of the match
partial Number Total points of the game

Choice

An Object with these properties:

Property name Type Value
player String The name of the player who have to choose which cards take
takes Array of Array of Card objects List of possible takes

GameInfo

An Object with these properties:

Property name Type Value
name String Name of the game
number_of_players Array of Array of Number List of pairs of the allowed number of teams and players per team
description String Description of the game

CardsGroup

An Object with these properties:

Property name Type Value
type String One of the following:
  • "deck"
  • "hand"
  • "table"
id String A unique identifier
length Number The number of cards inside the group
owners Array of String List of group owners' names
covered Boolean Indicate whether the cards are covered (valid only if type is "hand")
side_cards Array of Card objects List of cards to show next to the deck (valid only if type is "deck")

Move

An Object with these properties:

Property name Type Value
source String The id of the source CardsGroup
dest String The id of the destination CardsGroup
cards Array of Card objects List of the cards to be moved
visible Boolean Indicate whether tha cards are visible to all players or not
move_on Card Card of the destination group where move cards on
visible_to String The name of the only player who can see this cards, valid only if visible is false

Card

An Object with these properties:

Property name Type Value
suit Number The suit of the card (between 0 and 3)
value Number The value of the card (between 1 and 10)
id String A unique identifier
new_value Number The new value of the card (between 1 and 10)

Suits are mapped as follows:

Value of the suit property Italian suit French suit
0 Coins Diamonds
1 Cups Hearths
2 Clubs Clubs
3 Swords Spades

Basic types

Boolean

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean

Number

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number

String

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String

Array

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

object

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object