Esempio n. 1
0
def getAllSkill():
    '''初始化技能信息
    #职业技能组
    #技能池
    #技能组
    '''
    global  ALL_SKILL_INFO,SKILL_GROUP,PROFESSION_SKILLGROUP
    sql = "SELECT * FROM tb_skill_info"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    for skill in result:
        effectInfo = getSkillEffectByID(skill['effect'])
        skill['effect'] = effectInfo
        ALL_SKILL_INFO[skill['skillId']] = skill
        if not SKILL_GROUP.has_key(skill['skillGroup']):
            SKILL_GROUP[skill['skillGroup']] = {}
        SKILL_GROUP[skill['skillGroup']][skill['level']] = skill
    #初始化职业技能组ID
    for groupID in SKILL_GROUP:
        skillInfo = SKILL_GROUP[groupID].get(1)
        profession = skillInfo.get('profession',0)
        if not PROFESSION_SKILLGROUP.has_key(profession):
            PROFESSION_SKILLGROUP[profession] = []
        PROFESSION_SKILLGROUP[profession].append(groupID)
Esempio n. 2
0
def getPlayerAllMailList(characterId):
    '''获取角色邮件列表
    @param characterId: int 角色的id
    '''
    filedList = ['id','sender','title','type','isReaded','sendTime']
    sqlstr = ''
    sqlstr = forEachQueryProps(sqlstr, filedList)
    sql = "select %s from `tb_mail` where receiverId = %d  and isSaved = 0\
     order by isReaded ,sendTime desc"%(sqlstr,characterId)
    conn = dbpool.connection()
    cursor = conn.cursor()
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    data = []
    for mail in result:
        mailInfo = {}
        for i in range(len(mail)):
            if filedList[i]=='sendTime':
                mailInfo['sendTime'] = str(mail[i])
            else:
                mailInfo[filedList[i]] = mail[i]
        data.append(mailInfo)
    return data
Esempio n. 3
0
def set_resoult(user_id, count):
    
    tb_user_info = userdataconfig.admin_by_tablename("tb_user_info")
    record_user = userdataconfig.get_user_data(tb_user_info, user_id)
    
    props = {}
    props["money"] = count * 50 + record_user["money"]
    userdataconfig.set_user_value(tb_user_info, user_id, props)
    
    pro = {}
    pro["score"] = count * 20
    
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass = DictCursor)
    resoult = 0
    if user_id:
        sql = u'select * from tb_user_ranking where user_id=%d' % (user_id)
        cursor.execute(sql)
        resoult = cursor.fetchone()

    cursor.close()
    conn.close()
    
    tb_user_ranking = userdataconfig.admin_by_tablename("tb_user_ranking")
    index = resoult["index"]
    record_ranking = userdataconfig.get_user_data(tb_user_ranking, index)
    userdataconfig.set_user_value(tb_user_ranking, index, pro)
    
    return userdataconfig.get_user_data(tb_user_info, user_id)
Esempio n. 4
0
def creatNewCharacter(nickname ,profession ,userId,sex=1):
    '''创建新的角色
    @param nickname: str 角色的昵称
    @param profession: int 角色的职业编号
    @param userId: int 用户的id
    @param fieldname: str 用户角色关系表中的字段名,表示用户的第几个角色
    '''
    nowdatetime = str(datetime.datetime.today())
    sql = "insert into `tb_character`(nickName,profession,sex,createtime) \
    values('%s',%d,%d,'%s')"%(nickname ,profession,sex,nowdatetime)
    sql2 = "SELECT @@IDENTITY"
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.execute(sql2)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    if result and count:
        characterId = result[0]
        InsertUserCharacter(userId,characterId)
        return characterId
    else:
        return 0
