Ejemplo n.º 1
0
def _moveHall51DataBack(userId, gameId, clientId):
    try:
        gameId = HALL_ID
        flag = gamedata.getGameAttrInt(userId, gameId, 'userChipMoveGame')
        ftlog.info('_moveHall51DataBack', userId, gameId, flag)
        if flag > 0:
            # 当前用户登录过HALL51
            chip, exp, charm, coupon = gamedata.getGameAttrs(
                userId, gameId, ['chip', 'exp', 'charm', 'coupon'])
            chip, exp, charm, coupon = strutil.parseInts(
                chip, exp, charm, coupon)
            ftlog.info('_moveHall51DataBack data->', userId, gameId, chip, exp,
                       charm, coupon)
            if charm > 0:
                userdata.incrCharm(userId, charm)
            if exp > 0:
                userdata.incrExp(userId, exp)
            if coupon > 0:
                trueDelta, finalCount = userchip.incrCoupon(
                    userId, gameId, coupon, userchip.ChipNotEnoughOpMode.NOOP,
                    userchip.EVENT_NAME_SYSTEM_REPAIR, 0, clientId)
                ftlog.info('_moveHall51DataBack data coupon->', userId, gameId,
                           coupon, trueDelta, finalCount)
            if chip > 0:
                trueDelta, finalCount = userchip.incrChip(
                    userId, gameId, chip, userchip.ChipNotEnoughOpMode.NOOP,
                    userchip.EVENT_NAME_SYSTEM_REPAIR, 0, clientId)
                ftlog.info('_moveHall51DataBack data chip->', userId, gameId,
                           chip, trueDelta, finalCount)
            gamedata.delGameAttrs(
                userId, gameId,
                ['chip', 'exp', 'charm', 'coupon', 'userChipMoveGame'])
            datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
    except:
        ftlog.error()
Ejemplo n.º 2
0
def doTableSmiliesFrom_v3_775(roomId,
                              bigRoomId,
                              tableId,
                              userId,
                              smilie,
                              minchip,
                              price,
                              self_charm,
                              clientId,
                              wcount=1):
    ftlog.debug('doTableSmiliesFrom_v3_775:1', 'userId=', userId, 'price=',
                price, 'smilie=', smilie, 'wcount=', wcount)
    eventId = 'EMOTICON_' + smilie.upper() + '_CONSUME'
    trueDelta, final = userchip.incrChipLimit(
        userId, DIZHU_GAMEID, -price * wcount, -1, -1,
        daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, eventId, roomId, clientId)
    # 真实的发送个数,金币不足也至少发送一次
    rcostchip = abs(trueDelta)
    rcount = 1
    if price > 0:
        rcount = max(1, int(math.ceil(rcostchip / price)))

    bireport.gcoin('out.chip.emoticon', DIZHU_GAMEID, rcostchip)
    ftlog.debug('doTableSmiliesFrom_v3_775:2', 'userId=', userId, 'rcostchip=',
                rcostchip, 'rcount=', rcount, 'final=', final)

    # 发送通知
    if rcostchip > 0:
        datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, userId, 'chip')

    # 魅力值
    userdata.incrCharm(userId, self_charm * rcount)
    bireport.gcoin('out.smilies.' + smilie + '.' + str(bigRoomId),
                   DIZHU_GAMEID, rcostchip)

    from dizhu.game import TGDizhu
    for _ in xrange(rcount):
        TGDizhu.getEventBus().publishEvent(
            UseTableEmoticonEvent(DIZHU_GAMEID, userId, roomId, tableId,
                                  smilie, price))
    return rcount, trueDelta, final
Ejemplo n.º 3
0
def doTableThrowEmojiFrom_3_775(gameId,
                                userId,
                                roomId,
                                bigRoomId,
                                tableId,
                                emojiId,
                                minchip,
                                price,
                                charmDelta,
                                clientId,
                                count,
                                throwWhenChipZero=False):
    assert (count > 0)
    if 0 == price:
        return count, 0, 0

    eventId = 'EMOTICON_%s_CONSUME' % (emojiId.upper())
    costChip = price * count
    trueDelta, final = userchip.incrChipLimit(
        userId, gameId, -costChip, -1, -1,
        daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, eventId, roomId, clientId)
    # 没有金币则返回0
    if trueDelta == 0:
        return 0, trueDelta, final

    # 真实的发送个数,金币不足也至少发送一次
    realCostChip = abs(trueDelta)
    realCount = max(1, int(math.ceil(realCostChip / price)))
    if realCostChip > 0:
        datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
        bireport.gcoin('out.chip.emoticon', gameId, realCostChip)
        bireport.gcoin('out.smilies.' + emojiId + '.' + str(bigRoomId), gameId,
                       realCostChip)
    # 魅力值
    userdata.incrCharm(userId, charmDelta * realCount)
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(
            UseTableEmoticonEvent(gameId, userId, roomId, tableId, emojiId,
                                  price, realCount))
    return realCount, trueDelta, final
Ejemplo n.º 4
0
def doTableThrowEmojiFrom(gameId, userId, roomId, bigRoomId, tableId, emojiId,
                          minchip, price, charmDelta, clientId):
    eventId = 'EMOTICON_%s_CONSUME' % (emojiId.upper())
    trueDelta, final = userchip.incrChipLimit(
        userId, gameId, -price, price + minchip, -1,
        daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE, eventId, roomId, clientId)
    # 发送通知
    if trueDelta != 0:
        datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')

    if trueDelta != -price:
        return 0, trueDelta, final
    bireport.gcoin('out.chip.emoticon', gameId, price)
    # 魅力值
    userdata.incrCharm(userId, charmDelta)
    bireport.gcoin('out.smilies.' + emojiId + '.' + str(bigRoomId), gameId,
                   price)

    TYGame(gameId).getEventBus().publishEvent(
        UseTableEmoticonEvent(gameId, userId, roomId, tableId, emojiId, price))
    return 1, trueDelta, final
