胜利条件添加队友
This commit is contained in:
parent
d51777bdbe
commit
e77831bdc3
@ -1926,7 +1926,7 @@ namespace RuntimeData
|
||||
{
|
||||
foreach (var player in PlayerMap.PlayerDataList)
|
||||
{
|
||||
if (MatchSettlement.IsWin(player.Id)) return player;
|
||||
if (MatchSettlement.IsWin(this, player.Id)) return player;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -1935,7 +1935,7 @@ namespace RuntimeData
|
||||
// 游戏是否结束
|
||||
public bool CheckIfGameEnd(out bool isWin)
|
||||
{
|
||||
isWin = MatchSettlement.IsWin(PlayerMap.SelfPlayerId);
|
||||
isWin = MatchSettlement.IsWin(this, PlayerMap.SelfPlayerId);
|
||||
return MatchSettlement.IsFinished;
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ using Logic.CrashSight;
|
||||
using MemoryPack;
|
||||
using RuntimeData;
|
||||
using TH1_Logic.Collect;
|
||||
using TH1_Logic.Core;
|
||||
|
||||
|
||||
namespace TH1_Logic.MatchConfig
|
||||
@ -54,11 +55,31 @@ namespace TH1_Logic.MatchConfig
|
||||
}
|
||||
|
||||
public bool IsWin(uint id)
|
||||
{
|
||||
return IsWin(Main.MapData, id);
|
||||
}
|
||||
|
||||
public bool IsWin(MapData map, uint id)
|
||||
{
|
||||
if (!IsFinished) return false;
|
||||
var settlementGroup = PlayerSettlements.GetValueOrDefault(id);
|
||||
if (settlementGroup == null) return false;
|
||||
return settlementGroup.IsWin;
|
||||
if (settlementGroup != null && settlementGroup.IsWin) return true;
|
||||
|
||||
if (map == null) return false;
|
||||
if (!map.PlayerMap.GetPlayerDataByPlayerID(id, out var selfPlayer)) return false;
|
||||
|
||||
foreach (var kv in PlayerSettlements)
|
||||
{
|
||||
if (kv.Key == id) continue;
|
||||
if (kv.Value == null || !kv.Value.IsWin) continue;
|
||||
if (!map.PlayerMap.GetPlayerDataByPlayerID(kv.Key, out var teammatePlayer)) continue;
|
||||
if (!selfPlayer.GetCountryDiplomacyInfo(teammatePlayer.Id, out var selfToTeammateDip)) continue;
|
||||
if (!teammatePlayer.GetCountryDiplomacyInfo(selfPlayer.Id, out var teammateToSelfDip)) continue;
|
||||
if (!selfToTeammateDip.IsTeammate && !teammateToSelfDip.IsTeammate) continue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public MatchSettlementInfo(MatchSettlementInfo copyData)
|
||||
@ -278,4 +299,4 @@ namespace TH1_Logic.MatchConfig
|
||||
info.IsFinished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user