Esempio n. 5
0
def getDayRecordList(index,limit = 10):
    """获取每日的记录
    """
    sql ="SELECT * FROM tb_statistics ORDER BY recorddate DESC LIMIT %s,%s;"%((index-1)*limit,index*limit)
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    recordlist = []
    for daterecord in result:
        recorddate = daterecord['recorddate']
        IncomeInfo = getIncomeByDate(recorddate)
        info = daterecord
        info['f_arpu'] = 0 if not IncomeInfo['cnt'] else IncomeInfo['goal']/IncomeInfo['cnt']
        info['z_arpu'] = 0 if not info['createrole'] else IncomeInfo['goal']/info['createrole']
        info['pay_rate'] = 0 if not info['loginuser'] else IncomeInfo['cnt']*100/info['loginuser']
        info['r_rate'] = 0 if not info['createrole'] else info['loginuser']*100/info['createrole']
        info['recorddate'] = str(info['recorddate'])
        info['pay_cnt'] = IncomeInfo['cnt']
        info['pay_goal'] = IncomeInfo['goal']
        info.update(getDayConsume(recorddate))
        recordlist.append(info)
    return recordlist
Esempio n. 6
0
def getShopInfo(shopcategory):
	sql="select * from tb_shop where shopcategory=%d and begintime<now() and endtime>now()"%(shopcategory)
	conn=dbpool.connection()
	cursor=conn.cursor(cursorclass=DictCursor)
	cursor.execute(sql)
	result=cursor.fetchall()
	cursor.close()
	conn.close()
	return result
Esempio n. 7
0
def getPlayerFriMailCnd(characterId):
    '''获取角色玩家邮件的数量'''
    sql = "SELECT COUNT(id) FROM tb_mail WHERE receiverId = %d AND `type`=1  and isSaved = 0"%characterId
    conn = dbpool.connection()
    cursor = conn.cursor()
    cursor.execute(sql)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    return result[0]
Esempio n. 8
0
def getMailInfo(mailId):
    '''获取邮件详细信息'''
    sql = "select * from `tb_mail` where id = %d"%(mailId)
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    return result
Esempio n. 9
0
def CheckUserInfo(Uid):
    '''检测用户信息'''
    sql = "SELECT * from tb_register where username = '******'"%Uid
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    return result
Esempio n. 10
0
def getGamerSysMailCnd(characterId):
	'''获取角色系统邮件数量'''
	sql="SELECT COUNT(id) FROM tb_mail WHERE receiverId=%d and `type`=0 and isSaved=0"%characterId
	conn=dbpool.connection()
	cursor=conn.cursor()
	cursor.execute(sql)
	result=cursor.fetchone()
	cursor.close()
	conn.close()
	return result[0]
Esempio n. 11
0
def getGamerAllMailCnd(characterId):
	'''获取玩家所有邮件的数量'''
	sql="SELECT COUNT(`id`) FROM tb_mail WHERE receiverId=%d and isSaved =0"%characterId
	conn=dbpool.connection()
	cursor=conn.cursor()
	cursor.execute(sql)
	result=cursor.fetchone()
	cursor.close()
	conn.close()
	return result[0]
Esempio n. 12
0
def getTrainbaseInfo(characterId):
	'''获取玩家训练基地信息'''
	sql="SELECT * FROM tb_character_trainbase where characterId=%s"%characterId
	conn=dbpool.connection()
	cursor=conn.cursor(cursorclass=DictCursor)
	cursor.execute(sql)
	result=cursor.fetchone()
	cursor.close()
	conn.close()
	return result
Esempio n. 13
0
def getGamerSavMailCnd(characterId):
	'''获取保存邮件的数量'''
	sql="SELECT COUNT(id) FROM tb_mail where receiverId=%d and `isSaved`=1"%characterId
	conn=dbpool.connection()
	cursor=conn.cursor()
	cursor.execute(sql)
	result=cursor.fetchone()
	cursor.close()
	conn.close()
	return result[0]
Esempio n. 14
0
def getAll_ShieldWord():
    global SHIELDWORD
    sql = "SELECT sword FROM tb_shieldword;"
    conn = dbpool.connection()
    cursor = conn.cursor()
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    SHIELDWORD = result
Esempio n. 15
0
def getAllProcessInfo(characterId):
	'''获取所有的在进行中的任务列表'''
	sql="SELECT * FROM tb_task_process WHERE characterId=%d"%characterId
	conn=dbpool.connection()
	cursor=conn.cursor(cursorclass=DictCursor)
	cursor.execute(sql)
	result=cursor.fetchall()
	cursor.close()
	conn.close()
	return result
