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