当前位置: 首页>>代码示例>>Python>>正文


Python Achievement.trig方法代码示例

本文整理汇总了Python中core.achievement.Achievement.trig方法的典型用法代码示例。如果您正苦于以下问题:Python Achievement.trig方法的具体用法?Python Achievement.trig怎么用?Python Achievement.trig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.achievement.Achievement的用法示例。


在下文中一共展示了Achievement.trig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: got_plundered

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def got_plundered(self, from_char_id, from_char_name, from_win, standard_drop):
        if from_win:
            tp = 1
        else:
            tp = 2

        gold = standard_drop['gold']
        item_text = standard_drop_to_readable_text(standard_drop, sign='-')

        log = MongoEmbeddedHangLog()
        log.timestamp = arrow.utcnow().timestamp
        log.tp = tp
        log.who = from_char_name
        log.gold = gold
        log.item_text = item_text

        self.mongo_affairs.logs.append(log)

        if len(self.mongo_affairs.logs) > PLUNDER_LOG_MAX_AMOUNT:
            self.mongo_affairs.logs.pop(0)

        self.mongo_affairs.save()
        self.send_hang_notify()

        achievement = Achievement(self.char_id)
        achievement.trig(33, 1)
开发者ID:yaosj,项目名称:sanguo-server,代码行数:28,代码来源:affairs.py

示例2: reset

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
def reset():
    amount = MongoArenaWeek.objects.count()

    logger = Logger("reset_arena_week.log")
    logger.write("Reset Arena Week: Start. chars amount: {0}".format(amount))

    data = MongoArenaWeek.objects.all()
    MongoArenaWeek.objects.delete()


    for d in data:
        reward = _get_reward(d.rank)
        gold = reward.week_gold
        attachment = Attachment(d.id)
        attachment.save_to_attachment(3, gold=gold)

        achievement = Achievement(d.id)
        achievement.trig(10, d.rank)

        if d.rank in TOP_RANKS:
            try:
                top = MongoArenaTopRanks.objects.get(id=d.rank)
            except DoesNotExist:
                top = MongoArenaTopRanks(id=d.rank)

            char_name = Char(d.id).cacheobj.name
            top.name = char_name
            top.save()

    logger.write("Reset Arena Week: Complete")
    logger.close()
开发者ID:wyrover,项目名称:sanguo-server,代码行数:33,代码来源:reset_arena_week.py

示例3: save_drop

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def save_drop(self):
        stage_id = self.hang_doing.stage_id
        actual_seconds = self.hang_doing.actual_seconds
        times = actual_seconds / 15

        stage = STAGES[stage_id]

        drop_exp = stage.normal_exp * times
        drop_gold = stage.normal_gold * times
        drop_gold = self._actual_gold(drop_gold)

        drop_ids = [int(i) for i in stage.normal_drop.split(',')]
        prepare_drop = get_drop(drop_ids, multi=times, gaussian=True)

        prepare_drop['exp'] += drop_exp
        prepare_drop['gold'] += drop_gold

        self.hang_doing.delete()
        self.hang_doing = None
        self.send_notify()

        prepare_drop = drop_after_stage_type(stage_id, prepare_drop)

        resource = Resource(self.char_id, "Hang Reward", "actual seconds = {0}, times = {1}".format(actual_seconds, times))
        standard_drop = resource.add(**prepare_drop)

        achievement = Achievement(self.char_id)
        achievement.trig(29, drop_exp)

        return standard_drop_to_attachment_protomsg(standard_drop)
开发者ID:wyrover,项目名称:sanguo-server,代码行数:32,代码来源:stage.py

示例4: plundered

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def plundered(self, who, self_win):
        if not self.hang_doing:
            return

        if self_win:
            if self.hang_doing.plunder_win_times >= PLUNDER_DEFENSE_SUCCESS_MAX_TIMES:
                return

            self.hang_doing.plunder_win_times += 1
            gold = PLUNDER_DEFENSE_SUCCESS_GOLD
        else:
            if self.hang_doing.plunder_lose_times >= PLUNDER_DEFENSE_FAILURE_MAX_TIMES:
                return

            self.hang_doing.plunder_lose_times += 1
            gold = -PLUNDER_DEFENSE_FAILURE_GOLD

        l = MongoEmbededPlunderLog()
        l.name = who
        l.gold = gold

        if len(self.hang_doing.logs) >= 5:
            self.hang_doing.logs.pop(0)

        self.hang_doing.logs.append(l)
        self.hang_doing.save()

        achievement = Achievement(self.char_id)
        achievement.trig(33, 1)
