-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
61 lines (49 loc) · 1.5 KB
/
utils.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from card import *
def silence(minion):
def doNothing(pos):
pass
minion.deathrattle = doNothing
minion.silence()
def createCard(data,player):
if 'card_' + data['id'] in globals():
return globals()['card_' + data['id']](data,player)
else:
return card(data,player)
def selectTarget(player):
targetCmd = raw_input(player.getName() + \
': Select a target(e.g. L 0): ')
target = player.game.getTarget(player,targetCmd.split())
return target
def selectMinion(player):
target = None
if player.totalMinionNum() + \
player.getComponent().totalMinionNum() > 0:
targetCmd = raw_input(player.getName() + \
': Select a minion(e.g. L 1): ')
target = player.game.getTarget(player,targetCmd.split())
return target
def selectFriendlyMinion(player):
target = None
if player.totalMinionNum() > 0:
targetCmd = raw_input(player.getName() + \
': Select a friendly minion(e.g. 1): ')
target = player.game.getTarget(player,['L',targetCmd])
return target
def selectEnemyTarget(player):
targetCmd = raw_input(player.getName() + \
': Select an enemy(e.g. 0): ')
target = player.game.getTarget(player,['U',targetCmd])
return target
def selectMinionWithMinAttack(player,minAttack):
targetExist = False
target = None
for minion in player.game.getFirstPlayer().getAllMinions() + \
player.game.getSecondPlayer().getAllMinions():
if minion.getAttack() >= minAttack:
targetExist = True
break
if targetExist:
target = selectMinion(player)
return target