修复阿空bug

This commit is contained in:
daixiawu 2026-05-10 17:57:28 +08:00
parent 0b0c5cca2d
commit 18ed27b829
3 changed files with 41 additions and 22 deletions

View File

@ -1023,6 +1023,25 @@ namespace RuntimeData
// 投降
public void Surrender(MapData map)
{
// 退出前解除所有盟友/刚背盟关系League / LeagueRupture → Neutral
// LeagueRupture 自动转 Neutral 依赖双方都跑 OnTurnEnd 标 IsLeagueRupture投降后该标记永远凑不齐 → 必须主动清
foreach (var otherPlayer in map.PlayerMap.PlayerDataList)
{
if (otherPlayer.Id == Id) continue;
if (!this.GetCountryDiplomacyInfo(otherPlayer.Id, out var selfToOther)) continue;
if (selfToOther.DiplomacyState != DiplomacyState.League
&& selfToOther.DiplomacyState != DiplomacyState.LeagueRupture) continue;
Main.PlayerLogic.SetDiplomacyLeague(map, this, otherPlayer, DiplomacyState.Neutral);
selfToOther.IsEmbassy = false;
selfToOther.IsLeagueRupture = false;
if (otherPlayer.GetCountryDiplomacyInfo(Id, out var otherToSelf))
{
otherToSelf.IsEmbassy = false;
otherToSelf.IsLeagueRupture = false;
}
}
IsSurrender = true;
using var pooledSelfUnits = THCollectionPool.GetHashSetHandle<UnitData>(out var selfUnits);
map.GetUnitDataListByPlayerId(Id, selfUnits);

View File

@ -37,10 +37,10 @@ namespace Logic.Skill
// ========== ReadyMove 冲锋完整逻辑 ==========
//
// Step 1 - 确定终点:
// 沿路径从path[1]开始扫描,找到第一个非自身单位
// - 盟友/背盟 → 终点 = 该单位的前一格 (path[i-1])
// - 敌方 → 终点 = 该敌方所在格 (path[i]),标记 hasEnemyAtEnd
// - 没有遇到任何单位 → 终点 = 路径末尾
// 沿路径从path[1]开始扫描,找到第一个挡路目标
// - 盟友/背盟单位 或 盟友/背盟城市中心格 → 终点 = 该格前一格 (按盟友挡路处理)
// - 敌方单位 → 终点 = 该敌方所在格 (path[i]),标记 hasEnemyAtEnd
// - 没有遇到任何挡路目标 → 终点 = 路径末尾
// 截断路径为 path[0..endIndex]
//
// Step 2 - 溅射伤害:
@ -85,21 +85,16 @@ namespace Logic.Skill
for (int i = 1; i < path.Count; i++)
{
if (!mapData.GridMap.GetGridDataByV2(path[i], out var grid)) continue;
if (!grid.RealUnit(mapData, out var unit)) continue;
if (unit.Id == selfUnit.Id) continue;
if (mapData.IsLeagueOrJustBreakByUnit(selfUnit.Id, unit.Id))
{
// 盟友/背盟:终点在该单位前一格
endIndex = i ;
hasAllyAtEnd = true;
}
else
{
// 敌方:终点在敌方所在格
endIndex = i;
hasEnemyAtEnd = true;
}
// 盟友/刚背盟的城心即使无驻军也算挡路,否则终点落在城心会触发自动宣战
bool isLeagueCity = mapData.IsLeagueOrJustBreakCityCenter(selfUnit.Id, grid);
bool hasOtherUnit = grid.RealUnit(mapData, out var unit) && unit.Id != selfUnit.Id;
if (!hasOtherUnit && !isLeagueCity) continue;
bool isAlly = isLeagueCity || (hasOtherUnit && mapData.IsLeagueOrJustBreakByUnit(selfUnit.Id, unit.Id));
endIndex = i;
if (isAlly) hasAllyAtEnd = true;
else hasEnemyAtEnd = true;
break;
}
// 截断路径到 [0..endIndex]

View File

@ -46,8 +46,8 @@ namespace Logic.Skill
// 对整条路径上的所有敌方单位每个造成一次常规DelayAttack伤害
//
// Step 4 - 终点回退:
// 从终点开始往回检查:如果该格有单位且不是BonePile,终点回退一格并追加到路径
// 重复直到终点为空 或 终点上是BonePile
// 从终点开始往回检查:如果该格有非BonePile单位 或 是盟友/背盟城市中心,终点回退一格并追加到路径
// 重复直到终点为"格且非盟友城心" 或 终点上是BonePile
//
// Step 5 - 处理终点占位:
// 如果终点有单位此时一定是BonePilePassiveMoveAway
@ -130,8 +130,13 @@ namespace Logic.Skill
while (realEndIndex > 0)
{
if (!mapData.GridMap.GetGridDataByV2(path[realEndIndex], out var checkGrid)) break;
if (!checkGrid.RealUnit(mapData, out var occupant)) break;
if (occupant.UnitFullType.UnitType == UnitType.BonePile) break;
// 盟友/刚背盟的城心即使无驻军也算不能停留,否则终点落在城心会触发自动宣战
bool isLeagueCity = mapData.IsLeagueOrJustBreakCityCenter(selfUnit.Id, checkGrid);
bool hasOccupant = checkGrid.RealUnit(mapData, out var occupant);
if (!hasOccupant && !isLeagueCity) break;
if (hasOccupant && occupant.UnitFullType.UnitType == UnitType.BonePile) break;
realEndIndex--;
path.Add(path[realEndIndex]);
}