/// <summary> /// sauvegarde une partie /// </summary> public void saveGame(bool endGame = false) { GameModelDB.GameStatus gameStatus = GameModelDB.GameStatus.STARTING; if (playerWhoPlay != null) { gameStatus = (playerWhoPlay.Equals(p1)) ? GameModelDB.GameStatus.TURNPLAYER1 : GameModelDB.GameStatus.TURNPLAYER2; } if (endGame) { gameStatus = GameModelDB.GameStatus.FINISHED; } board.MementoManager.saveData(board.convertBoardForCpp(), p1, p2, gameStatus); }
/// <summary> /// Constructeur du game <see cref="Diaballik.Game"/> /// </summary> /// <param name="board">Plateau du jeu</param> /// <param name="p1">Joueur 1 </param> /// <param name="p2">Joueur 2</param> /// <param name="gameStatus">Statut du jeu</param> public Game(Board board, Player p1, Player p2, GameModelDB.GameStatus gameStatus) { this.board = board; this.p1 = p1; this.p2 = p2; this.P1.Pass = this.IWantStopMyTurn; this.P2.Pass = this.IWantStopMyTurn; board.MementoManager.TurnDone = this.hePlayed; if (gameStatus == GameModelDB.GameStatus.TURNPLAYER1) { p1.Canplay = true; playerWhoPlay = p1; } else if (gameStatus == GameModelDB.GameStatus.TURNPLAYER2) { p2.Canplay = true; playerWhoPlay = p2; } else if (gameStatus == GameModelDB.GameStatus.STARTING) { choosePlayerTurn(); } }
/// <summary> /// sauvegarde les mouvements dans la base de données /// </summary> /// <param name="currentBoard">Board</param> /// <param name="p1">Joueur 1</param> /// <param name="p2">Joueur 2</param> /// <param name="gS">statut de la partie <see cref="GameModelDB.GameStatus"/></param> public void saveData(int[] currentBoard, Player p1, Player p2, GameModelDB.GameStatus gS) { GameModelDB gameModelDB = gameDataManager.getGameById(this.idGame); gameModelDB.lastBoard = currentBoard; List <String> listTurnInfo = gameModelDB.turnInformation.ToList <String>(); while (listMementoObjects.Count != 0) { MementoTurn mt = listMementoObjects.ElementAt(0); listMementoObjects.RemoveAt(0); listTurnInfo.Add(mt.dataToString()); } gameModelDB.numberTurnP1 = p1.NumberTurn; gameModelDB.numberTurnP2 = p2.NumberTurn; gameModelDB.nbMoveP1 = p1.Nbmove; gameModelDB.nbMoveP2 = p2.Nbmove; gameModelDB.turnInformation = listTurnInfo.ToArray <String>(); gameModelDB.gameStatus = gS; gameDataManager.updateGame(gameModelDB); }