using System.Collections.Generic; using System.Linq; namespace Luneraria.Core.Tests { /// /// S4: what guests see of the extended rules. Over the in-process loopback a guest receives /// the running glyph of each team (extra values after the building HP of a frame) and the /// stun flag of every unit, and its fog sources match the host's (LuneFog.Vision). /// public sealed class S4NetSuite : CheckSuite { public override string Name { get { return "s4"; } } protected override void RunChecks() { var hub = new LuneLoopback(); LuneSession host = hub.Attach(1, new LuneSession()); var options = new MatchOptions { Seed = 42, HumanSlot = 0, Extended = true, Bunds = new List { "glutpakt", "wurzelbund", "glutpakt", "wurzelbund", "glutpakt", "wurzelbund" } }; Check(host.HostNetwork(options, "Host"), "host starts"); LuneSession guest = hub.Attach(10, new LuneSession()); guest.JoinNetwork("Gast"); guest.OnClientConnected(); Check(guest.MatchState != null && guest.MatchState.Extended, "the guest's match has the extended rules"); host.PlanBotSeats(); host.Submit(Command.Buy("g01")); host.ReadyUp(); guest.Submit(Command.Buy(guest.MatchState.BaseIds(guest.MatchState.Players[guest.LocalSlot].Bund)[0])); guest.ReadyUp(); for (int i = 0; i < 20 && host.MatchState.Phase != Phase.Combat; i++) host.HostTick(LuneNet.FrameInterval); Check(host.MatchState.Phase == Phase.Combat && guest.MatchState.Phase == Phase.Combat, "both sides are in combat"); LuneCombat combat = host.MatchState.Combat; for (int i = 0; i < 10; i++) host.MatchState.StepCombat(); combat.GlyphLane[0] = "mid"; combat.GlyphUntil[0] = combat.Elapsed + 3.0; LuneUnit target = combat.Units.First(u => u.IsMobile() && u.Team == 1 && u.Alive); target.ApplyEffect("valkyrie_stun", "stun", 1.0, 2.0); host.HostTick(LuneNet.FrameInterval); LuneCombat mirror = guest.MatchState.Combat; Check(mirror.GlyphLane[0] == "mid" && mirror.GlyphLane[1] == "", "the guest knows Blau's glyph on mid"); LuneUnit tower; Check(mirror.Buildings.TryGetValue("blau_mid_outer", out tower) && mirror.Glyphed(tower), "the guest sees the mid tower glyphed"); LuneUnit copy = mirror.Units.FirstOrDefault(u => u.Id == target.Id); Check(copy != null && copy.ShowsStun(), "the guest sees the stun"); Check(mirror.Units.Where(u => u.Id != target.Id && u.IsMobile()).All(u => !u.ShowsStun()), "nobody else looks stunned"); int team = 0; int hostSources = LuneFog.Vision(host.MatchState, combat, team).Count; int guestSources = LuneFog.Vision(guest.MatchState, mirror, team).Count; Check(hostSources == guestSources && hostSources > 0, "fog sources agree on host and guest (" + hostSources + "/" + guestSources + ")"); } } }