   submitCurrentAction: (gameId) ->
     game = getGame(gameId)
     ensureIsCurrentPlayer(game, this.userId)
-    currentActionId = game.currentAction
-
-    unless noughts.isLegalAction(getAction(currentActionId))
+
+    unless noughts.isLegalAction(gameId, game.currentAction)
       die("Illegal action!")
 
     newPlayerId = if game.currentPlayer == X_PLAYER then O_PLAYER else X_PLAYER

  # participant in it.
  validateGameId: (gameId) -> noughts.Games.findOne(gameId)

# Checks if somebody has won this game. If they have, returns the winner's
# user ID. Otherwise, returns false.
noughts.checkForVictory = (game) ->
  getMove = (column, row) ->
    _.find(game.moves, (x) -> x.column == column and x.row == row)

  # All possible winning lines in (col, row) format
  victoryLines = [ [[0,0], [1,0], [2,0]], [[0,1], [1,1], [2,1]],
      [[0,2], [1,2], [2,2]], [[0,0], [0,1], [0,2]], [[1,0], [1,1], [1,2]],
      [[2,0], [2,1], [2,2]], [[0,0], [1,1], [2,2]], [[2,0], [1,1], [0,2]] ]

  for line in victoryLines
    move1 = getMove(line[0][0], line[0][1])
    move2 = getMove(line[1][0], line[1][1])
    move3 = getMove(line[2][0], line[2][1])
    continue unless move1? and move2? and move3?
    if move1.isX == move2.isX and move2.isX == move3.isX
      return if move1.isX then game.players[X_PLAYER] else game.players[O_PLAYER]
  return false

# Returns true if this game is a draw, otherwise false.
noughts.isDraw = (game) -> game.actions.length == 9

noughts.isLegalAction = (action) ->
  # TODO(dthurn): Implement this.
  true

      $set: {currentPlayer: newPlayerId, currentAction: newActionId}
      $push: {actions: newActionId}

    noughts.Actions.update game.currentAction,
      $set: {submitted: true}

  # Adds the provided command to the current action's command list. No
