Example #1
0
 def _moveHall51DataBack(self, userId, gameId, clientId):
     try:
         flag = DaoGameDataHall.HGET(userId, 'userChipMoveGame')
         ftlog.info('_moveHall51DataBack', userId, gameId, flag)
         if flag > 0:
             # 当前用户登录过HALL51
             chip, exp, charm, coupon = DaoGameDataHall.HMGET(
                 userId, ['chip', 'exp', 'charm', 'coupon'])
             chip, exp, charm, coupon = ftstr.parseInts(
                 chip, exp, charm, coupon)
             ftlog.info('_moveHall51DataBack data->', userId, gameId, chip,
                        exp, charm, coupon)
             if charm > 0:
                 self.incrCharm(userId, charm)
             if exp > 0:
                 self.incrExp(userId, exp)
             if coupon > 0:
                 trueDelta, finalCount = self.incrCoupon(
                     userId, gameId, coupon, ChipNotEnoughOpMode.NOOP,
                     'SYSTEM_REPAIR', 0)
                 ftlog.info('_moveHall51DataBack data coupon->', userId,
                            gameId, coupon, trueDelta, finalCount)
             if chip > 0:
                 trueDelta, finalCount = self.incrChip(
                     userId, gameId, chip, ChipNotEnoughOpMode.NOOP,
                     'SYSTEM_REPAIR', 0)
                 ftlog.info('_moveHall51DataBack data chip->', userId,
                            gameId, chip, trueDelta, finalCount)
             DaoGameDataHall.HDEL(
                 userId,
                 ['chip', 'exp', 'charm', 'coupon', 'userChipMoveGame'])
             pluginCross.halldatanotify.sendDataChangeNotify(
                 userId, gameId, 'chip')
     except:
         ftlog.error()
Example #2
0
 def destoryPlugin(self):
     '''
     当插件被动态卸载时,执行此方法,进行清理工作
     '''
     DaoUserData.finalize()
     DaoGameDataHall.finalize()
     DaoTableChip.finalize()
Example #3
0
 def getHallDataList(self, userId, keys):
     """
     取得用户的大厅数据内容(即游戏gamedata:9999:<userId>存储的数据内容)
     @param userId: 用户ID
     @param keys: 数据字段列表,如果为空,则获取所有信息, 请使用HallKeys中定义的KEY值
     """
     if isinstance(keys, (str, unicode)):
         ret = DaoGameDataHall.HGET(userId, keys)
     else:
         ret = DaoGameDataHall.HMGET(userId, keys)
     return ret
Example #4
0
 def onHallUserEventLogin(self, event):
     # 记录上线时间
     ct = fttime.formatTimeMs()
     DaoGameDataHall.HMSET(event.userId, {
         HallKeys.ATT_ALIVE_TIME: ct,
         HallKeys.ATT_AUTHOR_TIME: ct
     })
     # 登录天数加1
     if event.isDayfirst:
         DaoGameDataHall.HINCRBY(event.userId, HallKeys.ATT_LOGIN_DAYS, 1)
     # 登录次数加1
     DaoGameDataHall.HINCRBY(event.userId, HallKeys.ATT_LOGIN_SUM, 1)
Example #5
0
 def on_user_logout(self, event):
     # 记录下线时间
     ct = fttime.formatTimeMs()
     DaoGameDataHall.HMSET(event.userId, {
         HallKeys.ATT_ALIVE_TIME: ct,
         HallKeys.ATT_OFFLINE_TIME: ct
     })
Example #6
0
 def incrPlayTime(self, userId, detalTime, gameId, roomId, tableId):
     """
     各个游戏向大厅汇报玩家的游戏时长
     """
     DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_TOTAL_TIME, detalTime)
     datas = DaoGameDataHall.HGET(userId, HallKeys.ATT_TODAY_TIME)
     today = datetime.now().strftime('%Y%m%d')[-6:]
     if today in datas:
         datas[today] += detalTime
     else:
         datas[today] = detalTime
     oldday = (datetime.now() - timedelta(days=7)).strftime('%Y%m%d')[-6:]
     for k in datas.keys()[:]:
         if k < oldday:
             del datas[k]
     DaoGameDataHall.HSET(userId, HallKeys.ATT_TODAY_TIME, datas)
     return 1
Example #7
0
 def saveVipGiftStatus(self, userId, vipGiftStatus):
     '''
     保存用户VIP礼包状态
     @param userId: 哪个用户
     @param vipGiftStatus: 用户VIP礼包状态
     '''
     return DaoGameDataHall.HSET(userId, HallKeys.ATT_VIP_GIFT_STATES,
                                 vipGiftStatus)
