-
Notifications
You must be signed in to change notification settings - Fork 0
/
the game again.py
232 lines (181 loc) · 5.81 KB
/
the game again.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import random
print "What is your name?"
name = raw_input(">>> ")
print "Hello %s." %name
print "Are you ready for the game?"
print '''
Start by typing "Story".
type "Help" for help.
'''
#For normal digging mode.
normal_loot_list = ['Your dog found some silver.',
'Your dog found an ants house.',
'Your dog did not found anything.',
'The ground is very solid to dig.',
'There was nothing.',
'Your dog found a good loot map.',
'Your dog found a worms house.']
#For good Digging mode.
good_loot_list = ['Your dog found some gold.',
'Your dog found a treasure chestt.',
'Your dog found a best loot map.',
'Your dog found a big rock.']
#For the best Digging mode.
best_loot_list = ['']
#To make the random text.
wNear = ['Your dog found A Goblin.\nThe Goblin stool 10$.\n-10$',
'Nothing happined.\nTry again maybe you find a good thing',
'Your dog found a Blackberry tree.\n+20Food.' ]
wMiddle = ['Your dog found a traidor.\nYou can\'t do anything with him yet.',
'Your dog didn\'t found anything.',
'Your dog found a good loot map.',
'Your dog found a 100$ in a bag on the ground.']
wFar = ['Your dog is tired.',
'Your dog found a best loot map.',
'Your dog found a chest full of money and food.']
story = '''
'''
#for helping visitors to understand the game.
help ='''
.___________________________________.
|Event |ID |Description |
|______|____|_______________________|
|Help |0 |To see available events|
|Walk |1 |To move the dog. |
|Dig |2 |For possible loot. |
[______[____]_______________________]
'''
def Help():
print help
def Story():
print story
class dog(object):
Money = 100
Food = 100
good_loot = 0
best_loot = 0
@classmethod
def info(cls):
print '\nMoney = ',dog.Money,' Food = ',dog.Food
if dog.good_loot > 0:
print "%d Good loot map" %dog.good_loot
if dog.best_loot > 0:
print "%d Best loot map" %dog.best_loot
@classmethod
def walk(cls):
walked = random.randrange(2,101,1)
print "Your dog walked %dMetter" %walked
if dog.Food < 10:
dog.Food += 10
dog.Money -= 25
print "+10Food\n-25$"
elif walked < 30:
dog.Food -= 5
res = random.choice(wFar)
print res
if res == wFar[2]:
mf = random.randrange(50,100,5)
dog.Money += mf
dog.Food += mf
print "+%d$" %mf
print "+%dFood" %mf
elif res == wFar[1]:
dog.best_loot += 1
elif walked < 60:
dog.Food -= 5
res = random.choice(wMiddle)
print res
if res == wMiddle[3]:
dog.Money += 100
elif res == wMiddle[2]:
dog.good_loot += 1
elif walked < 100:
dog.Food -= 5
res = random.choice(wNear)
print res
if res == wNear[0]:
dog.Money -= 10
elif res == wNear[2]:
dog.Food += 20
@classmethod
def dig(cls):
if dog.Food > 40:
if dog.good_loot > 0:
dog.Food -= 10
print"you used a good loot map."
dog.good_loot -= 1
res = random.choice(good_loot_list)
print res
if res == good_loot_list[0]:
dog.Money += 50
print"+50$"
elif res == good_loot_list[1]:
terasure = random.randrange(30,100)
dog.Money += treasure
print"+%d$" %treasure
elif res == good_loot_list[2]:
dog.best_loot += 1
elif dog.best_loot > 0:
dog.Food -= 10
print "You used a best loot map."
dog.best_loot -= 1
dog.Money += 100
dog.Food += 100
else:
res = random.choice(normal_loot_list)
print res
if res == normal_loot_list[0]:
dog.Money += 20
print "+20$"
elif res == normal_loot_list[5]:
dog.good_loot += 1
else:
print "Your dog needs more food."
@classmethod
def save(cls):
f = open('MFGB.opp','w')
f.write(str(dog.Money))
f.write("\n")
f.write(str(dog.Food))
f.write("\n")
f.write(str(dog.good_loot))
f.write("\n")
f.write(str(dog.best_loot))
@classmethod
def load(cls):
with open("MFGB.opp", "r") as ins:
loots = []
for line in ins:
loots.append(line)
dog.Money = int(loots[0])
dog.Food = int(loots[1])
dog.good_loot = int(loots[2])
dog.best_loot = int(loots[3])
try:
dog.load()
except:
dog.save()
print help
while True:
dog.save()
dog.info()
comands = raw_input("\n>>> ")
if comands == "Walk":
dog.walk()
elif comands == "Dig":
dog.dig()
elif comands == "Help":
Help()
elif comands == "Info":
dog.info()
elif comands == "Story":
Story()
elif comands == "Save":
dog.save()
elif comands == "Load":
try:
dog.load()
except:
print "Can't load the file."
else:
print "There's no use for %s" %comands