forked from OlympicCode/vHackOSBot-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.py
More file actions
66 lines (57 loc) · 3.1 KB
/
update.py
File metadata and controls
66 lines (57 loc) · 3.1 KB
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
from utils import Utils
from player import Player
import os, time, random
class Update():
def __init__(self, ut):
self.ut = ut
self.Configuration = self.ut.readConfiguration()
self.store = self.ut.requestString("store.php",
accesstoken=self.Configuration["accessToken"])
self.startFunctionUpdate()
def startFunctionUpdate(self):
# get money info
if "money" in self.store and "apps" in self.store:
money = int(self.store["money"])
apps = self.store["apps"]
else:
apps = []
money = 0
p = Player(self.ut)
getTask = self.ut.requestString("tasks.php", accesstoken=self.Configuration["accessToken"])
if 'updateCount' in getTask.keys():
update = int(getTask['updateCount'])
else:
update = 0
# get applications and update this
for count_update, applications in enumerate(apps):
# update application
if (count_update+update) < 9:
Appid = int(applications["appid"])
random.shuffle(self.Configuration["update"])
for list_update in self.Configuration["update"]:
time.sleep(0.3)
application_update = int(p.getHelperApplication()[list_update]["appid"])
if money >= int(applications["price"]):
result = self.ut.requestString("store.php",
accesstoken=self.Configuration["accessToken"],
appcode=application_update,
action="100")
money = money - int(applications["price"])
if result['result'] == '0':
update = update+1
self.ut.viewsPrint("showMsgUpdate", "[{}] - Updated {} +1".format(os.path.basename(__file__), list_update))
time.sleep(0.5)
else:
self.ut.viewsPrint("showMsgUpdate", "[{}] - you have not money to upgrade {}".format(os.path.basename(__file__), list_update))
time.sleep(0.5)
else:
self.ut.viewsPrint("showMsgUpdatefull", "[{}] - full task list, please wait.".format(os.path.basename(__file__)))
time.sleep(0.5)
# install application if level required < level
if int(applications["require"]) <= int(self.store["level"]) and int(applications["level"]) == 0:
result = self.ut.requestString("store.php",
accesstoken=self.Configuration["accessToken"],
appcode=applications["appid"],
action="200")
self.ut.viewsPrint("showMsgInstalleApp", "[{}] - Installed new application.".format(os.path.basename(__file__)))
break