Server ~ GameLogicInterface - UofM-COMP4350-4/NBGI GitHub Wiki
Interprets the generic-form message the Server passes to it into something game-specific that can be used by the particular game logic. Translates game data back to a generic format for use by the server elsewhere.
##Component Events Event name: "stateChanged"
Send when a gameboard state has changed
- Event data:
{
instanceID:0, // {Number} - Instance ID for match gameboard data
gameID:0, // {Number} - Type of game the game is
userToPlay:0, // {String} - User ID whose turn it is
players: { // {Object} - JSON of userID:userName pairs.
<userID>:"", // {String} - <userID> is the {String} value of the userID number
// and returns the displayable username
... // Repeating the userID:userName format for each player
},
currentBoard: { // {Object} - JSON of pieceID:piecePosition pairs.
<pieceID>: { // {Object} - <pieceID> is the {String} value of the pieceID
pos: { // {Object} - Position data for the piece
x:0, // {Number} - Board x-coordinate position number
y:0, // OPTIONAL {Number} - Board y-coordinate position number
z:0 // OPTIONAL {Number} - Board z-coordinate position number
}
},
... // Repeating the pieceID:piecePosition format for each piece on the board
},
status: undefined // {Object} - Any extra game-specific board data passed; undefined if none
}
Event name: "achievementAwarded"
Sent when the user gets an achievement in a game
- Event data:
{
instanceID:0, // {Number} - Instance ID for match results
title:"", // {String} - Title of the achievement
caption:"", // {String} - Caption for the achievement.
}
Event name: "matchFinished"
Send when a game is finished
- Event data:
{
instanceID:0, // {Number} - Instance ID for match results
winner:0, // {Number} - User ID of the match winner
score:0, // {Number} - Player's score for the match
gameBoard:undefined, // {Object} - Final game state in format of the "stateChanged" event data
moves:undefined // {Array} - List of all the user's moves
}
##Component API
evalute(moveData)
-
moveData
{Object} - Move data to be tested
{
instanceID:0, // {Number} - Instance ID for match the move request is for
reason:"", // {String} - Game-specific purpose of move
pieceID:0, // {Number} - Piece ID of the piece requesting to move
play:"", // {String} - Game-specific play information
pos1: { // {Object} - First position data for move request
x:0, // {Number} - Board x-coordinate position number
y:0, // OPTIONAL {Number} - Board y-coordinate position number
z:0 // OPTIONAL {Number} - Board z-coordinate position number
},
pos2: { // OPTIONAL {Object} - Second position data for move request
x:0, // OPTIONAL {Number} - Board x-coordinate position number
y:0, // OPTIONAL {Number} - Board y-coordinate position number
z:0 // OPTIONAL {Number} - Board z-coordinate position number
}
}
-
Function should return:
- {Object} - Gameboard state (in format of the "stateChanged" event data) after the move is executed; undefined if move is invalid
players
{Object} - JSON of userID:userName pairs.
{
<userID>:"", // {String} - <userID> is the {String} value of the userID number
// and returns the displayable username
... // Repeating the userID:userName format for each player
}