public void EditCharacter(Guid id, string name, string faction, string race, string characterclass, short level, bool Active) { CharacterFaction cf; CharacterRace cr; CharacterClass cc; List<Character> characters = GetCharacter(); if (!Enum.TryParse<CharacterFaction>(faction, out cf)) { throw new Exception("Faction invalid"); } if (!Enum.TryParse<CharacterRace>(race, out cr)) { throw new Exception("Race invalid"); } if (!Enum.TryParse<CharacterClass>(characterclass, out cc)) { throw new Exception("Class invalid"); } Character newCharacter = new Character(name, cf, cr, cc); newCharacter.Id = id; newCharacter.Level = level; newCharacter.Active = Active; PlayerData p = new PlayerData(FileName); p.EditCharacter(UserName, newCharacter); }
public void AddCharacter(string name, string faction, string race, string characterclass) { CharacterFaction cf; CharacterRace cr; CharacterClass cc; List<Character> characters = GetCharacter(); if(!Enum.TryParse<CharacterFaction>(faction, out cf)) { throw new Exception("Faction invalid"); } if(!Enum.TryParse<CharacterRace>(race, out cr)) { throw new Exception("Race invalid"); } if(!Enum.TryParse<CharacterClass>(characterclass, out cc)) { throw new Exception("Class invalid"); } if(characters.Count(x => x.Faction != cf && x.Active == true) > 0) { throw new Exception("All Characters must be part of the " + characters.First().Faction.ToString()); } Character newCharacter = new Character(name, cf, cr, cc); PlayerData p = new PlayerData(FileName); p.AddCharacter(UserName, newCharacter); }
public void AddCharacter(Character character) { if(character.Class == CharacterClass.DeathKnight) { if(!this.Characters.Exists(x => x.Level >= 55 && x.Active)) { throw new Exception("Cannot create a Death Knight untill one of your Characters is at least level 55"); } } if(this.Characters.Count > 0 && this.Characters.Exists(x => x.Faction != character.Faction && x.Active)) { throw new Exception("Stay loyal to your faction and only create characters within the same faction"); } this.Characters.Add(character); }
public void EditCharacter(Character character) { Character c = this.Characters.FirstOrDefault(x => x.Id == character.Id); if (c == null) { throw new Exception("This Character does not exist"); } if (this.Characters.Count > 0 && this.Characters.Exists(x => character.Active && x.Faction != character.Faction && x.Active)) { throw new Exception("Stay loyal to your faction and only create characters within the same faction"); } c.Name = character.Name; c.Faction = character.Faction; c.Race = character.Race; c.Class = character.Class; c.Level = character.Level; c.Active = character.Active; }
public void setCharacter(Core.Character character) { m_character = character; }
public void CreateValidCharacterDeleteUndelete() { Character c = new Character("TestCharacter", CharacterFaction.Alliance, CharacterRace.Human, CharacterClass.Warrior); Assert.IsTrue(c.Active); c.Delete(); Assert.IsFalse(c.Active); c.Undelete(); Assert.IsTrue(c.Active); }
public void EditCharacter(string userName, Character character) { lock (fileLock) { List<Player> players = GetAllPlayers(); Player p = players.FirstOrDefault(x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)); if (p == null) { throw new Exception("This User doesn't exists"); } p.EditCharacter(character); Save(players); } }
public void AddCharacter(string userName, Character character) { lock (fileLock) { List<Player> players = GetAllPlayers(); if (!players.Exists(x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase))) { throw new Exception("This User doesn't exists"); } players.First(x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)).AddCharacter(character); Save(players); } }