//execute manual private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { DatasetMonster.Clear(); DatasetCharacter.Clear(); MonstersViewModel.Instance.newRoundMonsters(); // call new instance of monster var datasett = CharactersViewModel.Instance.Dataset; battleInstance.setViewModel(); refreshMonster();//adds new monsters //Load Characters from party List <Character> SortedCharacterList = new List <Character>(); foreach (var data in PartyList) //place current partylist created into a list for sorting { var mydata = datasett.FirstOrDefault(arg => arg.Id == data); if (mydata.Id == data) { Character _character = new Character(mydata); //character copy _character.Id = Guid.NewGuid().ToString(); //sets new ID for coppy character SortedCharacterList.Add(_character); //sorts character to lst for sorting } } var newlist = SortedCharacterList.OrderByDescending(s => s.Speed + s.StatModifier(AttributeEnum.Speed)).ThenByDescending(n => n.Name).ToList(); //sort character DatasetCharacter.Clear(); //clear DatasetCharacter even if blank foreach (var _character in newlist) //loop to add sortedlistcharacters to dataset { DatasetCharacter.Add(_character); } //Load Characters and Monster turns battleInstance.GetMonsters(); Debug.WriteLineIf(battleInstance.ListMonsters.Count == 0, "null getmonsters"); battleInstance.GetCharacters(); Debug.WriteLineIf(battleInstance.ListMonsters.Count == 0, "null getcharacters"); battleInstance.LoadTurnOrder(); //at start of execution load battle turns for initial battle } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
//execute auto private async Task ExecuteLoadDataCommandAuto() { if (IsBusy) { return; } IsBusy = true; try { DatasetMonster.Clear(); DatasetCharacter.Clear();; MonstersViewModel.Instance.newRoundMonsters(); // call new instance of monster CharactersViewModel.Instance.FillParty(); //fill party with new characters battleInstance.setAutoViewModel(); //auto set of VM await Task.Delay(1000); NewCharacters(); Debug.WriteLineIf(DatasetCharacter.Count == 0, "Datset on load is empty for character"); refreshMonster();//adds new monsters Debug.WriteLineIf(DatasetMonster.Count == 0, "Datset on load is empty for Monster"); await Task.Delay(1000); //Load Characters and Monster turns battleInstance.GetMonsters(); Debug.WriteLineIf(battleInstance.ListMonsters.Count == 0, "null getmonsters"); battleInstance.GetCharacters(); Debug.WriteLineIf(battleInstance.ListMonsters.Count == 0, "null getcharacters"); battleInstance.LoadTurnOrder(); //at start of execution load battle turns for initial battle } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
//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(); }