public void TestUnitListsNoUnitsInStub(TroopStub stub) { stub.AddFormation(FormationType.Normal); stub.AddFormation(FormationType.Attack); var units = stub.ToUnitList(); units.Count.Should().Be(0); }
public void TestStarveMultiFormation(TroopStub stub) { stub.AddFormation(FormationType.Normal); stub.AddFormation(FormationType.Attack); stub.AddUnit(FormationType.Normal, 0, 10); stub.AddUnit(FormationType.Attack, 0, 100); stub.Starve(); Assert.Equal(stub[FormationType.Normal][0], 9); Assert.Equal(stub[FormationType.Attack][0], 95); }
public void TestUnitListConflictingTypes(TroopStub stub) { stub.AddFormation(FormationType.Normal); stub.AddFormation(FormationType.Attack); stub.AddUnit(FormationType.Normal, 1, 4); stub.AddUnit(FormationType.Attack, 1, 5); var units = stub.ToUnitList(); Assert.True(units.Count == 1); Assert.True(units[0].Type == 1); Assert.True(units[0].Count == 9); }
public void TestStarveToZeroBypassProtection(TroopStub stub) { stub.AddFormation(FormationType.Normal); stub.AddUnit(FormationType.Normal, 0, 1); stub.Starve(5, true); Assert.False(stub[FormationType.Normal].ContainsKey(0)); }
public void TestStarveToZero(TroopStub stub) { stub.AddFormation(FormationType.Normal); stub.AddUnit(FormationType.Normal, 0, 1); stub.Starve(); Assert.Equal(stub[FormationType.Normal][0], 1); }
public void TestStarveSingleUnit(TroopStub stub) { stub.AddFormation(FormationType.Normal); stub.AddUnit(FormationType.Normal, 0, 10); stub.Starve(); Assert.Equal(stub[FormationType.Normal][0], 9); }
public void TestUnitListSpecificFormations(TroopStub stub) { stub.AddFormation(FormationType.Normal); stub.AddFormation(FormationType.Attack); stub.AddUnit(FormationType.Normal, 1, 4); stub.AddUnit(FormationType.Attack, 1, 5); stub.AddUnit(FormationType.Attack, 2, 10); var units = stub.ToUnitList(FormationType.Attack); Assert.True(units.Count == 2); Assert.True(units[0].Type == 1); Assert.True(units[0].Count == 5); Assert.True(units[1].Type == 2); Assert.True(units[1].Count == 10); }
public void MoveFromBattleToNormal(CityBattleProcedure cityBattleProcedure, IGlobal global, TroopStub stub) { Global.Current = global; Global.Current.FireEvents.Returns(false); stub.AddFormation(FormationType.Normal); stub.AddFormation(FormationType.Garrison); stub.AddFormation(FormationType.InBattle); stub.AddUnit(FormationType.Normal, 101, 10); cityBattleProcedure.MoveUnitFormation(stub, FormationType.Normal, FormationType.InBattle); cityBattleProcedure.MoveUnitFormation(stub, FormationType.InBattle, FormationType.Normal); Assert.True(stub[FormationType.Normal].Type == FormationType.Normal); Assert.True(stub[FormationType.InBattle].Type == FormationType.InBattle); }
public void TestMoveFromBattleToNormal(TroopStub stub) { Global.Current = Substitute.For <IGlobal>(); Global.Current.FireEvents.Returns(false); stub.AddFormation(FormationType.Normal); stub.AddFormation(FormationType.Garrison); stub.AddFormation(FormationType.InBattle); stub.AddUnit(FormationType.Normal, 101, 10); var fixture = FixtureHelper.Create(); var procedure = fixture.Create <CityBattleProcedure>(); procedure.MoveUnitFormation(stub, FormationType.Normal, FormationType.InBattle); procedure.MoveUnitFormation(stub, FormationType.InBattle, FormationType.Normal); Assert.True(stub[FormationType.Normal].Type == FormationType.Normal); Assert.True(stub[FormationType.InBattle].Type == FormationType.InBattle); }
public Group() { player = new Player(playerId, DateTime.MinValue, SystemClock.Now, "player " + playerId, string.Empty, PlayerRights.Basic); playerId++; BaseBattleStats baseBattleStats = new BaseBattleStats(type: 2000, lvl: 1, weapon: WeaponType.Sword, wpnClass: WeaponClass.Elemental, armor: ArmorType.Building3, armrClass: ArmorClass.Stone, maxHp: 500, atk: 0, splash: 0, range: 0, stealth: 0, speed: 0, groupSize: 1, carry: 0, normalizedCost: 0); StructureBaseStats structureBaseStats = new StructureBaseStats(name: "MainBuilding", spriteClass: "", type: 2000, lvl: 1, radius: 0, cost: null, baseBattleStats: baseBattleStats, maxLabor: 0, buildTime: 0, workerId: 0); StructureStats structurestats = new StructureStats(structureBaseStats); var main = new Structure(structurestats); city = Ioc.Kernel.Get <ICityFactory>() .CreateCity(id: cityId, owner: player, name: "city " + cityId, resource: Formula.Current.GetInitialCityResources(), radius: Formula.Current.GetInitialCityRadius(), ap: 0); main.ObjectId = 1; city.Add(main.ObjectId, main, false); player.Add(city); cityId++; AttackStub = new TroopStub(0, city); AttackStub.AddFormation(FormationType.Normal); obj = new TroopObject(AttackStub); using (Concurrency.Current.Lock(city)) { city.Troops.Add(AttackStub); city.Add(obj); } TroopObject = new TroopObject(AttackStub) { X = city.X, Y = city.Y }; TroopObject.BeginUpdate(); TroopObject.Stats = new TroopStats(Formula.Current.GetTroopRadius(AttackStub, null), Formula.Current.GetTroopSpeed(AttackStub)); TroopObject.EndUpdate(); city.Add(TroopObject); }