Ejemplo n.º 5
0
def doTableThrowEmojiFromBursts(gameId, userId, roomId, tableId, emojiId,
                                charmDelta, burstsConf):

    assert (burstsConf.get('cost', {}).get('count', 0) > 0)

    cost = burstsConf.get('cost')
    contentItemList = [cost]
    eventId = 'EMOTICON_%s_CONSUME' % (emojiId.upper())
    assetKindId, count = user_remote.consumeAssets(gameId, userId,
                                                   contentItemList, eventId,
                                                   roomId)
    if assetKindId:
        return 0

    # 魅力值
    userdata.incrCharm(userId, charmDelta * burstsConf.get('count', 1))
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(
            UseTableEmoticonEvent(gameId, userId, roomId, tableId, emojiId,
                                  cost.get('count', 0),
                                  burstsConf.get('count', 0)))
    return burstsConf.get('count', 0)
Ejemplo n.º 6
0
def doTableSmiliesFrom(roomId, bigRoomId, tableId, userId, smilie, minchip,
                       price, self_charm, clientId):
    eventId = 'EMOTICON_' + smilie.upper() + '_CONSUME'
    trueDelta, final = userchip.incrChipLimit(
        userId, DIZHU_GAMEID, -price, price + minchip, -1,
        daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE, eventId, roomId, clientId)
    # 发送通知
    if abs(trueDelta) > 0:
        datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, userId, 'chip')

    if trueDelta != -price:
        return 0, trueDelta, final
    bireport.gcoin('out.chip.emoticon', DIZHU_GAMEID, price)

    # 魅力值
    userdata.incrCharm(userId, self_charm)
    bireport.gcoin('out.smilies.' + smilie + '.' + str(bigRoomId),
                   DIZHU_GAMEID, price)

    from dizhu.game import TGDizhu
    TGDizhu.getEventBus().publishEvent(
        UseTableEmoticonEvent(DIZHU_GAMEID, userId, roomId, tableId, smilie,
                              price))
    return 1, trueDelta, final
Ejemplo n.º 7
0
def doTableSmiliesTo(userId, other_charm, count=1):
    # 魅力值
    userdata.incrCharm(userId, other_charm * count)
    return count
Ejemplo n.º 8
0
def incUserCharm(userId, charm):
    return userdata.incrCharm(userId, charm)
Ejemplo n.º 9
0
def doTableThrowEmojiTo(gameId, userId, charmDelta, count=1):
    # 魅力值
    userdata.incrCharm(userId, charmDelta * count)
    return count
Ejemplo n.º 10
0
def do_xq_creat_new_user(snsId, chessExp, totalNum, winNum, loseNum, drawNum):
    
    uid = daobase.executeMixCmd('incrby', 'global.userid', 1)
    #assert(uid > 148670897)
    ct = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
    datas = {
             'password' : 'ty' + str(random.randint(100000, 999999)),
             'mdevid' : '',
             'isbind' : 1,
             'snsId' : snsId,
             'name' : '',
             'source' : '',
             'purl' : 'http://ddz.image.tuyoo.com/avatar/head_china.png',
             'address' : '',
             'sex' : 0,
             'state' : 0,
             'payCount' : 0,
             'snsinfo' : '',
             'vip' : 0,
             'dayang' : 0,
             'idcardno' : '',
             'phonenumber' : '',
             'truename' : '',
             'detect_phonenumber' : '',
             'email' : '',
             'createTime' : ct,
             'userAccount' : '',
             'clientId' : PCCLIENTID,
             'appId' : 9999,
             'bindMobile' : '',
             'mac' : '',
             'idfa' : '',
             'imei' : '',
             'androidId' : '',
             'uuid' : '',
             'userId' : uid,
             "lang" : '',
             "country" : "",
             "signature" : "",
             "agreeAddFriend" : 1,
#              "aliveTime" :  ct,
#              "exp" : 0,
#              "charm" : 0,
#              "diamond" : 0,
#              "chip" : 3000,
#              "coin" : 0
             }
#     attrlist = []
#     valuelist = []
#     for k, v in datas.items() :
#         attrlist.append(k)
#         valuelist.append(v)

    ftlog.info('PCXQ_USER', 'creat new user of->', uid, snsId)
    # userdata._setAttrsForce(uid, datas)
    userdata.setAttrs(uid, datas)
    userchip.incrChip(uid, 3, 3000, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'SYSTEM_REPAIR', 0, PCCLIENTID)
    userchip.incrCoin(uid, 3, 0, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'SYSTEM_REPAIR', 0, PCCLIENTID)
    userchip.incrDiamond(uid, 3, 0, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'SYSTEM_REPAIR', 0, PCCLIENTID)
    userchip.incrCoupon(uid, 3, 0, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'SYSTEM_REPAIR', 0, PCCLIENTID)
    userdata.incrCharm(uid, 0)
    userdata.incrExp(uid, 0)
    
    ikey = 'item2:9999:' + str(uid)
    for k, v in itemdatas.items() :
        daobase.executeUserCmd(uid, 'hset', ikey, k, v)
    daobase._executeKeyMapCmd('set', 'snsidmap:' + str(snsId), uid)
    
    creat_gamedata(uid, chessExp, totalNum, winNum, loseNum, drawNum)