102 lines
4.2 KiB
C#
102 lines
4.2 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace TKS.OutGame
|
|
{
|
|
/// <summary>
|
|
/// 내정 영웅 파견(PD 2026-11-12 「훈련에 사용할 영웅을 지정(파견) · 병종 별 지휘관 1명」 · 「순찰에도 영웅을 파견」 · 「개발 메뉴에도 영웅을 배치」) —
|
|
/// 자리 = 훈련 병종마다 1(그 병종 영웅만) · 순찰 1 · 개발 1. 한 영웅은 한 자리에만(다른 자리에 있으면 옮김). **장면 표시만 · 능력치 효과 없음**(기획 미정).
|
|
/// </summary>
|
|
public static class DispatchRules
|
|
{
|
|
public const string Patrol = "patrol";
|
|
public const string Dev = "dev";
|
|
|
|
/// <summary>자리 키 = 「train:<병종 키>」 · 「patrol」 · 「dev」.</summary>
|
|
public static string TrainSlot(UnitType t)
|
|
{
|
|
return "train:" + UnitTypeInfo.Key(t);
|
|
}
|
|
|
|
public static string Get(SaveData d, string slot)
|
|
{
|
|
if (slot == Patrol) return d.patrol.hero ?? "";
|
|
if (slot == Dev) return d.dev.hero ?? "";
|
|
foreach (var s in d.training)
|
|
if (slot == "train:" + s.type) return s.commander ?? "";
|
|
return "";
|
|
}
|
|
|
|
static void Set(SaveData d, string slot, string id)
|
|
{
|
|
if (slot == Patrol) d.patrol.hero = id;
|
|
else if (slot == Dev) d.dev.hero = id;
|
|
else if (slot.StartsWith("train:"))
|
|
{
|
|
string key = slot.Substring(6);
|
|
foreach (UnitType t in System.Enum.GetValues(typeof(UnitType)))
|
|
if (UnitTypeInfo.Key(t) == key)
|
|
{
|
|
d.Train(t).commander = id;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>그 영웅이 파견된 자리(없으면 null).</summary>
|
|
public static string Where(SaveData d, string heroId)
|
|
{
|
|
if (string.IsNullOrEmpty(heroId)) return null;
|
|
if (d.patrol.hero == heroId) return Patrol;
|
|
if (d.dev.hero == heroId) return Dev;
|
|
foreach (var s in d.training)
|
|
if (s.commander == heroId) return "train:" + s.type;
|
|
return null;
|
|
}
|
|
|
|
public static string SlotKo(string slot)
|
|
{
|
|
if (slot == Patrol) return "순찰";
|
|
if (slot == Dev) return "개발";
|
|
if (slot != null && slot.StartsWith("train:"))
|
|
foreach (UnitType t in System.Enum.GetValues(typeof(UnitType)))
|
|
if ("train:" + UnitTypeInfo.Key(t) == slot) return UnitTypeInfo.Korean(t) + " 훈련";
|
|
return "";
|
|
}
|
|
|
|
/// <summary>그 자리에 보낼 수 있는 보유 영웅(병사 제외 · 훈련 = 그 병종만) — 보유 순서.</summary>
|
|
public static List<HeroDb.Hero> Candidates(OutGameData db, SaveData d, string slot)
|
|
{
|
|
var list = new List<HeroDb.Hero>();
|
|
string key = slot != null && slot.StartsWith("train:") ? slot.Substring(6) : null;
|
|
foreach (var hs in d.heroes)
|
|
{
|
|
var h = db.Heroes.Get(hs.id);
|
|
if (h == null || h.isSoldier) continue;
|
|
if (key != null && UnitTypeInfo.Key(h.type) != key) continue;
|
|
list.Add(h);
|
|
}
|
|
return list;
|
|
}
|
|
|
|
/// <summary>파견(null = 성공 · 아니면 사유) — 다른 자리에 있던 영웅이면 그 자리를 비우고 옮긴다.</summary>
|
|
public static string Assign(OutGameData db, SaveData d, string slot, string heroId)
|
|
{
|
|
var h = db.Heroes.Get(heroId);
|
|
if (h == null || !d.Owns(heroId)) return "보유하지 않은 영웅입니다";
|
|
if (h.isSoldier) return "영웅만 파견할 수 있습니다";
|
|
if (slot.StartsWith("train:") && UnitTypeInfo.Key(h.type) != slot.Substring(6)) return "그 병종 영웅만 지휘관이 될 수 있습니다";
|
|
var from = Where(d, heroId);
|
|
if (from == slot) return null;
|
|
if (from != null) Set(d, from, "");
|
|
Set(d, slot, heroId);
|
|
return null;
|
|
}
|
|
|
|
public static string Clear(SaveData d, string slot)
|
|
{
|
|
Set(d, slot, "");
|
|
return null;
|
|
}
|
|
}
|
|
}
|