Esempio n. 16
0
def getBuffEffect(buffEffectID):
    '''获取buff效果'''
    sql = "SELECT * FROM tb_buff_effect where buffEffectID = %d"%buffEffectID
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result=cursor.fetchone()
    cursor.close()
    conn.close()
    return result
Esempio n. 17
0
def getSkillEffectByID(skillEffectID):
    '''获取技能效果ID'''
    sql = "SELECT * FROM tb_skill_effect where effectId=%d"%skillEffectID
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result=cursor.fetchone()
    cursor.close()
    conn.close()
    return result
Esempio n. 18
0
def addMail(title,senderId,sender,receiverId,content,mailtype):
	'''添加邮件'''
	sql="INSERT INTO tb_mail(title,senderId,sender,receiverId,`type`,content,sendTime) VALUES ('%s',%d,'%s',%d,%d,'%s',CURRENT_TIMESTAMP())"%(title,senderId,sender,receiverId,mailtype,content)
	conn=dbpool.connection()
	cursor=conn.cursor()
	count=cursor.execute(sql)
	conn.commit()
	cursor.close()
	if(count>=1):
		return True
	return False
Esempio n. 19
0
def getCharacterPetList(character_id):
    """获取角色的宠物列表
    """
    sql = "SELECT `id` FROM  `tb_pet` WHERE `owner` = %d;"%character_id
    conn = dbpool.connection()
    cursor = conn.cursor()
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    return [_pinfo[0] for _pinfo in result]
Esempio n. 20
0
def getALLTask():
	'''获取所有任务'''
	sql="SELECT * FROM tb_task where enable=1"
	conn=dbpool.connection()
	cursor=conn.cursor(cursorclass=DictCursor)
	cursor.execute(sql)
	result=cursor.fetchall()
	cursor.close()
	conn.close()
	for taskInfo in result:
		all_TaskTemplate[taskInfo['taskId']]=taskInfo
Esempio n. 21
0
def deleteMail(mailId):
	'''删除邮件'''
	sql="DELETE FROM tb_mail WHERE id=%d"%mailId
	conn=dbpool.connection()
	cursor=conn.cursor()
	count=cursor.execute(sql)
	conn.commit()
	cursor.close()
	if(count>=1):
		return True
	return False
Esempio n. 22
0
def getCharacterInfoByUserId(userId):
	'''
	'''
	sql="select * from tb_character where userid=%d"%(userId)
	conn=dbpool.connection()
	cursor=conn.cursor(cursorclass=DictCursor)
	cursor.execute(sql)
	result=cursor.fetchone()
	cursor.close()
	conn.close()
	return result
Esempio n. 23
0
def getAllCharacterIdList():
    """获取所有角色的id列表
    """
    sql = "SELECT `id` FROM  `tb_character`;"
    conn = dbpool.connection()
    cursor = conn.cursor()
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    return [_cinfo[0] for _cinfo in result]
Esempio n. 24
0
def getVIPExp():
    global VIPEXP
    sql = "SELECT * FROM tb_vipexp"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result=cursor.fetchall()
    cursor.close()
    conn.close()
    for vipp in result:
        VIPEXP[vipp['viplevel']] = vipp['maxexp']
Esempio n. 25
0
def getIncomByData(onedata):
	'''获取每天的缴费情况'''
	sql="SELECT SUM(rmb) AS goal,COUNT(DISTINCT uid) AS cnt FROM tb_recharge WHERE DATE(rtime)=DATE('%s') and boo=1;"%onedata
	conn=dbpool.connection()
	cursor=conn.cursor(cursorclass=DictCursor)
	cursor.execute(sql)
	result=cursor.fetchone()
	cursor.close()
	conn.close()
	result['goal']=float(result.get('goal')) if result.get('goal') else 0
	return result
Esempio n. 26
0
def getPetExp():
    '''获取宠物的经验表'''
    global PET_EXP
    sql = "SELECT * FROM tb_pet_experience"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    for exp in result:
        PET_EXP[exp['level']] = exp['ExpRequired']
Esempio n. 27
0
def getAllsetInfo():
	'''获取所有的套装信息'''
	global ALL_SETINFO
	sql="SELECT * from tb_equipmentset;"
	conn=dbpool.connection()
	cursor=conn.cursor(cursorclass=DictCursor)
	cursor.execute(sql)
	result=cursor.fetchall()
	cursor.close()
	conn.close()
	for setinfo in result:
		ALL_SETINFO[setinfo['id']]=setinfo
