Skip to content

Commit 50ae3a4

Browse files
committed
map test
1 parent a85ac02 commit 50ae3a4

File tree

5 files changed

+125
-0
lines changed

5 files changed

+125
-0
lines changed

getmap.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import MySQLdb
2+
con = MySQLdb.connect(host='223.4.87.9', user='root', passwd='2e4n5k2w2x', db='stcHong')
3+
cursor = con.cursor()
4+
sql = 'select mapid from warMap where mapid != -1 group by mapid'
5+
cursor.execute(sql)
6+
data = cursor.fetchall()
7+
for d in data:
8+
#print d[0]
9+
sql = 'select userid, map_kind from warMap where mapid = ' + str(d[0])
10+
cursor.execute(sql)
11+
res = cursor.fetchall()
12+
mapkind = set()
13+
for r in res:
14+
mapkind.add(r[1])
15+
l = len(mapkind)
16+
if l > 1:
17+
print d[0], l

handlmap.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import json
2+
import MySQLdb
3+
f = file('res2.txt', 'r').read()
4+
d = json.loads(f)
5+
con = MySQLdb.connect(host='223.4.87.9', user='root', passwd='2e4n5k2w2x', db='stcHong')
6+
cursor = con.cursor()
7+
8+
res = {}
9+
for k in d:
10+
sql = 'select userid, map_kind from warMap where mapid = '+k
11+
cursor.execute(sql)
12+
out = cursor.fetchall()
13+
res[k] = []
14+
for r in out:
15+
res[k].append(r)
16+
f = file('res3.txt', 'w')
17+
f.write(json.dumps(res))

mergemap.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import MySQLdb
2+
import json
3+
con = MySQLdb.connect(host="223.4.87.9", user='root', passwd='2e4n5k2w2x', db='stcHong')
4+
cursor = con.cursor()
5+
6+
def exe(sql):
7+
print sql
8+
cursor.execute(sql)
9+
sql = 'select mapid, count(*) from warMap where map_kind = 2 group by mapid'
10+
exe(sql)
11+
data = cursor.fetchall()
12+
13+
mapNum = 60
14+
lastMap = -1
15+
gid = []
16+
usercount = 0
17+
for d in data:
18+
if d[1] < 10:
19+
sql = 'select mapid, count(*) from warMap where mapid = ' + str(d[0])
20+
cursor.execute(sql)
21+
mapinfo = cursor.fetchall()
22+
for m in mapinfo:
23+
print d[0], d[1], m[1]
24+
usercount += d[1]
25+
print usercount
26+
27+
28+
29+

moveMap.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import MySQLdb
2+
import json
3+
con = MySQLdb.connect(host="223.4.87.9", user='root', passwd='2e4n5k2w2x', db='stcHong')
4+
cursor = con.cursor()
5+
6+
sql = 'select mapid, count(*) from warMap where map_kind = 1 group by mapid'
7+
cursor.execute(sql)
8+
allMap = cursor.fetchall()
9+
for aMap in allMap:
10+
if aMap[1] < 10:
11+
sql = 'select userid, map_kind from warMap where mapid = ' + str(aMap[0])
12+
cursor.execute(sql)
13+
data = cursor.fetchall()
14+
maxnob = -1000
15+
notEqual = []
16+
for d in data:
17+
sql = 'select nobility from operationalData where userid = '+str(d[0])
18+
cursor.execute(sql)
19+
res = cursor.fetchall()
20+
if len(res) == 0:
21+
continue
22+
for n in res:
23+
nob = n[0]
24+
if nob > maxnob:
25+
maxnob = nob
26+
if nob != d[1]:
27+
print d[0], nob, d[1]
28+
sql = 'update warMap set map_kind = '+str(nob) +' where userid = ' + str(d[0]) + ' and mapid = ' + str(aMap[0])
29+
print sql
30+
cursor.execute(sql)
31+
print "max", maxnob
32+

newmap.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import MySQLdb
2+
import json
3+
con = MySQLdb.connect(host="223.4.87.9", user='root', passwd='2e4n5k2w2x', db='stcHong')
4+
cursor = con.cursor()
5+
def exe(sql):
6+
print sql
7+
cursor.execute(sql)
8+
mapkind = 0
9+
sql = 'select mapid, count(*) from warMap where map_kind = '+str(mapkind) +' group by mapid'
10+
exe(sql)
11+
data = cursor.fetchall()
12+
13+
gids = 0
14+
total = 30
15+
newmap = 1900
16+
for d in data:
17+
if d[1] < 3:
18+
sql = 'select userid, map_kind from warMap where mapid = ' + str(d[0]) + ' and map_kind = '+str(mapkind)
19+
exe(sql)
20+
seUsers = cursor.fetchall()
21+
for u in seUsers:
22+
sql = 'update warMap set mapid = '+ str(newmap)+', gridid = '+str(gids)+ ' where userid = ' + str(u[0]) + ' and mapid = '+ str(d[0])
23+
exe(sql)
24+
gids += 1
25+
if gids >= total:
26+
break
27+
if gids >= total:
28+
break
29+
30+
con.commit()

0 commit comments

Comments
 (0)