-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathregal_target_func.py
34 lines (34 loc) · 1.89 KB
/
regal_target_func.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from my_enum import *
always_true_func = lambda target:True
TURN_PLAYER_ID = 1
NON_TURN_PLAYER_ID = 0
def decide_target(field,card,player_num,evo=False,target_category=None,target_regulation=None,with_ids=False):
player = field.players[player_num]
player_side = field.card_location[player_num]
can_be_targeted = field.get_can_be_targeted(player_num=player_num)
opponent_side = field.card_location[1 - player_num]
player_side_followers = field.get_creature_location()[player_num]
if target_regulation == None:
target_regulation = always_true_func
if target_category == Target_Type.ENEMY_FOLLOWER.value:
if target_category == Target_Type.ENEMY_FOLLOWER.value:
regal_targets = [card_id for card_id in can_be_targeted if
target_regulation(opponent_side[card_id], card)]
if with_ids:
target_card_ids = [(player_side[location_id].name, TURN_PLAYER_ID) for location_id in regal_targets]
elif target_category == Target_Type.ALLIED_FOLLOWER.value:
regal_targets = [card_id for card_id in player_side_followers if
target_regulation(player_side[card_id],card)]
if with_ids:
target_card_ids = [(player_side[location_id].name, NON_TURN_PLAYER_ID) for location_id in regal_targets]
elif target_category == Target_Type.ENEMY.value:
regal_targets = [-1] + [card_id for card_id in can_be_targeted if
target_regulation(opponent_side[card_id], card)]
if with_ids:
target_card_ids = [(0, TURN_PLAYER_ID)]
if len(regal_targets) > 1:
target_card_ids += [(opponent_side[location_id].name, TURN_PLAYER_ID) for location_id in
regal_targets[1:]]
if with_ids:
return regal_targets,target_card_ids
return regal_targets