Esempio n. 28
0
def getProfession_Config():
    '''获取职业配置表信息'''
    global tb_Profession_Config
    sql = "select * from tb_profession"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    for _item in result:
        tb_Profession_Config[_item['preId']] = _item
Esempio n. 29
0
def getUserCharacterInfo(characterId):
    '''获取用户角色列表的所需信息
    @param id: int 用户的id
    '''
    sql = "select town from tb_character where id = %d"%(characterId)
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    return result
Esempio n. 30
0
def getByid(characterId):
	'''根据角色id获取寻找球员信息'''
	sql="SELECT * FROM tb_player_inner where characterId=%s"%characterId
	conn=dbpool.connection()
	cursor=conn.cursor(cursorclass=DictCursor)
	cursor.execute(sql)
	result=cursor.fetchone()
	cursor.close()
	conn.close()
	if result:
		return result
	return None
Esempio n. 31
0
def setfubenInfo(cid, info):
    '''根据任务ID角色设置的日常任务完成度

    '''
    sql = "update `tb_zhanyi_record` set zhanyi = '%d' where characterId = '%d'" % (
        info, cid)
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    else:
        return False
Esempio n. 32
0
def getAllBuffInfo():
    '''获取所有技能的信息'''
    global ALL_BUFF_INFO
    sql = "SELECT * FROM tb_buff_info"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    for buff in result:
        ALL_BUFF_INFO[buff['buffId']] = buff  # 根据buff技能信息id 获得 buff技能信息
        effectInfo = getBuffEffect(
            buff['buffEffectID'])  # 根据buff效果id 获得 buff效果
        ALL_BUFF_INFO[buff['buffId']][
            'buffEffects'] = effectInfo  # 二维字典为 buffId + 常量'buffEffects' 获得 buff效果
Esempio n. 33
0
def getBuffAddition():
    '''获取buff对技能的加成
    '''
    global BUFF_SKILL
    sql = "SELECT * FROM tb_buff_skill"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    for addition in result:
        if not BUFF_SKILL.has_key(addition['buffId']):
            BUFF_SKILL[addition['buffId']] = {}
        BUFF_SKILL[addition['buffId']][
            addition['skillId']] = addition['addition']
Esempio n. 34
0
def updateFriendTop(characterid,friendsid,readersid):
	'''修改最近联系人
	@param characterid:int 当前角色id
	@param friendsid:str 最近联系人角色id列表
	@param readersid:str 未读取的信息发送者角色id
	'''
	sql="update tb_friend_chat set friendsid="+friendsid+",reader="+readersid+"where characterid="+str(characterid)
	conn=dbpool.connection()
	cursor=conn.cursor()
	count=cursor.execute(sql)
	conn.commit()
	cursor.close()
	conn.close()
	if count>=1:
		return True
	return False
Esempio n. 35
0
def setlogintime(id):
    '''设置登录时间
    @param loginsign
    '''
    sql = "update `tb_character` set logintime = now()  where id ='%d'"%(id)
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    else:
        log.err(sql)
        return False
Esempio n. 36
0
def getAll():
    '''获取所有翻译信息'''
    # id content(内容) txt(中文) typeid
    sql = "SELECT * FROM tb_language"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    if not result:
        return None
    data = {}
    for item in result:
        data[item['id']] = item['content']
    return data
Esempio n. 37
0
def getAllZhangJieInfo():
    '''获取章节的信息
    '''
    global ALL_ZHANGJIE_INFO, ALL_ZHANGJIE_GROP
    sql = "SELECT * FROM tb_zhangjie"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    for zhangjie in result:
        ALL_ZHANGJIE_INFO[zhangjie['id']] = zhangjie
        if not ALL_ZHANGJIE_GROP.get(zhangjie['yid']):
            ALL_ZHANGJIE_GROP[zhangjie['yid']] = []
        ALL_ZHANGJIE_GROP[zhangjie['yid']].append(zhangjie['id'])
