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)
def incrVipExp(self, userId, count): ''' 给用户增加count个经验值,count可以为负数 @param userId: 哪个用户 @param count: 数量 @return: 变化后的值 ''' return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_VIP_EXP, count)
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
def getNewMsgId(self, userId): return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_MESSAGE_ID_MAX, 1)
def roulette_soldier_reward(self, userId): return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_GET_REWARD_NUM, 1)
def roulette_attend_soldier_lottery(self, userId): return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_CHECKIN_SOLDIERS, 1)
def incrLoginSum(self, userId, deltaCount): return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_LOGIN_SUM, deltaCount)
def incrLoginDays(self, userId, deltaCount): return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_LOGIN_DAYS, deltaCount)
def incrSetNameSum(self, userId, detal): return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_SET_NAME_SUM, detal)
def add_share_count(self, userId, delta): return DaoGameDataHall.HINCRBY(userId, HallKeys.ATT_SHARE_COUNT, delta)