开发者ID:wyrover,项目名称:sanguo-server,代码行数:31,代码来源:stage.py

示例5: finish

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def finish(self, actual_seconds=None, set_hang=True):
        if not self.hang_doing:
            raise SanguoException(
                errormsg.HANG_NOT_EXIST,
                self.char_id,
                "Hang Finish",
                "Hang Finish. But no hang exist"
            )

        if not actual_seconds:
            actual_seconds = arrow.utcnow().timestamp - self.hang_doing.start

        if set_hang:
            self.hang.used += actual_seconds
            self.hang.save()

        self.hang_doing.finished = True
        self.hang_doing.actual_seconds = actual_seconds
        self.hang_doing.save()

        self.send_notify()

        attachment = Attachment(self.char_id)
        attachment.save_to_prize(1)

        actual_hours = actual_seconds / 3600
        achievement = Achievement(self.char_id)
        achievement.trig(28, actual_hours)
开发者ID:wyrover,项目名称:sanguo-server,代码行数:30,代码来源:stage.py

示例6: step_up

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def step_up(self):
        to = self.equip.upgrade_to
        if not to:
            raise SanguoException(
                errormsg.EQUIPMENT_REACH_MAX_STEP,
                self.char_id,
                "Equipment Step Up",
                "Equipment {0} Can not step up".format(self.equip_id)
            )

        step_up_need_gold = self.step_up_need_gold()

        stuff_needs = []
        for x in self.equip.stuff_needs.split(','):
            _id, _amount = x.split(':')
            stuff_needs.append((int(_id), int(_amount)))

        resouce = Resource(self.char_id, "Equipment Step Up", "equipment {0}".format(self.equip_id))
        with resouce.check(gold=-step_up_need_gold, stuffs=stuff_needs):
            self.oid = to
            self.equip = EQUIPMENTS[self.oid]

            self.mongo_item.equipments[str(self.equip_id)].oid = to
            add_gem_slots = self.equip.slots - len(self.mongo_item.equipments[str(self.equip_id)].gems)
            for i in range(add_gem_slots):
                self.mongo_item.equipments[str(self.equip_id)].gems.append(0)

            self.mongo_item.save()

        achievement = Achievement(self.char_id)
        achievement.trig(22, 1)
        if not self.equip.upgrade_to:
            achievement.trig(23, 1)

        return stuff_needs
开发者ID:yaosj,项目名称:sanguo-server,代码行数:37,代码来源:item.py

示例7: checkin

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def checkin(self):
        if self.c.has_checked:
            raise SanguoException(
                errormsg.CHECKIN_ALREADY_CHECKIN,
                self.char_id,
                "CheckIn checkin",
                "already checkin",
            )

        self.c.has_checked = True

        day = self.c.day

        if self.c.day == MAX_DAYS:
            self.c.day = 1
        else:
            self.c.day += 1

        self.c.save()

        resource = Resource(self.char_id, "Daily Checkin", 'checkin reward. day {0}'.format(day))
        resource_add = CHECKIN_DATA[str(day)]['package']
        resource_add = get_drop_from_raw_package(resource_add)

        standard_drop = resource.add(**resource_add)

        msg = CheckInResponse()
        msg.ret = 0
        msg.reward.MergeFrom(standard_drop_to_attachment_protomsg(standard_drop))

        achievement = Achievement(self.char_id)
        achievement.trig(34, 1)

        self.send_update_notify(day)
        return msg
开发者ID:wyrover,项目名称:sanguo-server,代码行数:37,代码来源:daily.py