Esempio n. 38
0
def deletePlayerFriend(characterId, friendId):
    '''删除角色好友
    @param friendId: int 好友编号
    '''
    # 要根据 characterId 和 friendId 删除
    sql = 'delete from `tb_friend` where characterId=%d friendId = %d' % (
        characterId, friendId)
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    return False
Esempio n. 39
0
def getAllLevelMail():
    '''获取所有的等级邮件提示
	'''
    global LEVEL_MAIL
    sql = "SELECT * FROM tb_levelmail"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    sceneInfo = {}
    for scene in result:
        sceneInfo[scene['level']] = scene
    LEVEL_MAIL = sceneInfo
    return sceneInfo
Esempio n. 40
0
def checkMail(mailId, characterId):
    '''检测邮件是否属于characterId
	@param characterId:int 角色的id
	@param mailId:int 邮件的id
	'''
    sql = "SELECT `id` from tb_mail WHERE id=%d and receiverId=%d" % (
        mailId, characterId)
    conn = dbpool.connection()
    cursor = conn.cursor()
    cursor.execute(sql)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    if result:
        return True
    return False
Esempio n. 41
0
def getUserInfoByUsername(username, password):
    '''获取用户信息
    @param username: str 用户的用户名
    @param password: str 用户密码
    '''
    # id(用户id), username, password, email, characterId(用户的角色id), pid(邀请人的角色id),
    # lastonline(最后在线时间), logintimes(登陆次数), enable(是否可以登录)
    sql = "select * from `tb_register` where username = '******'\
     and password = '******'" % (username, password)
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    return result
Esempio n. 42
0
def getIncomeByDate(onedate):
    """获取某天的缴费情况
    """
    # id, uid, rbm人民币, zuan充值钻, serviceid服务器id, lyid联运商id,
    # rtime充值时间, orderid订单id, boo充值是否成功
    # SUM(rbm)  人民币总数
    # COUNT(DISTINCT uid)  充值次数
    sql = "SELECT SUM(rbm) AS goal,COUNT(DISTINCT uid) AS cnt\
    FROM tb_recharge WHERE DATE(rtime)=DATE('%s') and boo=1;"%onedate
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    result['goal'] = float(result.get('goal')) if result.get('goal') else 0
    return result
Esempio n. 43
0
def updatePlayerDB(player):
    '''更新角色的数据库信息'''
    characterId = player.baseInfo.id
    props = {'level':player.level.getLevel(),'coin':player.finance.getCoin(),'gold':player.finance.getGold(),
             'exp':player.level.getExp(),'nickname':player.baseInfo.getNickName()}
    sqlstr = util.forEachUpdateProps('tb_character',props, {'id':characterId})
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sqlstr)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    else:
        log.err(sqlstr)
        return False
Esempio n. 44
0
def checkUserPassword(username, password):
    '''检测用户名户密码
    @param username: str 用户的用户名
    @param password: str 用户密码
    '''
    sql = "select id from `tb_register` where username = '******' and password = '******'" % (
        username, password)
    conn = dbpool.connection()
    cursor = conn.cursor()
    cursor.execute(sql)
    result = cursor.fetchone()
    cursor.close()
    conn.close()
    pid = 0
    if result:
        pid = result[0]
    return pid
Esempio n. 45
0
def getCharacterRivalList(ranklist):
    '''获取角色的对手列表
    '''
    orsql = forEachSelectORByList('b.ranking', ranklist)
    if orsql:
        sql = "SELECT b.characterId,b.ranking,\
        a.nickname,a.level,a.profession from tb_character as a,\
        tb_arena as b where a.id=b.characterId and (%s) order by `ranking`;"%(orsql)
    else:
        return []
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    return result
Esempio n. 46
0
def addGuyongRecord(characterId, rolename, zyname, zyid, bresult, coinbound,
                    huoli):
    '''添加雇用记录
    '''
    sql = "INSERT INTO tb_guyong_record (characterId,\
    chaname,zyname,zyid,battleresult,coinbound,huoli) VALUES \
    (%d,'%s','%s',%d,%d,%d,%d)"                               %((characterId,rolename,zyname,\
                                  zyid,bresult,coinbound,huoli))
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    return False
Esempio n. 47
0
def getAllPetGrowthConfig():
    '''获取宠物成长配置
    '''
    global PET_GROWTH
    sql = "SELECT * FROM tb_pet_growth"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    for growthconfig in result:
        attrType = growthconfig['pettype']
        quality = growthconfig['quality']
        if not PET_GROWTH.has_key(attrType):
            PET_GROWTH[attrType] = {}
        PET_GROWTH[attrType][quality] = growthconfig
