def tr_write(groupid, eventmaster, eventrankmaster, uidlist, now):
        """書き込み.
        """
        group = None
        if groupid:
            group = BattleEventGroup.getByKeyForUpdate(groupid)

        model_mgr = ModelRequestMgr()
        playerexp_dict = BackendApi.get_model_dict(model_mgr, PlayerExp,
                                                   uidlist)
        for uid in uidlist:
            if group and group.fixed:
                group = None
            rankrecord = BattleEventRank.makeInstance(
                BattleEventRank.makeID(uid, eventmaster.id))
            rankrecord.rank_next = eventrankmaster.rank
            rankrecord.rank = rankrecord.rank_next
            rankrecord.fame = 0
            rankrecord.fame_next = 0
            rankrecord.groups = []
            playerexp = playerexp_dict.get(uid)
            level = playerexp.level if playerexp else 1
            group = BackendApi.tr_battleevent_regist_group(
                model_mgr, eventrankmaster, rankrecord, False, group, level,
                now)
            print '%s => %s' % (rankrecord.uid, group.id)

        model_mgr.write_all()
        return model_mgr, group
Esempio n. 2
0
    def tr_create(groupid, eventmaster, eventrankmaster, uidlist, tomorrow):
        """書き込み.
        """
        group = None
        if groupid:
            group = BattleEventGroup.getByKeyForUpdate(groupid)

        model_mgr = ModelRequestMgr()
        rankrecordlist = BattleEventRank.fetchByKeyForUpdate(
            [BattleEventRank.makeID(uid, eventmaster.id) for uid in uidlist])
        playerexp_dict = BackendApi.get_model_dict(model_mgr, PlayerExp,
                                                   uidlist)
        for rankrecord in rankrecordlist:
            if rankrecord.groups and BattleEventGroup.getByKey(
                    rankrecord.groups):
                # すでに参加している.
                continue
            if group and group.fixed:
                group = None

            playerexp = playerexp_dict.get(rankrecord.uid)
            level = playerexp.level if playerexp else 1
            group = BackendApi.tr_battleevent_regist_group(
                model_mgr, eventrankmaster, rankrecord, False, group, level,
                tomorrow)
            print 'set group:%s => %s' % (rankrecord.uid, group.id)

        model_mgr.write_all()
        return model_mgr, group
Esempio n. 3
0
    def tr_close(eventmaster, eventrankmaster, groupid, now):
        """グループ閉鎖書き込み.
        """
        group = BattleEventGroup.getByKeyForUpdate(groupid)
        model_mgr = ModelRequestMgr()
        BackendApi.tr_battleevent_close_group(model_mgr,
                                              eventmaster,
                                              eventrankmaster,
                                              group,
                                              now,
                                              do_send_famebonus=True)
        model_mgr.write_all()

        return model_mgr