Board Game Example
Here is an example of an object literal for a computer game that is played on a board:
codeconst gameDetails = {
name: "Super Board Game",
players: 2,
minAge: 8,
maxAge: 99,
duration: 60,
boardSize: {
width: 30,
height: 30
},
pieces: ["pawn", "rook", "knight", "bishop", "queen", "king"],
colors: ["red", "blue", "green", "yellow"],
rules: {
setup: "Each player chooses a color and places their pieces on the board according to the instructions.",
turns: "Players take turns moving their pieces according to the game rules.",
win: "The first player to capture the opponent's king wins the game."
},
accessories: ["dice", "timer", "scoreboard"],
ratings: {
overall: 4.5,
fun: 4.8,
difficulty: 3.2
},
recommendedPlayers: 2,
recommendedAge: 8,
variants: ["Super Board Game Deluxe", "Super Board Game Junior"],
madeBy: "Awesome Games Inc.",
releaseYear: 2020
}
In this object, the keys are: name
, players
, minAge
, maxAge
, duration
, boardSize
, pieces
, colors
, rules
, accessories
, ratings
, recommendedPlayers
, recommendedAge
, variants
, and madeBy
. Each key has a corresponding value that provides more details about the game. For example, the name
key has a value of "Super Board Game", which is the name of the game. The players
key has a value of 2
, which indicates that the game is designed for two players. The rules
key has a value of an object, which contains the instructions for how to set up, play, and win the game.
Last updated