// -------------------------------------------------------------------------------------------------------------------------------- public void DeleteGame(PAPIGame game) { if (game != null) { int rowNumber = -1; foreach (Control control in gameTable.Controls) { if (control.Text == game._dateOfCreation.ToString()) { rowNumber = gameTable.GetRow(control); break; } } WfLogger.Log(this, LogLevel.DEBUG, "Remove Game " + game._genre + ", " + game._dateOfCreation + " from List (Number " + rowNumber + ")"); _savedGames.Remove(game); TableLayoutHelper.RemoveRowNumber(gameTable, rowNumber); } else { WfLogger.Log(this, LogLevel.WARNING, "No Game was found, which could be removed"); } }
// -------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Calls the CTOR of PAPIGame and creates a new game with the given genre and the current player as game master /// </summary> /// <param name="genre"></param> public static void CreateNewGame(GenreEnum genre, string id) { _runningGame = new PAPIGame(genre, PAPIApplication.GetPlayer(), null, DateTime.Now, DateTime.Now, null, id); SaveFileManager.Save(_runningGame); WfLogger.Log("PAPIApplication.CreateNewGame", LogLevel.DEBUG, "Created new Game"); }
// -------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Saves the given game persistently in a save file /// </summary> /// <param name="game"></param> public static void Save(PAPIGame game) { if (!_isInitialized) { Init(); } WfLogger.Log("SaveFileManager.Save()", LogLevel.DEBUG, "Pass game to SerializationManager to save"); _gameManager.Save(game); }
// -------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Sets the running game to the given value /// </summary> /// <param name="selectedGame">if null, nothing happens</param> public static void StartSession(PAPIGame selectedGame) { if (selectedGame == null) { WfLogger.Log("Application.StartSession()", LogLevel.WARNING, "Couldn't start session, because the game is null"); return; } _runningGame = selectedGame; WfLogger.Log("PAPIApplication.StartSession", LogLevel.DEBUG, "Started new Session of Game"); }
// -------------------------------------------------------------------------------------------------------------------------------- private void Load_Game_Button_Click(object sender, EventArgs e) { PAPIGame selectedGame = null; foreach (KeyValuePair <PAPIGame, Button> gameButton in _gameButtons) { if (gameButton.Value == (Button)sender) { selectedGame = gameButton.Key; break; } } if (selectedGame == null) { throw new GameNotFoundException("There is no game for the clicked button"); } WfLogger.Log(this, LogLevel.DEBUG, "Button 'Load' was clicked, open Popup"); PAPIApplication.StartSession(selectedGame); ((ShowGameOverviewView)ViewController.showGameOverviewView).Open(this); }