Esempio n. 48
0
def updatePlayerDB(player):
    '''更新角色的数据库信息'''
    characterId = player.baseInfo.id
    props = {'level': 0, 'coin': 0, 'exp': 0, 'hp': 0}
    sqlstr = util.forEachUpdateProps('tb_character', props,
                                     {'id': characterId})
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sqlstr)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    else:
        log.err(sqlstr)
        return False
Esempio n. 49
0
def updateUserCharacter(userId, filename, characterId):
    '''
	@param userId
	@param filename:str
	@param characterId:int
	'''
    sql = "update `tb_user_character` set %s=%d where id=%d" % (
        filename, characterId, userId)
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    else:
        return False
Esempio n. 50
0
def getGuYongList(pid):
    '''获取角色的所有好友或者黑名单
    @param pid: int 角色id
    '''
    sql = "SELECT playerId FROM tb_friend WHERE characterId=%s AND guyong=1" % (
        pid)
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    if not result:
        return []
    listdata = []
    for item in result:
        listdata.append(item['playerId'])
    return listdata
Esempio n. 51
0
def getCharacterArenaInfo(characterId):
    '''获取角色竞技场信息
    @param characterId: int 角色的ID
    '''
    sql = "SELECT * FROM tb_arena where characterId =%d"%characterId
    conn = dbpool.connection()  # 连接数据库
    cursor = conn.cursor(cursorclass=DictCursor)  # 设置游标
    cursor.execute(sql)  # 执行 sql 语句
    result = cursor.fetchone()  # 获取一条数据
    cursor.close()  # 游标关闭
    conn.close()  # 连接关闭
    if not result:  # 查找失败...
        insertCharacterArenaInfo(characterId)  # 插入角色竞技场信息
        result = {'characterId':characterId,'score':0,'liansheng':0,
                  'lastresult':0,'lasttime':datetime.datetime(2012,6,20,12),
                  'ranking':0,'surplustimes':15,'buytimes':0,'receive':0,
                  'recorddate':datetime.date.today()}
    return result  
Esempio n. 52
0
def addFriend(characterId, playerId, friendType, isSheildedMail=0):
    '''添加一个好友
    @param characterId: int 角色的id
    @param playerId: int 好友的id
    @param friendType: int(1,2) 好友的类型 1:好友  2:仇敌
    @param isSheildedMail:int 是否屏蔽邮件 0.不屏蔽邮件 1.屏蔽
    '''
    sql = "insert into `tb_friend`(characterId,playerId,friendType,isSheildedMail)\
     values(%d,%d,%d,%d)" % (characterId, playerId, friendType, isSheildedMail)
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    return False
Esempio n. 53
0
def getFriendTopLevel(characterId, index, limit=20):
    '''获取好友的等级排行
    WHERE `id`!=%d ORDER BY level LIMIT %d,%d
    首先`id`!=%d 表示不能是自己
    然后ORDER BY 默认根据升序排名 asc(升序) 或desc(降序)
    最后LIMIT %d,%d 第一个参数是offset(偏移量),第二个参数是rows(行数)
    即查找 level在 offset ~ offset + rows 之间的好友
    '''
    sql = "SELECT id,nickname,level,coin \
    FROM tb_character WHERE `id`!=%d ORDER BY level LIMIT %d,%d;" % (
        characterId, index, limit)
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    return result
Esempio n. 54
0
def updateUserCharacter(userId, fieldname, characterId):
    '''更新用户角色关系表
    @param userId: 用户的id
    @param fieldname: str 用户角色关系表中的字段名,表示用户的第几个角色
    @param characterId: int 角色的id
    '''
    sql = "update `tb_user_character` set %s = %d where id = %d" % (
        fieldname, characterId, userId)
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    else:
        return False
