更新主城信息查询

This commit is contained in:
milimoe 2025-06-26 01:29:11 +08:00
parent e62efbef32
commit f9821a71cf
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
2 changed files with 62 additions and 1 deletions

View File

@ -5130,6 +5130,50 @@ namespace Oshima.FunGame.WebAPI.Controllers
return regions;
}
[HttpGet("getplayerregion")]
public List<string> GetPlayerRegion([FromQuery] int? index = null, bool showDokyoDetail = true)
{
List<string> regions = [];
if (index != null)
{
if (FunGameConstant.PlayerRegions.FirstOrDefault(kv => kv.Id == index) is OshimaRegion region)
{
regions.Add(region.ToString());
}
else
{
regions.Add($"找不到指定编号的地区!");
}
}
else if (FunGameConstant.PlayerRegions.Count > 0)
{
regions.Add($"铎京城及周边地区地图:");
List<OshimaRegion> regionList = [.. FunGameConstant.PlayerRegions];
if (showDokyoDetail)
{
OshimaRegion dokyo = regionList.First();
regionList.Remove(dokyo);
regions.Add(dokyo.ToString());
}
for (int i = 0; i < regionList.Count; i++)
{
OshimaRegion region = regionList[i];
List<Item> crops = [];
if (FunGameConstant.ExploreItems.TryGetValue(region, out List<Item>? list) && list != null)
{
crops = list;
}
regions.Add($"{region.Id}. {region.Name}" + (crops.Count > 0 ? "(作物:" + string.Join("", crops.Select(i => i.Name)) + "" : ""));
}
regions.Add($"提示:使用【查地区+序号】指令来查看指定地区的信息。");
}
else
{
regions.Add($"铎京城及周边地区的地图遇到了问题,暂时无法显示……");
}
return regions;
}
[HttpPost("exploreregion")]
public string ExploreRegion([FromQuery] long? uid = null, [FromQuery] long? id = null)
{

View File

@ -2031,9 +2031,16 @@ namespace Oshima.FunGame.WebAPI.Services
string detail = e.Detail.Replace("查地区", "").Replace("查询地区", "").Trim();
List<string> msgs = [];
if (int.TryParse(detail, out int cid))
{
if (cid > 0 && cid <= 12)
{
msgs = Controller.GetRegion(cid);
}
else if (cid == 0 || cid > 12)
{
msgs = Controller.GetPlayerRegion(cid);
}
}
else
{
msgs = Controller.GetRegion();
@ -2045,6 +2052,16 @@ namespace Oshima.FunGame.WebAPI.Services
return result;
}
if (e.Detail == "主城" || e.Detail == "铎京")
{
List<string> msgs = Controller.GetPlayerRegion();
if (msgs.Count > 0)
{
await SendAsync(e, "铎京", string.Join("\r\n", msgs));
}
return result;
}
if (e.Detail == "世界地图")
{
List<string> msgs = Controller.GetRegion();