
include("SharedFunctions.lua")




local bBesisgeQiRun = false

function BesisgeQi(iOldOwner, bIsCapital, iX, iY, iNewOwner, iPop,bConquest)
if bBesisgeQiRun == true then
	print("攻齐之战已经发生过")
	return
end
if not Players[iOldOwner]:IsMinorCiv() or bConquest==false or Players[iNewOwner]:IsMinorCiv() then
print("不是从城邦手里夺来")
return
end
if (iX ~=30) or (iY ~=27)then
	return
	else
	print("宋亡")
end

local playerQi = Players[iNewOwner]
local iTeam = playerQi:GetTeam()
for _, pPlayer in pairs(Players) do
if (pPlayer:IsAlive()) and (not pPlayer:IsHuman()) and (not pPlayer:IsMinorCiv()) and (not pPlayer:IsBarbarian()) and (not ( pPlayer == playerQi)) then
	if (EvaluePower(pPlayer))>0.06 then
		local pTeam = Teams[pPlayer:GetTeam()]
			if  not pTeam:IsAtWar(iTeam) then
			pTeam:DeclareWar(iTeam)
			end
		end
	else
		print("无力动手")
	end
	if pPlayer:IsHuman() then
		local splayerName = GetPlayerName(playerQi)
		local heading = Locale.ConvertTextKey("TXT_KEY_NOTIFICATION_BESIEGE_SHORT")
		local text = Locale.ConvertTextKey("TXT_KEY_NOTIFICATION_BESIEGE",splayerName)
		pPlayer:AddNotification(NotificationTypes.NOTIFICATION_GENERIC ,text,heading,iX,iY)
	end
end

	bBesisgeQiRun = true
end

GameEvents.CityCaptureComplete.Add(BesisgeQi)
-----Reference resources:   GameEvents.CityCaptureComplete(iOldOwner--playerID, bIsCapital, iX, iY--City, iNewOwner, iPop, bConquest)
