Client ~ GameInterface Schema - UofM-COMP4350-4/NBGI GitHub Wiki

Draft 1

Interprets the generic-form message the Client passes to it into something game-specific that can be used by the game controllers/views. Translates game data back to a generic format for use by the client elsewhere. One GameInterface for each game in the infrastructure.

##Component Events Event name: "onMove"

Forwards a request from a game to make a move request.

  • Event data:
{
    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
    }
}

##Component API

gameName {String} - Displayable name of the game

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
}

updateGameBoard(data)

  • data {Object} - Current gameboard state data to update to
{
    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
}

resultsDeclared(results)

  • results {Object} - Match end-result data to forward to the game.
{
    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 the form of "updateGameBoard" function data format
    moves:undefined // {Array} - List of all the user's moves (successful "onMove" event data objects)
}
⚠️ **GitHub.com Fallback** ⚠️