-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulator.py
111 lines (92 loc) · 3.89 KB
/
simulator.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from shuffler import *
from hearthstone.deckstrings import Deck
from hearthstone.enums import FormatType
##Example Mage Deck we will be using ("AAECAf0ECO0Fcem6AoivAuwHobcCxQS/CAuBsgKVA8HBApYF17YCmMQCqwTAAbC8ArsCo7YCAA==")
class simulator:
def __init__(self):
"""
Information to be written in the database
"""
self.decklist = []
self.order = None
self.originaldecklist = None
self.deck = None
self.opponent = ""
self.hand = []
self.handID = []
self.deckcode = None
self.user_selection = None
self.urls = []
self.hand_names = []
self.results = {}
self.nextfourdraws = []
def simulate_mulligan(self, deckcode):
#determine order & draw initial cards
self.deckcode = str(deckcode)
self.order = isFirst()
self.deck = Deck.from_deckstring(self.deckcode)
self.decklist = fulldecklist(self.deckcode)
self.originaldecklist = self.decklist
random.shuffle(self.decklist)
self.opponent = opponent_selection()
self.hand = initial_draw(self.decklist, self.order)
self.hand_names = self.display_cards(self.hand)
self.handID = self.display_cards_ID(self.hand)
self.urls = self.ID_to_url(self.handID)
#creates the next four possible draws for the next mulligan. In this case, top card starts from the index 0
self.nextfourdraws = [self.decklist.pop(), self.decklist.pop(), self.decklist.pop(), self.decklist.pop()]
self.nextfourdraws = self.display_cards_ID(self.nextfourdraws)
self.nextfourdraws = self.ID_to_url(self.nextfourdraws)
self.results.update({"order":self.order, "hand_url":self.urls,
"opponent": self.opponent, "decklist": self.originaldecklist,
"smalldeck":self.nextfourdraws, "deckcode":self.deckcode,
"hand_names": self.hand_names})
def display_cards(self, cards):
"""
matches the dbfids to the numbers outputted by the strings in everysingle card
"""
to_display = []
for card in cards:
to_display.append(matchdbfid(str(card)))
return to_display
def display_cards_ID(self, cards):
"""
matches the dbfids to the ids of the cards and then to the images
"""
CardIDs = []
for card in cards:
CardIDs.append(matchdbfidtoid(str(card)))
print(CardIDs)
return CardIDs
def ID_to_url(self, cards):
"""
matches the ids to the urls of the card images
"""
Cardurls = []
for card in cards:
Cardurls.append(matchidtourl(str(card)))
return Cardurls
"""
def replace_cards(self):
Choosing an index to replace what ever card is at the index that one decides
self.user_selection = input("Which cards would you like to keep (0 for keep & 1 for toss, space separated):")
self.user_selection = self.user_selection.split()
trash = [position for position, choice in enumerate(self.user_selection) if choice == '1']
for hand_index in trash:
self.hand.insert(hand_index, self.decklist.pop())
del self.hand[hand_index + 1]
return self.hand
def reset(self):
choice to restart with same deck, enter a new deck, or exit the simulation.
we do not need to include an else, since we will turn this to click based
upon interface creation
choice = input("To simulate the same deck press 1, to simulate a new decklist press 2, to exit the simulation press 3:")
if choice == '1':
self.simulate_mulligan(self.deckcode)
if choice == '2':
newdeckcode = str(input("Enter the deckcode of the deck you wish to practice:"))
self.simulate_mulligan(newdeckcode)
if choice == '3':
print("Thanks for playing")
return False
"""