Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public List<Character> GetCharacter()
 {
     PlayerData p = new PlayerData(FileName);
     return p.GetCharacter(UserName);
 }
Пример #4
0
 public Character GetCharacter(Guid id)
 {
     PlayerData p = new PlayerData(FileName);
     return p.GetCharacter(UserName, id);
 }
Пример #5
0
 public List<Player> GetPlayer()
 {
     PlayerData p = new PlayerData(FileName);
     return p.GetPlayer();
 }
Пример #6
0
 public Player GetPlayer(string userName)
 {
     PlayerData p = new PlayerData(FileName);
     return p.GetPlayer(userName);
 }
Пример #7
0
 public Player GetPlayer(string userName, string password)
 {
     PlayerData p = new PlayerData(FileName);
     return p.GetPlayer(userName, password);
 }
Пример #8
0
 public void EditPlayer(string userName, bool isAdmin)
 {
     PlayerData p = new PlayerData(FileName);
     p.EditPlayer(userName, isAdmin);
 }
Пример #9
0
 public void AddPlayer(string userName, string password)
 {
     PlayerData p = new PlayerData(FileName);
     p.AddPlayer(userName, password);
 }