Ejemplo n.º 1
0
 def log_mutation_details(mutation):
     message = "Mutation {} finished processing".format(mutation.summary)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.GameLogic)
     if mutation.expired:
         Logger.log("Mutation expired ({})".format(mutation.id),
                    level=LogLevel.Info,
                    log_type=LogType.GameLogic)
Ejemplo n.º 2
0
 def _log_operation(student, seat, old_seat):
     template = "Modified student {student} seat. Was: {old_coords}, now is: {coords}"
     Logger.log(template.format(
         student=student.actor_info,
         old_coords=old_seat.coordinates_str_readable,
         coords=seat.coordinates_str_readable
     ), level=LogLevel.Debug, log_type=LogType.Operational)
Ejemplo n.º 3
0
 def _action_card_by_actor(self, actor_id, card_id):
     actor = self.get(actor_id)
     for card in actor.action_card_hand.cards:
         if card.id == card_id:
             return card
     message = "Card not found: {}, actor id: {}".format(card_id, actor_id)
     message_warning = "Ensure card was moved to inPlay ({})".format(
         [c.card.id for c in actor.cards_in_play])
     Logger.log("WARNING:", message, message_warning, level=LogLevel.Warning, log_type=LogType.IndexError)
Ejemplo n.º 4
0
 def _log_mod_operation(actor, stat, operation):
     template = "Modified actor {actor} '{stat}' via '{operator}' with value of '{value}'. Now is: {current_value}"
     Logger.log(template.format(
         actor=actor.label,
         stat=stat,
         operator=operation.operator,
         value=operation.value,
         current_value=getattr(actor, stat)
     ), level=LogLevel.Debug, log_type=LogType.Operational)
Ejemplo n.º 5
0
 def _log_mutations(mutations):
     if mutations:
         log_message = "Adding queued mutations (count: {}) to new turn.".format(
             len(mutations))
     else:
         log_message = "No mutations to add to new turn."
     Logger.log(log_message,
                level=LogLevel.Debug,
                log_type=LogType.GameLogic)
Ejemplo n.º 6
0
 def execute(self, actor_id, api):
     super().execute(actor_id, api)
     actor = api.actors.get(actor_id)
     template = " -> Score for actor {actor_name} ({actor_id}): {score} (Grades: {grades}, Popularity: {popularity})"
     Logger.log(template.format(
         actor_name=actor.name,
         actor_id=actor_id,
         score=actor.grades + actor.popularity,
         grades=actor.grades,
         popularity=actor.popularity))
Ejemplo n.º 7
0
 def _log_turn_details(api, action, actor_id, phase_type):
     actor = api.actors.get(actor_id)
     action_class_name = type(action).__name__
     template = "Executing phase: '{phase}' with action '{action}' for actor '{actor}': {summary}"
     message = template.format(
         phase=phase_type,
         action=action_class_name,
         actor=actor.label,
         summary=actor.summary)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.GameLogic)
Ejemplo n.º 8
0
 def log_script_start(self, *a, api, **k):
     super().log_script_start(self.actor_id, api, self.prompt)
     answers = {
         k: v["selected_option"]["id"]
         for k, v in self.prompt.closed.items()
     }
     Logger.log("Executing with answers:",
                answers,
                level=LogLevel.Info,
                log_type=LogType.Operational)
Ejemplo n.º 9
0
 def expend_action_card(self, actor_id, card_id):
     # TODO: kinda ugly, this line...
     card = self._action_card_by_actor(actor_id, card_id)
     actor = self._get(actor_id)
     # TODO: discard
     try:
         actor.action_card_hand.cards.remove(card)
     except ValueError:
         message = "Card not found: {}, actor id: {}".format(card_id, actor_id)
         Logger.log(message, level=LogLevel.Error, log_type=LogType.IndexError)
     self.program_api.increment_metadata("expended_action_cards", 1)