Esempio n. 55
0
def getStatistics():
	'''获取单服总数据'''
	sql1="SELECT COUNT(id) FROM tb_register;"
	sql2="SELECT COUNT(id) FROM tb_character;"
	sql3="SELECT COUNT(DISTINCT uid) FROM tb_recharge WHERE boo=1;"
	sql4="SELECT SUM(rmb) FROM tb_recharge WHERE boo=1;"
	conn=dbpool.connection()
	cursor=conn.cursor()
	cursor.execute(sql1)
	result1=cursor.fetchone()[0]
	cursor.execute(sql2)
	result2=cursor.fetchone()[0]
	cursor.execute(sql3)
	result3=cursor.fetchone()[0]
	cursor.execute(sql4)
	result4=cursor.fetchone()[0]
	cursor.close()
	conn.close()
	return {'reg_cnt':0 if not result1 else result1,'role_cnt':0 if not result2 else result2,'fu_cnt':0 if not result3 else result3,'income':0.0 if not result4 else float(result4)}
Esempio n. 56
0
def getFirendListByFlg(pid, flg):
    '''获取角色的所有好友或者黑名单
    @param pid: int 角色id
    @param flg: int 1好友   2黑名单 
    '''
    sql = "SELECT playerId FROM tb_friend WHERE characterId=%s AND friendType=%s" % (
        pid, flg)
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    if not result:
        return []
    listdata = []
    for item in result:
        listdata.append(item['playerId'])
    return listdata
Esempio n. 57
0
def getAll():
    '''获取所有掉落信息'''
    global DROPOUT_CONFIG
    sql = "select * from tb_dropout"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    if not result:
        return None
    for item in result:
        # id 表示 怪物的id, itemid 表示对应怪物掉落物品的几种可能
        # id = 1 => itemid = [53000001,1,99999],[53000002,1,99999],[53000003,1,99999],[54000006,1,99999],[54000007,1,99999],[54000008,1,99999],[10150001,1,99999]
        # 上面为第一列itemid的数据,表示 [物品id, 数量, 概率(基数100000)]
        item['itemid'] = eval("[" + item['itemid'] +
                              "]")  # eval 可以执行一条语句,将上面几个列表合并
        DROPOUT_CONFIG[item['id']] = item
Esempio n. 58
0
def updateUserCharacter(userId, fieldname, characterId):
    '''更新用户角色关系表
    @param userId: 用户的id
    @param fieldname: str 用户角色关系表中的字段名,表示用户的第几个角色
    @param characterId: int 角色的id
    '''
    # id, [character_1, character_2, character_3, character_4, character_5]五个字段,应该是最多可以创建5个角色
    # pid(邀请人id), last_character(最后登录的角色)
    sql = "update `tb_user_character` set %s = %d where id = %d" % (
        fieldname, characterId, userId)
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    else:
        return False
Esempio n. 59
0
def updatePlayerDB(player):
    '''更新角色的数据库任务完成信息'''
    characterId = player.baseInfo.id
    props = {
        'ifcompleted': player.level.getLevel(),
        'ifrewarded': player.finance.getCoin()
    }
    sqlstr = util.forEachUpdateProps('tb_task_completed', props,
                                     {'id': characterId})
    conn = dbpool.connection()
    cursor = conn.cursor()
    count = cursor.execute(sqlstr)
    conn.commit()
    cursor.close()
    conn.close()
    if count >= 1:
        return True
    else:
        log.err(sqlstr)
        return False
Esempio n. 60
0
def getBuffOffsetInfo():
    '''获取所有buff之间效果的信息配置
    buffId  buff
    tbuffId  能与之产生效果的buff
    nbuffId  新产生的buff
    nstack  新产生的buff的层叠数
    effect  产生效果后生产的效果
    '''
    global BUFF_BUFF
    sql = "SELECT * FROM tb_buff_buff"
    conn = dbpool.connection()
    cursor = conn.cursor(cursorclass=DictCursor)
    cursor.execute(sql)
    result = cursor.fetchall()
    cursor.close()
    conn.close()
    for offset in result:
        if not BUFF_BUFF.has_key(offset['buffId']):  # 还没有key
            BUFF_BUFF[offset['buffId']] = {}  # 初始化一个
        BUFF_BUFF[offset['buffId']][
            offset['tbuffId']] = offset  # 二维字典  value是 一个列表