Example #8
0
 def incrVipExp(self, userId, count):
     '''
     给用户增加count个经验值,count可以为负数
     @param userId: 哪个用户
     @param count: 数量
     @return: 变化后的值
     '''
     return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_VIP_EXP, count)
Example #9
0
 def doBindUser(self, userId, gameId, intClientId):
     '''
     用户TCP连接建立,绑定用户,检查并建立用户的主游戏基础数据,并返回是否是新用户
     '''
     self._moveHall51DataBack(userId, gameId, intClientId)
     ret = DaoGameDataHall.checkAndInit(userId)
     if ret:
         tybireport.reportGameEvent('CREATE_GAME_DATA', userId, gameId, 0,
                                    0, 0, 0, 0, 0, [], intClientId, 0, 0)
     return ret
Example #10
0
 def setBiggestHallVersion(self, userId, version):
     return DaoGameDataHall.HSET(userId, HallKeys.ATT_BIGGEST_HALL5_VERSION,
                                 version)
Example #11
0
 def setReliefShareDate(self, userId, timestamp):
     '''
     '''
     return DaoGameDataHall.HSET(userId, HallKeys.ATT_RELIEF_SHARE_DATE,
                                 timestamp)
Example #12
0
 def setLoginBeforeVersion511flag(self, userId):
     return DaoGameDataHall.HSET(userId,
                                 HallKeys.ATT_LOGIN_BEFORE_VERSION_TO_511,
                                 1)
Example #13
0
 def getBiggestHallVersion(self, userId):
     """
     取得用户登录过的最高客户端版本
     """
     return DaoGameDataHall.HGET(userId, HallKeys.ATT_BIGGEST_HALL5_VERSION)
Example #14
0
 def roulette_soldier_reward(self, userId):
     return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_GET_REWARD_NUM, 1)
Example #15
0
 def setBeneFitsInfo(self, userId, datas):
     '''
     '''
     return DaoGameDataHall.HSET(userId, HallKeys.ATT_BENEFITS, datas)
Example #16
0
 def first_gold_roulette(self, userId):
     return DaoGameDataHall.HSETNX(userId, HallKeys.ATT_FIRST_GOLD_ROULETTE,
                                   1)
Example #17
0
 def _setDataValue(self, userId, attName, attValue):
     return DaoGameDataHall.HSET(userId, attName, attValue)
Example #18
0
 def incrLoginDays(self, userId, deltaCount):
     return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_LOGIN_DAYS,
                                    deltaCount)
Example #19
0
 def incrSetNameSum(self, userId, detal):
     return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_SET_NAME_SUM,
                                    detal)
Example #20
0
 def getReliefShareDate(self, userId):
     '''
     '''
     return DaoGameDataHall.HGET(userId, HallKeys.ATT_RELIEF_SHARE_DATE)
Example #21
0
 def getSetNameSum(self, userId):
     return DaoGameDataHall.HGET(userId, HallKeys.ATT_SET_NAME_SUM)
Example #22
0
 def isFirstGamelist5(self, userId):
     """
     判定该用户是否第一次使用gamelist5
     """
     return DaoGameDataHall.HGET(userId, HallKeys.ATT_FIRST_GAME_LIST5)
Example #23
0
 def incrLoginSum(self, userId, deltaCount):
     return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_LOGIN_SUM,
                                    deltaCount)
Example #24
0
 def changeFirstGamelist5(self, userId):
     return DaoGameDataHall.HSET(userId, HallKeys.ATT_FIRST_GAME_LIST5, 1)
Example #25
0
 def set_monthcheckin(self, userId, d):
     return DaoGameDataHall.HSET(userId, HallKeys.ATT_MONTH_CHECKIN, d)
Example #26
0
 def getUpdateToVersion511flag(self, userId):
     """
     判定该用户是否升级到5.11
     """
     return DaoGameDataHall.HGET(userId,
                                 HallKeys.ATT_UPDATE_CLIENT_VERSION_TO_511)
Example #27
0
 def roulette_attend_soldier_lottery(self, userId):
     return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_CHECKIN_SOLDIERS,
                                    1)
Example #28
0
 def setUpdateToVersion511flag(self, userId):
     return DaoGameDataHall.HSET(userId,
                                 HallKeys.ATT_UPDATE_CLIENT_VERSION_TO_511,
                                 1)
Example #29
0
 def getNewMsgId(self, userId):
     return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_MESSAGE_ID_MAX, 1)
Example #30
0
 def getLoginBeforeVersion511flag(self, userId):
     """
     判定该用户是否在5.11版本之前登录过
     """
     return DaoGameDataHall.HGET(userId,
                                 HallKeys.ATT_LOGIN_BEFORE_VERSION_TO_511)