private static void AddLoot(Monster monster, int itemId, int chance) { if (GodOfRandom.NumberBetween(1, 100) <= chance) { monster.AddItemToInventory(LootFactory.CreateLoot(itemId)); } }
public Monster GetMonster() { if (!Monsters.Any()) { return(null); } int totalChance = Monsters.Sum(m => m.ChanceOfEncounter); int randomNumber = GodOfRandom.NumberBetween(1, totalChance); int runningTotal = 0; foreach (var monsterEncounter in Monsters) { runningTotal += monsterEncounter.ChanceOfEncounter; if (randomNumber <= runningTotal) { return(MonsterFactory.GetMonster(monsterEncounter.MonsterId)); } } //fail check return(MonsterFactory.GetMonster(Monsters.Last().MonsterId)); }
public void Execute(LivingBeing actor, LivingBeing target) { int damage = GodOfRandom.NumberBetween(_minDamage, _maxDamage); if (damage == 0) { ReportResult($"{actor.Name} missed"); } else { ReportResult($"{actor.Name} hit {target.Name} for {damage}"); target.TakeDamage(damage); } }