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


Python TimePrototype.get_current_turn_number方法代码示例

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


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

示例1: test_sync_data__power_from_bonuses_2

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def test_sync_data__power_from_bonuses_2(self):
        person_1 = self.p1.persons[0]

        self.assertEqual(self.p1.power, 0)
        self.assertEqual(person_1.power, 0)

        person_1.push_power(TimePrototype.get_current_turn_number(), 10000)
        self.p1.push_power(TimePrototype.get_current_turn_number(), 10000)

        self.worker.process_change_power(
            person_id=person_1.id, power_delta=-1000, place_id=None, positive_bonus=0, negative_bonus=0
        )

        self.worker.sync_data()

        self.assertEqual(self.p1.power, 10000 - 1000 * 2 * 1.5)
        self.assertEqual(person_1.power, 10000 - 1000 * 2)

        self.worker.process_change_power(
            place_id=self.p1.id, power_delta=100, person_id=None, positive_bonus=0, negative_bonus=0
        )

        self.worker.sync_data()

        self.assertEqual(self.p1.power, 10000 - 1000 * 2 * 1.5 + 100 * 1.25)
        self.assertEqual(person_1.power, 10000 - 1000 * 2)
开发者ID:lshestov,项目名称:the-tale,代码行数:28,代码来源:test_highlevel_worker.py

示例2: create_person

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
def create_person(place, race, type, utg_name, gender, personality_cosmetic=None, personality_practical=None):

    if personality_cosmetic is None:
        personality_cosmetic = relations.PERSONALITY_COSMETIC.random()

    if personality_practical is None:
        personality_practical = relations.PERSONALITY_PRACTICAL.random()

    person = objects.Person(
        id=None,
        created_at_turn=TimePrototype.get_current_turn_number(),
        updated_at_turn=TimePrototype.get_current_turn_number(),
        updated_at=datetime.datetime.now(),
        place_id=place.id,
        gender=gender,
        race=race,
        type=type,
        attrs=attributes.Attributes(),
        personality_cosmetic=personality_cosmetic,
        personality_practical=personality_practical,
        politic_power=PersonPoliticPower.create(),
        utg_name=utg_name,
        job=PersonJob.create(normal_power=NORMAL_PERSON_JOB_POWER),
        moved_at_turn=TimePrototype.get_current_turn_number(),
    )
    person.refresh_attributes()
    place.refresh_attributes()
    save_person(person, new=True)
    return person
开发者ID:Tiendil,项目名称:the-tale,代码行数:31,代码来源:logic.py

示例3: create_place

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def create_place(self, x, y, size, roads_to, persons=(), name_forms=None, is_frontier=False): # pylint: disable=R0914

        place_power = int(max(place.power for place in places_storage.all()) * float(size) / places_settings.MAX_SIZE)

        place_power_steps = int(places_settings.POWER_HISTORY_LENGTH / c.MAP_SYNC_TIME)
        place_power_per_step = (place_power / place_power_steps) + 1

        place = PlacePrototype.create( x=x,
                                       y=y,
                                       utg_name=name_forms.word,
                                       is_frontier=is_frontier,
                                       size=size)

        initial_turn = TimePrototype.get_current_turn_number() - places_settings.POWER_HISTORY_LENGTH
        for i in xrange(place_power_steps):
            place.push_power(int(initial_turn+i*c.MAP_SYNC_TIME), int(place_power_per_step))

        for person_name_forms, power_percent, race, gender, tp in persons:
            person = PersonPrototype.create(place=place,
                                            race=race,
                                            gender=gender,
                                            tp=tp,
                                            name_forms=person_name_forms)

            person_power = place_power * power_percent
            person_power_steps = int(persons_conf.settings.POWER_HISTORY_LENGTH / c.MAP_SYNC_TIME)
            person_power_per_step = (person_power / person_power_steps) + 1
            initial_turn = TimePrototype.get_current_turn_number() - persons_conf.settings.POWER_HISTORY_LENGTH
            for i in xrange(person_power_steps):
                person.push_power(int(initial_turn+i*c.MAP_SYNC_TIME), int(person_power_per_step))
            person.save()

        place.sync_persons(force_add=True)

        power_delta = self.INITIAL_PERSON_POWER

        for person in place.persons:
            person.fill_power_evenly(power_delta)
            person.save()
            power_delta /= 2

        place.sync_race()
        place.save()

        for destination in roads_to:
            Road.objects.create(point_1=place._model, point_2=destination._model)

        persons_storage.update_version()
        places_storage.update_version()
        roads_storage.update_version()

        persons_storage.refresh()
        places_storage.refresh()
        roads_storage.refresh()

        return place
开发者ID:Alkalit,项目名称:the-tale,代码行数:58,代码来源:map_create_places.py

示例4: create

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def create(cls, subcategory, caption, author, text, markup_method=MARKUP_METHOD.POSTMARKUP, technical=False):

        from the_tale.post_service.prototypes import MessagePrototype
        from the_tale.post_service.message_handlers import ForumThreadHandler

        if isinstance(subcategory, int):
            subcategory = SubCategoryPrototype.get_by_id(subcategory)

        thread_model = Thread.objects.create(subcategory=subcategory._model,
                                             caption=caption,
                                             author=author._model,
                                             last_poster=author._model,
                                             technical=technical,
                                             posts_count=0)

        Post.objects.create(thread=thread_model,
                            author=author._model,
                            markup_method=markup_method,
                            technical=technical,
                            text=text,
                            created_at_turn=TimePrototype.get_current_turn_number(),
                            state=POST_STATE.DEFAULT)

        prototype = cls(model=thread_model)

        subcategory.update()

        MessagePrototype.create(ForumThreadHandler(thread_id=prototype.id))

        return prototype
开发者ID:alexudracul,项目名称:the-tale,代码行数:32,代码来源:prototypes.py

示例5: update

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def update(self, text):
        self._model.text = text
        self._model.updated_at_turn = TimePrototype.get_current_turn_number()
        self.save()

        self.thread.update()
        self.thread.subcategory.update()
开发者ID:alexudracul,项目名称:the-tale,代码行数:9,代码来源:prototypes.py

示例6: process_next_turn

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def process_next_turn(self, turn_number):

        self.turn_number += 1

        if turn_number != self.turn_number:
            raise LogicException('dessinchonization: workers turn number (%d) not equal to command turn number (%d)' % (self.turn_number, turn_number))


        if TimePrototype.get_current_turn_number() != self.turn_number:
            raise LogicException('dessinchonization: workers turn number (%d) not equal to saved turn number (%d)' % (self.turn_number,
                                                                                                                      TimePrototype.get_current_turn_number()))

        self.storage.process_turn(logger=self.logger)
        self.storage.save_changed_data(logger=self.logger)

        for hero_id in self.storage.skipped_heroes:
            hero = self.storage.heroes[hero_id]
            if hero.actions.current_action.bundle_id in self.storage.ignored_bundles:
                continue
            environment.workers.supervisor.cmd_account_release_required(hero.account_id)

        environment.workers.supervisor.cmd_answer('next_turn', self.worker_id)

        if game_settings.COLLECT_GARBAGE and self.turn_number % game_settings.COLLECT_GARBAGE_PERIOD == 0:
            self.logger.info('GC: start')
            gc.collect()
            self.logger.info('GC: end')
开发者ID:Alkalit,项目名称:the-tale,代码行数:29,代码来源:logic.py

示例7: add_power_evenly

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def add_power_evenly(self, delta):
        cells_number = len(self.power_points)

        turn_number = TimePrototype.get_current_turn_number()

        self.power_points[:] = [ (turn, value+delta/cells_number / (1 - float(turn_number- turn) / history_length))
                                 for turn, value in self.power_points ]
开发者ID:Alkalit,项目名称:the-tale,代码行数:9,代码来源:power.py

示例8: create

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def create(cls, person, utg_name):
        from the_tale.game.places import storage

        building = storage.buildings.get_by_person_id(person.id)

        if building:
            return building

        # remove any destroyed buildings for person
        cls._model_class.objects.filter(person_id=person.id).delete()

        x, y = random.choice(list(cls.get_available_positions(person.place.x, person.place.y)))

        model = models.Building.objects.create(x=x,
                                        y=y,
                                        data=s11n.to_json({'name': utg_name.serialize()}),
                                        place_id=person.place_id,
                                        person_id=person.id,
                                        state=relations.BUILDING_STATE.WORKING,
                                        created_at_turn=TimePrototype.get_current_turn_number(),
                                        type=person.type.building_type)

        prototype = cls(model=model)

        storage.buildings.add_item(prototype.id, prototype)
        storage.buildings.update_version()

        return prototype
开发者ID:Jazzis18,项目名称:the-tale,代码行数:30,代码来源:prototypes.py

