Combat tracker: multiple named encounters
- Encounter entity; Combatant now belongs to an encounter (ON DELETE
CASCADE). Migration adds encounter_id, rehoming any existing combatants.
- /tracker lists encounters (name, count, last updated) with a "New
encounter" form; /tracker/{id} is the HP tracker for one encounter.
- Encounters can be renamed, have their combatants cleared, or be deleted.
- The Enemies list gains an encounter picker next to "Add to tracker"
(existing encounter or "— New encounter —", which prompts for a name);
an encounter's "Add enemies" link pre-selects it via ?encounter=.
- Routes for combatant HP/remove moved under /tracker/combatant/ to keep
the numeric {id} for encounters.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,10 @@ class Combatant
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Encounter::class, inversedBy: 'combatants')]
|
||||
#[ORM\JoinColumn(name: 'encounter_id', nullable: false, onDelete: 'CASCADE')]
|
||||
private ?Encounter $encounter = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Enemy::class)]
|
||||
#[ORM\JoinColumn(name: 'enemy_id', onDelete: 'SET NULL', nullable: true)]
|
||||
private ?Enemy $enemy = null;
|
||||
@@ -73,6 +77,18 @@ class Combatant
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEncounter(): ?Encounter
|
||||
{
|
||||
return $this->encounter;
|
||||
}
|
||||
|
||||
public function setEncounter(?Encounter $encounter): static
|
||||
{
|
||||
$this->encounter = $encounter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEnemy(): ?Enemy
|
||||
{
|
||||
return $this->enemy;
|
||||
|
||||
Reference in New Issue
Block a user