Skip to content

Instantly share code, notes, and snippets.

@syshack
Created May 23, 2012 03:11
Show Gist options
  • Select an option

  • Save syshack/2773054 to your computer and use it in GitHub Desktop.

Select an option

Save syshack/2773054 to your computer and use it in GitHub Desktop.
check fomation
#!/usr/bin/env python
import web
import simplejson as sj
def FomationCheck():
db=web.database(dbn='mysql', host='',db='shdb1', user='', pw='')
jsons = list(db.query("SELECT json FROM Formation"))
for json in jsons:
jsonData=json.json.encode('utf-8')
jsonVar=sj.loads(jsonData)
playerId=jsonVar['playerId']
siteArray=jsonVar['siteArray']
siteList=[]
for i in siteArray:
s=i["site"]
siteList+=str(s)
d={}.fromkeys(siteList).keys()
if len(d)<len(siteList):
print str(playerId)+":Have More than 1 hero in same position"
elif len(siteArray) >5:
print str(playerId) +":Have more than 5 hero"
else:
site=str(siteArray)
if site.find('hero101')==-1 and site.find('hero102')==-1:
print str(playerId)+":Have no Player"
if __name__ =="__main__":
FomationCheck()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment