champions-of-luneraria/Assets/Luneraria/Tests/UI/PlayMode/S4PolishViewsTests.cs
Martin Stickelbroeck 7b86973197 S4 Feinschliff: Betäubung sichtbar, Nebel im Gelände, Glyphe für Gäste
Betäubungs-Ring über dem Kopf (Gäste über Bit 18 der Rahmen-Flags),
Nebel-Gitter LuneFogOverlay mit Shader Luneraria/FogOverlay aus
LuneFog.Vision (10 Hz, weiche Kante), laufende Glyphe je Team als vier
Zusatzwerte nach den Gebäude-Lebenspunkten. Reine Darstellung.
Kern 627/627 (s4 8), EditMode 35/35, PlayMode 20/20, Verify 718/0,
Selbsttest 30/30, Golden 0, Fingerabdruck unverändert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 17:55:42 +02:00

87 lines
4.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
{
/// <summary>
/// S4 in the real scene: the fog of war darkens the terrain outside the team's vision (light
/// at the own base, dark at the enemy base), and a stunned unit shows the gold ring over its
/// head. S4Bilder (explicit) captures both at 1920×1080; LUNE_EVIDENCE names the folder below
/// docs/port/screenshots (default s4/spiel).
/// </summary>
public sealed class S4PolishViewsTests
{
static float AlphaAt(LuneFogOverlay fog, Vec2 point)
{
int side = Mathf.CeilToInt((float)(LuneMap.HalfExtent * 2.0) / LuneFogOverlay.Cell) + 1;
int column = Mathf.Clamp(Mathf.RoundToInt((float)((point.X + LuneMap.HalfExtent) / LuneFogOverlay.Cell)), 0, side - 1);
int row = Mathf.Clamp(Mathf.RoundToInt((float)((point.Y + LuneMap.HalfExtent) / LuneFogOverlay.Cell)), 0, side - 1);
return fog.Alpha[row * side + column];
}
static IEnumerator Fight(HudSession s)
{
yield return s.Starter();
s.Leave();
s.Game.Key(KeyCode.Space);
yield return HudSession.Frames(2);
yield return s.Fight(4.0);
yield return HudSession.Frames(4);
}
[UnityTest, Timeout(600000)]
public IEnumerator S4Views()
{
var s = new HudSession();
yield return s.Open(1920, 1080, seed: 4, startRound: 6, extraGold: 500, extended: true);
yield return Fight(s);
LuneFogOverlay fog = s.Game.View.Fog;
Assert.IsNotNull(fog, "an extended match with a human seat has the fog overlay");
Assert.IsTrue(fog.gameObject.activeSelf && fog.Refreshes > 0, "the fog is active and refreshed");
Assert.Less(AlphaAt(fog, s.Match.Map.CorePosition(0)), .05f, "the own Ancient stands in light");
Assert.Greater(AlphaAt(fog, s.Match.Map.CorePosition(1)), .5f, "the enemy Ancient lies in the fog");
LuneUnit victim = s.Match.Combat.Units.First(u => u.IsMobile() && u.Alive && u.Team == 0);
victim.ApplyEffect("valkyrie_stun", "stun", 1.0, 3.0);
yield return HudSession.Frames(3);
LuneUnitView view = UnityEngine.Object.FindObjectsByType<LuneUnitView>(FindObjectsSortMode.None).First(v => v.Unit == victim);
Transform ring = view.transform.Find("StunRing");
Assert.IsTrue(ring != null && ring.gameObject.activeSelf, "a stunned unit shows the stun ring");
s.Close();
var reference = new HudSession();
yield return reference.Open(1920, 1080, seed: 4, startRound: 6, extraGold: 500);
yield return Fight(reference);
Assert.IsTrue(reference.Game.View.Fog == null || !reference.Game.View.Fog.gameObject.activeSelf, "no fog under the reference rules");
reference.Close();
}
[UnityTest, Timeout(600000), Explicit("Bildwerkzeug: nur gezielt per -testFilter")]
public IEnumerator S4Bilder()
{
string evidence = Environment.GetEnvironmentVariable("LUNE_EVIDENCE");
string folder = "docs/port/screenshots/" + (string.IsNullOrEmpty(evidence) ? "s4/spiel" : evidence) + "/";
var s = new HudSession();
yield return s.Open(1920, 1080, seed: 4, startRound: 6, extraGold: 500, extended: true);
yield return Fight(s);
s.Driver.Paused = true;
s.Rig.LookAt(new Vec2(0.0, 0.0), 60f, true);
yield return new WaitForSecondsRealtime(.6f);
yield return s.Shot(folder + "01-nebel-uebersicht.png");
LuneUnit front = s.Match.Combat.Units.Where(u => u.IsMobile() && u.Alive && u.Team == 0 && u.Lane == "mid").OrderByDescending(u => u.Progress).First();
s.Rig.LookAt(front.Position, 22f, true);
yield return new WaitForSecondsRealtime(.5f);
yield return s.Shot(folder + "02-nebelgrenze-mid.png");
foreach (LuneUnit unit in s.Match.Combat.Units.Where(u => u.IsMobile() && u.Alive && u.Position.DistanceTo(front.Position) < 6.0))
unit.ApplyEffect("valkyrie_stun", "stun", 1.0, 10.0);
s.Rig.LookAt(front.Position, 9f, true);
yield return new WaitForSecondsRealtime(.6f);
yield return s.Shot(folder + "03-betaeubung.png");
s.Close();
}
}
}