b451f83174
Captures the pre-Godot-port state of the codebase. This is the rollback anchor for the Godot port (M0 of theriapolis-rpg-implementation-plan-godot-port.md). All Phase 0 through Phase 6.5 work is included; Phase 7 is in flight. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using Theriapolis.Core;
|
|
using Theriapolis.Core.Data;
|
|
using Theriapolis.Core.Entities;
|
|
using Theriapolis.Core.Rules.Character;
|
|
using Theriapolis.Core.Rules.Combat;
|
|
using Theriapolis.Core.Util;
|
|
using Xunit;
|
|
|
|
namespace Theriapolis.Tests.Combat;
|
|
|
|
public sealed class EncounterTriggerTests
|
|
{
|
|
private readonly ContentResolver _content = new(new ContentLoader(TestHelpers.DataDirectory));
|
|
|
|
[Fact]
|
|
public void FindHostileTrigger_ReturnsNullWhenNoHostiles()
|
|
{
|
|
var mgr = new ActorManager();
|
|
mgr.SpawnPlayer(new Vec2(100, 100));
|
|
Assert.Null(EncounterTrigger.FindHostileTrigger(mgr));
|
|
}
|
|
|
|
[Fact]
|
|
public void FindHostileTrigger_ReturnsNearbyHostile()
|
|
{
|
|
var mgr = new ActorManager();
|
|
mgr.SpawnPlayer(new Vec2(100, 100));
|
|
var wolf = mgr.SpawnNpc(_content.Npcs.Templates.First(t => t.Id == "wolf"),
|
|
new Vec2(105, 100));
|
|
var hit = EncounterTrigger.FindHostileTrigger(mgr);
|
|
Assert.Same(wolf, hit);
|
|
}
|
|
|
|
[Fact]
|
|
public void FindHostileTrigger_IgnoresHostilesPastTriggerRadius()
|
|
{
|
|
var mgr = new ActorManager();
|
|
mgr.SpawnPlayer(new Vec2(100, 100));
|
|
mgr.SpawnNpc(_content.Npcs.Templates.First(t => t.Id == "wolf"),
|
|
new Vec2(100 + C.ENCOUNTER_TRIGGER_TILES + 5, 100));
|
|
Assert.Null(EncounterTrigger.FindHostileTrigger(mgr));
|
|
}
|
|
|
|
[Fact]
|
|
public void FindHostileTrigger_IgnoresFriendlyAndNeutral()
|
|
{
|
|
var mgr = new ActorManager();
|
|
mgr.SpawnPlayer(new Vec2(100, 100));
|
|
var merchant = _content.Npcs.Templates.First(t => t.Id == "merchant_traveler");
|
|
mgr.SpawnNpc(merchant, new Vec2(102, 100));
|
|
Assert.Null(EncounterTrigger.FindHostileTrigger(mgr));
|
|
}
|
|
|
|
[Fact]
|
|
public void FindInteractCandidate_FindsFriendlyOrNeutralInRange()
|
|
{
|
|
var mgr = new ActorManager();
|
|
mgr.SpawnPlayer(new Vec2(100, 100));
|
|
var merchant = _content.Npcs.Templates.First(t => t.Id == "merchant_traveler");
|
|
var npc = mgr.SpawnNpc(merchant, new Vec2(101, 100));
|
|
var hit = EncounterTrigger.FindInteractCandidate(mgr);
|
|
Assert.Same(npc, hit);
|
|
}
|
|
|
|
[Fact]
|
|
public void FindInteractCandidate_IgnoresHostiles()
|
|
{
|
|
var mgr = new ActorManager();
|
|
mgr.SpawnPlayer(new Vec2(100, 100));
|
|
mgr.SpawnNpc(_content.Npcs.Templates.First(t => t.Id == "wolf"), new Vec2(101, 100));
|
|
Assert.Null(EncounterTrigger.FindInteractCandidate(mgr));
|
|
}
|
|
}
|