public Player(string _name, string _id) { this._name = (_name == null || _name == "") ? "NOT_VALID_FROM_CTOR" : _name; this._id = (_id == null || _id == "") ? PAPIApplication.GetUniqueId() : _id; WfLogger.Log(this, LogLevel.DETAILED, "Created new Player " + _name); }
/* -------------------------------------------------------------------------------------------------------------------------------- * Functionality removed, but code saved for other views * public void AddPlayer(Player player) * { * foreach(KeyValuePair<Player, Button> playerButton in players_removeButtons) * { * if(playerButton.Key._id == player._id) * { * WfLogger.Log(this, LogLevel.WARNING, "Add player " + player._name + " not possible, there already is a player with this id"); * return; * } * } * WfLogger.Log(this, LogLevel.DEBUG, "Add player " + player._name + " to list of players"); * * playerListPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 44)); * playerListPanel.RowCount++; * * // Show name of player and put it into list * playerListPanel.Controls.Add(new Label() * { * Text = player._name, * Anchor = AnchorStyles.Left | AnchorStyles.Top, * Width = 200 * }, 0, players_removeButtons.Count+1); * * * // Create formatted button and its functionality * Button button = new Button() * { * Text = "", * FlatStyle = FlatStyle.Flat, * Anchor = AnchorStyles.Right | AnchorStyles.Top, * Size = new Size(40, 40), * Name = "removePlayerButton" + (players_removeButtons.Count + 1) * }; * * string imagePath = GameDirectory.GetFilePath_Images(PAPIApplication.GetDesign()) + "\\cancel.bmp"; * Image image = Image.FromFile(imagePath); * button.Image = (Image)(new Bitmap(image, new Size(40, 40))); * * playerListPanel.Controls.Add(button, 1, players_removeButtons.Count + 1); * _buttons.Add(button); * button.Click += RemovePlayerButton_Click; * * players_removeButtons.Add(player, button); * * // Set all rows to same size * foreach (RowStyle rowStyle in playerListPanel.RowStyles) * { * rowStyle.SizeType = SizeType.Absolute; * rowStyle.Height = 44; * } * WfLogger.Log(this, LogLevel.DEBUG, "Added player " + player._name + " to List"); * SetButtonDesign(); * } * * private void RemovePlayerButton_Click(object sender, EventArgs e) * { * string value = ((Button)sender).Name; * Player playerToRemove = null; * foreach(KeyValuePair<Player, Button> playerButton in players_removeButtons) * { * if(playerButton.Value == (Button)sender) * { * playerToRemove = playerButton.Key; * break; * } * } * if (playerToRemove != null) * { * int rowNumber = -1; * foreach(Control control in playerListPanel.Controls) * { * if(control.Text == playerToRemove._name) * { * rowNumber = playerListPanel.GetRow(control); * break; * } * } * * WfLogger.Log(this, LogLevel.DEBUG, "Remove Player " + playerToRemove._name + " from List (Number " + rowNumber + ")"); * players_removeButtons.Remove(playerToRemove); * * TableLayoutHelper.RemoveRowNumber(playerListPanel, rowNumber); * } * else * { * WfLogger.Log(this, LogLevel.WARNING, "For the given Button no player was found, who could be removed"); * } * } */ // -------------------------------------------------------------------------------------------------------------------------------- public override void SetTextToActiveLanguage() { if (_shownLanguage == PAPIApplication.GetLanguage()) { return; } using (ResXResourceSet resSet = new ResXResourceSet(GetTranslationFile())) { Translate(resSet, gm_name_label); Translate(resSet, game_id_label); gm_name.Text = PAPIApplication.GetPlayer()._name; id_textbox.Text = PAPIApplication.GetUniqueId(); Translate(resSet, cancel_button); Translate(resSet, create_and_start_button); Translate(resSet, create_and_return_button); Translate(resSet, genre_label); genreDropdown.Items[0] = TranslatedString(resSet, "GenreEnum_NUCLEAR_FALLOUT"); genreDropdown.Items[1] = TranslatedString(resSet, "GenreEnum_MEDIEVAL_FANTASY"); genreDropdown.Items[2] = TranslatedString(resSet, "GenreEnum_MAGICAL_WORLD"); genreDropdown.Items[3] = TranslatedString(resSet, "GenreEnum_SPACE_OPERA"); _genreDescriptions.Clear(); _genreDescriptions.Add(GenreEnum.NUCLEAR_FALLOUT, TranslatedDescription(resSet, "GenreEnum_NUCLEAR_FALLOUT")); _genreDescriptions.Add(GenreEnum.MEDIEVAL_FANTASY, TranslatedDescription(resSet, "GenreEnum_MEDIEVAL_FANTASY")); _genreDescriptions.Add(GenreEnum.MAGICAL_WORLD, TranslatedDescription(resSet, "GenreEnum_MAGICAL_WORLD")); _genreDescriptions.Add(GenreEnum.SPACE_OPERA, TranslatedDescription(resSet, "GenreEnum_SPACE_OPERA")); _genreDescriptions.Add(GenreEnum.NOT_VALID, TranslatedDescription(resSet, "GenreEnum_NOT_VALID")); } }
// -------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Creates a default game with the current player as game master /// </summary> public PAPIGame() : this(GenreEnum.NOT_VALID, null, null, DateTime.Now, DateTime.Now, null, PAPIApplication.GetUniqueId()) { WfLogger.Log(this, LogLevel.DETAILED, "Created new default Game"); }