Exemplo n.º 1
0
        private CharacterChoices GetCharacter(int id)
        {
            CharacterChoices character = null;

            FileIoStatus = FileIoMessage.None;
            try
            {
                using (CharacterRepo cRepo = new CharacterRepo())
                {
                    character = cRepo.GetById(id);
                };
                if (character != null)
                {
                    FileIoStatus = FileIoMessage.Complete;
                }
                else
                {
                    FileIoStatus = FileIoMessage.RecordNotFound;
                }
            }
            catch (Exception)
            {
                FileIoStatus = FileIoMessage.FileAccessError;
            }
            return(character);
        }
        public AddCharacterView(CharacterChoices character)
        {
            InitializeComponent();
            CharacterBusiness charBusiness = new CharacterBusiness();
            AddCharVM         addChar      = new AddCharVM(character);

            DataContext = addChar;
        }
 public async Task LoadAsync()
 {
     foreach (var characterType in (await CharacterChoices.GetAsync()).CharacterTypes)
     {
         CharacterTypes.Add(characterType);
     }
     PlayerNumbers = GetPlayerNumbers();
 }
Exemplo n.º 4
0
        private void BuildEnemyTeam(CharacterChoices character)
        {
            CharacterChoices[] rndIndex = _characters.ToArray();
            var rnd   = new Random();
            int rndId = rnd.Next(1, rndIndex.Length);
            CharacterChoices rndChoice = rndIndex[rndId];

            RandomEnemy = _charBusiness.GetCharacterById(rndChoice.Id);
        }
Exemplo n.º 5
0
 public void Add(CharacterChoices character)
 {
     try
     {
         _characters.Add(character);
         _dataService.WriteAll(_characters);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
 public void Update(CharacterChoices character)
 {
     try
     {
         _characters.Remove(_characters.FirstOrDefault(c => c.Id == character.Id));
         _characters.Add(character);
         _dataService.WriteAll(_characters);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 7
0
        private void AddCharacter()
        {
            CharacterChoices cc = new CharacterChoices();


            AddCharacterView av = new AddCharacterView(cc);

            av.ShowDialog();

            if (cc.Rank != 0)
            {
                cc.Id = AddId();
                _charBusiness.AddCharacter(cc);
                Characters.Add(cc);
            }
        }
Exemplo n.º 8
0
        private void ConfirmAdd()
        {
            ErrMsg = "";


            if (IsValidateForm() == true)
            {
                _character.Rank     = rand.Next(1, 5);
                _character.Name     = AddName;
                _character.Race     = AddRace;
                _character.Weapon   = AddWeapon;
                _character.Weakness = AddWeakness;
                _character.Morality = AddMorality;
                _character.Series   = AddSeries;
                _character          = Character;
            }
        }
Exemplo n.º 9
0
 public void AddCharacter(CharacterChoices character)
 {
     try
     {
         if (character != null)
         {
             using (CharacterRepo cRepo = new CharacterRepo())
             {
                 cRepo.Add(character);
             };
             FileIoStatus = FileIoMessage.Complete;
         }
     }
     catch (Exception)
     {
         FileIoStatus = FileIoMessage.FileAccessError;
     }
 }
Exemplo n.º 10
0
 public void UpdateCharacter(CharacterChoices updatedCharacter)
 {
     try
     {
         if (GetCharacter(updatedCharacter.Id) != null)
         {
             using (CharacterRepo cRepo = new CharacterRepo())
             {
                 cRepo.Update(updatedCharacter);
             }
             FileIoStatus = FileIoMessage.Complete;
         }
         else
         {
             FileIoStatus = FileIoMessage.RecordNotFound;
         }
     }
     catch (Exception)
     {
         FileIoStatus = FileIoMessage.FileAccessError;
     }
 }
Exemplo n.º 11
0
 public AddCharVM(CharacterChoices character)
 {
     _character = character;
 }