Created
May 23, 2012 03:11
-
-
Save syshack/2773054 to your computer and use it in GitHub Desktop.
check fomation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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