示例8: battle

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def battle(self):
        counter = Counter(self.char_id, 'arena')
        try:
            # 免费次数
            counter.incr()
        except CounterOverFlow:
            counter = Counter(self.char_id, 'arena_buy')

            try:
                # 花费元宝次数
                counter.incr()
            except CounterOverFlow:
                char = Char(self.char_id).mc
                if char.vip < VIP_MAX_LEVEL:
                    raise SanguoException(
                        errormsg.ARENA_NO_TIMES,
                        self.char_id,
                        "Arena Battle",
                        "arena no times. vip current: {0}, max {1}".format(char.vip, VIP_MAX_LEVEL)
                    )
                raise SanguoException(
                    errormsg.ARENA_NO_TIMES_FINAL,
                    self.char_id,
                    "Arena Battle",
                    "arena no times. vip reach max level {0}".format(VIP_MAX_LEVEL)
                )

            else:
                resource = Resource(self.char_id, "Arena Battle", "battle for no free times")
                resource.check_and_remove(sycee=-ARENA_COST_SYCEE)

        rival_id = self.choose_rival()

        msg = protomsg.Battle()
        b = PVP(self.char_id, rival_id, msg)
        b.start()

        achievement = Achievement(self.char_id)

        if msg.self_win:
            score = ARENA_GET_SCORE_WHEN_WIN
            achievement.trig(11, 1)
            self.mongo_arena.continues_win += 1
        else:
            score = ARENA_GET_SCORE_WHEN_LOST
            self.mongo_arena.continues_win = 0

        self.mongo_arena.save()

        if score:
            self.mongo_day.score += score
            self.mongo_day.save()

        t = Task(self.char_id)
        t.trig(2)

        self.send_notify()
        return msg
开发者ID:wyrover,项目名称:sanguo-server,代码行数:60,代码来源:arena.py

示例9: _char_level_up

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
def _char_level_up(char_id, new_level, **kwargs):
    _all_hero_changed(char_id)

    achievement = Achievement(char_id)
    achievement.trig(18, new_level)
    activity_stage = ActivityStage(char_id)
    activity_stage.check(new_level)

    ActivityStatic(char_id).trig(1001)
开发者ID:yaosj,项目名称:sanguo-server,代码行数:11,代码来源:character.py

示例10: someone_accept_me

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def someone_accept_me(self, from_id):
        self.mf.friends[str(from_id)] = FRIEND_OK
        self.mf.save()

        achievement = Achievement(self.char_id)
        achievement.trig(27, self.real_cur_amount)

        msg = protomsg.UpdateFriendNotify()
        self._msg_friend(msg.friend, from_id, FRIEND_OK)
        publish_to_char(self.char_id, pack_msg(msg))
开发者ID:wyrover,项目名称:sanguo-server,代码行数:12,代码来源:friend.py

示例11: plunder

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def plunder(self):
        if not self.mongo_plunder.char_id:
            raise SanguoException(errormsg.PLUNDER_NO_RIVAL, self.char_id, "Plunder Battle", "no rival target")

        if self.mongo_plunder.current_times <= 0:
            raise SanguoException(errormsg.PLUNDER_NO_TIMES, self.char_id, "Plunder Battle", "no times")

        self.change_current_plunder_times(change_value=-1)

        rival_battle_heros = dill.loads(base64.b64decode(self.mongo_plunder.battle_heros))

        msg = MsgBattle()
        pvp = PlunderBattle(
            self.char_id, self.mongo_plunder.char_id, msg, self.mongo_plunder.char_name, rival_battle_heros
        )
        pvp.start()

        t = Task(self.char_id)
        t.trig(3)

        to_char_id = self.mongo_plunder.char_id
        target_server_url = self.mongo_plunder.server_url

        if msg.self_win:
            standard_drop = self._get_plunder_reward(
                self.mongo_plunder.char_city_id, self.mongo_plunder.char_gold, self.mongo_plunder.char_hero_original_ids
            )

            self.clean_plunder_target()

            achievement = Achievement(self.char_id)
            achievement.trig(12, 1)

            PlunderLeaderboardWeekly.incr(self.char_id)
        else:
            standard_drop = make_standard_drop_from_template()

        self.mongo_plunder.plunder_times += 1
        self.mongo_plunder.save()
        self.send_notify()

        plunder_finished_signal.send(
            sender=None,
            from_char_id=self.char_id,
            from_char_name=Char(self.char_id).mc.name,
            to_char_id=to_char_id,
            from_win=msg.self_win,
            standard_drop=standard_drop,
            target_server_url=target_server_url,
        )

        return (msg, standard_drop)
开发者ID:yaosj,项目名称:sanguo-server,代码行数:54,代码来源:plunder.py

