private void CopyCharacter(EncounterCharacterViewModel encounterCharacterModel) { EncounterCharacterModel copy = new EncounterCharacterModel(encounterCharacterModel.EncounterCharacterModel); copy.Name += " (copy)"; copy.ID = Guid.NewGuid(); _encounterModel.Creatures.Add(copy); CreateCreatureViewModels(); EstimateEncounterChallenge(); OnPropertyChanged(nameof(Characters)); OnPropertyChanged(nameof(AverageCharacterLevel)); OnPropertyChanged(nameof(AverageCharacterMaxHP)); OnPropertyChanged(nameof(AverageCharacterAC)); OnPropertyChanged(nameof(AverageCharacterSaveDC)); OnPropertyChanged(nameof(AverageCharacterPassivePerception)); OnPropertyChanged(nameof(AverageCharacterPassiveInvestigation)); }
private void RemoveCharacter(EncounterCharacterViewModel encounterCharacterModel) { bool?result = _dialogService.ShowConfirmationDialog("Remove Character", "Are you sure you want to remove " + encounterCharacterModel.Name + "?", "Yes", "No", null); if (result == true) { _encounterModel.Creatures.RemoveAll(x => x.ID == encounterCharacterModel.EncounterCharacterModel.ID); CreateCreatureViewModels(); EstimateEncounterChallenge(); OnPropertyChanged(nameof(Characters)); OnPropertyChanged(nameof(AverageCharacterLevel)); OnPropertyChanged(nameof(AverageCharacterMaxHP)); OnPropertyChanged(nameof(AverageCharacterAC)); OnPropertyChanged(nameof(AverageCharacterSaveDC)); OnPropertyChanged(nameof(AverageCharacterPassivePerception)); OnPropertyChanged(nameof(AverageCharacterPassiveInvestigation)); } }
private void CreateCreatureViewModels() { _creatures.Clear(); _creaturesExpanded.Clear(); foreach (EncounterCreatureModel encounterCreatureModel in _encounterModel.Creatures) { if (encounterCreatureModel is EncounterCharacterModel) { EncounterCharacterViewModel encounterCharacterViewModel = new EncounterCharacterViewModel(encounterCreatureModel as EncounterCharacterModel); _creatures.Add(encounterCharacterViewModel); _creaturesExpanded.Add(encounterCharacterViewModel); } else if (encounterCreatureModel is EncounterMonsterModel) { EncounterMonsterViewModel encounterMonsterViewModel = new EncounterMonsterViewModel(encounterCreatureModel as EncounterMonsterModel); _creatures.Add(encounterMonsterViewModel); if (encounterMonsterViewModel.Quantity > 1) { for (int i = 0; i < encounterMonsterViewModel.Quantity; ++i) { EncounterMonsterModel encounterMonsterModelCopy = new EncounterMonsterModel(encounterCreatureModel as EncounterMonsterModel); EncounterMonsterViewModel encounterMonsterViewModelCopy = new EncounterMonsterViewModel(encounterMonsterModelCopy); encounterMonsterViewModelCopy.Name += $" ({i + 1})"; _creaturesExpanded.Add(encounterMonsterViewModelCopy); } } else { _creaturesExpanded.Add(encounterMonsterViewModel); } } } _creatures = _creatures.OrderByDescending(x => x.Initiative).ToList(); _creaturesExpanded = _creaturesExpanded.OrderByDescending(x => x.Initiative).ToList(); }
private void ShowEditCharacterWindow(EncounterCharacterViewModel encounterCharacterModel) { EncounterCharacterModel editedCharacterModel = _dialogService.ShowEncounterCharacterDialog("Edit Character", encounterCharacterModel.EncounterCharacterModel); if (editedCharacterModel != null) { EncounterCreatureModel originalCharacter = _encounterModel.Creatures.FirstOrDefault(x => x.ID == encounterCharacterModel.EncounterCharacterModel.ID); if (originalCharacter != null) { _encounterModel.Creatures[_encounterModel.Creatures.IndexOf(originalCharacter)] = editedCharacterModel; CreateCreatureViewModels(); EstimateEncounterChallenge(); OnPropertyChanged(nameof(Characters)); OnPropertyChanged(nameof(AverageCharacterLevel)); OnPropertyChanged(nameof(AverageCharacterMaxHP)); OnPropertyChanged(nameof(AverageCharacterAC)); OnPropertyChanged(nameof(AverageCharacterSaveDC)); OnPropertyChanged(nameof(AverageCharacterPassivePerception)); OnPropertyChanged(nameof(AverageCharacterPassiveInvestigation)); } } }