//grabs monsters randomly who are not too difficult public void ResetMonsters() { //clear out the dead monsters DatasetMonster.Clear(); //get the party level to only get monsters who are not too much higher than average level int partyAverageLevel = GetPartyAverageLevel(); //will crash if no monsters... int nextMonsterIndex; for (int i = 0; i < MaxPartySize; i++) { //generates a new random index nextMonsterIndex = RNG.Next() % MonsterViewModel.Instance.Dataset.Count; DatasetMonster.Add(new Monster()); //adds a monster to update with the random monster //while too high of a level, choose a new monster while (MonsterViewModel.Instance.Dataset[nextMonsterIndex].attributes.level > (partyAverageLevel + 2)) { nextMonsterIndex = RNG.Next() % MonsterViewModel.Instance.Dataset.Count; } //copy the monster from the master monster list DatasetMonster[i].Update(MonsterViewModel.Instance.Dataset[nextMonsterIndex]); } }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { DatasetMonster.Clear(); DatasetCharacter.Clear(); var dataset = await DataStore.GetPartyAsync_Monster(true); var datasett = await DataStore.GetPartyAsync_Character(true); foreach (var data in dataset) { DatasetMonster.Add(data); } foreach (var data in datasett) { DatasetCharacter.Add(data); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
//_____________________NEW MONSTER__________________________________________________ #region commands //refresher for monster list public void refreshMonster() { DatasetMonster.Clear(); //clear any current datasetmonster //Call levelscale to reset globals and get averages before new round battleInstance.LevelScale(); // call new instance of monster MonstersViewModel.Instance.newRoundMonsters(); //new monsters get but into var dataset var dataset = MonstersViewModel.Instance.Dataset; List <Monster> SortedList = new List <Monster>(); //insert dataset for sorting foreach (var data in dataset) { //var mydata = dataset.FirstOrDefault(arg => arg.Id == data); if (DatasetMonster.Count < 6) { Monster _monster = new Monster(data); // monster copy ////////TEST _monster.Id = Guid.NewGuid().ToString(); //If round count does not equal 1? //Set's monster's Level to average character level _monster.Level = (int)(GlobalVariables.AverageLevel); //Set's monster's experience to current experience level if level is 1 else experience*level if (_monster.Level <= 1) { _monster.CurrentExperience = _monster.CurrentExperience; } else { _monster.CurrentExperience = _monster.CurrentExperience * _monster.Level; } //Set's monsters health to 50% of Averagehealth * base max health _monster.MaximumHealth = (int)(0.5 * (GlobalVariables.AverageHealth + _monster.MaximumHealth)); //Set current health to maximum health _monster.CurrentHealth = _monster.MaximumHealth; //Set's attack to 50% of average attack + base attack _monster.Attack = (int)(0.5 * (GlobalVariables.AverageAttack + _monster.Attack)); //Set's defense to 50% of average defense + base defense _monster.Defense = (int)(0.5 * (GlobalVariables.AverageDefense + _monster.Defense)); //Set's speed to 50% of average speed + base speed _monster.Speed = (int)(0.5 * (GlobalVariables.AverageSpeed + _monster.Speed)); SortedList.Add(_monster); } } var newlist = SortedList.OrderByDescending(s => s.Speed).ThenByDescending(n => n.Name).ToList(); foreach (var data in newlist) //load dataset with sorted list { data.GrabItem(); DatasetMonster.Add(data); } battleInstance.GetCharacters(); battleInstance.GetMonsters(); }