Skip to content

Commit bca31e4

Browse files
committed
separating into mvc strcuture, code.py still contains Images class def
1 parent c88d795 commit bca31e4

20 files changed

+545
-54
lines changed

Images/trade/canceled_trade.png

3.68 KB
Loading

code.py

+132-54
Large diffs are not rendered by default.

file_io_test.sikuli/file_io_test.html

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
2+
<html>
3+
<head>
4+
<style type="text/css">
5+
.sikuli-code {
6+
font-size: 20px;
7+
font-family: "Osaka-mono", Monospace;
8+
line-height: 1.5em;
9+
display:table-cell;
10+
white-space: pre-wrap; /* css-3 */
11+
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
12+
white-space: -pre-wrap; /* Opera 4-6 */
13+
white-space: -o-pre-wrap; /* Opera 7 */
14+
word-wrap: break-word; /* Internet Explorer 5.5+ */
15+
width: 99%; /* remove horizontal scroll-bar when viewing in IE7 */
16+
}
17+
.sikuli-code img {
18+
vertical-align: middle;
19+
margin: 2px;
20+
border: 1px solid #ccc;
21+
padding: 2px;
22+
-moz-border-radius: 5px;
23+
-webkit-border-radius: 5px;
24+
-moz-box-shadow: 1px 1px 1px gray;
25+
-webkit-box-shadow: 1px 1px 2px gray;
26+
}
27+
.kw {
28+
color: blue;
29+
}
30+
.skw {
31+
color: rgb(63, 127, 127);
32+
}
33+
34+
.str {
35+
color: rgb(128, 0, 0);
36+
}
37+
38+
.dig {
39+
color: rgb(128, 64, 0);
40+
}
41+
42+
.cmt {
43+
color: rgb(200, 0, 200);
44+
}
45+
46+
h2 {
47+
display: inline;
48+
font-weight: normal;
49+
}
50+
51+
.info {
52+
border-bottom: 1px solid #ddd;
53+
padding-bottom: 5px;
54+
margin-bottom: 20px;
55+
display: none;
56+
}
57+
58+
a {
59+
color: #9D2900;
60+
}
61+
62+
body {
63+
font-family: "Trebuchet MS", Arial, Sans-Serif;
64+
}
65+
66+
</style>
67+
</head>
68+
<body>
69+
<div class="info">
70+
<h2>file_io_test.sikuli\file_io_test.sikuli</h2> <a href="file_io_test.sikuli\file_io_test.zip">(Download this script)</a>
71+
</div>
72+
<pre class="sikuli-code">
73+
<span class="cmt">#handles reading and writing to files
74+
</span>
75+
<span class="kw">import</span> sys
76+
77+
<span class="kw">class</span> ProductPriceModel(object):
78+
79+
<span class="kw">def</span> __init__(self):
80+
81+
self.pricelist = {}
82+
<span class="kw">try</span>:
83+
self.pricelist[<span class="str">"packs_buy"</span>] = open(<span class="str">"c:/users/darkray16/desktop/my dropbox/mtgo bot/pricelist/packs/buy.txt"</span>, <span class="str">"r"</span>)
84+
<span class="kw">except</span> IOError:
85+
sys.exit(<span class="str">"Pack buy price file not found at pricelist/packs/buy/"</span>)
86+
<span class="kw">try</span>:
87+
self.pricelist[<span class="str">"packs_sell"</span>] = open(<span class="str">"c:/users/darkray16/desktop/my dropbox/mtgo bot/pricelist/packs/sell.txt"</span>, <span class="str">"r"</span>)
88+
<span class="kw">except</span> IOError:
89+
sys.exit(<span class="str">"Pack sell price file not found at pricelist/packs/sell/"</span>)
90+
<span class="kw">try</span>:
91+
self.pricelist[<span class="str">"cards_buy"</span>] = open(<span class="str">"c:/users/darkray16/desktop/my dropbox/mtgo bot/pricelist/cards/buy.txt"</span>, <span class="str">"r"</span>)
92+
<span class="kw">except</span> IOError:
93+
sys.exit(<span class="str">"Card buy price file not found at pricelist/packs/buy/"</span>)
94+
<span class="kw">try</span>:
95+
self.pricelist[<span class="str">"cards_sell"</span>] = open(<span class="str">"c:/users/darkray16/desktop/my dropbox/mtgo bot/pricelist/cards/sell.txt"</span>, <span class="str">"r"</span>)
96+
<span class="kw">except</span> IOError:
97+
sys.exit(<span class="str">"Card sell price file not found at pricelist/packs/buy/"</span>)
98+
99+
<span class="kw">def</span> get_prices(self, pricelist):
100+
<span class="str">"""valid strings for pricelist = "packs_buy", "packs_sell", "cards_buy", "cards_sell" """</span>
101+
<span class="cmt">#this will return a dictionary containg all the buy or sell prices for requested products
102+
</span>
103+
pricelist_dict = {}
104+
105+
raw_feed = self.pricelist[pricelist]
106+
107+
<span class="kw">while</span> True:
108+
newline = raw_feed.readline()
109+
<span class="kw">if</span> newline == <span class="str">"/n"</span> <span class="kw">or</span> newline == <span class="str">""</span>:
110+
<span class="kw">break</span>
111+
single_product = newline.split(<span class="str">" $"</span>)
112+
pricelist_dict[single_product[<span class="dig">0</span>]] = single_product[<span class="dig">1</span>]
113+
114+
<span class="kw">return</span> pricelist_dict
115+
116+
prices = ProductPriceModel()
117+
price_dict = {}
118+
price_dict = prices.get_prices(<span class="str">"packs_buy"</span>)
119+
<span class="kw">print</span> (price_dict[<span class="str">"WWK"</span>])
120+
</pre>
121+
</body>
122+
</html>

