Advertisement
UrsaMauris

basic AI ToR general minigame

Oct 31st, 2021
3,273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func targetingMyCards(card, target_node):
  2.     var goodPosition: bool
  3.     if card.get_node("Card/BattleType").texture == preload("res://infantry token-1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://spearman token -1.png.png"):
  4.         goodPosition = true
  5.     elif card.get_node("Card/BattleType").texture == preload("res://spearman token -1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://cavalry token-1.png.png"):
  6.         goodPosition = true
  7.     elif card.get_node("Card/BattleType").texture == preload("res://cavalry token-1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://infantry token-1.png.png"):
  8.         goodPosition = true
  9.     else:
  10.         goodPosition = false
  11.     print (card, "GP", goodPosition)
  12.    
  13.     if goodPosition == false and int(card.get_node("Card/MovCard").text) >= 0 and pos < 35:   # looks to the right for a better position
  14.         get_new_target_card_right(target_node)
  15.         print("looking right")
  16.         var betterPosition: bool
  17.         if card.get_node("Card/BattleType").texture == preload("res://infantry token-1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://spearman token -1.png.png"):
  18.             betterPosition = true
  19.         elif card.get_node("Card/BattleType").texture == preload("res://spearman token -1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://cavalry token-1.png.png"):
  20.             betterPosition = true
  21.         elif card.get_node("Card/BattleType").texture == preload("res://cavalry token-1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://infantry token-1.png.png"):
  22.             betterPosition = true
  23.         print(card, "BP", betterPosition)
  24.        
  25.         if betterPosition == true:
  26.             get_back_node(target_node)
  27.             if target_node.get_node("Card").visible == false:
  28.                 moveEnemyCard(card, target_node)
  29.                 print("I moved")
  30.    
  31.     elif goodPosition == false and int(card.get_node("Card/MovCard").text) >= 0 and pos > 31:
  32.         var betterPosition: bool
  33.         get_new_target_card_left(target_node)                                 # looks to the left for a better position
  34.         print("looking left")
  35.         if card.get_node("Card/BattleType").texture == preload("res://infantry token-1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://spearman token -1.png.png"):
  36.             betterPosition = true
  37.         elif card.get_node("Card/BattleType").texture == preload("res://spearman token -1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://cavalry token-1.png.png"):
  38.             betterPosition = true
  39.         elif card.get_node("Card/BattleType").texture == preload("res://cavalry token-1.png.png") and target_node.get_node("Card/BattleType").texture == preload("res://infantry token-1.png.png"):
  40.             betterPosition = true
  41.        
  42.         if betterPosition == true:
  43.             get_back_node(target_node)
  44.             if target_node.get_node("Card").visible == false:
  45.                 moveEnemyCard(card, target_node)
  46.                 print("I moved")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement