Beispiel #1
0
 def on_place_initial_resources(self, resource_cards):
     card_types = set([type(c) for c in resource_cards])
     card_slots = []
     for card_slot_column in self._card_slot_grid:
         for card_slot in card_slot_column:
             for card_type in card_types:
                 if card_slot.accepts_type(card_type):
                     card_slots.append(card_slot)
                     break
     if len(resource_cards) != len(card_slots):
         raise (
             ValueError(
                 "Cannot place initial resources. Missmatch in number of available slots ("
                 + str(len(card_slots))
                 + ") and provided cards("
                 + str(len(resource_cards))
                 + ")"
             )
         )
     # walk along all avalable resource slots and fill in randomly chosen
     # initial resource cards
     for slot in card_slots:
         card = random_pop(resource_cards)
         card.change_owner(self.get_owner())
         card.make_face_up()
         slot.add(card)
Beispiel #2
0
    def on_prepare_game(self, context):
        # neutral zone
        self._neutral_zone.reset()
        player = [self.get_player1(), self.get_player2()]
        # player
        player_white = random_pop(player)
        player_black = random_pop(player)
        player_white.change_color(color.WHITE)
        player_black.change_color(color.BLACK)
        realm_white = player_white.get_realm()
        realm_black = player_black.get_realm()
        realm_white.on_prepare_initial_state()
        realm_white.on_place_initial_resources(
            initial_resource_card_library_white.get_all()
        )
        realm_black.on_prepare_initial_state()
        realm_black.on_place_initial_resources(
            initial_resource_card_library_black.get_all()
        )

        # fill hand with random cards (AGAINST RULES, dummy rule to test gui)
        # TODO: REMOVE later!
        def fill_hand_randomly(player):
            expansion_card_stack = random_pick(
                self._neutral_zone.get_expansion_card_stacks()
            )
            hand = player.get_hand()
            while not hand.is_full() and not expansion_card_stack.is_empty():
                card = random_pick(expansion_card_stack)
                expansion_card_stack.remove(card)
                card.change_owner(player_white)
                card.make_face_down()
                hand.add(card)

        fill_hand_randomly(player_white)
        fill_hand_randomly(player_black)
Beispiel #3
0
 def _fill_resource_card_stack(self, resource_cards):
     # fill cards in a random order
     while len(resource_cards) > 0:
         self._resource_card_stack.push_top(random_pop(resource_cards))
Beispiel #4
0
 def _fill_expension_card_stacks(self, expansion_card):
     # fill cards in a random order while cycling over all stacks
     for stack in cycle(self._expansion_card_stacks):
         if len(expansion_card) == 0:
             break
         stack.push_top(random_pop(expansion_card))
Beispiel #5
0
 def _fill_event_card_intake_stack(self, event_cards):
     # fill cards in a random order
     while len(event_cards) > 0:
         self._event_card_intake_stack.push_top(random_pop(event_cards))