/// <summary> /// Creates an instance of <see cref="EncounterModel"/> /// </summary> public EncounterModel(EncounterModel encounterModel) : base(encounterModel) { _encounterCreatures = new List <EncounterCreatureModel>(); foreach (EncounterCreatureModel encounterCreature in encounterModel.Creatures) { if (encounterCreature is EncounterCharacterModel encounterCharacter) { _encounterCreatures.Add(new EncounterCharacterModel(encounterCharacter)); } else if (encounterCreature is EncounterMonsterModel encounterMonster) { _encounterCreatures.Add(new EncounterMonsterModel(encounterMonster)); } } _round = encounterModel.Round; _encounterChallenge = encounterModel.EncounterChallenge; _totalCharacterHP = encounterModel.TotalCharacterHP; _totalMonsterHP = encounterModel.TotalMonsterHP; _timeElapsed = encounterModel.TimeElapsed; _currentTurn = encounterModel.CurrentTurn; _encounterState = encounterModel.EncounterState; _notes = encounterModel.Notes; }
/// <summary> /// Gets an estimate of the challenge for an encounter. /// </summary> public EncounterChallenge EstimateEncounterChallenge(IEnumerable <EncounterCreatureModel> characters, IEnumerable <EncounterCreatureModel> monsters) { EncounterChallenge challenge = EncounterChallenge.Unknown; int easyThreshold = 0; int mediumThreshold = 0; int hardThreshold = 0; int deadlyThreshold = 0; int tpkThreshold = 0; int totalMonsters = 0; int totalMonsterXP = 0; foreach (EncounterCharacterModel character in characters) { int baseThreshold = _baseXPThresholds[1]; if (_baseXPThresholds.ContainsKey(character.Level)) { baseThreshold = _baseXPThresholds[character.Level]; } easyThreshold += baseThreshold; mediumThreshold += (2 * baseThreshold); hardThreshold += (3 * baseThreshold); deadlyThreshold += (4 * baseThreshold); tpkThreshold += (5 * baseThreshold); } foreach (EncounterMonsterModel monster in monsters) { totalMonsterXP += (GetMonsterXP(monster.MonsterModel) * monster.Quantity); totalMonsters += monster.Quantity; } float adjustedMonsterXP = totalMonsterXP * GetXPMultiplier(totalMonsters); if (adjustedMonsterXP > 0) { challenge = EncounterChallenge.Easy; if (adjustedMonsterXP > easyThreshold) { if (adjustedMonsterXP < mediumThreshold) { challenge = EncounterChallenge.Easy; } else if (adjustedMonsterXP < hardThreshold) { challenge = EncounterChallenge.Medium; } else if (adjustedMonsterXP < deadlyThreshold) { challenge = EncounterChallenge.Hard; } else if (adjustedMonsterXP < tpkThreshold) { challenge = EncounterChallenge.Deadly; } else { challenge = EncounterChallenge.TPK; } } } return(challenge); }