public void BookOfWisdomWorksForWizards() { Scenario scenario = new Scenario(); Wizard gandalf = new Wizard(); Orc orc = new Orc(); Excalibur sword = new Excalibur(); gandalf.AddItem(sword); List <CharacterClass> heroes = new List <CharacterClass>() { gandalf }; List <CharacterClass> villains = new List <CharacterClass>() { orc }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.AreEqual($"-{everything[1][0].Name} has been slain by {everything[0][0].Name}", everything[0][0].Registres.ShowRegistres()); }
public void WhatIfThereAreMoreEnemiesThanHeroes() { Scenario scenario = new Scenario(); Dwarf gimli = new Dwarf(); Elf legolas = new Elf(); ChosenOne aragorn = new ChosenOne(); Wizard gandalf = new Wizard(); Orc orc = new Orc(); Orc orc2 = new Orc(); Orc orc3 = new Orc(); Orc orc4 = new Orc(); Orc orc5 = new Orc(); List <CharacterClass> heroes = new List <CharacterClass>() { gimli, legolas, aragorn, gandalf }; List <CharacterClass> villains = new List <CharacterClass>() { orc, orc2, orc3, orc4, orc5 }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.IsTrue(battle.EveryoneDead(everything[1])); }
public void Only_one_character_alive_after_battle_encounter_2() { Satan satan = new Satan(10, 9000, 0); ShadowHunter shadowHunter = new ShadowHunter(1, 10, 10); BattleEncounter encounter = new BattleEncounter(shadowHunter, satan); encounter.RunEncounter(); int heroesAlive = 0; int villainsAlive = 0; foreach (var hero in encounter.Heroes) { if (hero.IsAlive()) { heroesAlive++; } } foreach (var villain in encounter.Villains) { if (villain.IsAlive()) { villainsAlive++; } } Assert.IsTrue((heroesAlive == 0 && villainsAlive == 1) || (villainsAlive == 0 && heroesAlive == 1)); }
public void BattleEncounterEndsWhenEveryoneOnOneSideDiesPart2Test() { Scenario scenario = new Scenario(); Dwarf gimli = new Dwarf(); Elf legolas = new Elf(); ChosenOne aragorn = new ChosenOne(); Wizard gandalf = new Wizard(); DarkLord orc = new DarkLord(); DarkLord orc2 = new DarkLord(); DarkLord orc3 = new DarkLord(); DarkLord orc4 = new DarkLord(); List <CharacterClass> heroes = new List <CharacterClass>() { gimli, legolas, aragorn, gandalf }; List <CharacterClass> villains = new List <CharacterClass>() { orc, orc2, orc3, orc4 }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.IsTrue(battle.EveryoneDead(everything[0])); }
public void BattleEncounterEndsWhenEveryoneOnOneSideDiesTest() { Scenario scenario = new Scenario(); Dwarf gimli = new Dwarf(); Elf legolas = new Elf(); ChosenOne aragorn = new ChosenOne(); Wizard gandalf = new Wizard(); Orc orc = new Orc(); Orc orc2 = new Orc(); Orc orc3 = new Orc(); Orc orc4 = new Orc(); List <CharacterClass> heroes = new List <CharacterClass>() { gimli, legolas, aragorn, gandalf }; List <CharacterClass> villains = new List <CharacterClass>() { orc, orc2, orc3, orc4 }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.AreEqual(0, everything[1][0].HealthActual + everything[1][1].HealthActual + everything[1][2].HealthActual + everything[1][3].HealthActual); }
public void BattleEncounterWithArmorAndWeaponsTest() { Scenario scenario = new Scenario(); Dwarf gimli = new Dwarf(); Orc orc = new Orc(); BasicSword sword = new BasicSword(); ChainMail armor = new ChainMail(); GoldenCoat coat = new GoldenCoat(); orc.AddItem(sword); orc.AddItem(armor); orc.AddItem(coat); List <CharacterClass> heroes = new List <CharacterClass>() { gimli }; List <CharacterClass> villains = new List <CharacterClass>() { orc }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.AreEqual(0, everything[0][0].HealthActual); }
public BattleSimulationArmy(SimulationObject simulationObject, BattleContender contender) : base(simulationObject) { if (simulationObject == null) { throw new ArgumentNullException("simulationObject"); } if (contender == null) { throw new ArgumentNullException("contender"); } this.contender = contender; if (contender.DefaultTargetingStrategy != null) { StaticString armyBattleTargetingStrategy = contender.DefaultTargetingStrategy; this.ArmyBattleTargetingStrategy = armyBattleTargetingStrategy; this.ArmyBattleTargetingWantedStrategy = armyBattleTargetingStrategy; } else { StaticString armyBattleTargetingStrategy = BattleEncounter.GetDefaultStrategy(); this.ArmyBattleTargetingWantedStrategy = armyBattleTargetingStrategy; this.ArmyBattleTargetingStrategy = armyBattleTargetingStrategy; } this.WaitingArmyActions = new List <BattleArmyAction>(); }
public void LoadParty(BattleEncounter encounter) { Party.CreateFormation(encounter); Ranks.DistributeParty(Party); foreach (var unit in Party.Units) { unit.Formation = this; } Overlay.LockOnUnits(Party); }
public void Only_one_character_alive_after_battle_encounter_1() { Satan satan = new Satan(10, 9000, 0); Dragon dragon = new Dragon(56, 52, 34); Orc orc = new Orc(23, 34, 4); ShadowHunter shadowHunter = new ShadowHunter(1, 10, 10); Angel angel = new Angel(231, 223, 343); Archer archer = new Archer(2323, 323, 32); Knight knight = new Knight(23, 3334, 132); BattleEncounter encounter = new BattleEncounter(new List <AbstractHero>() { shadowHunter, angel, archer, knight }, new List <AbstractVillain>() { satan, dragon, orc }); encounter.RunEncounter(); int heroesAlive = 0; int villainsAlive = 0; foreach (var hero in encounter.Heroes) { if (hero.IsAlive()) { heroesAlive++; } } foreach (var villain in encounter.Villains) { if (villain.IsAlive()) { villainsAlive++; } } Assert.IsTrue(heroesAlive == 0 || villainsAlive == 0); }
public void Expected_battle_result_2() { Satan satan = new Satan(10, 9000, 0); ShadowHunter shadowHunter = new ShadowHunter(1, 10, 10); BattleEncounter encounter = new BattleEncounter(new List <AbstractHero>() { shadowHunter }, new List <AbstractVillain>() { satan }); Assert.IsFalse(encounter.RunEncounter()); }
public void EternalStoneWorksForHeroes() { Scenario scenario = new Scenario(); Dwarf gimli = new Dwarf(); Orc orc = new Orc(); List <CharacterClass> heroes = new List <CharacterClass>() { gimli }; List <CharacterClass> villains = new List <CharacterClass>() { orc }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.AreEqual("1", gimli.Registres.ShowRegistres()); }
public void BattleEncounterNoWeaponsTest() { Scenario scenario = new Scenario(); Dwarf gimli = new Dwarf(); Orc orc = new Orc(); List <CharacterClass> heroes = new List <CharacterClass>() { gimli }; List <CharacterClass> villains = new List <CharacterClass>() { orc }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.AreEqual(0, everything[1][0].HealthActual); }
public void ThousandYearTreeTest() { Scenario scenario = new Scenario(); Dwarf gimli = new Dwarf(); Dragon dragon = new Dragon(); List <CharacterClass> heroes = new List <CharacterClass>() { gimli }; List <CharacterClass> villains = new List <CharacterClass>() { dragon }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.AreEqual(gimli.Name, everything[1][0].Registres.ShowRegistres()); }
public void Heroes_win_battle_encounter() { Dwarf dwarf = new Dwarf(1000, 80, 0); Elf elf = new Elf(67060, 45, 0); Wizard wizard = new Wizard(9595, 54, 0); Demon demon = new Demon(23, 1, 24); Dragon dragon = new Dragon(10, 10, 0); Orc orc = new Orc(24, 4, 1); var heroes = new List <AbstractHero> { dwarf, elf, wizard }; var villains = new List <AbstractVillain> { demon, dragon, orc }; BattleEncounter encounter = new BattleEncounter(heroes, villains); Assert.IsTrue(encounter.RunEncounter()); }
public void Villains_win_battle_encounter() { Dwarf dwarf = new Dwarf(9, 1, 0); Elf elf = new Elf(10, 3, 0); Wizard wizard = new Wizard(8, 4, 0); Demon demon = new Demon(23, 6547, 24); Dragon dragon = new Dragon(10, 10, 0); Orc orc = new Orc(24, 4, 1); var heroes = new List <AbstractHero> { dwarf, elf, wizard }; var villains = new List <AbstractVillain> { demon, dragon, orc }; BattleEncounter encounter = new BattleEncounter(heroes, villains); Assert.IsFalse(encounter.RunEncounter()); }
public virtual void Write(BinaryWriter bw) { bw.Write(Id); bw.Write(GridX); bw.Write(GridY); bw.Write(TextureId); bw.Write((int)Type); bw.Write((int)Knowledge); bw.Write(Prop != null); if (Prop != null) { Prop.Write(bw); } bw.Write(BattleEncounter != null); if (BattleEncounter != null) { BattleEncounter.Write(bw); } }
private void validFormatAssert(string file) { TypeHandler firstHandler = new BattleEncounterHandler(new GenericItemHandler(new ElfHandler(null))); FileReader fileReader = new FileReader(firstHandler); Scenario scenario = fileReader.Read(file); Assert.AreEqual(scenario.ListOfEncounter.Count, 1); Assert.IsInstanceOf <BattleEncounter>(scenario.ListOfEncounter[0]); BattleEncounter battleEncounter = scenario.ListOfEncounter[0] as BattleEncounter; Character elf = battleEncounter.ListOfHero[0]; Assert.IsInstanceOf <Elf>(elf); Assert.AreEqual(elf.Name, "elf1"); Assert.AreEqual(elf.GetItems().Count, 1); Item item = elf.GetItems()[0]; Assert.IsInstanceOf <GenericItem>(item); Assert.AreEqual(item.Name, "espada"); }
public void CreateFormation(BattleEncounter encounter) { Units = new List <FormationUnit>(); int summonRank = 1; foreach (var monster in encounter.Monsters) { GameObject unitObject = Resources.Load("Prefabs/Monsters/" + monster.Class) as GameObject; if (unitObject == null) { unitObject = (Resources.Load("Prefabs/Monsters/brigand_cutthroat") as GameObject); } FormationUnit unit = Instantiate(unitObject).GetComponent <FormationUnit>(); unit.transform.SetParent(transform, false); unit.Party = this; unit.Initialize(monster, summonRank, Team.Monsters); Units.Add(unit); summonRank += monster.Size; unit.ResetAnimations(); } }
public BattleEncounterState_Setup(BattleEncounter battleEncounter) : base(battleEncounter) { }
public BattleEncounterState_Terminate(BattleEncounter battleEncounter) : base(battleEncounter) { }
public void SpawnEncounter(BattleEncounter encounter, bool campfireSurprise) { MonsterFormation.LoadParty(encounter); for (int i = 0; i < MonsterParty.Units.Count; i++) { var monster = MonsterParty.Units[i].Character as Monster; MonsterParty.Units[i].CombatInfo.PrepareForBattle(PickId(), monster, true); if (monster.TorchlightModifier != null) { RaidSceneManager.TorchMeter.Modify(monster.TorchlightModifier); } RaidSceneManager.TorchMeter.ApplyBuffsForUnit(MonsterParty.Units[i]); if (monster.Data.BattleBackdrop != null) { backdrop.Activate(monster.Data.BattleBackdrop); } #region Spawn Check if (monster.Data.Spawn != null) { for (int k = 0; k < monster.Data.Spawn.Effects.Count; k++) { for (int j = 0; j < monster.Data.Spawn.Effects[k].SubEffects.Count; j++) { monster.Data.Spawn.Effects[k].SubEffects[j].ApplyInstant(MonsterParty.Units[i], MonsterParty.Units[i], monster.Data.Spawn.Effects[k]); } } MonsterParty.Units[i].OverlaySlot.UpdateOverlay(); } #endregion } var shared = MonsterParty.Units.Find(unit => unit.Character.SharedHealth != null); if (shared != null) { SharedHealth.Initialize(MonsterParty.Units, shared.Character.SharedHealth); } MonsterFormation.overlay.UpdateOverlay(); SurpriseStatus = SurpriseStatus.Nothing; if (MonsterFormation.AlwaysSurprises() || campfireSurprise) { SurpriseStatus = SurpriseStatus.HeroesSurprised; } else if (MonsterFormation.AlwaysBeSurprised()) { SurpriseStatus = SurpriseStatus.MonstersSurprised; } else { if (MonsterFormation.CanBeSurprised()) { float monstersSurprised = 0.1f + RaidSceneManager.TorchMeter.CurrentRange.MonstersSurprised; for (int i = 0; i < HeroParty.Units.Count; i++) { monstersSurprised += HeroParty.Units[i].Character[AttributeType.MonsterSurpirseChance].ModifiedValue; } monstersSurprised = Mathf.Clamp(monstersSurprised, 0, 0.65f); if (RandomSolver.CheckSuccess(monstersSurprised)) { SurpriseStatus = SurpriseStatus.MonstersSurprised; } } if (MonsterFormation.CanSurprise() && SurpriseStatus == SurpriseStatus.Nothing) { float heroesSurprised = 0.1f + RaidSceneManager.TorchMeter.CurrentRange.HeroesSurprised; for (int i = 0; i < HeroParty.Units.Count; i++) { heroesSurprised += HeroParty.Units[i].Character[AttributeType.PartySurpriseChance].ModifiedValue; } heroesSurprised = Mathf.Clamp(heroesSurprised, 0, 0.65f); if (RandomSolver.CheckSuccess(heroesSurprised)) { SurpriseStatus = SurpriseStatus.HeroesSurprised; } } } Round.StartBattle(this); }
public HallSector(string id, int gridX, int gridY, Hallway parentHallway, Knowledge knowledge, AreaType areaType, string textureId, string dungeon, string encounter, int mashId, int index) : this(id, gridX, gridY, parentHallway, knowledge, areaType, textureId) { BattleEncounter = new BattleEncounter(DarkestDungeonManager.Data.DungeonEnviromentData[dungeon].BattleMashes. Find(mash => mash.MashId == mashId).NamedEncounters[encounter][index].MonsterSet); }
public void SetNamedEncounter(string dungeon, string encounter, int index, int mashId) { BattleEncounter = new BattleEncounter(DarkestDungeonManager.Data.DungeonEnviromentData[dungeon].BattleMashes. Find(mash => mash.MashId == mashId).NamedEncounters[encounter][index].MonsterSet); }
public void SetBossEncounter(string dungeon, string boss, int mashId) { BattleEncounter = new BattleEncounter(DarkestDungeonManager.Data.DungeonEnviromentData[dungeon].BattleMashes. Find(mash => mash.MashId == mashId).BossEncounters.Find(enc => enc.MonsterSet.Contains(boss)).MonsterSet); }