Пример #1
0
    def on_user_login(cls, uid, gid):
        Context.Data.set_game_attr(uid, gid, 'session_login',
                                   Time.datetime_now())
        login = Context.Daily.incr_daily_data(uid, gid, 'login.times', 1)
        if login == 1:
            channel = Context.Data.get_game_attr(uid, gid, 'session_channel',
                                                 'jiyu')
            login_user_count = Context.Stat.incr_daily_data(
                gid, '%s.login.user.count' % channel, 1)
            if login_user_count <= 10:  # 多次测试
                in_chip, out_chip = Context.RedisMix.hash_mget(
                    'game.%d.info.hash' % gid, 'in.chip', 'out.chip')
                in_chip = Tool.to_int(in_chip, 0)
                out_chip = Tool.to_int(out_chip, 0)
                Context.Stat.setnx_daily_data(gid, 'carrying.volume.chip',
                                              in_chip - out_chip)

        Context.Log.report('user.login:', [uid, gid, login])
        return login
Пример #2
0
 def createUserInfo(self, userId, dictInfo):
     sex = random.choice([Const.SEX_MAN, Const.SEX_WOMAN])
     if sex == Const.SEX_WOMAN:
         avatar = random.choice(Const.DEFAULT_AVATAR_WOMAN)
     else:
         avatar = random.choice(Const.DEFAULT_AVATAR_MAN)
     value = {
         'userName': dictInfo['userName'],
         'idType': dictInfo['idType'],
         'token': dictInfo['token'],
         'nick': dictInfo['nick'],
         'sex': sex,
         'avatar': avatar,
         'status': 0,
         'deviceId': dictInfo['deviceId'],
         'createIp': dictInfo['createIp'],
         'createTime': Time.datetime_now(),
         'accessToken': '',
         'channel': dictInfo['channel'],
         'platform': dictInfo['platform']
     }
     if 'openid' in dictInfo:
         value['openid'] = dictInfo['openid']
     return Context.Data.set_attrs_dict(userId, value)
Пример #3
0
 def log(cls, *args):
     prefix = Time.datetime_now()
     msg = [str(arg) for arg in args]
     print '%s | %s' % (prefix, ' '.join(msg))