Summons write no stance: ZoneStage.Summon loses its player anchor, Neutral writes no override
ZoneStage.Place and AdmitPlaced write no IFF; authored stance is ScenarioStage's run-start verb (Hostile written both ways once, in Admit). A summoned ship now answers a provocation (Entity.Provoke), as the faction rule and grudges decide (ruling summons-follow-faction-logic). Closes the summon anchor refusals, which guarded an anchor that no longer exists. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e700ead684
commit
5bf507aba0
4 changed files with 82 additions and 78 deletions
|
|
@ -33,6 +33,8 @@ public abstract class Scenario
|
|||
public abstract void Stage(ScenarioStage stage);
|
||||
}
|
||||
|
||||
// A run-start placement's stance toward the player. Hostile is written as an override both ways; Neutral writes nothing,
|
||||
// so the faction rule and grudges decide.
|
||||
public enum ScenarioStance
|
||||
{
|
||||
Neutral,
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ using float3 = CultMath.float3;
|
|||
// Every verb names what it could not do instead of throwing, so one bad name in a script lists every bad name.
|
||||
// Designs, hulls and products are named as the catalog names them.
|
||||
// ZoneStage is the placement vocabulary and the admission of what it placed; Zone.Admit stays the only admission.
|
||||
// RunStart builds a ScenarioStage (a ZoneStage that also stages the player); ZoneStage.Summon builds a ZoneStage for a
|
||||
// running zone. A ZoneStage has no Player verb, so a summon placing a player is unrepresentable.
|
||||
// RunStart builds a ScenarioStage (a ZoneStage that also stages the player and authors stance); ZoneStage.Summon builds a
|
||||
// ZoneStage for a running zone. A ZoneStage has no Player verb and no stance, so a summon placing a player or writing who
|
||||
// fights whom is unrepresentable: a summon's stance is the faction rule's and its grudges'.
|
||||
public class ZoneStage
|
||||
{
|
||||
private readonly ItemManager _items;
|
||||
|
|
@ -52,7 +53,6 @@ public class ZoneStage
|
|||
internal sealed class Placement
|
||||
{
|
||||
public Entity Entity;
|
||||
public ScenarioStance Stance;
|
||||
public bool Piloted;
|
||||
public AgentTask Task;
|
||||
// What the pilot already knows at the start: an entity its sensors hold a track of (Approach). Seeded through the
|
||||
|
|
@ -122,18 +122,17 @@ public class ZoneStage
|
|||
return new ScenarioFit(preset);
|
||||
}
|
||||
|
||||
// Anything else in the arena. A stance holds both ways between it and the player. A piloted ship gets the zone's
|
||||
// pilot; an unpiloted entity has none and goes nowhere on its own unless it is placed moving: velocity is the planar
|
||||
// velocity it starts with, and the sim carries it from there. A turret hull stays where it is put.
|
||||
public Entity Place(ScenarioFit fit, float2 at, float2 facing = default, ScenarioStance stance = ScenarioStance.Neutral, bool piloted = false,
|
||||
float2 velocity = default)
|
||||
// Anything else in the arena. A piloted ship gets the zone's pilot; an unpiloted entity has none and goes nowhere on its
|
||||
// own unless it is placed moving: velocity is the planar velocity it starts with, and the sim carries it from there. A
|
||||
// turret hull stays where it is put. It writes no stance: who fights whom is the faction rule's (stance is ScenarioStage's).
|
||||
public Entity Place(ScenarioFit fit, float2 at, float2 facing = default, bool piloted = false, float2 velocity = default)
|
||||
{
|
||||
var where = $"entity {_placements++}";
|
||||
var entity = Build(fit, where, at, facing);
|
||||
if (entity == null) return null;
|
||||
entity.Velocity = velocity;
|
||||
if (piloted && !(entity is Ship)) _failures.Add($"{where}: {entity.Name} is not a ship hull, so it cannot be piloted");
|
||||
_placed.Add(new Placement { Entity = entity, Stance = stance, Piloted = piloted });
|
||||
_placed.Add(new Placement { Entity = entity, Piloted = piloted });
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
|
@ -181,17 +180,13 @@ public class ZoneStage
|
|||
}
|
||||
}
|
||||
|
||||
// Admits what was placed: each entity's stance set both ways with the player, then Zone.Admit with a pilot for each
|
||||
// piloted one. A start state includes what a pilot knows (ruling stage-states-pilot-knowledge): its anchor is tracked
|
||||
// Admits what was placed: Zone.Admit with a pilot for each piloted one. It writes no stance. A start state includes what a pilot knows (ruling stage-states-pilot-knowledge): its anchor is tracked
|
||||
// from the first step, by the sensors' own path (info gathered past the detection threshold), so they can lose it
|
||||
// like any track. The one owner of admitting placements.
|
||||
private protected void AdmitPlaced(Ship player)
|
||||
private protected void AdmitPlaced()
|
||||
{
|
||||
foreach (var placed in _placed)
|
||||
{
|
||||
var hostile = placed.Stance == ScenarioStance.Hostile;
|
||||
placed.Entity.SetIff(player, hostile);
|
||||
player.SetIff(placed.Entity, hostile);
|
||||
Arena.Admit(placed.Entity, placed.Piloted, placed.Task);
|
||||
}
|
||||
foreach (var placed in _placed)
|
||||
|
|
@ -200,22 +195,12 @@ public class ZoneStage
|
|||
}
|
||||
|
||||
// Places ships into a running zone through the admission a run start uses: the script places with the stage's verbs,
|
||||
// and the entities join with their stance toward the player, a pilot when piloted and the knowledge the script stated.
|
||||
// and the entities join with a pilot when piloted and the knowledge the script stated. A summon writes no stance: the
|
||||
// faction rule decides who fights whom, and a grudge (Entity.Provoke) turns the summoned faction on whoever attacks it.
|
||||
// Returns the placed entities in order, or null with every failure listed and the zone and the item stream and lot ledger unchanged.
|
||||
// It draws from the live item stream and does not reseed (a reseed would give every summon the same fits). The anchor
|
||||
// is the player's ship: the stance is written against it.
|
||||
public static IReadOnlyList<Entity> Summon(ItemManager items, Zone zone, Ship player, Action<ZoneStage> script, List<string> failures)
|
||||
// It draws from the live item stream and does not reseed (a reseed would give every summon the same fits).
|
||||
public static IReadOnlyList<Entity> Summon(ItemManager items, Zone zone, Action<ZoneStage> script, List<string> failures)
|
||||
{
|
||||
if (player == null || !player.IsPlayerShip)
|
||||
{
|
||||
failures.Add("summon: the anchor is not the player's ship");
|
||||
return null;
|
||||
}
|
||||
if (!zone.Entities.Contains(player))
|
||||
{
|
||||
failures.Add("summon: the player is not in this zone");
|
||||
return null;
|
||||
}
|
||||
var mark = items.Mark();
|
||||
var stage = new ZoneStage(items, zone);
|
||||
script(stage);
|
||||
|
|
@ -226,7 +211,7 @@ public class ZoneStage
|
|||
return null;
|
||||
}
|
||||
stage.StockUnauthoredAmmunition();
|
||||
stage.AdmitPlaced(player);
|
||||
stage.AdmitPlaced();
|
||||
return stage._placed.Select(placed => placed.Entity).ToList();
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +256,8 @@ public class ZoneStage
|
|||
}
|
||||
|
||||
// The run-start stage: a ZoneStage that also stages the player, the credits the run starts with and the hull it
|
||||
// starts in. Only RunStart builds one.
|
||||
// starts in, and the one place a script authors stance: a Hostile placement is hostile both ways with the player, written
|
||||
// once at admission. Neutral writes nothing (the faction rule and grudges decide). Only RunStart builds one.
|
||||
public sealed class ScenarioStage : ZoneStage
|
||||
{
|
||||
internal ScenarioStage(ItemManager items, Zone arena, string startingHull) : base(items, arena)
|
||||
|
|
@ -285,6 +271,17 @@ public sealed class ScenarioStage : ZoneStage
|
|||
// What the run starts with: the gameplay settings' starting credits unless the scenario sets another amount.
|
||||
public int Credits { get; set; }
|
||||
|
||||
private readonly List<Entity> _hostile = new List<Entity>();
|
||||
|
||||
// Anything else in the arena, as ZoneStage.Place, with a stance toward the player: Hostile holds both ways from the start.
|
||||
public new Entity Place(ScenarioFit fit, float2 at, float2 facing = default, ScenarioStance stance = ScenarioStance.Neutral, bool piloted = false,
|
||||
float2 velocity = default)
|
||||
{
|
||||
var entity = base.Place(fit, at, facing, piloted, velocity);
|
||||
if (entity != null && stance == ScenarioStance.Hostile) _hostile.Add(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
internal bool PlayerPlaced { get; private set; }
|
||||
internal Ship PlayerShip { get; private set; }
|
||||
|
||||
|
|
@ -312,7 +309,12 @@ public sealed class ScenarioStage : ZoneStage
|
|||
StockUnauthoredAmmunition();
|
||||
PlayerShip.IsPlayerShip = true;
|
||||
Arena.Admit(PlayerShip, piloted: false);
|
||||
AdmitPlaced(PlayerShip);
|
||||
foreach (var entity in _hostile)
|
||||
{
|
||||
entity.SetIff(PlayerShip, true);
|
||||
PlayerShip.SetIff(entity, true);
|
||||
}
|
||||
AdmitPlaced();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public sealed partial class RunStartTests
|
|||
var (_, arena, staged, failures) = Launch(new Scripted(false, stage => stage.Player(stage.Bare("Djinni"), float2(0, 0))), Inputs(() => GalaxySeed));
|
||||
Assert.True(failures.Count == 0, string.Join("; ", failures));
|
||||
|
||||
var summoned = ZoneStage.Summon(_items, arena, staged.Player, stage =>
|
||||
var summoned = ZoneStage.Summon(_items, arena, stage =>
|
||||
{
|
||||
stage.Place(stage.Fit(hull, slots), float2(300, 0));
|
||||
var authored = stage.Place(stage.Fit(hull, slots), float2(-300, 0));
|
||||
|
|
|
|||
|
|
@ -400,9 +400,9 @@ public sealed partial class RunStartTests
|
|||
}
|
||||
|
||||
// A summon places into a running zone through the stage's admission (ruling ifl-ships-in-demo-as-tactical-view): after a run
|
||||
// has started and stepped, a hostile piloted generated ship that approaches the player is a member with one agent, hostile
|
||||
// both ways, and its pilot knows the player by the sensors' own path. Kills: a summon that skips the stance, the pilot or
|
||||
// the knowledge seed.
|
||||
// has started and stepped, a piloted generated ship that approaches the player is a member with one agent, and its pilot
|
||||
// knows the player by the sensors' own path. It holds no stance either way (ruling summons-follow-faction-logic: the faction
|
||||
// rule decides). Kills: a summon that skips the pilot or the knowledge seed, or that writes any override.
|
||||
[Fact]
|
||||
public void ASummonJoinsARunningZone()
|
||||
{
|
||||
|
|
@ -411,9 +411,9 @@ public sealed partial class RunStartTests
|
|||
for (var tick = 0; tick < 20; tick++) zone.Update(.1f);
|
||||
|
||||
var failures = new List<string>();
|
||||
var summoned = ZoneStage.Summon(_items, zone, player, stage =>
|
||||
var summoned = ZoneStage.Summon(_items, zone, stage =>
|
||||
{
|
||||
var placed = stage.Place(stage.Generated("Longinus"), float2(400, 0), stance: ScenarioStance.Hostile, piloted: true);
|
||||
var placed = stage.Place(stage.Generated("Longinus"), float2(400, 0), piloted: true);
|
||||
stage.Approach(placed, player);
|
||||
}, failures);
|
||||
|
||||
|
|
@ -421,13 +421,50 @@ public sealed partial class RunStartTests
|
|||
var raider = Assert.Single(summoned);
|
||||
SafeAssert.In(zone, raider, "the summoned ship is admitted");
|
||||
Assert.Equal(1, AgentsOf(zone, raider));
|
||||
Assert.True(player.IsHostileTo(raider) && raider.IsHostileTo(player), "hostile both ways");
|
||||
Assert.Null(raider.IffOverride(player));
|
||||
Assert.Null(player.IffOverride(raider));
|
||||
Assert.Equal((_items.GameplaySettings.TargetDetectionInfoThreshold + 1f) / 2f, raider.EntityInfoGathered[player]);
|
||||
for (var tick = 0; tick < 20; tick++) zone.Update(.1f);
|
||||
Assert.True(player.EntityHostility[raider] && raider.EntityHostility[player], "the live hostility agrees");
|
||||
Assert.Equal(1, AgentsOf(zone, raider));
|
||||
}
|
||||
|
||||
// A summon writes no pin, so the grudge a provocation raises still lands (an override already held is never replaced:
|
||||
// Entity.Provoke). Kills: any stance written at summon, which blocks the formation from fighting back.
|
||||
[Fact]
|
||||
public void ASummonedShipAnswersAProvocation()
|
||||
{
|
||||
var zone = Arena(true);
|
||||
var player = Stage(zone, new Scripted(true, stage => stage.Player(stage.Bare("Djinni"), float2(0, 0)))).Player;
|
||||
var failures = new List<string>();
|
||||
var placed = Assert.Single(ZoneStage.Summon(_items, zone, stage =>
|
||||
stage.Place(stage.Generated("Longinus"), float2(400, 0), piloted: true), failures));
|
||||
Assert.True(failures.Count == 0, string.Join("; ", failures));
|
||||
|
||||
placed.Provoke(player);
|
||||
|
||||
Assert.True(placed.IsHostileTo(player), "a provoked summon did not turn on its attacker");
|
||||
}
|
||||
|
||||
// A run-start script's Hostile is the only authored stance: written both ways with the player. Neutral is the absence of
|
||||
// an override, not a pin to false. Kills: Neutral writing false; a Hostile written one way only.
|
||||
[Fact]
|
||||
public void ANeutralPlacementWritesNoOverride()
|
||||
{
|
||||
var staged = Stage(Arena(true), new Scripted(true, stage =>
|
||||
{
|
||||
stage.Player(stage.Bare("Djinni"), float2(0, 0));
|
||||
stage.Place(stage.Generated("Longinus"), float2(300, 0), stance: ScenarioStance.Hostile, piloted: true);
|
||||
stage.Place(stage.Bare("Longinus"), float2(-300, 0), stance: ScenarioStance.Neutral);
|
||||
}));
|
||||
var player = staged.Player;
|
||||
var hostile = staged.Entities[0];
|
||||
var neutral = staged.Entities[1];
|
||||
|
||||
Assert.Null(neutral.IffOverride(player));
|
||||
Assert.Null(player.IffOverride(neutral));
|
||||
Assert.True(hostile.IffOverride(player) == true && player.IffOverride(hostile) == true, "hostile both ways");
|
||||
}
|
||||
|
||||
// A summon naming a design the catalog lacks admits nothing, and names it. Kills: admitting before the failure check.
|
||||
[Fact]
|
||||
public void ARefusedSummonAdmitsNothing()
|
||||
|
|
@ -438,9 +475,9 @@ public sealed partial class RunStartTests
|
|||
var agents = zone.Agents.ToList();
|
||||
var failures = new List<string>();
|
||||
|
||||
var summoned = ZoneStage.Summon(_items, zone, player, stage =>
|
||||
var summoned = ZoneStage.Summon(_items, zone, stage =>
|
||||
{
|
||||
stage.Place(stage.Generated("Longinus"), float2(400, 0), stance: ScenarioStance.Hostile, piloted: true);
|
||||
stage.Place(stage.Generated("Longinus"), float2(400, 0), piloted: true);
|
||||
stage.Place(stage.Bare("No Such Hull"), float2(-400, 0));
|
||||
}, failures);
|
||||
|
||||
|
|
@ -449,26 +486,6 @@ public sealed partial class RunStartTests
|
|||
SafeAssert.Unchanged(zone, entities, agents);
|
||||
}
|
||||
|
||||
// A summon needs the player to be in the zone it summons into: with the player docked it refuses, names why and admits nothing.
|
||||
// Kills: dropping the membership check, which would write stance onto a non-member.
|
||||
[Fact]
|
||||
public void ASummonNeedsThePlayerInTheZone()
|
||||
{
|
||||
var zone = Arena(true);
|
||||
var player = Stage(zone, new Scripted(true, stage => stage.Player(stage.Bare("Djinni"), float2(0, 0)))).Player;
|
||||
Assert.True(zone.Remove(player));
|
||||
var entities = zone.Entities.ToList();
|
||||
var agents = zone.Agents.ToList();
|
||||
var failures = new List<string>();
|
||||
|
||||
var summoned = ZoneStage.Summon(_items, zone, player, stage =>
|
||||
stage.Place(stage.Bare("Longinus"), float2(400, 0), stance: ScenarioStance.Hostile), failures);
|
||||
|
||||
Assert.Null(summoned);
|
||||
Assert.Equal(new[] { "summon: the player is not in this zone" }, failures);
|
||||
SafeAssert.Unchanged(zone, entities, agents);
|
||||
}
|
||||
|
||||
// A refused summon leaves the item stream and the lot ledger (which a run save persists) where they were, so a refusal is neither
|
||||
// a draw nor a mint. Kills: a summon that keeps the draws or the lots of the fits it built before refusing.
|
||||
[Fact]
|
||||
|
|
@ -481,7 +498,7 @@ public sealed partial class RunStartTests
|
|||
var lots = _items.Lots.Lots.Keys.ToList();
|
||||
var failures = new List<string>();
|
||||
|
||||
Assert.Null(ZoneStage.Summon(_items, zone, player, stage =>
|
||||
Assert.Null(ZoneStage.Summon(_items, zone, stage =>
|
||||
{
|
||||
stage.Place(stage.Generated("Longinus"), float2(400, 0));
|
||||
stage.Place(stage.Bare("No Such Hull"), float2(-400, 0));
|
||||
|
|
@ -493,23 +510,6 @@ public sealed partial class RunStartTests
|
|||
Assert.Equal(lots.OrderBy(id => id), _items.Lots.Lots.Keys.OrderBy(id => id));
|
||||
}
|
||||
|
||||
// The anchor of a summon is the player's ship, not any ship in the zone. Kills: a summon that takes any zone member as the player.
|
||||
[Fact]
|
||||
public void ASummonNeedsThePlayersShipAsItsAnchor()
|
||||
{
|
||||
var zone = Arena(true);
|
||||
var player = Stage(zone, new Scripted(true, stage => stage.Player(stage.Bare("Djinni"), float2(0, 0)))).Player;
|
||||
var other = zone.Entities.OfType<Ship>().First(ship => !ship.IsPlayerShip);
|
||||
var entities = zone.Entities.ToList();
|
||||
var agents = zone.Agents.ToList();
|
||||
var failures = new List<string>();
|
||||
|
||||
Assert.Null(ZoneStage.Summon(_items, zone, other, stage => stage.Place(stage.Bare("Longinus"), float2(400, 0), stance: ScenarioStance.Hostile), failures));
|
||||
|
||||
Assert.Equal(new[] { "summon: the anchor is not the player's ship" }, failures);
|
||||
SafeAssert.Unchanged(zone, entities, agents);
|
||||
}
|
||||
|
||||
// A faction's boss is the zone generator's to place (boss-hulls-exclusive): a preset naming the loadout Loadouts.BossOf
|
||||
// returns is refused, through a summon as through a run start. Kills: a Preset that places any catalog loadout.
|
||||
[Fact]
|
||||
|
|
@ -522,8 +522,8 @@ public sealed partial class RunStartTests
|
|||
var agents = zone.Agents.ToList();
|
||||
var failures = new List<string>();
|
||||
|
||||
Assert.Null(ZoneStage.Summon(_items, zone, player, stage =>
|
||||
stage.Place(stage.Preset(boss.Name), float2(400, 0), stance: ScenarioStance.Hostile, piloted: true), failures));
|
||||
Assert.Null(ZoneStage.Summon(_items, zone, stage =>
|
||||
stage.Place(stage.Preset(boss.Name), float2(400, 0), piloted: true), failures));
|
||||
|
||||
Assert.Contains(failures, failure => failure.Contains(boss.Name) && failure.Contains("boss"));
|
||||
SafeAssert.Unchanged(zone, entities, agents);
|
||||
|
|
|
|||
Loading…
Reference in a new issue