# FROM is the taker
# ROOT is the target
targetted_decisions = {
	play_dice_poker = {
		filter = all
		ai_target_filter = court
		diplomacy_icon = GFX_dice_poker_decision
		
		from_potential = {
			OR = {
				ai = no
				trait = gambler
			}
			NOT = { has_character_flag = flag_playing_game }
			wealth = 0.5 # Bet+raise money
		}
		potential = {
			NOT = { has_character_flag = flag_playing_game }
			NOT = { character = FROM } # Can't play against oneself, would mess up the variables.
		}
		allow = {
			at_location = FROM # Might be too restrictive ?
			
			# Conditions for A.I. to accept
			trait = gambler # Only gamblers play dice poker.
			NOT = { war_with = FROM }
			OR = {
				opinion = { who = FROM value = 0 }
				prisoner = yes
			}
			
			# Note: no wealth condition on A.I., since most characters have no money.
			# The bet money will be generated, if character cannot afford it
		}
		effect = {
			wealth = -0.5 # Initial bet
			# Propose a game to opponent
			character_event = { id = dice_poker.0 }
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.01
			}
			
			modifier = { # AI only targets human players
				factor = 0
				ROOT = {
					ai = yes
				}
			}
			
			modifier = { # AI only targets human players
				factor = 0
				ROOT = {
					has_character_modifier = no_mood_for_game
				}
			}
			
			modifier = { # AI only targets gamblers
				factor = 0
				FROM = {
					NOT = { trait = gambler } 
				}
			}
			
			# Timer
			modifier = {
				factor = 0				
				OR = {
					has_opinion_modifier = { who = ROOT modifier = won_last_game }
					has_opinion_modifier = { who = ROOT modifier = lost_last_game }
				}
			}
			
			modifier = { # AI will only target gamblers they like
				factor = 0
				NOT = {
					opinion = { who = ROOT value = 25 } 
				}
			}
			
			modifier = {
				factor = 5
				FROM = {
					wealth = 25
				}
			}
			
			modifier = {
				factor = 10
				FROM = {
					wealth = 50
				}
			}
		}
	}
}