Ejemplo n.º 10
0
 def remove_card_in_play(self, mutation_id):
     card_to_remove = None
     for actor in self._actors():
         for card_in_play in actor.cards_in_play:
             if card_in_play.mutation_id == mutation_id:
                 card_to_remove = card_in_play
                 break
         if card_to_remove is not None:
             actor.cards_in_play.remove(card_to_remove)
             message = "Removed card associated to mutation {} from play".format(mutation_id)
             Logger.log(message, level=LogLevel.Info, log_type=LogType.GameLogic)
         return
Ejemplo n.º 11
0
 def _cast_or_none(self, cls, data):
     if data is None:
         return None
     try:
         args = [data]
         if issubclass(cls, DocumentBase):
             args.append(self)
         return cls(*args)
     except TypeError as e:
         message = "Warning: could not convert {}: {}".format(
             cls.__name__ if cls else "NONE?", e)
         Logger.log(message,
                    level=LogLevel.Warning,
                    log_type=LogType.DocumentConversion)
         raise Exception(message)
Ejemplo n.º 12
0
 def execute(self, data, start):
     register_exit_hook(data["public"]["game_id"])
     if not data["complete"]:
         actors = self.__generate_actors(data)
         Logger.log("Starting game", data["public"]["game_id"], level=LogLevel.Info, log_type=LogType.TestRunner)
         actor = choice(actors)
         while True:
             actor_id = actor.take_turn_if_possible()
             if not actor_id:
                 break
             actor = self.get_actor_by_id(actor_id, actors)
     elapsed = datetime.utcnow() - start
     complete_msg = "Done! Game ID: {}".format(data["public"]["game_id"])
     Logger.log(complete_msg, level=LogLevel.Info, log_type=LogType.TestRunner)
     performance_msg = "Processing took {}s".format(elapsed.total_seconds())
     Logger.log(performance_msg, level=LogLevel.Info, log_type=LogType.TestRunner)
Ejemplo n.º 13
0
 def __think(*a):
     Logger.log(*a, level=LogLevel.Info, log_type=LogType.Ai)
Ejemplo n.º 14
0
 def _log_card_expense(actor, card_id):
     message = "Expending action card {} for actor {}".format(
         card_id, actor.label)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.GameLogic)
Ejemplo n.º 15
0
 def log_stage_created(stage):
     message = "Stage Created: {stage_type}".format(
         stage_type=stage.stage_type)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.Gameflow)
Ejemplo n.º 16
0
 def _log_action_card_draw(card):
     message = "Drew action card '{}', pc: {}".format(
         card.template.name, card.id)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.GameLogic)
Ejemplo n.º 17
0
 def _log_phase_complete(phase):
     message = "Phase Complete: {phase_type}".format(
         phase_type=phase.phase_type)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.Gameflow)
Ejemplo n.º 18
0
 def _log_discipline_card_draw(discipline_card, phase_type):
     message = "Drew dismissal card '{}' for phase '{}'".format(
         discipline_card.template.name, phase_type)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.GameLogic)
Ejemplo n.º 19
0
 def _log_trouble_application(actor, card):
     template = "Assigning {} {} trouble from action card {}"
     message = template.format(actor.label, card.template.trouble_cost,
                               card.id)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.GameLogic)
Ejemplo n.º 20
0
 def _log_refresh_hand(actor):
     template = "Actor {actor} is refilling hand."
     Logger.log(template.format(actor=actor.label), level=LogLevel.Debug, log_type=LogType.Operational)
Ejemplo n.º 21
0
 def _log_process(actor, value):
     template = "Actor {} gained {} trouble at the end of the phase for being in seat {}."
     message = template.format(actor.label, value, actor.seat.coordinates_str_readable)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.GameLogic)
Ejemplo n.º 22
0
 def log_stage_complete(stage):
     message = "Stage Complete: {stage_type}".format(
         stage_type=stage.stage_type)
     Logger.log(message, level=LogLevel.Info, log_type=LogType.Gameflow)