def matchBattle(randomID, mess, dbi): try: if randomID == '': VirusManager.VirusManager.addError('12000') else: if mess == '': VirusManager.VirusManager.addError('12001') else: mes = mess.split(',') if mes[0] == '': VirusManager.VirusManager().addError('') else: if mes[1] == '': VirusManager.VirusManager.addError('') else: num = dbi.combatmatch.getmaxID() if num == None: idnum = 1 else: idnum = num + 1 dbi.combatmatch.addMatcher(idnum, randomID, mes[0], mes[1]) except Exception as e: VirusManager.VirusManager().addError('12999') VirusManager.VirusManager().addError(e)
def showHero(self): try: cur = dba.dba().excute('select * from hero') for row in cur.fetchall(): return str(row) except Exception as e: VirusManager.VirusManager().addError('22222') VirusManager.VirusManager().addError(e)
def getMaxVersion(self): try: cur = dba.dba().excute('select Max(id) as id FROM filetable') for row in cur.fetchall(): return row[0] except Exception as e: VirusManager.VirusManager().addError('101111') VirusManager.VirusManager().addError(e)
def deleteMatcher(self,randomID): try: if randomID=='': VirusManager.VirusManager().addError('80002') else: cur=dba.dba().excute('delete FROM combatmatch WHERE userRandom='+"'"+randomID+"'") except Exception as e: VirusManager.VirusManager().addError('88888') VirusManager.VirusManager().addError(e)
def deleteUserMap(self,random): try: if random=='': VirusManager.VirusManager().addError('70001') else: cur=dba.dba().excute('delete from usermap where random='+"'"+random+"'") except Exception as e: VirusManager.VirusManager().addError('77777') VirusManager.VirusManager().addError(e)
def deleteHero(self, heroid): try: if heroid == '': VirusManager.VirusManager().addError('50001') else: cur = dba.dba().excute('delete FROM heroconfig WHERE heroID=' + "'" + heroid + "'") except Exception as e: VirusManager.VirusManager().addError('55555') VirusManager.VirusManager().addError(e)
def deleteHero(self, id): try: if id == '': VirusManager.VirusManager().addError('20002') else: cur = dba.dba().excute('delete FROM hero WHERE id=' + "'" + id + "'") except Exception as e: #print('s8') VirusManager.VirusManager().addError('22222') VirusManager.VirusManager().addError(e)
def getUserID(self,random): try: if random=='': VirusManager.VirusManager().addError('70001') else: cur=dba.dba().excute('select userID from usermap where random= '+"'"+random+"'") for row in cur.fetchall(): return row[0] except Exception as e: VirusManager.VirusManager().addError('77777') VirusManager.VirusManager().addError(e)
def deleteSkill(self, skillid): try: if skillid == '': VirusManager.VirusManager().addError('60001') else: cur = dba.dba().excute( 'delete from skillconfig where skillID=' + "'" + skillid + "'") except Exception as e: VirusManager.VirusManager().addError('66666') VirusManager.VirusManager().addError(e)
def getUserID(self,userrandom): try: if userrandom=='': VirusManager.VirusManager().addError('80001') else: cur=dba.dba().excute('select userID from combatmatch WHERE userRandom='+"'"+userrandom+"'") for row in cur.fetchall(): return row[0] except Exception as e: VirusManager.VirusManager().addError('88888') VirusManager.VirusManager().addError(e)
def addHouse(self, houseid): try: if houseid == '': VirusManager.VirusManager().addError('90001') else: cur = dba.dba().excute( "insert into combatnews(houseid,news) VALUE ('" + str(houseid) + "','')") except Exception as e: VirusManager.VirusManager().addError('99999') VirusManager.VirusManager().addError(e)
def getMatcher(self,id): try: if id=='': VirusManager.VirusManager().addError('80001') else: cur=dba.dba().excute('select * from combatmatch where id='+"'"+id+"'") for row in cur.fetchall(): return row[0]+','+row[1]+','+row[2]+','+row[3] except Exception as e: VirusManager.VirusManager().addError('88888') VirusManager.VirusManager().addError(e)
def deleteItem(self, id): try: if id == '': VirusManager.VirusManager().addError('30001') else: #print(userid) cur = dba.dba().excute('delete from item where id=' + "'" + id + "'") except Exception as e: VirusManager.VirusManager().addError('33333') VirusManager.VirusManager().addError(e)
def deleteNews(self, houseid): try: if houseid == '': VirusManager.VirusManager().addError('90001') else: cur = dba.dba().excute( 'delete FROM combatnews WHERE houseID=' + "'" + houseid + "'") except Exception as e: VirusManager.VirusManager().addError('99999') VirusManager.VirusManager().addError(e)
def getUserHero(self, heroid): try: if heroid == '': VirusManager.VirusManager().addError('50001') else: cur = dba.dba().excute( 'select * from heroconfig where heroID=' + "'" + heroid + "'") for row in cur.fetchall(self): return row[0] + ',' + row[1] + ',' + row[2] except Exception as e: VirusManager.VirusManager().addError(e)
def addUserMap(self,random,userid): try: if random=='': VirusManager.VirusManager().addError('70001') else: if userid=='': VirusManager.VirusManager().addError('70002') else: cur=dba.dba().excute("insert into usermap(random,userID) VALUE ('"+str(random)+"','"+str(userid)+"')") except Exception as e: VirusManager.VirusManager().addError('77777') VirusManager.VirusManager().addError(e)
def getFile(self, id): try: if id == '': VirusManager.VirusManager().addError('100000') else: cur = dba.dba().excute('select * from filetable where id=' + "'" + str(id) + "'") for row in cur.fetchall(): return row[1] + '|' + row[2] + '|' + row[3] except Exception as e: VirusManager.VirusManager().addError('101111') VirusManager.VirusManager().addError(e)
def getItemID(self, id): try: if id == '': VirusManager.VirusManager().addError('30001') else: cur = dba.dba().excute('select itemID from item where id=' + "'" + id + "'") for row in cur.fetchall(): return row[0] except Exception as e: VirusManager.VirusManager().addError('33333') VirusManager.VirusManager().addError(e)
def getNews(self, houseid): try: if houseid == '': VirusManager.VirusManager().addError('90001') else: cur = dba.dba().excute( 'select * from combatnews where houseID=' + "'" + houseid + "'") for row in cur.fetchall(): return str(row[1]) except Exception as e: VirusManager.VirusManager().addError('99999') VirusManager.VirusManager().addError(e)
def getUserHero(self, userid): try: if userid == '': VirusManager.VirusManager().addError('20006') else: cur = dba.dba().excute( 'select heroID from hero where userID=' + "'" + userid + "'") for row in cur.fetchall(): return row[0] except Exception as e: VirusManager.VirusManager().addError('22222') VirusManager.VirusManager().addError(e)
def getSkill(self, skillid): try: if skillid == '': VirusManager.VirusManager().addError('60001') else: cur = dba.dba().excute( 'select * from skillconfig where skillID=' + "'" + skillid + "'") for row in cur.fetchall(): return row[1] except Exception as e: VirusManager.VirusManager().addError('66666') VirusManager.VirusManager().addError(e)
def updateItemNumber(self, itemid, itemnumber): try: if itemid == '': VirusManager.VirusManager().addError('30002') else: if itemnumber == '': VirusManager.VirusManager().addError('30003') else: cur = dba.dba().excutecur = dba.dba().excute( 'update item set itemNumber="' + str(itemnumber) + '"where itemID=' + "'" + itemid + "'") except Exception as e: VirusManager.VirusManager().addError('33333') VirusManager.VirusManager().addError(e)
def getSkill(randomID, mess, dbi): try: if randomID == '': VirusManager.VirusManager().addError('') else: if mess == '': VirusManager.VirusManager().addError('') else: userid = dbi.usermap.getUserID(randomID) skill = dbi.hero.getSkill(mess, userid) return '300202' + '|' + skill except Exception as e: VirusManager.VirusManager().addError('') VirusManager.VirusManager().addError(e)
def reSelectSkill(randomID, mess, dbi): try: if randomID == '': VirusManager.VirusManager().addError('') else: if mess == '': VirusManager.VirusManager().addError('') else: userid = dbi.usermap.getUserID(randomID) dbi.hero.updateTalent(userid, '1|1|1') preskill = '0001' + ',' + '0008' + ',' + '0020' return '300102' + '|' + '' + '|' + preskill except Exception as e: VirusManager.VirusManager().addError('') VirusManager.VirusManager().addError(e)
def getMatchRandom(self,num): try: if num=='': VirusManager.VirusManager().addError('') else: cur=dba.dba().excute('select userRandom from combatmatch where playerNumber='+"'"+num+"'") randoms='' i=0 for row in cur.fetchall(): randoms=randoms+row[0]+',' i=i+1 return randoms+'.'+i except Exception as e: VirusManager.VirusManager().addError('88888') VirusManager.VirusManager().addError(e)
def updateHero(self, heroid, heroatt): try: if heroid == '': VirusManager.VirusManager().addError('50001') else: if heroatt == '': VirusManager.VirusManager().addError('50002') else: cur = dba.dba().excute("update heroconfig set heroAtt=" '+str(heroatt)+' " where heroID=" + "'" + heroid + "'") except Exception as e: VirusManager.VirusManager().addError('55555') VirusManager.VirusManager().addError(e)
def sendVersionFile(randomID, mess, dbi): try: if randomID == '': VirusManager.VirusManager().addError('15000') else: if mess == '': VirusManager.VirusManager().addError('15001') else: mes = int(mess) filenews = dbi.filetable.getRealFile(mes) row = dbi.filetable.readFile(mes) file = '200202' + '|' + filenews + '|' + row return file except Exception as e: VirusManager.VirusManager().addError('15999') VirusManager.VirusManager().addError(e)
def readFile(self, id): try: if id == '': VirusManager.VirusManager().addError('100000') else: file = self.getFile(id) fileatt = file.split('|') fg = open(fileatt[1] + fileatt[0] + '.' + fileatt[2], 'r') row = fg.read() return row '''f.read(size)参数size表示读取的数量,如果size省略,则表示读所有的内容 f.readline()读取一行 f.readlines()读取所有的行到数组里面[line1,line2,...lineN]。在避免将所有文件内容加载到内存中。''' except Exception as e: VirusManager.VirusManager().addError('101111') VirusManager.VirusManager().addError(e)
def getmaxID(self): try: cur=dba.dba().excute('select Max(id) as id FROM combatmatch') for row in cur.fetchall(): return row[0] except Exception as e: VirusManager.VirusManager().addError(e)
def addNews(self, houseid, news): houseid = houseid oldNews = self.getNews(houseid) try: if houseid == '': VirusManager.VirusManager().addError('90001') else: if news == '': VirusManager.VirusManager().addError('90002') else: cur = dba.dba().excute('update combatnews set news="' + oldNews + '|' + news + '"where houseID=' + "'" + houseid + "'") except Exception as e: VirusManager.VirusManager().addError('99999') VirusManager.VirusManager().addError(e)