file_io_test.sikuli/file_io_test.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#handles reading and writing to files
2+
3+
import sys
4+
5+
class ProductPriceModel(object):
6+
7+
def __init__(self):
8+
9+
self.pricelist = {}
10+
try:
11+
self.pricelist["packs_buy"] = open("c:/users/darkray16/desktop/my dropbox/mtgo bot/pricelist/packs/buy.txt", "r")
12+
except IOError:
13+
sys.exit("Pack buy price file not found at pricelist/packs/buy/")
14+
try:
15+
self.pricelist["packs_sell"] = open("c:/users/darkray16/desktop/my dropbox/mtgo bot/pricelist/packs/sell.txt", "r")
16+
except IOError:
17+
sys.exit("Pack sell price file not found at pricelist/packs/sell/")
18+
try:
19+
self.pricelist["cards_buy"] = open("c:/users/darkray16/desktop/my dropbox/mtgo bot/pricelist/cards/buy.txt", "r")
20+
except IOError:
21+
sys.exit("Card buy price file not found at pricelist/packs/buy/")
22+
try:
23+
self.pricelist["cards_sell"] = open("c:/users/darkray16/desktop/my dropbox/mtgo bot/pricelist/cards/sell.txt", "r")
24+
except IOError:
25+
sys.exit("Card sell price file not found at pricelist/packs/buy/")
26+
27+
def get_prices(self, pricelist):
28+
"""valid strings for pricelist = "packs_buy", "packs_sell", "cards_buy", "cards_sell" """
29+
#this will return a dictionary containg all the buy or sell prices for requested products
30+
31+
pricelist_dict = {}
32+
33+
raw_feed = self.pricelist[pricelist]
34+
35+
while True:
36+
newline = raw_feed.readline()
37+
if newline == "/n" or newline == "":
38+
break
39+
single_product = newline.split(" $")
40+
pricelist_dict[single_product[0]] = single_product[1]
41+
42+
return pricelist_dict
43+
44+
prices = ProductPriceModel()
45+
price_dict = {}
46+
price_dict = prices.get_prices("packs_buy")
47+
print (price_dict["WWK"])

model/CardPricesDAL$py.class

4.3 KB
Binary file not shown.

model/CardPricesDAL.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
class CardPricesDAL(object):
3+
#DAL layer for pricelist for buying and selling single cards
4+
5+
def __init__(self):
6+
price_model = ProductPriceModel()
7+
self.pack_buy = price_model.get_prices("cards_buy")
8+
self.pack_sell = price_model.get_prices("cards_sell")

model/ImagesModel$py.class

42.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)