-
Notifications
You must be signed in to change notification settings - Fork 0
/
card.py
85 lines (69 loc) · 2.33 KB
/
card.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
class Price:
def __init__(self):
self.url = ""
self.buy_price = 0.0
self.sell_price = 0.0
self.bot_name_buy = ""
self.bot_name_sell = ""
self.number = 0
def __init__(self, url, buy_price, sell_price, bot_name_buy, bot_name_sell, number):
self.url = url
self.buy_price = buy_price
self.sell_price = sell_price
self.bot_name_buy = bot_name_buy
self.bot_name_sell = bot_name_sell
self.number = number
def __str__(self):
return str(self.buy_price) + "\t" + self.bot_name_buy + "\t" + str(self.sell_price) + "\t" + self.bot_name_sell +"\t"
class Card:
def __init__(self):
self.name = ""
self.set = ""
self.foil = False
self.prices = []
def __init__(self, name, set, prices, foil):
self.name = name
self.set = set
self.prices = [prices]
self.foil = foil
def AddPrice(self, price):
self.prices.append(price)
def __hash__(self):
return hash(self.name + self.set)
def MaxBuyPrice(self):
prices = [price.buy_price for price in self.prices if price.buy_price > 0]
try:
return max(prices)
except:
return 0.0
def MinSellPrice(self):
prices = [price.sell_price for price in self.prices if price.sell_price > 0]
try:
return min(prices)
except:
return 100000.0
def __str__(self):
str1 = ""
for price in self.prices:
str1 += str(price)
return self.name + "\t" + self.set + "\t" + str(self.foil) + "\t" + str1 + "\t" + str(self.MaxBuyPrice() - self.MinSellPrice())
def BestSellPrice(self):
best_price = None
for price in self.prices:
if price == None:
continue
if best_price == None:
best_price = price
elif price.sell_price < best_price.sell_price:
best_price = price
return best_price
def BestBuyPrice(self):
best_price = None
for price in self.prices:
if price == None:
continue
if best_price == None:
best_price = price
elif price.buy_price > best_price.buy_price:
best_price = price
return best_price