refactor: merge land command Before/After into shared phase-aware dispatch

This commit is contained in:
2026-07-18 11:46:32 +02:00
parent fffc046126
commit de2026d239
4 changed files with 108 additions and 80 deletions
+8 -8
View File
@@ -68,35 +68,35 @@ public class ClaimLinkRegistry
Save();
}
public bool IsClaimLinked(string ownerPlayerUid, int localIndex) =>
FindLinkContaining(ownerPlayerUid, localIndex) != null;
public bool IsClaimLinked(string ownerPlayerUid, int claimIndex) =>
FindLinkContaining(ownerPlayerUid, claimIndex) != null;
public ClaimLink? FindLinkContaining(string ownerPlayerUid, int localIndex)
public ClaimLink? FindLinkContaining(string ownerPlayerUid, int claimIndex)
{
if (!byPlayer.TryGetValue(ownerPlayerUid, out Dictionary<int, List<int>>? perGroup))
return null;
foreach (KeyValuePair<int, List<int>> entry in perGroup)
if (entry.Value.Contains(localIndex))
if (entry.Value.Contains(claimIndex))
return Get(entry.Key);
return null;
}
public void AddEntry(string ownerPlayerUid, int groupId, int localClaimIndex)
public void AddEntry(string ownerPlayerUid, int groupId, int claimIndex)
{
GetOrCreateIndices(ownerPlayerUid, groupId).Add(localClaimIndex);
GetOrCreateIndices(ownerPlayerUid, groupId).Add(claimIndex);
Save();
}
public void RemoveEntry(string ownerPlayerUid, int groupId, int localClaimIndex)
public void RemoveEntry(string ownerPlayerUid, int groupId, int claimIndex)
{
if (
byPlayer.TryGetValue(ownerPlayerUid, out Dictionary<int, List<int>>? perGroup)
&& perGroup.TryGetValue(groupId, out List<int>? indices)
)
{
indices.Remove(localClaimIndex);
indices.Remove(claimIndex);
if (indices.Count == 0)
perGroup.Remove(groupId);