CvDiplomacy.py 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. ## Sid Meier's Civilization 4
  2. ## Copyright Firaxis Games 2005
  3. from CvPythonExtensions import *
  4. import CvUtil
  5. import PyHelpers
  6. PyPlayer = PyHelpers.PyPlayer
  7. DebugLogging = False
  8. gc = CyGlobalContext()
  9. class CvDiplomacy:
  10. "Code used by Civ Diplomacy interface"
  11. def __init__(self):
  12. "constructor - set up class vars, AI and User strings"
  13. if DebugLogging:
  14. print "Launching Diplomacy"
  15. self.iLastResponseID = -1
  16. self.diploScreen = CyDiplomacy()
  17. def setDebugLogging(self, bDebugLogging):
  18. global DebugLogging
  19. DebugLogging = bDebugLogging
  20. def determineResponses (self, eComment):
  21. "Will determine the user responses given an AI comment"
  22. if DebugLogging:
  23. print "CvDiplomacy.determineResponses: %s" %(eComment,)
  24. # Eliminate previous comments
  25. self.diploScreen.clearUserComments()
  26. # If the AI is declaring war
  27. if (self.isComment(eComment, "AI_DIPLOCOMMENT_DECLARE_WAR") ):
  28. # We respond to their declaration
  29. self.addUserComment("USER_DIPLOCOMMENT_WAR_RESPONSE", -1, -1)
  30. self.diploScreen.endTrade()
  31. # If this is the first time we are being contacted by the AI
  32. # Or if the AI is no longer a vassal
  33. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_FIRST_CONTACT") or self.isComment(eComment, "AI_DIPLOCOMMENT_NO_VASSAL")):
  34. # if you are on different teams and NOT at war, give the user the option to declare war
  35. if (gc.getTeam(gc.getGame().getActiveTeam()).canDeclareWar(gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam())):
  36. self.addUserComment("USER_DIPLOCOMMENT_WAR", -1, -1)
  37. # We say hi and begin our peace
  38. self.addUserComment("USER_DIPLOCOMMENT_PEACE", -1, -1)
  39. self.diploScreen.endTrade()
  40. # The AI refuses to talk
  41. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_REFUSE_TO_TALK") ):
  42. # Give the option to exit
  43. self.addUserComment("USER_DIPLOCOMMENT_EXIT", -1, -1)
  44. self.diploScreen.endTrade();
  45. # If the AI is offering a city oo
  46. # If the AI is giving help
  47. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_OFFER_CITY") or
  48. self.isComment(eComment, "AI_DIPLOCOMMENT_GIVE_HELP")):
  49. # We can accept their offer
  50. self.addUserComment("USER_DIPLOCOMMENT_ACCEPT_OFFER", -1, -1)
  51. # Or reject it...
  52. self.addUserComment("USER_DIPLOCOMMENT_REJECT_OFFER", -1, -1)
  53. # If the AI is offering a deal
  54. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_OFFER_PEACE") or
  55. self.isComment(eComment, "AI_DIPLOCOMMENT_OFFER_DEAL") or
  56. self.isComment(eComment, "AI_DIPLOCOMMENT_OFFER_VASSAL")):
  57. # We can accept their offer
  58. self.addUserComment("USER_DIPLOCOMMENT_ACCEPT_OFFER", -1, -1)
  59. # Or we can try to negotiate
  60. self.addUserComment("USER_DIPLOCOMMENT_RENEGOTIATE", -1, -1)
  61. # Or reject it...
  62. self.addUserComment("USER_DIPLOCOMMENT_REJECT_OFFER", -1, -1)
  63. # If the AI is cancelling a deal
  64. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_CANCEL_DEAL")):
  65. # We can try to renegotiate
  66. self.addUserComment("USER_DIPLOCOMMENT_RENEGOTIATE", -1, -1)
  67. # Or just exit...
  68. self.addUserComment("USER_DIPLOCOMMENT_NO_RENEGOTIATE", -1, -1)
  69. # If the AI is demanding tribute
  70. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_ASK_FOR_HELP")):
  71. # We can give them help
  72. self.addUserComment("USER_DIPLOCOMMENT_GIVE_HELP", -1, -1)
  73. # Or refuse...
  74. self.addUserComment("USER_DIPLOCOMMENT_REFUSE_HELP", -1, -1)
  75. # If the AI is demanding tribute
  76. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_DEMAND_TRIBUTE")):
  77. # We can accept their demands
  78. self.addUserComment("USER_DIPLOCOMMENT_ACCEPT_DEMAND", -1, -1)
  79. # Or reject them...
  80. self.addUserComment("USER_DIPLOCOMMENT_REJECT_DEMAND", -1, -1)
  81. # If the AI is pressuring us to convert to their religion
  82. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_RELIGION_PRESSURE")):
  83. # We can accept their demands
  84. self.addUserComment("USER_DIPLOCOMMENT_CONVERT", -1, -1)
  85. # Or reject them...
  86. self.addUserComment("USER_DIPLOCOMMENT_NO_CONVERT", -1, -1)
  87. # If the AI is pressuring us to switch to their favorite civic
  88. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_CIVIC_PRESSURE")):
  89. # We can accept their demands
  90. self.addUserComment("USER_DIPLOCOMMENT_REVOLUTION", -1, -1)
  91. # Or reject them...
  92. self.addUserComment("USER_DIPLOCOMMENT_NO_REVOLUTION", -1, -1)
  93. # If the AI is pressuring us to join their war
  94. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_JOIN_WAR")):
  95. # We can accept their demands
  96. self.addUserComment("USER_DIPLOCOMMENT_JOIN_WAR", -1, -1)
  97. # Or reject them...
  98. self.addUserComment("USER_DIPLOCOMMENT_NO_JOIN_WAR", -1, -1)
  99. # If the AI is pressuring us to stop trading with their enemy
  100. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_STOP_TRADING")):
  101. # We can accept their demands
  102. self.addUserComment("USER_DIPLOCOMMENT_STOP_TRADING", -1, -1)
  103. # Or reject them...
  104. self.addUserComment("USER_DIPLOCOMMENT_NO_STOP_TRADING", -1, -1)
  105. #Afforess Advanced Diplomacy Start
  106. #If the AI is pressuring us to end a war with their friend
  107. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_MAKE_PEACE_WITH")):
  108. #We can accept their demands
  109. self.addUserComment("USER_DIPLOCOMMENT_MAKE_PEACE_WITH", -1, -1)
  110. #Or reject them...
  111. self.addUserComment("USER_DIPLOCOMMENT_NO_MAKE_PEACE_WITH", -1, -1)
  112. #Afforess Advanced Diplomacy End
  113. # If we are viewing our current deals or
  114. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_CURRENT_DEALS")):
  115. # Exit option
  116. self.addUserComment("USER_DIPLOCOMMENT_NEVERMIND", -1, -1)
  117. self.addUserComment("USER_DIPLOCOMMENT_EXIT", -1, -1)
  118. self.diploScreen.startTrade( eComment, true)
  119. # If we are trading or
  120. # If we are trying another proposal or
  121. # If they reject our offer or
  122. # If they reject our demand
  123. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_TRADING") or
  124. self.isComment(eComment, "AI_DIPLOCOMMENT_REJECT") or
  125. self.isComment(eComment, "AI_DIPLOCOMMENT_SORRY") or
  126. self.isComment(eComment, "AI_DIPLOCOMMENT_TRY_THIS_DEAL") or
  127. self.isComment(eComment, "AI_DIPLOCOMMENT_NO_DEAL") or
  128. self.isComment(eComment, "AI_DIPLOCOMMENT_REJECT_ASK") or
  129. self.isComment(eComment, "AI_DIPLOCOMMENT_REJECT_DEMAND")):
  130. # If no one is currently offering anything
  131. if (self.diploScreen.ourOfferEmpty() == 1 and self.diploScreen.theirOfferEmpty() == 1):
  132. # If we are at war, allow us to suggest a peace treaty
  133. if (self.diploScreen.atWar()):
  134. self.addUserComment("USER_DIPLOCOMMENT_PROPOSE", -1, -1)
  135. self.addUserComment("USER_DIPLOCOMMENT_OFFER_PEACE", -1, -1)
  136. # If one of us has something on the table
  137. if (self.diploScreen.ourOfferEmpty() == 0 or self.diploScreen.theirOfferEmpty() == 0):
  138. # If the offer is from the AI
  139. if (self.diploScreen.isAIOffer()):
  140. # We can accept or reject the offer
  141. self.addUserComment("USER_DIPLOCOMMENT_ACCEPT", -1, -1)
  142. self.addUserComment("USER_DIPLOCOMMENT_REJECT", -1, -1)
  143. # Otherwise this is a player offer to the AI
  144. else:
  145. # This is a two way deal
  146. if (self.diploScreen.ourOfferEmpty() == 0 and self.diploScreen.theirOfferEmpty() == 0):
  147. # Insert the propose trade button
  148. self.addUserComment("USER_DIPLOCOMMENT_PROPOSE", -1, -1)
  149. # During peace, see what we can get for these items
  150. if (not self.diploScreen.atWar()):
  151. if (gc.getGame().getActiveTeam() != gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam()):
  152. self.addUserComment("USER_DIPLOCOMMENT_COMPLETE_DEAL", -1, -1)
  153. # Otherwise they have something on the table and we dont
  154. elif (self.diploScreen.theirOfferEmpty() == 0):
  155. # If we are at war, demand the items for peace or ask what they want
  156. if (self.diploScreen.atWar()):
  157. self.addUserComment("USER_DIPLOCOMMENT_PROPOSE", -1, -1)
  158. # Otherwise (during peacetime) ask what they want for our item or demand they give it to us
  159. else:
  160. if (gc.getGame().getActiveTeam() == gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam()):
  161. self.addUserComment("USER_DIPLOCOMMENT_DEMAND_TEAM", -1, -1)
  162. else:
  163. self.addUserComment("USER_DIPLOCOMMENT_OFFER", -1, -1)
  164. if (gc.getTeam(gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam()).isVassal(gc.getGame().getActiveTeam()) and self.diploScreen.theirVassalTribute()):
  165. self.addUserComment("USER_DIPLOCOMMENT_VASSAL_TRIBUTE", -1, -1)
  166. elif (gc.getPlayer(self.diploScreen.getWhoTradingWith()).AI_getAttitude(gc.getGame().getActivePlayer()) >= AttitudeTypes.ATTITUDE_PLEASED):
  167. self.addUserComment("USER_DIPLOCOMMENT_ASK", -1, -1)
  168. elif (gc.getTeam(gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam()).isVassal(gc.getGame().getActiveTeam()) or gc.getTeam(gc.getGame().getActiveTeam()).canDeclareWar(gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam())):
  169. self.addUserComment("USER_DIPLOCOMMENT_DEMAND", -1, -1)
  170. # Otherwise we have something on the table and they dont
  171. else:
  172. # If we are at war, use this item to fish for peace or propose peace with the items
  173. if (self.diploScreen.atWar()):
  174. self.addUserComment("USER_DIPLOCOMMENT_PROPOSE", -1, -1)
  175. # During peace, see what we can get for these items or simply gift them to the AI
  176. else:
  177. if (gc.getGame().getActiveTeam() != gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam()):
  178. self.addUserComment("USER_DIPLOCOMMENT_FISH_FOR_DEAL", -1, -1)
  179. self.addUserComment("USER_DIPLOCOMMENT_GIFT", -1, -1)
  180. # Exit option
  181. self.addUserComment("USER_DIPLOCOMMENT_NEVERMIND", -1, -1)
  182. self.addUserComment("USER_DIPLOCOMMENT_EXIT", -1, -1)
  183. self.diploScreen.startTrade( eComment, false )
  184. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_SOMETHING_ELSE")):
  185. if (gc.getTeam(gc.getGame().getActiveTeam()).canDeclareWar(gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam())):
  186. self.addUserComment("USER_DIPLOCOMMENT_WAR", -1, -1)
  187. self.addUserComment("USER_DIPLOCOMMENT_ATTITUDE", -1, -1)
  188. if (gc.getGame().getActiveTeam() == gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam() or gc.getTeam(gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam()).isVassal(gc.getGame().getActiveTeam())):
  189. self.addUserComment("USER_DIPLOCOMMENT_RESEARCH", -1, -1)
  190. if (gc.getTeam(gc.getGame().getActiveTeam()).AI_shareWar(gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam())):
  191. self.addUserComment("USER_DIPLOCOMMENT_TARGET", -1, -1)
  192. self.addUserComment("USER_DIPLOCOMMENT_NEVERMIND", -1, -1)
  193. self.addUserComment("USER_DIPLOCOMMENT_EXIT", -1, -1)
  194. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_RESEARCH")):
  195. for i in range(gc.getNumTechInfos()):
  196. if (gc.getPlayer(self.diploScreen.getWhoTradingWith()).canResearch(i, False)):
  197. self.addUserComment("USER_DIPLOCOMMENT_RESEARCH_TECH", i, -1, gc.getTechInfo(i).getTextKey())
  198. self.addUserComment("USER_DIPLOCOMMENT_SOMETHING_ELSE", -1, -1)
  199. self.addUserComment("USER_DIPLOCOMMENT_EXIT", -1, -1)
  200. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_ATTITUDE") or
  201. self.isComment(eComment, "AI_DIPLOCOMMENT_ATTITUDE_PLAYER_FURIOUS") or
  202. self.isComment(eComment, "AI_DIPLOCOMMENT_ATTITUDE_PLAYER_ANNOYED") or
  203. self.isComment(eComment, "AI_DIPLOCOMMENT_ATTITUDE_PLAYER_CAUTIOUS") or
  204. self.isComment(eComment, "AI_DIPLOCOMMENT_ATTITUDE_PLAYER_PLEASED") or
  205. self.isComment(eComment, "AI_DIPLOCOMMENT_ATTITUDE_PLAYER_FRIENDLY")):
  206. for i in range(gc.getMAX_CIV_PLAYERS()):
  207. if (gc.getPlayer(i).isAlive()):
  208. if ((i != gc.getGame().getActivePlayer()) and (i != self.diploScreen.getWhoTradingWith())):
  209. if (gc.getTeam(gc.getGame().getActiveTeam()).isHasMet(gc.getPlayer(i).getTeam()) and gc.getTeam(gc.getPlayer(self.diploScreen.getWhoTradingWith()).getTeam()).isHasMet(gc.getPlayer(i).getTeam())):
  210. self.addUserComment("USER_DIPLOCOMMENT_ATTITUDE_PLAYER", i, -1, gc.getPlayer(i).getNameKey())
  211. self.addUserComment("USER_DIPLOCOMMENT_SOMETHING_ELSE", -1, -1)
  212. self.addUserComment("USER_DIPLOCOMMENT_EXIT", -1, -1)
  213. elif (self.isComment(eComment, "AI_DIPLOCOMMENT_TARGET")):
  214. for i in range(gc.getMAX_CIV_PLAYERS()):
  215. if (gc.getPlayer(i).isAlive()):
  216. if (gc.getTeam(gc.getGame().getActiveTeam()).isAtWar(gc.getPlayer(i).getTeam())):
  217. player = PyPlayer(i)
  218. cityList = player.getCityList()
  219. for city in cityList:
  220. if (city.isRevealed(gc.getGame().getActiveTeam())):
  221. self.addUserComment("USER_DIPLOCOMMENT_TARGET_CITY", i, city.getID(), city.getNameKey())
  222. self.addUserComment("USER_DIPLOCOMMENT_SOMETHING_ELSE", -1, -1)
  223. self.addUserComment("USER_DIPLOCOMMENT_EXIT", -1, -1)
  224. # The default...
  225. else:
  226. if (gc.getPlayer(gc.getGame().getActivePlayer()).canTradeWith(self.diploScreen.getWhoTradingWith())):
  227. # Allow us to begin another proposal
  228. self.addUserComment("USER_DIPLOCOMMENT_PROPOSAL", -1, -1)
  229. if (self.isComment(eComment, "AI_DIPLOCOMMENT_GREETINGS") or
  230. self.isComment(eComment, "AI_DIPLOCOMMENT_UNIT_BRAG") or
  231. self.isComment(eComment, "AI_DIPLOCOMMENT_NUKES") or
  232. self.isComment(eComment, "AI_DIPLOCOMMENT_WORST_ENEMY") or
  233. self.isComment(eComment, "AI_DIPLOCOMMENT_WORST_ENEMY_TRADING")):
  234. # If we are at war, allow to suggest peace
  235. if (self.diploScreen.atWar()):
  236. self.addUserComment("USER_DIPLOCOMMENT_SUGGEST_PEACE", -1, -1)
  237. # If we have a current deal, allow us to see the deals
  238. if (self.diploScreen.hasAnnualDeal()):
  239. self.addUserComment("USER_DIPLOCOMMENT_CURRENT_DEALS", -1, -1)
  240. self.addUserComment("USER_DIPLOCOMMENT_SOMETHING_ELSE", -1, -1)
  241. ###############Advanced Diplomacy START###############################
  242. #RevolutionDCM - start new diplomacy option
  243. thePlayerContacted = gc.getPlayer(self.diploScreen.getWhoTradingWith())
  244. if not thePlayerContacted == None and not gc.getGame().isNetworkMultiPlayer():
  245. if not thePlayerContacted.isDoNotBotherStatus(gc.getGame().getActivePlayer()):
  246. self.addUserComment("USER_DO_NOT_BOTHER_US", -1, -1)
  247. else:
  248. self.addUserComment("USER_RESUME_TALKS", -1, -1)
  249. #RevolutionDCM - end
  250. ###############Advanced Diplomacy END ###############################
  251. # Exit potential
  252. self.addUserComment("USER_DIPLOCOMMENT_EXIT", -1, -1)
  253. self.diploScreen.endTrade();
  254. def addUserComment(self, eComment, iData1, iData2, *args):
  255. " Helper for adding User Comments "
  256. iComment = self.getCommentID( eComment )
  257. self.diploScreen.addUserComment( iComment, iData1, iData2, self.getDiplomacyComment(iComment), args)
  258. def setAIComment (self, eComment, *args):
  259. " Handles the determining the AI comments"
  260. AIString = self.getDiplomacyComment(eComment)
  261. if DebugLogging:
  262. print "CvDiplomacy.setAIComment: %s" %(eComment,)
  263. if (len(args)):
  264. print "args", args
  265. AIString = "(%d) - %s" %(self.getLastResponseID(), AIString)
  266. self.diploScreen.setAIString(AIString, args)
  267. self.diploScreen.setAIComment(eComment)
  268. self.determineResponses(eComment)
  269. self.performHeadAction(eComment)
  270. def performHeadAction( self, eComment ):
  271. if ( eComment == self.getCommentID("AI_DIPLOCOMMENT_NO_PEACE") or
  272. eComment == self.getCommentID("AI_DIPLOCOMMENT_REJECT") or
  273. eComment == self.getCommentID("AI_DIPLOCOMMENT_NO_DEAL") or
  274. eComment == self.getCommentID("AI_DIPLOCOMMENT_CANCEL_DEAL") or
  275. eComment == self.getCommentID("AI_DIPLOCOMMENT_REJECT_ASK") or
  276. eComment == self.getCommentID("AI_DIPLOCOMMENT_REJECT_DEMAND") ):
  277. self.diploScreen.performHeadAction( LeaderheadAction.LEADERANIM_DISAGREE )
  278. elif ( eComment == self.getCommentID("AI_DIPLOCOMMENT_ACCEPT") or
  279. eComment == self.getCommentID("AI_DIPLOCOMMENT_TRY_THIS_DEAL") ):
  280. self.diploScreen.performHeadAction( LeaderheadAction.LEADERANIM_AGREE )
  281. elif ( eComment == self.getCommentID("AI_DIPLOCOMMENT_FIRST_CONTACT") or
  282. eComment == self.getCommentID("AI_DIPLOCOMMENT_GREETINGS") or
  283. eComment == self.getCommentID("AI_DIPLOCOMMENT_WORST_ENEMY") or
  284. eComment == self.getCommentID("AI_DIPLOCOMMENT_UNIT_BRAG") or
  285. eComment == self.getCommentID("AI_DIPLOCOMMENT_NUKES") or
  286. eComment == self.getCommentID("AI_DIPLOCOMMENT_OFFER_PEACE") or
  287. eComment == self.getCommentID("AI_DIPLOCOMMENT_OFFER_VASSAL") or
  288. eComment == self.getCommentID("AI_DIPLOCOMMENT_OFFER_CITY") or
  289. eComment == self.getCommentID("AI_DIPLOCOMMENT_OFFER_DEAL") or
  290. eComment == self.getCommentID("AI_DIPLOCOMMENT_GIVE_HELP") or
  291. eComment == self.getCommentID("AI_DIPLOCOMMENT_RELIGION_PRESSURE") or
  292. eComment == self.getCommentID("AI_DIPLOCOMMENT_CIVIC_PRESSURE") or
  293. eComment == self.getCommentID("AI_DIPLOCOMMENT_JOIN_WAR") or
  294. eComment == self.getCommentID("AI_DIPLOCOMMENT_STOP_TRADING") or
  295. ###############Afforess Advanced Diplomacy Start###############################
  296. eComment == self.getCommentID("AI_DIPLOCOMMENT_MAKE_PEACE_WITH") or
  297. #####################Afforess Advanced Diplomacy End########################
  298. eComment == self.getCommentID("AI_DIPLOCOMMENT_ASK_FOR_HELP") or
  299. eComment == self.getCommentID("AI_DIPLOCOMMENT_DEMAND_TRIBUTE") ):
  300. self.diploScreen.performHeadAction( LeaderheadAction.LEADERANIM_GREETING )
  301. elif ( eComment == self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_FURIOUS") or
  302. eComment == self.getCommentID("AI_DIPLOCOMMENT_WORST_ENEMY_TRADING") or
  303. eComment == self.getCommentID("AI_DIPLOCOMMENT_HELP_REFUSED") or
  304. eComment == self.getCommentID("AI_DIPLOCOMMENT_DEMAND_REJECTED") or
  305. eComment == self.getCommentID("AI_DIPLOCOMMENT_RELIGION_DENIED") or
  306. eComment == self.getCommentID("AI_DIPLOCOMMENT_CIVIC_DENIED") or
  307. eComment == self.getCommentID("AI_DIPLOCOMMENT_JOIN_DENIED") or
  308. eComment == self.getCommentID("AI_DIPLOCOMMENT_STOP_DENIED") ):
  309. self.diploScreen.performHeadAction( LeaderheadAction.LEADERANIM_FURIOUS )
  310. elif ( eComment == self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_ANNOYED") ):
  311. self.diploScreen.performHeadAction( LeaderheadAction.LEADERANIM_ANNOYED )
  312. elif ( eComment == self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_CAUTIOUS") ):
  313. self.diploScreen.performHeadAction( LeaderheadAction.LEADERANIM_CAUTIOUS )
  314. elif ( eComment == self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_PLEASED") or
  315. eComment == self.getCommentID("AI_DIPLOCOMMENT_SORRY") ):
  316. self.diploScreen.performHeadAction( LeaderheadAction.LEADERANIM_PLEASED )
  317. elif ( eComment == self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_FRIENDLY") or
  318. eComment == self.getCommentID("AI_DIPLOCOMMENT_GLAD") or
  319. eComment == self.getCommentID("AI_DIPLOCOMMENT_THANKS") ):
  320. self.diploScreen.performHeadAction( LeaderheadAction.LEADERANIM_FRIENDLY )
  321. return
  322. def getDiplomacyComment (self, eComment):
  323. "Function to get the user String"
  324. debugString = "CvDiplomacy.getDiplomacyComment: %s" %(eComment,)
  325. eComment = int(eComment)
  326. if DebugLogging:
  327. print debugString, eComment
  328. szString = ""
  329. szFailString = "Error***: No string found for eComment: %s"
  330. if ( gc.getDiplomacyInfo(eComment) ):
  331. DiplomacyTextInfo = gc.getDiplomacyInfo(eComment)
  332. if ( not DiplomacyTextInfo ):
  333. print "%s IS AN INVALID DIPLOCOMMENT" %(eComment,)
  334. CvUtil.pyAssert(True, "CvDiplomacy.getDiplomacyComment: %s does not have a DiplomacyTextInfo" %(eComment,))
  335. return szFailString %(eComment,)
  336. szString = self.filterUserResponse(DiplomacyTextInfo)
  337. else:
  338. szString = szFailString %(eComment,)
  339. return szString
  340. def setLastResponseID(self, iResponse):
  341. self.iLastResponseID = iResponse
  342. def getLastResponseID(self):
  343. return self.iLastResponseID
  344. def isUsed(self, var, i, num):
  345. "returns true if any element in the var list is true"
  346. for j in range(num):
  347. if (var(i, j)):
  348. return true
  349. return false
  350. def filterUserResponse(self, diploInfo):
  351. "pick the user's response from a CvDiplomacyTextInfo, based on response conditions"
  352. if (self.diploScreen.getWhoTradingWith() == -1):
  353. return ""
  354. theirPlayer = gc.getPlayer(self.diploScreen.getWhoTradingWith())
  355. ourPlayer = gc.getActivePlayer()
  356. responses = []
  357. for i in range(diploInfo.getNumResponses()):
  358. # check attitude of other player towards me
  359. if (self.isUsed(diploInfo.getAttitudeTypes, i, AttitudeTypes.NUM_ATTITUDE_TYPES)):
  360. att = theirPlayer.AI_getAttitude(CyGame().getActivePlayer())
  361. if (not diploInfo.getAttitudeTypes(i, att)):
  362. continue
  363. # check civ type
  364. if (self.isUsed(diploInfo.getCivilizationTypes, i, gc.getNumCivilizationInfos()) and
  365. not diploInfo.getCivilizationTypes(i, theirPlayer.getCivilizationType())):
  366. continue
  367. # check leader type
  368. if (self.isUsed(diploInfo.getLeaderHeadTypes, i, gc.getNumLeaderHeadInfos()) and
  369. not diploInfo.getLeaderHeadTypes(i, theirPlayer.getLeaderType())):
  370. continue
  371. # check power type
  372. if (self.isUsed(diploInfo.getDiplomacyPowerTypes, i, DiplomacyPowerTypes.NUM_DIPLOMACYPOWER_TYPES)):
  373. theirPower = theirPlayer.getPower()
  374. ourPower = ourPlayer.getPower()
  375. if (ourPower < (theirPower / 2)):
  376. if not diploInfo.getDiplomacyPowerTypes(i, DiplomacyPowerTypes.DIPLOMACYPOWER_STRONGER):
  377. continue
  378. elif (ourPower > (theirPower * 2)):
  379. if not diploInfo.getDiplomacyPowerTypes(i, DiplomacyPowerTypes.DIPLOMACYPOWER_WEAKER):
  380. continue
  381. else:
  382. if not diploInfo.getDiplomacyPowerTypes(i, DiplomacyPowerTypes.DIPLOMACYPOWER_EQUAL):
  383. continue
  384. # passed all tests, so add to response list
  385. for j in range(diploInfo.getNumDiplomacyText(i)):
  386. responses.append(diploInfo.getDiplomacyText(i, j))
  387. # pick a random response
  388. numResponses = len(responses)
  389. if (numResponses>0):
  390. iResponse = gc.getASyncRand().get(numResponses, "Python Diplomacy ASYNC")
  391. self.setLastResponseID(iResponse)
  392. return responses[iResponse]
  393. return "" # no responses matched
  394. def handleUserResponse(self, eComment, iData1, iData2):
  395. if DebugLogging:
  396. print "CvDiplomacy.handleUserResponse: %s" %(eComment,)
  397. diploScreen = CyDiplomacy()
  398. # If we accept peace
  399. if (self.isComment(eComment, "USER_DIPLOCOMMENT_PEACE")):
  400. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_PEACE"))
  401. # If we choose war
  402. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_WAR")):
  403. diploScreen.declareWar()
  404. #diploScreen.closeScreen()
  405. # If we wish to make a trade proposal or try to renegotiate
  406. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_PROPOSAL") or
  407. self.isComment(eComment, "USER_DIPLOCOMMENT_RENEGOTIATE")):
  408. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_TRADING"))
  409. diploScreen.showAllTrade(True)
  410. # If we want to propose a trade
  411. elif(self.isComment(eComment, "USER_DIPLOCOMMENT_PROPOSE")):
  412. if (diploScreen.offerDeal() == 1):
  413. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ACCEPT"))
  414. else:
  415. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_REJECT"))
  416. # If we ask for peace
  417. elif(self.isComment(eComment, "USER_DIPLOCOMMENT_SUGGEST_PEACE")):
  418. if (diploScreen.offerDeal() == 1):
  419. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_PEACE"))
  420. else:
  421. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_NO_PEACE"))
  422. # If we accept a trade
  423. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_ACCEPT")):
  424. diploScreen.implementDeal()
  425. diploScreen.setAIOffer(0)
  426. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_GLAD"))
  427. # If we reject a trade
  428. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_REJECT")):
  429. diploScreen.setAIOffer(0)
  430. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_SORRY"))
  431. # If we offer a deal, or is we are fishing for a deal, or if we are offering peace or fishing for peace
  432. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_OFFER") or
  433. self.isComment(eComment, "USER_DIPLOCOMMENT_COMPLETE_DEAL") or
  434. self.isComment(eComment, "USER_DIPLOCOMMENT_FISH_FOR_DEAL") or
  435. self.isComment(eComment, "USER_DIPLOCOMMENT_OFFER_PEACE")):
  436. if (diploScreen.counterPropose() == 1):
  437. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_TRY_THIS_DEAL"))
  438. else:
  439. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_NO_DEAL"))
  440. # if we are asking for something
  441. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_ASK")):
  442. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_ASK_HELP, -1, -1)
  443. if (diploScreen.offerDeal()):
  444. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ACCEPT_ASK"))
  445. else:
  446. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_REJECT_ASK"))
  447. # if we are demanding something
  448. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_DEMAND")):
  449. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_MADE_DEMAND, -1, -1)
  450. if (diploScreen.offerDeal()):
  451. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ACCEPT_DEMAND"))
  452. else:
  453. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_REJECT_DEMAND"))
  454. # if we are demanding something with the threat of war
  455. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_VASSAL_TRIBUTE")):
  456. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_MADE_DEMAND_VASSAL, -1, -1)
  457. if (diploScreen.offerDeal()):
  458. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ACCEPT_DEMAND"))
  459. else:
  460. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_DECLARE_WAR"))
  461. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_DEMAND_WAR, -1, -1)
  462. # if we are demanding something from our teammate
  463. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_DEMAND_TEAM")):
  464. diploScreen.offerDeal()
  465. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ACCEPT_DEMAND_TEAM"))
  466. # If we are giving a gift
  467. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_GIFT")):
  468. diploScreen.offerDeal()
  469. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  470. # If we decide to view current deals
  471. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_CURRENT_DEALS")):
  472. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_CURRENT_DEALS"))
  473. diploScreen.showAllTrade(False)
  474. # If we give help
  475. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_GIVE_HELP")):
  476. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_GIVE_HELP, -1, -1)
  477. diploScreen.implementDeal()
  478. diploScreen.setAIOffer(0)
  479. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  480. # If we accept their demand
  481. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_ACCEPT_DEMAND")):
  482. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_ACCEPT_DEMAND, -1, -1)
  483. diploScreen.implementDeal()
  484. diploScreen.setAIOffer(0)
  485. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  486. # If we accept the offer
  487. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_ACCEPT_OFFER")):
  488. diploScreen.implementDeal()
  489. diploScreen.setAIOffer(0)
  490. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  491. # If we refuse to help
  492. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_REFUSE_HELP")):
  493. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_REFUSED_HELP, -1, -1)
  494. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_HELP_REFUSED"))
  495. # If we reject their demand
  496. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_REJECT_DEMAND")):
  497. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_REJECTED_DEMAND, -1, -1)
  498. if (gc.getPlayer(self.diploScreen.getWhoTradingWith()).AI_demandRebukedWar(gc.getGame().getActivePlayer())):
  499. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_DECLARE_WAR"))
  500. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_DEMAND_WAR, -1, -1)
  501. else:
  502. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_DEMAND_REJECTED"))
  503. # If we convert to their state religion
  504. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_CONVERT")):
  505. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_CONVERT, -1, -1)
  506. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  507. # If we refuse to convert to their state religion
  508. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_NO_CONVERT")):
  509. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_NO_CONVERT, -1, -1)
  510. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_RELIGION_DENIED"))
  511. # If we adopt their favorite civic
  512. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_REVOLUTION")):
  513. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_REVOLUTION, -1, -1)
  514. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  515. # If we refuse to adopt their favorite civic
  516. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_NO_REVOLUTION")):
  517. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_NO_REVOLUTION, -1, -1)
  518. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_CIVIC_DENIED"))
  519. # If we join their war
  520. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_JOIN_WAR")):
  521. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_JOIN_WAR, diploScreen.getData(), -1)
  522. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  523. # If we refuse to join their war
  524. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_NO_JOIN_WAR")):
  525. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_NO_JOIN_WAR, -1, -1)
  526. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_JOIN_DENIED"))
  527. # If we stop the trading
  528. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_STOP_TRADING")):
  529. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_STOP_TRADING, diploScreen.getData(), -1)
  530. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  531. # If we refuse to stop the trading
  532. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_NO_STOP_TRADING")):
  533. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_NO_STOP_TRADING, -1, -1)
  534. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_STOP_DENIED"))
  535. #Afforess Advanced Diplomacy Start
  536. #If we accept making peace with their ally
  537. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_MAKE_PEACE_WITH")):
  538. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_MAKE_PEACE_WITH, diploScreen.getData(), -1)
  539. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_THANKS"))
  540. #If we refuse to make peace with their ally
  541. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_NO_MAKE_PEACE_WITH")):
  542. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_NO_MAKE_PEACE_WITH, diploScreen.getData(), -1)
  543. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_MAKE_PEACE_DENIED"))
  544. #Afforess Advanced Diplomacy End
  545. # If we want to go back to first screen
  546. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_NEVERMIND")):
  547. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_WELL"))
  548. # If we want to discuss something else
  549. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_SOMETHING_ELSE")):
  550. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_SOMETHING_ELSE"))
  551. # If we want to ask them to change their research
  552. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_RESEARCH")):
  553. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_RESEARCH"))
  554. # If we want to ask them to change their research to a specific tech
  555. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_RESEARCH_TECH")):
  556. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_RESEARCH_TECH, iData1, -1)
  557. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_RESEARCH_TECH"))
  558. # If we want to ask them to what their attitude is
  559. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_ATTITUDE")):
  560. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE"))
  561. # If we want to ask them to what their attitude is on a specific player
  562. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_ATTITUDE_PLAYER")):
  563. eAttitude = gc.getPlayer(self.diploScreen.getWhoTradingWith()).AI_getAttitude(iData1)
  564. if (eAttitude == AttitudeTypes.ATTITUDE_FURIOUS):
  565. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_FURIOUS"), gc.getPlayer(iData1).getNameKey())
  566. elif (eAttitude == AttitudeTypes.ATTITUDE_ANNOYED):
  567. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_ANNOYED"), gc.getPlayer(iData1).getNameKey())
  568. elif (eAttitude == AttitudeTypes.ATTITUDE_CAUTIOUS):
  569. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_CAUTIOUS"), gc.getPlayer(iData1).getNameKey())
  570. elif (eAttitude == AttitudeTypes.ATTITUDE_PLEASED):
  571. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_PLEASED"), gc.getPlayer(iData1).getNameKey())
  572. else:
  573. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_ATTITUDE_PLAYER_FRIENDLY"), gc.getPlayer(iData1).getNameKey())
  574. # If we want to ask them to change their target
  575. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_TARGET")):
  576. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_TARGET"))
  577. # If we want to ask them to change their target to a specific city
  578. elif (self.isComment(eComment, "USER_DIPLOCOMMENT_TARGET_CITY")):
  579. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_TARGET_CITY, iData1, iData2)
  580. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_TARGET_CITY"))
  581. ###############Advanced Diplomacy Start###############################
  582. # RevolutionDCM - start new diplomacy option
  583. # If we have asked them to not bother us
  584. elif (self.isComment(eComment, "USER_DO_NOT_BOTHER_US")):
  585. eAttitude = gc.getPlayer(self.diploScreen.getWhoTradingWith()).AI_getAttitude(gc.getGame().getActivePlayer())
  586. if (eAttitude == AttitudeTypes.ATTITUDE_FURIOUS or eAttitude == AttitudeTypes.ATTITUDE_ANNOYED):
  587. self.setAIComment(self.getCommentID("AI_ASSUME_REALLY_SNUFFED"))
  588. diploScreen.performHeadAction(LeaderheadAction.LEADERANIM_DISAGREE)
  589. elif (eAttitude == AttitudeTypes.ATTITUDE_CAUTIOUS):
  590. self.setAIComment(self.getCommentID("AI_ASSUME_SNUFFED"))
  591. diploScreen.performHeadAction(LeaderheadAction.LEADERANIM_AGREE)
  592. else:
  593. self.setAIComment(self.getCommentID("AI_ASSUME_NOT_SNUFFED"))
  594. diploScreen.performHeadAction(LeaderheadAction.LEADERANIM_AGREE)
  595. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_DO_NOT_BOTHER, gc.getGame().getActivePlayer(), iData2)
  596. # If we have asked them to resume talks
  597. elif (self.isComment(eComment, "USER_RESUME_TALKS")):
  598. eAttitude = gc.getPlayer(self.diploScreen.getWhoTradingWith()).AI_getAttitude(gc.getGame().getActivePlayer())
  599. if (eAttitude == AttitudeTypes.ATTITUDE_FURIOUS or eAttitude == AttitudeTypes.ATTITUDE_ANNOYED):
  600. self.setAIComment(self.getCommentID("AI_RESUME_TALKS_RELUCTANT"))
  601. diploScreen.performHeadAction(LeaderheadAction.LEADERANIM_DISAGREE)
  602. elif (eAttitude == AttitudeTypes.ATTITUDE_CAUTIOUS):
  603. self.setAIComment(self.getCommentID("AI_RESUME_TALKS"))
  604. diploScreen.performHeadAction(LeaderheadAction.LEADERANIM_AGREE)
  605. else:
  606. self.setAIComment(self.getCommentID("AI_RESUME_TALKS_GLADLY"))
  607. diploScreen.performHeadAction(LeaderheadAction.LEADERANIM_AGREE)
  608. diploScreen.diploEvent(DiploEventTypes.DIPLOEVENT_RESUME_BOTHER, gc.getGame().getActivePlayer(), iData2)
  609. # RevolutionDCM - end
  610. ###############Advanced Diplomacy End###############################
  611. else:
  612. diploScreen.closeScreen()
  613. def dealCanceled( self ):
  614. self.setAIComment(self.getCommentID("AI_DIPLOCOMMENT_TRADING"))
  615. return
  616. def isComment(self, eComment, strComment):
  617. 'bool - comment matching'
  618. if ( gc.getDiplomacyInfo(eComment).getType() == strComment ):
  619. return True
  620. return False
  621. def getCommentID(self, strComment):
  622. 'int - ID for DiploCommentType'
  623. for i in range(gc.getNumDiplomacyInfos()):
  624. if ( gc.getDiplomacyInfo(i).getType() == strComment ):
  625. return i
  626. return -1