示例12: _get_plunder_reward

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def _get_plunder_reward(self, city_id, gold, hero_original_ids):
        def _get_prisoner():
            prison = 0
            heros = [hid for hid in hero_original_ids if hid]

            while heros:
                hid = random.choice(heros)
                heros.remove(hid)
                if hid in PRISONER_POOL:
                    prison = hid
                    break

            if random.randint(1, 100) <= PLUNDER_GET_PRISONER_PROB:
                return prison
            return 0

        char = Char(self.char_id).mc
        vip_plus = VIP_FUNCTION[char.vip].plunder_addition

        standard_drop = make_standard_drop_from_template()
        standard_drop["gold"] = int(gold * (1 + vip_plus / 100.0))

        # 战俘
        got_hero_id = _get_prisoner()
        if got_hero_id:
            p = Prison(self.char_id)
            p.prisoner_add(got_hero_id, gold / 2)

            achievement = Achievement(self.char_id)
            achievement.trig(13, 1)

        # 掉落
        city = BATTLES[city_id]
        if city.normal_drop:
            drop_ids = [int(i) for i in city.normal_drop.split(",")]
            drop_prob = max(
                PLUNDER_GET_DROPS_TIMES - (self.mongo_plunder.plunder_times - 1) * PLUNDER_DROP_DECREASE_FACTOR,
                PLUNDER_GET_DROPS_TIMES * PLUNDER_DROP_MIN_FACTOR,
            )

            drop = get_drop(drop_ids, multi=int(drop_prob))
            drop.pop("gold")
            standard_drop.update(drop)

        resource = Resource(self.char_id, "Plunder Reward")
        resource.add(**standard_drop)

        self.send_notify()
        if got_hero_id:
            standard_drop["heros"] = [(got_hero_id, 1)]

        return standard_drop
开发者ID:yaosj,项目名称:sanguo-server,代码行数:54,代码来源:plunder.py

示例13: get_reward

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def get_reward(self, _id):
        try:
            this_task = TASKS[_id]
        except KeyError:
            raise SanguoException(
                errormsg.TASK_NOT_EXIST,
                self.char_id,
                "Task Get Reward",
                "Task {0} not exist".format(_id)
            )

        if _id not in self.task.finished:
            raise SanguoException(
                errormsg.TASK_NOT_FINISH,
                self.char_id,
                "Task Get Reward",
                "Task {0} not finish".format(_id)
            )

        if _id in self.task.complete:
            raise SanguoException(
                errormsg.TASK_ALREADY_GOT_REWARD,
                self.char_id,
                "Task Get Reward",
                "Task {0} already got reward".format(_id)
            )

        sycee = this_task.sycee if this_task.sycee else 0
        gold = this_task.gold if this_task.gold else 0

        resource = Resource(self.char_id, "Task Reward", "task {0}".format(_id))
        standard_drop = resource.add(gold=gold, sycee=sycee)

        if this_task.next_task:
            next_task = TASKS[this_task.next_task]
            if self.task.tasks[str(this_task.tp)] >= next_task.times:
                self.task.finished.append(this_task.next_task)

            index = self.task.doing.index(_id)
            self.task.doing.pop(index)
            self.task.doing.insert(index, this_task.next_task)

        self.task.finished.remove(_id)
        self.task.complete.append(_id)
        self.task.save()
        self.send_notify()

        if self.all_complete():
            achievement = Achievement(self.char_id)
            achievement.trig(30, 1)

        return standard_drop_to_attachment_protomsg(standard_drop)
开发者ID:hx002,项目名称:sanguo-server,代码行数:54,代码来源:task.py

示例14: kill

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def kill(self, _id):
        p = self._abandon(_id, action="Prisoner Kill")

        soul_amount = random.randint(3, 10)
        souls = [(p.oid, soul_amount)]

        resource = Resource(self.char_id, "Prisoner Kill")
        standard_drop = resource.add(souls=souls)

        achievement = Achievement(self.char_id)
        achievement.trig(15, 1)

        return standard_drop_to_attachment_protomsg(standard_drop)
开发者ID:yueyoum,项目名称:sanguo-server,代码行数:15,代码来源:prison.py

示例15: release

# 需要导入模块: from core.achievement import Achievement [as 别名]
# 或者: from core.achievement.Achievement import trig [as 别名]
    def release(self, _id):
        p = self._abandon(_id, action="Prisoner Release")

        got_gold = p.gold
        got_treasure = random.choice(PRISONER_RELEASE_GOT_TREASURE[HEROS[p.oid].quality])

        resource = Resource(self.char_id, "Prisoner Release")
        standard_drop = resource.add(gold=got_gold, stuffs=[(got_treasure, 1)])

        achievement = Achievement(self.char_id)
        achievement.trig(16, 1)

        return standard_drop_to_attachment_protomsg(standard_drop)
开发者ID:yueyoum,项目名称:sanguo-server,代码行数:15,代码来源:prison.py


注:本文中的core.achievement.Achievement.trig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。