-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
94 lines (78 loc) · 2.54 KB
/
main.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import ld_deck as ldd
import yugidb as db
from actions import *
from game import Game
from playfield import *
# Request user input from specific value
# value is exclusive
def request_input(minval, maxval):
ex = False
i = "NONE"
while not ex:
i = input("Enter a Number: ")
if not i.isdigit():
continue
i = int(i)
if i <= maxval and minval <= i:
ex = True
return i
# print options as integers
def print_options(options):
for ind in range(1, len(options) + 1):
print(ind, ": ", options[ind - 1])
print()
def main():
db.load_card_names()
game = Game()
playfield = Playfield()
set_deck(game.pf, P1, ldd.load_deck("madolche_test"))
set_deck(game.pf, P2, ldd.load_deck("madolche_test"))
shuffle_deck(game.pf, P1)
shuffle_deck(game.pf, P2)
print("\n")
print("INTIALIZING GAME....")
game.start()
print("GAME HAND INFO FOR CURRENT PLAYER: ")
print(allinfo(game.pf, game.cur_player))
for actions in game:
# Check if current result is a response phase
if game.is_reponse():
print("\nRESPONSE P"+ str(game.cur_player + 1))
else:
print("\nROUND ", game.pf.ROUND_CNT + 1)
# Print currect cards
print(fieldinfo(game.pf, game.cur_player))
print(handinfo(game.pf, game.cur_player))
# Values for accessing the options array
fro = -1
typ = -1
cardind = -1
# Get fro info
fro_opt = list(actions.keys())
print("Select a Location:")
print("0 : Do Nothing")
print_options(fro_opt)
fro = request_input(0, len(fro_opt))
# Action if the user chooses to do nothing.
if fro == 0:
game.play_action(None)
continue
fro = fro_opt[fro - 1]
# Get the specific type
typ_opt = list(actions[fro].keys())
print("Select a Card: ")
print_options(typ_opt)
typ = request_input(1, len(typ_opt))
typ = typ_opt[typ - 1]
# Get our specific card options
card_opt = list(actions[fro][typ].keys())
print("Select an Action: ")
print_options(card_opt)
cardind = request_input(1, len(card_opt))
cardind = card_opt[cardind-1]
# Play the action
print(actions[fro][typ][cardind])
game.play_action(actions[fro][typ][cardind])
db.unload_card_names()
if __name__ == '__main__':
main()