using System; using System.Collections; using System.Linq; using Luneraria.Core; using Luneraria.View; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; namespace Luneraria.UI.Tests { /// /// U5.5 pilot pictures of one figure in the real game (the Meshy Kohlenbeißer against the /// Phase-4 model it replaces): the human seat plays the Glutpakt, buys the starter army and /// four Kohlenbeißer (g01) in round 3, and the camera shows them in the planning formation, /// in the HUD portrait and in the fight on the own lane, close (zoom 12) and at the benchmark's /// lane distance (zoom 22). Like HudViewsTests, commands go straight to the match followed by /// the preview rebuild. A capture tool, not part of the suite: /// -testFilter "Luneraria.UI.Tests.FigureViewsTests"; LUNE_EVIDENCE names the folder below /// docs/port/screenshots (default u5.5/spiel). LUNE_FIGURE names another Glutpakt troop /// (default g01); an upgraded troop (g02) is bought as its base and upgraded. /// [Explicit("Bildwerkzeug: nur gezielt per -testFilter")] public sealed class FigureViewsTests { /// The human seat 1 plays the Glutpakt, as do the bots of seats 2 and 5. static readonly string[] Bunds = { "wurzelbund", "glutpakt", "glutpakt", "wurzelbund", "wurzelbund", "glutpakt" }; string _folder; IEnumerator Shot(HudSession s, string label) { yield return s.Shot(_folder + label + ".png"); } static void Send(HudSession s, Command command) { CommandResult result = s.Match.Submit(HudSession.Human, command); Assert.IsTrue(result.Ok, command.Type + ": " + result.Message); s.Game.RebuildPreview(); s.Sync(); } /// The own Kohlenbeißer on the field: the one nearest to the enemy (the front of the fight). static LuneUnit Front(HudSession s, string figure) { int team = s.Me.Team; return s.Match.Combat.Units.Where(u => u.Alive && u.Team == team && u.Def.Id == figure) .OrderByDescending(u => u.Progress).FirstOrDefault(); } [UnityTest, Timeout(900000)] public IEnumerator Kohlenbeisser() { string evidence = Environment.GetEnvironmentVariable("LUNE_EVIDENCE"); _folder = "docs/port/screenshots/" + (string.IsNullOrEmpty(evidence) ? "u5.5/spiel" : evidence) + "/"; string figure = Environment.GetEnvironmentVariable("LUNE_FIGURE"); if (string.IsNullOrEmpty(figure)) figure = "g01"; bool upgrade = figure != "g01"; var s = new HudSession(); yield return s.Open(1920, 1080, seed: 4, bunds: Bunds); s.Match.RoundNumber = 3; s.Me.Draft.Gold = upgrade ? 2000 : 900; yield return s.Starter(); s.Leave(); for (int i = 0; i < 4; i++) Send(s, Command.Buy("g01", s.Me.Lane)); if (upgrade) { foreach (RosterEntry entry in s.Me.Draft.Roster.Where(e => e.TypeId == "g01").ToList()) Send(s, Command.Upgrade(entry.Uid)); } yield return new WaitForSecondsRealtime(.4f); RosterEntry first = s.Me.Draft.Roster.First(e => e.TypeId == figure); // The planning preview stands the army in its formation on the own lane. LuneUnit waiting = s.View.Preview?.Units.FirstOrDefault(u => u.Team == s.Me.Team && u.Def.Id == figure); Assert.IsNotNull(waiting, "Kohlenbeißer in the planning preview"); s.Rig.LookAt(waiting.Position, 12f, true); yield return new WaitForSecondsRealtime(.5f); yield return Shot(s, "01-aufstellung-nah"); s.Hud.SelectUnit(first.Uid); yield return new WaitForSecondsRealtime(.4f); yield return Shot(s, "02-portraet"); s.Hud.ClearSelection(); s.Game.Key(KeyCode.Space); yield return HudSession.Frames(1); Assert.AreEqual(LuneMatchRunner.Stage.Combat, s.Runner.Current, "combat of round 3"); yield return s.Fight(7.0); s.Driver.Paused = true; LuneUnit front = Front(s, figure); Assert.IsNotNull(front, "a Kohlenbeißer on the field"); s.Rig.LookAt(front.Position, 12f, true); yield return new WaitForSecondsRealtime(.5f); yield return Shot(s, "03-kampf-nah"); s.Rig.LookAt(front.Position, 22f, true); yield return new WaitForSecondsRealtime(.5f); yield return Shot(s, "04-kampf-lane"); s.Close(); } } }