func (self *GameAPI) CreateMatch(challengerPlayer, challengedPlayer string) *model.Match { matchID := challengerPlayer + "_" + challengedPlayer match := model.NewMatch(matchID, challengerPlayer, challengedPlayer) match.MatchStartTs = util.Now() log.Info(challengerPlayer + " challenged " + challengedPlayer) self.gameDAO.CreateMatch(match) controller := model.NewGameController() controller.Create(challengerPlayer, challengedPlayer) data, failure := controller.GetBoardData() if failure == nil { self.gameDAO.SaveGame(match.MatchID, data) } else { // xxx TODO! fmt.Println("BAAAAD!", failure) } return match }
func (self *GameAPI) GetGameController(matchID string) *model.GameController { gameData := self.gameDAO.GetGame(matchID) controller := model.NewGameController() controller.SetBoardData(gameData) return controller }
// private func getGameController(api *GameAPI, matchID string) *model.GameController { gameData := api.gameDAO.GetGame(matchID) controller := model.NewGameController() controller.SetBoardData(gameData) return controller }