-
Notifications
You must be signed in to change notification settings - Fork 0
/
openseed_game.py
executable file
·94 lines (86 loc) · 3.14 KB
/
openseed_game.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
#!/usr/bin/python
import sys
sys.path.append("..")
import mysql.connector
#import hive_submit as Submit
import openseed_setup as Settings
settings = Settings.get_settings()
#### These functions will need to be changed to match the current versions. We can move leaderboard to history and use filters to find just highscores based on apps #####
#### Save functions can also be moved to the app_data tables. The main purpose of this area will be for simple servers and other tools that could be a boone to any real time activities
####
def update_leaderboard(devID,appID,user,data):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
scoresearch = openseed.cursor()
search = "SELECT * FROM `history` WHERE `devID` = %s AND `appID` = %s AND `username` = %s AND `data` = %s `type` = '7'"
vals = (str(devID),str(appID),str(user),str(data))
scoresearch.execute(search,vals)
result = len(scoresearch.fetchall())
if result == 0:
sql = "INSERT INTO `history` (`devID`,`appID`,`username`,`data`, `type`) VALUES (%s,%s,%s,%s,'99')"
vals = (str(devID),str(appID),str(user),str(data))
scoresearch.execute(sql,vals)
openseed.commit()
Submit.leaderboard(devID,appID,user,data)
scoresearch.close()
openseed.close()
return "1"
def get_leaderboard(devID,appID):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
scoresearch = openseed.cursor()
output = ""
search = "SELECT username,data FROM `history` WHERE `type` = '7' AND `devID` = '"+str(devID)+"' AND `appID` = '"+str(appID)+"'"
scoresearch.execute(search)
result = scoresearch.fetchall()
for score in result:
output = str(score)+","+output
scoresearch.close()
openseed.close()
return str(output)
def save_game(devID,appID,token,data):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
save = openseed.cursor()
search = "SELECT * FROM `app_data_priv` WHERE `devID` = %s AND `appID` = %s AND `data` = %s"
vals = (str(devID),str(appID),str(user),str(data))
save.execute(search,vals)
result = len(scoresearch.fetchall())
if result == 0:
sql = "INSERT INTO `app_data_priv` (`devID`,`appID`,`data`) VALUES (%s,%s,%s,%s,'299')"
vals = (str(devID),str(appID),str(user),str(data))
save.execute(sql,vals)
openseed.commit()
save.close()
openseed.close()
def get_saved_games(devID,appID,token):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
save = openseed.cursor()
search = "SELECT * FROM `app_data_priv` WHERE `devID` = %s AND `appID` = %s AND `data` = %s"
vals = (str(devID),str(appID),str(user),str(data))
save.execute(search,vals)
result = len(scoresearch.fetchall())
if result == 0:
sql = "INSERT INTO `app_data_priv` (`devID`,`appID`,`data`) VALUES (%s,%s,%s,%s,'299')"
vals = (str(devID),str(appID),str(user),str(data))
save.execute(sql,vals)
openseed.commit()
save.close()
openseed.close()