/game-of-the-generals

Game of the Generals implemented in meteor

Primary LanguageJavaScriptMIT LicenseMIT

This is a meteor implementation of Game of the Generals, a Filipino board game invented by Sofronio H. Pasola, Jr. in 1970.

Code Climate

Getting Started

Improving

Suggestions on how to write better code are very welcome. I'm not satisfied with the current implementation.

OngoingGames Document

{
  "_id" : "J7fixfrMuCea76y2L",
  "p1" : "Q7TxcMn7",    // id of player 1
  "p2" : "u4fc2sc5",    // id of player 2
  "turn" : "Q7TxcMn7",  // id of active player
  "winner": null,       // id of winner
  "donePositioning" : {"Q7TxcMn7" : true, "u4fc2sc5" : true},
  "boardActual": {"11": {"owner": 1, "piece": 2}, ...},
  "boardViews": {
    "Q7TxcMn7": {"11": 2, ...},
    "u4fc2sc5": {"67": 2, ...},
  },
  "messages": [
    {"sender": "Arbiter", "message": "I want ice cream"},
    ...
  ],
  "lastMove" : {
	"1" : {
	    "from" : {"x" : 3, "y" : 2},
		"dest" : {"x" : 3, "y" : 3}
	},
	"2" : {
		"from" : {"x" : 5, "y" : 5},
		"dest" : {"x" : 5, "y" : 4}
	}
  },
  "numMoves": 1
}

Board Actual

This represents the true view of the board.

Keys are 2 character strings representing (x,y) coordinates in the board. Columns go from 0 to 8. Rows go from 0 to 7.

Player 1 starts at rows 0, 1, and 2; while player 2 starts at rows 6, 7, and 8.

Values are the pieces where "owner" is either 1 or 2, representing the player number, and "piece" is the piece code, as defined in lib/utils/pieces.js.

Board View

Since players can only know the location of enemy pieces but not the identity, each player has her own board view.

Pieces are now represented directly using piece codes for the player's own pieces and VIEW_PIECES.UNKNOWN for enemy pieces.

TODO Also, player 2's view is flipped from board actual.