public void unit_count_is_exact() { Arena a4 = new Arena(); Team t4 = a4.CreateTeam("RED"); t4.AddArcher(10); t4.AddPaladin(5); t4.AddGoblin(3); Assert.That(t4.UnitCount, Is.EqualTo(18)); }
public void gold_calculation() { Arena ag = new Arena(); Team tb = ag.CreateTeam("Blue"); Team tr = ag.CreateTeam("RED"); tb.AddArcher(5); tr.AddArcher(5); //50.0 tr.AddGoblin(10); //30.0 tr.AddPaladin(6); //75.0 }
public void add_a_goblin() { Arena arena = new Arena(); Team t1 = arena.CreateTeam("RED"); t1.AddGoblin(1); Unit[] tab = t1.Find(); Unit u = t1.FindUnitByName(tab[0].Name); Assert.That(u, Is.SameAs(tab[0])); }
/// <summary> /// Writte the different levels in a JSON /// </summary> internal void LevelWritte() { Dictionary <int, Arena> arenas = new Dictionary <int, Arena>(); string path = "../../../../res/HistoryMode.JSON"; Arena a = new Arena(); Team t = a.CreateTeam("red"); t.AddArcher(10); t.Acount = 10; arenas.Add(0, a); Arena a1 = new Arena(); Team t1 = a1.CreateTeam("red"); t1.AddGoblin(10); t.Gcount = 10; arenas.Add(1, a1); Arena a2 = new Arena(); Team t2 = a2.CreateTeam("red"); t2.AddDrake(10); t2.Dcount = 10; arenas.Add(2, a2); Arena a3 = new Arena(); Team t3 = a3.CreateTeam("red"); t3.AddPaladin(10); t3.Pcount = 10; arenas.Add(3, a3); Arena a4 = new Arena(); Team t4 = a4.CreateTeam("red"); t4.AddCatapult(10); t4.Ccount = 10; arenas.Add(4, a4); { JToken jToken = Serialize(arenas); using (FileStream fs = File.OpenWrite(path)) using (StreamWriter sw = new StreamWriter(fs)) using (JsonTextWriter jw = new JsonTextWriter(sw)) { jToken.WriteTo(jw); } } Console.WriteLine("serilization ended"); }
public void Spawn_unit() { Arena arena = new Arena(); Team firstTeam = arena.CreateTeam("firstTeam"); firstTeam.AddGoblin(1); Unit[] tab = firstTeam.Find(); Unit u = firstTeam.FindUnitByName(tab[0].Name); u = arena.SpawnUnit(u); Vector testVector = new Vector(0, 0); Vector vector = u.Location; Assert.That(vector, !Is.EqualTo(testVector)); }
public void Aquire_a_target() { Arena arena = new Arena(); Team firstTeam = arena.CreateTeam("firstTeam"); Team secondTeam = arena.CreateTeam("secondTeam"); firstTeam.AddGoblin(1); secondTeam.AddGoblin(1); Unit[] tab = firstTeam.Find(); Unit firstUnit = firstTeam.FindUnitByName(tab[0].Name); firstUnit = arena.SpawnUnit(firstUnit); Unit[] tab2 = secondTeam.Find(); Unit secondUnit = secondTeam.FindUnitByName(tab2[0].Name); secondUnit = arena.SpawnUnit(secondUnit); Unit testUnit = arena.NearestEnemy(firstUnit); Assert.That(testUnit, Is.EqualTo(secondUnit)); secondTeam.AddGoblin(1); tab2 = secondTeam.Find(); Unit thirdUnit = secondTeam.FindUnitByName(tab2[1].Name); Vector vector1 = new Vector(0, 0); Vector vector2 = new Vector(0, 1); Vector vector3 = new Vector(0, 2); firstUnit.Location = vector1; secondUnit.Location = vector2; thirdUnit.Location = vector3; Unit testUnit2 = arena.NearestEnemy(firstUnit); Assert.That(testUnit2, Is.EqualTo(secondUnit)); }
public void team_is_wiped_when_there_is_no_unit_left() { Arena a = new Arena(); Team t = a.CreateTeam("RED"); Team t2 = a.CreateTeam("BLUE"); t.AddArcher(0); t.AddGoblin(1); t2.AddArcher(1); Unit[] tab = t.Find(); Unit u = t.FindUnitByName(tab[0].Name); t.RemoveUnit(u); Assert.That(t.UnitCount, Is.EqualTo(0)); Assert.That(t.IsWiped, Is.True); Assert.That(t2.UnitCount, Is.EqualTo(t2.Acount)); Assert.That(t2.UnitCount, Is.EqualTo(1)); Assert.That(t2.IsWiped, Is.False); }
public void serialize_a_team() { Arena arena = new Arena(); Team sut = arena.CreateTeam("blue"); sut.AddArcher(2); sut.AddBalista(2); sut.AddCatapult(2); sut.AddDrake(2); sut.AddGoblin(2); sut.AddPaladin(2); JToken jToken = sut.Serialize(); Team result = new Team(arena, jToken); IEnumerable <Unit> units = result.GetUnits(); Assert.That(units.Count(), Is.EqualTo(12)); Assert.That(units.Any(u => u.Life == 12.0 && u.Speed == 1.8)); Assert.That(units.All(u => u.Team == result)); }
public void PreGame() { Team blue = Arena.CreateTeam("blue"); Team red = Arena.CreateTeam("red"); Team green = null; Team yellow = null; string[] status = new string[8]; status[0] = "selected"; status[1] = "active"; status[2] = "inactive"; status[3] = "inactive"; status[4] = "none"; status[5] = "add"; status[6] = "1"; status[7] = "yes"; int[,] teamComposition = { { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; double previous = GetCurrentTime(); while (Window.IsOpen && Status == "preGame") { double current = GetCurrentTime(); if (current - previous >= 0.0000025) { previous = current; Shape[] buttons = InitPreGame(status, teamComposition); Window.DispatchEvents(); status = _iHandler.HandlerPreGame(buttons, status); if (status[7] == "no") { for (int i = 0; i < status.Length; i++) { if (status[i] == "selected") { teamComposition = FillRandom(i, teamComposition); status[7] = "yes"; } } } if (status[2] == "inactiveTemp") { status[3] = "inactive"; status[2] = "active"; for (int i = 0; i < 6; i++) { teamComposition[2, i] = teamComposition[3, i]; } } if (status[2] == "inactive") { for (int i = 0; i < 6; i++) { teamComposition[2, i] = 0; } } if (status[3] == "inactive") { for (int i = 0; i < 6; i++) { teamComposition[3, i] = 0; } } if (status[2] == "active" && Arena.FindTeam("green") == false) { green = Arena.CreateTeam("green"); } else if (status[3] == "active" && Arena.FindTeam("yellow") == false) { yellow = Arena.CreateTeam("yellow"); } switch (status[4]) { case "archer": for (int i = 0; i < 4; i++) { if (status[i] == "selected" && IsValidToAddUnit(teamComposition, i, status) == true && status[5] == "add") { teamComposition[i, 0] += Int32.Parse(status[6]); } else if (status[i] == "selected" && status[5] != "add") { teamComposition[i, 0] -= Int32.Parse(status[6]); if (teamComposition[i, 0] < 0) { teamComposition[i, 0] = 0; } } } break; case "drake": for (int i = 0; i < 4; i++) { if (status[i] == "selected" && IsValidToAddUnit(teamComposition, i, status) == true && status[5] == "add") { teamComposition[i, 1] += Int32.Parse(status[6]); } else if (status[i] == "selected" && status[5] != "add") { teamComposition[i, 1] -= Int32.Parse(status[6]); if (teamComposition[i, 1] < 0) { teamComposition[i, 1] = 0; } } } break; case "gobelin": for (int i = 0; i < 4; i++) { if (status[i] == "selected" && IsValidToAddUnit(teamComposition, i, status) == true && status[5] == "add") { teamComposition[i, 2] += Int32.Parse(status[6]); } else if (status[i] == "selected" && status[5] != "add") { teamComposition[i, 2] -= Int32.Parse(status[6]); if (teamComposition[i, 2] < 0) { teamComposition[i, 2] = 0; } } } break; case "paladin": for (int i = 0; i < 4; i++) { if (status[i] == "selected" && IsValidToAddUnit(teamComposition, i, status) == true && status[5] == "add") { teamComposition[i, 3] += Int32.Parse(status[6]); } else if (status[i] == "selected" && status[5] != "add") { teamComposition[i, 3] -= Int32.Parse(status[6]); if (teamComposition[i, 3] < 0) { teamComposition[i, 3] = 0; } } } break; case "balista": for (int i = 0; i < 4; i++) { if (status[i] == "selected" && IsValidToAddUnit(teamComposition, i, status) == true && status[5] == "add") { teamComposition[i, 4] += Int32.Parse(status[6]); } else if (status[i] == "selected" && status[5] != "add") { teamComposition[i, 4] -= Int32.Parse(status[6]); if (teamComposition[i, 4] < 0) { teamComposition[i, 4] = 0; } } } break; case "catapult": for (int i = 0; i < 4; i++) { if (status[i] == "selected" && IsValidToAddUnit(teamComposition, i, status) == true && status[5] == "add") { teamComposition[i, 5] += Int32.Parse(status[6]); } else if (status[i] == "selected" && status[5] != "add") { teamComposition[i, 5] -= Int32.Parse(status[6]); if (teamComposition[i, 5] < 0) { teamComposition[i, 5] = 0; } } } break; default: break; } status[4] = "none"; } } if (Status != "preGame") { for (int i = 0; i < teamComposition.GetLength(1); i++) { switch (i) { case 0: red.AddArcher(teamComposition[0, i]); break; case 1: red.AddDrake(teamComposition[0, i]); break; case 2: red.AddGoblin(teamComposition[0, i]); break; case 3: red.AddPaladin(teamComposition[0, i]); break; case 4: red.AddBalista(teamComposition[0, i]); break; case 5: red.AddCatapult(teamComposition[0, i]); break; default: break; } } for (int i = 0; i < teamComposition.GetLength(1); i++) { switch (i) { case 0: blue.AddArcher(teamComposition[1, i]); break; case 1: blue.AddDrake(teamComposition[1, i]); break; case 2: blue.AddGoblin(teamComposition[1, i]); break; case 3: blue.AddPaladin(teamComposition[1, i]); break; case 4: blue.AddBalista(teamComposition[1, i]); break; case 5: blue.AddCatapult(teamComposition[1, i]); break; default: break; } } if (Arena.FindTeam("green") == true) { for (int i = 0; i < teamComposition.GetLength(1); i++) { switch (i) { case 0: green.AddArcher(teamComposition[2, i]); break; case 1: green.AddDrake(teamComposition[2, i]); break; case 2: green.AddGoblin(teamComposition[2, i]); break; case 3: green.AddPaladin(teamComposition[2, i]); break; case 4: green.AddBalista(teamComposition[2, i]); break; case 5: green.AddCatapult(teamComposition[2, i]); break; default: break; } } } if (Arena.FindTeam("yellow") == true) { for (int i = 0; i < teamComposition.GetLength(1); i++) { switch (i) { case 0: yellow.AddArcher(teamComposition[3, i]); break; case 1: yellow.AddDrake(teamComposition[3, i]); break; case 2: yellow.AddGoblin(teamComposition[3, i]); break; case 3: yellow.AddPaladin(teamComposition[3, i]); break; case 4: yellow.AddBalista(teamComposition[3, i]); break; case 5: yellow.AddCatapult(teamComposition[3, i]); break; default: break; } } } TeamCompo = teamComposition; //Arena.SpawnUnit(); } }