Example #1
0
def isWillingToTalk(playerOrID, toPlayerOrID):
	"""
	Returns True if <player> is willing to talk to <toPlayer>.
	
	- Every player is willing to talk to themselves
	- All human players are willing to talk
	- Uses BUG DLL if present, otherwise scans attitude hover text
	  for "Refuses to Talk!!!" in the current language
	
	Note: This function does not check if the two players can make contact.
	"""
	playerID, player = PlayerUtil.getPlayerAndID(playerOrID)
	toPlayerID = PlayerUtil.getPlayerID(toPlayerOrID)
	# if playerID == toPlayerID or player.isHuman():
		# # all players talk to themselves, and all humans talk
		# return True
	# if BugDll.isPresent():
		# return player.AI_isWillingToTalk(toPlayerID)
	# else:
		# hover = AttitudeUtil.getAttitudeString(playerID, toPlayerID)
		# if hover:
			# return (hover.find(BugUtil.getPlainText("TXT_KEY_MISC_REFUSES_TO_TALK")) == -1)
		# else:
			# # haven't met yet
			# return False
	# K-Mod
	return playerID == toPlayerID or player.AI_isWillingToTalk(toPlayerID)
Example #2
0
def canContact(playerOrID, toPlayerOrID):
	"""
	Returns True if <player> can attempt to contact <toPlayer> given game settings, 
	initial contact, and war-time situation without regard to willingness to talk.
	
	- They must not be the same player
	- <toPlayer> must be alive, not minor, and not a barbarian
	- Their teams must have met
	- If they are at war, they must be able to sign a peace deal (no Always War or Permanent War/Peace options)
	"""
	playerID, player = PlayerUtil.getPlayerAndID(playerOrID)
	toPlayerID, toPlayer = PlayerUtil.getPlayerAndID(toPlayerOrID)
	if playerID == toPlayerID:
		return False
	if not toPlayer.isAlive() or toPlayer.isBarbarian() or toPlayer.isMinorCiv():
		return False
	if not PlayerUtil.getPlayerTeam(player).isHasMet(toPlayer.getTeam()):
		return False
	if PlayerUtil.getPlayerTeam(player).isAtWar(toPlayer.getTeam()) and (GameUtil.isAlwaysWar() or GameUtil.isPermanentWarPeace()):
		return False
	return True