public async Task <IActionResult> Birth()
        {
            var character = new Character();

            character.Name = await this.nameGenerator.GenerateName(NameGenerationOptions.None);

            character.Class      = ModelExtentions.AllClasses.Random();
            character.Race       = Race.StandardRaces().Random();
            character.Subclass   = character.Class.ChooseRandomSubclass();
            character.Subrace    = character.Race.Name.ChooseRandomSubrace();
            character.Stats      = Statistics.RollAll();
            character.Background = ModelExtentions.AllBackgrounds.Random();

            // Racial Modifiers
            foreach (var modifier in character.Race.Modifiers)
            {
                if (character.Stats.ContainsKey(modifier.Key))
                {
                    character.Stats[modifier.Key] += modifier.Value;
                }
            }

            var characterCreationCount = await this.creationCountRepository.UpdateCreationCount();

            var characterCreation = new CharacterCreationViewModel()
            {
                CharacterViewModel = new CharacterViewModel(character), CharacterCreationCount = characterCreationCount
            };

            return(View("CharacterCreationView", characterCreation));
        }
        public CharacterCreation()
        {
            InitializeComponent();

            VM          = new CharacterCreationViewModel();
            DataContext = VM;
        }
Example #3
0
        public void TestCharacterModelLoading()
        {
            //Arrange
            CharacterCreationViewModel ccvm = new CharacterCreationViewModel();
            ICharacterContext          _Icc = new TestCharacterContext();
            CharacterRepo _cr = new CharacterRepo(_Icc);

            //Act
            ccvm.CharModels = _cr.GetAllCharModels();
            //Assert
            Assert.IsTrue(ccvm.CharModels.Count == 3);
        }
        public IActionResult CharacterCreation()
        {
            if (HttpContext.Session.GetString("Username") == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            CharacterCreationViewModel ccvm = new CharacterCreationViewModel
            {
                CharModels = _cr.GetAllCharModels()
            };

            return(View(ccvm));
        }
 public IActionResult CharacterCreation(CharacterCreationViewModel ccvm)
 {
     if (ModelState.IsValid)
     {
         Account acc = _ar.GetByName(HttpContext.Session.GetString("Username"));
         var     c   = new Character()
         {
             Name           = ccvm.Name,
             CharacterModel = ccvm.CharacterModel
         };
         _cr.Create(c, acc);
         return(RedirectToAction("Characters"));
     }
     else
     {
         ccvm.CharModels = _cr.GetAllCharModels();
         return(View(ccvm));
     }
 }
Example #6
0
        public void TestLoadingGame()
        {
            //Arrange
            CharacterCreationViewModel ccvm = new CharacterCreationViewModel();
            ICharacterContext          _Icc = new TestCharacterContext();
            IItemContext  _IIc         = new TestItemContext();
            CharacterRepo _cr          = new CharacterRepo(_Icc);
            ItemRepo      _ir          = new ItemRepo(_IIc);
            var           mvm          = new MapViewModel();
            var           tempItemList = new List <ItemViewModel>();

            //Act

            mvm.character = CharacterToCharacterVM.ToCharVM(_cr.GetById(5));
            foreach (Item item in _ir.GetAllItems(0))
            {
                tempItemList.Add(ItemToItemVM.ToItemVM(item));
            }
            mvm.allitems = tempItemList;
            //Assert
            Assert.IsTrue(mvm.character != null && mvm.character.CharacterModel != "");
            Assert.IsTrue(mvm.allitems.Count > 0);
        }