Пример #1
0
 def create(self, student_info_id, as_actor=False):
     actor = self.actor_seed_factory.create() if as_actor else None
     return {
         "id": random_id(),
         "student_info_id": student_info_id,
         "actor": actor
     }
Пример #2
0
 def create():
     return Prompt({
         "id":     random_id(),
         "open":   {},
         "closed": {},
         "context_id": None
     })
 def create(templates, settings):
     template_list = sorted(templates.values(), key=lambda t: t["id"])
     filtered_templates = list(
         filter(lambda c: c["card_type"] == CardTypeName.ActionCard,
                template_list))
     total_cards = settings["action_card_deck_size"]
     cards_per_type = int(total_cards / len(filtered_templates))
     card_list = []
     for template in filtered_templates:
         for _ in range(0, cards_per_type):
             card_list.append({
                 "id": random_id(),
                 "card_template_id": template["id"]
             })
     shuffle(card_list)
     return {"id": random_id(), "cards": card_list}
Пример #4
0
 def create(phase_type, mutations=None):
     return {
         "id": random_id(),
         "phase_type": phase_type,
         "completed": None,
         "turns": [],
         "mutations": mutations or []
     }
Пример #5
0
 def create(self, actor_id, mutations):
     return {
         "id":        random_id(),
         "actor_id":  actor_id,
         "log":       [],
         "completed": None,
         "prompt":    self.prompt_seed_factory.create(),
         "mutations": mutations
     }
Пример #6
0
 def add_stage(self, stage_type):
     stage_data = {
         "id": random_id(),
         "stage_type": stage_type,
         "completed": None,
         "phases": [],
         "mutations": []
     }
     cls = self._field_definitions["stages"]
     stage = cls(stage_data, parent=self)
     self.stages.append(stage)
     return stage
Пример #7
0
 def create_from_template(cls, template, **exports):
     cls._validate_exports(exports)
     mutation_data = {
         "id":                 random_id(),
         "tags":               template.tags,
         "priority":           template.priority,
         "match_all":          template.match_all,
         "gameflow_binding":   template.gameflow_binding,
         "uses":               template.uses,
         "operation_modifier": template.operation_modifier
     }
     mutation_data.update(exports)
     return Mutation(mutation_data)
Пример #8
0
 def transfer_card_to_in_play(self, source_actor_id, targeted_actor_id, card_id, mutation_id):
     card = self._action_card_by_actor(source_actor_id, card_id)
     source_actor = self._get(source_actor_id)
     source_actor.action_card_hand.cards.remove(card)
     target_actor = source_actor if source_actor_id == targeted_actor_id else self._get(targeted_actor_id)
     # todo: move to factory
     in_play_effect_seed = {
         "id":          random_id(),
         "mutation_id": mutation_id,
         "card":        card
     }
     in_play_effect = InPlayEffect(in_play_effect_seed, target_actor)
     target_actor.cards_in_play.append(in_play_effect)
Пример #9
0
 def create():
     return {
         "id": random_id(),
         "name": random_name(),
         "user_id": None,
         "action_card_hand": {
             "id": random_id(),
             "cards": []
         },
         "afterschool_card_hand": {
             "id": random_id(),
             "cards": []
         },
         "discipline_card_hand": {
             "id": random_id(),
             "cards": []
         },
         "cards_in_play": [],
         "grades": 0,
         "popularity": 0,
         "torment": 0,
         "trouble": 0
     }
Пример #10
0
    def create(self, settings, student_info, player_count):
        seats = []
        total = settings["total_students"]
        for row in range(0, settings["seat_rows"]):
            for column in range(0, settings["seat_columns"]):
                seats.append({
                    "id": random_id(),
                    "row": row,
                    "column": column,
                    "student": None
                })
        shuffle(seats)
        student_info_ids = [si["id"] for si in student_info]
        shuffle(student_info_ids)
        for seat in seats:
            if total == 0:
                break
            seat["student"] = self.student_seed_factory.create(
                student_info_ids.pop(), player_count > 0)
            total -= 1
            player_count -= 1

        return seats
 def create(self, templates, settings):
     cards = self._create_cards(templates, settings)
     return {"id": random_id(), "cards": cards}
Пример #12
0
 def create(cards):
     return {"id": random_id(), "cards": []}