示例9: create

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def create(cls, owner, caption, rationale, bill, chronicle_on_accepted):

        model = Bill.objects.create(owner=owner._model,
                                    type=bill.type,
                                    caption=caption,
                                    rationale=rationale,
                                    created_at_turn=TimePrototype.get_current_turn_number(),
                                    technical_data=s11n.to_json(bill.serialize()),
                                    state=BILL_STATE.VOTING,
                                    chronicle_on_accepted=chronicle_on_accepted,
                                    votes_for=1) # author always wote for bill

        bill_prototype = cls(model)

        text = u'Обсуждение [url="%s%s"]закона[/url]' % (project_settings.SITE_URL,
                                                         reverse('game:bills:show', args=[model.id]) )

        thread = ThreadPrototype.create(SubCategoryPrototype.get_by_uid(bills_settings.FORUM_CATEGORY_UID),
                                        caption=caption,
                                        author=get_system_user(),
                                        text=bill_prototype.bill_info_text(text),
                                        technical=True,
                                        markup_method=MARKUP_METHOD.POSTMARKUP)

        model.forum_thread = thread._model
        model.save()

        ActorPrototype.update_actors(bill_prototype, bill_prototype.data.actors)

        VotePrototype.create(owner, bill_prototype, VOTE_TYPE.FOR)

        signals.bill_created.send(sender=cls, bill=bill_prototype)

        return bill_prototype
开发者ID:Alkalit,项目名称:the-tale,代码行数:36,代码来源:prototypes.py

示例10: process_turn

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def process_turn(self, logger=None, continue_steps_if_needed=True):
        self.switch_caches()

        timestamp = time.time()

        turn_number = TimePrototype.get_current_turn_number()

        processed_heroes = 0

        for hero in self.heroes.values():
            if hero.actions.current_action.bundle_id in self.ignored_bundles:
                continue

            if hero.id in self.skipped_heroes:
                continue

            if not hero.can_process_turn(turn_number):
                continue

            self.process_turn__single_hero(hero=hero, logger=logger, continue_steps_if_needed=continue_steps_if_needed)

            processed_heroes += 1

            if conf.game_settings.UNLOAD_OBJECTS:
                hero.unload_serializable_items(timestamp)

        if logger:
            logger.info('[next_turn] processed heroes: %d / %d' % (processed_heroes, len(self.heroes)))
            if self.ignored_bundles:
                logger.info('[next_turn] ignore bundles: %r' % list(self.ignored_bundles))
开发者ID:alexudracul,项目名称:the-tale,代码行数:32,代码来源:logic_storage.py

示例11: create_message

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
 def create_message(self, message, turn_delta=0, time_delta=0, position=u'some position info'):
     return messages.MessageSurrogate(turn_number=TimePrototype.get_current_turn_number() + turn_delta,
                                      timestamp=time.time() + time_delta,
                                      key=None,
                                      externals=None,
                                      message=message,
                                      position=position)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:9,代码来源:test_messages.py

示例12: test_initialize

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
    def test_initialize(self):
        self.assertEqual(self.person.place.persons_changed_at_turn, self.persons_changed_at_turn)

        self.assertEqual(self.person.friends_number, 0)
        self.assertEqual(self.person.enemies_number, 0)
        self.assertEqual(self.person.created_at_turn, TimePrototype.get_current_turn_number() - 1)
        self.assertTrue(self.person.is_stable)
开发者ID:Alkalit,项目名称:the-tale,代码行数:9,代码来源:test_prototypes.py

示例13: test_not_enough_money

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
 def test_not_enough_money(self):
     self.hero.position.last_place_visited_turn = TimePrototype.get_current_turn_number() - 1
     with contextlib.nested(
             self.check_delta(lambda: self.hero.money, -self.hero.money),
             self.check_delta(lambda: self.hero.statistics.money_spend_for_companions, self.hero.money),
             self.check_increased(lambda: len(self.hero.messages))
             ):
         prototypes.ActionInPlacePrototype.create(hero=self.hero)
开发者ID:alexudracul,项目名称:the-tale,代码行数:10,代码来源:test_action_inplace.py

示例14: test_buy_meal

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
 def test_buy_meal(self):
     self.hero.position.last_place_visited_turn = TimePrototype.get_current_turn_number() - c.TURNS_IN_HOUR * 12
     with contextlib.nested(
             self.check_decreased(lambda: self.hero.money),
             self.check_delta(lambda: self.hero.statistics.money_spend_for_companions, int(f.expected_gold_in_day(self.hero.level) / 2 * 0.5) + 1),
             self.check_increased(lambda: len(self.hero.messages))
             ):
         prototypes.ActionInPlacePrototype.create(hero=self.hero)
开发者ID:alexudracul,项目名称:the-tale,代码行数:10,代码来源:test_action_inplace.py

示例15: _start_quest

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_turn_number [as 别名]
 def _start_quest(self, start, hero):
     hero.quests.update_history(start.type, TimePrototype.get_current_turn_number())
     self.quests_stack.append(QuestInfo.construct(type=start.type,
                                                  uid=start.uid,
                                                  knowledge_base=self.machine.knowledge_base,
                                                  experience=self.get_expirience_for_quest(start.uid, hero),
                                                  power=self.get_politic_power_for_quest(start.uid, hero),
                                                  hero=hero))
开发者ID:Jazzis18,项目名称:the-tale,代码行数:10,代码来源:prototypes.py


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