示例#1
0
    def __init__(self,
                 objects_list=None,
                 gui_interface=None,
                 settings_json=None):
        super(MyGameController, self).__init__(objects_list=objects_list,
                                               gui_interface=gui_interface,
                                               settings_json=settings_json)

        deck_pos = self.settings_json["deck"]["position"]
        deck_offset = self.settings_json["deck"]["offset"]
        self.deck = deck.Deck(type_=enums.DeckType.short,
                              pos=deck_pos,
                              offset=deck_offset)

        stack_pos = self.settings_json["stack"]["position"]
        stack_offset = self.settings_json["stack"]["offset"]
        self.stack = card_holder.CardsHolder(pos=stack_pos,
                                             offset=stack_offset)

        # All game objects should be added to self objects list
        #  with add_object method in order to be rendered.
        self.add_rendered_object((self.deck, self.stack))

        # Create Restart button
        self.gui_interface.show_button(
            self.settings_json["gui"]["restart_button"], self.restart_game,
            "Restart")
示例#2
0
    def __init__(self,
                 objects_list=None,
                 gui_interface=None,
                 settings_json=None):
        super(KlondikeController, self).__init__(objects_list, gui_interface,
                                                 settings_json)

        setattr(deck.Deck, "render", holders.draw_empty_card_pocket)

        deck_pos = self.settings_json["deck"]["position"]
        deck_offset = self.settings_json["deck"]["offset"]
        self.deck = deck.Deck(enums.DeckType.full, deck_pos, deck_offset, None)

        self.deck_discard = holders.DeckDiscard()

        deck_pos = self.deck.pos
        x_offset = self.settings_json["stack"]["deck_offset"][0] \
                   + self.settings_json["card"]["size"][0]
        y_offset = self.settings_json["stack"]["deck_offset"][1]
        stack_pos = deck_pos[0] + x_offset, deck_pos[1] + y_offset
        stack_offset = self.settings_json["stack"]["inner_offset"]
        self.stack = card_holder.CardsHolder(stack_pos, stack_offset,
                                             enums.GrabPolicy.can_single_grab)

        self.add_rendered_object((self.deck, self.stack))

        self.piles = []
        pile_pos = self.settings_json["pile"]["position"]
        pile_offset = self.settings_json["pile"]["offset"]
        pile_inner_offset = self.settings_json["pile"]["inner_offset"]
        for i in range(1, 8):
            pile = holders.Pile(pile_pos, pile_inner_offset,
                                enums.GrabPolicy.can_multi_grab)
            pile_pos = pile_pos[0] + pile_offset[0], pile_pos[1] + pile_offset[
                1]
            self.add_rendered_object(pile)
            self.piles.append(pile)

        foundation_pos = self.settings_json["foundation"]["position"]
        foundation_offset = self.settings_json["foundation"]["offset"]
        foundation_inner_offset = self.settings_json["foundation"][
            "inner_offset"]
        self.foundations = []
        for i in range(0, 4):
            self.foundations.append(
                holders.Foundation(foundation_pos, foundation_inner_offset))
            foundation_pos = (foundation_pos[0] + foundation_offset[0],
                              foundation_pos[1] + foundation_offset[1])
            self.add_rendered_object(self.foundations[i])

        self.grabbed_cards_holder = card_holder.GrabbedCardsHolder((0, 0),\
                                        pile_inner_offset)
        self.add_rendered_object(self.grabbed_cards_holder)
        self.owner_of_grabbed_card = None

        self.gui_interface.show_button(
            self.settings_json["gui"]["restart_button"], self.restart_game,
            "Restart")

        self.game_start_time = None
示例#3
0
    def build_objects(self):
        """ Create permanent game objects (deck of cards, players etc.) and GUI elements
            in this method. This method is executed during creation of GameApp object.
        """
        setattr(deck.Deck, "render", osztalyok.PlaceHolder)
        setattr(card_holder.CardsHolder, "render", osztalyok.PlaceHolder)
        #setattr()

        talon_pos = self.settings_json["talon"]["position"]
        talon_offset = self.settings_json["talon"]["offset"]
        atlapos = self.settings_json["atlapoz"]["position"]
        atlapoffset = self.settings_json["atlapoz"]["offset"]
        asztal_pos = self.settings_json["asztal"]["position"]
        asztal_offset = self.settings_json["asztal"]["offset"]
        asztal_inner_offset = self.settings_json["asztal"]["inner_offset"]
        oszlop_pos = self.settings_json["oszlop"]["position"]
        oszlop_offset = self.settings_json["oszlop"]["offset"]

        self.custom_dict["talon"] = deck.Deck(enums.DeckType.short, talon_pos,
                                              talon_offset, None)
        self.custom_dict["atlapoz"] = card_holder.CardsHolder(
            atlapos, atlapoffset, enums.GrabPolicy.can_single_grab)
        self.custom_dict["asztal"] = []
        self.custom_dict["oszlop"] = []
        self.custom_dict["purgatory"] = osztalyok.Purgatory()
        #self.custom_dict["purgatory"] = card_holder.CardsHolder(atlapos,atlapoffset,enums.GrabPolicy.can_single_grab)
        self.custom_dict["kez"] = osztalyok.Kez()
        self.custom_dict["elozmeny"] = None
        elozmeny = ""

        for i in range(7):
            asztal = osztalyok.Asztal(asztal_pos, asztal_inner_offset,
                                      enums.GrabPolicy.can_multi_grab)
            asztal_pos = asztal_pos[0] + asztal_offset[0], asztal_pos[
                1] + asztal_offset[1]
            self.add_rendered_object(asztal)
            self.custom_dict["asztal"].append(asztal)

        suits = ["pikk", "coeur", "treff", "karo"]

        for i in range(4):
            oszlop = osztalyok.Oszlop(oszlop_pos, oszlop_offset, enums,
                                      enums.GrabPolicy.can_single_grab)
            oszlop_pos = oszlop_pos[0] + oszlop_offset[0], oszlop_pos[
                1] + oszlop_offset[1]
            self.add_rendered_object(oszlop)
            self.custom_dict["oszlop"].append((oszlop, [suits[i]]))

        self.add_rendered_object(self.custom_dict["talon"])
        self.add_rendered_object(self.custom_dict["atlapoz"])
        #self.add_rendered_object(self.custom_dict["asztal"])
        self.add_rendered_object(self.custom_dict["purgatory"])
        self.add_rendered_object(self.custom_dict["kez"])

        pass
示例#4
0
    def build_objects(self):
        setattr(deck.Deck, "render", holders.draw_empty_card_pocket)

        deck_pos = self.settings_json["deck"]["position"]
        deck_offset = self.settings_json["deck"]["offset"]
        self.custom_dict["deck"] = deck.Deck(enums.DeckType.full, deck_pos,
                                             deck_offset, None)

        self.custom_dict["deck_discard"] = holders.DeckDiscard()

        deck_pos = self.custom_dict["deck"].pos
        x_offset = self.settings_json["stack"]["deck_offset"][0] \
                   + self.settings_json["card"]["size"][0]
        y_offset = self.settings_json["stack"]["deck_offset"][1]
        stack_pos = deck_pos[0] + x_offset, deck_pos[1] + y_offset
        stack_offset = self.settings_json["stack"]["inner_offset"]
        self.custom_dict["stack"] = card_holder.CardsHolder(
            stack_pos, stack_offset, enums.GrabPolicy.can_single_grab)

        self.add_rendered_object(
            (self.custom_dict["deck"], self.custom_dict["stack"]))

        self.custom_dict["piles"] = []
        pile_pos = self.settings_json["pile"]["position"]
        pile_offset = self.settings_json["pile"]["offset"]
        pile_inner_offset = self.settings_json["pile"]["inner_offset"]
        for i in range(1, 8):
            pile = holders.Pile(pile_pos, pile_inner_offset,
                                enums.GrabPolicy.can_multi_grab)
            pile_pos = pile_pos[0] + pile_offset[0], pile_pos[1] + pile_offset[
                1]
            self.add_rendered_object(pile)
            self.custom_dict["piles"].append(pile)

        foundation_pos = self.settings_json["foundation"]["position"]
        foundation_offset = self.settings_json["foundation"]["offset"]
        foundation_inner_offset = self.settings_json["foundation"][
            "inner_offset"]
        self.custom_dict["foundations"] = []
        for i in range(0, 4):
            self.custom_dict["foundations"].append(
                holders.Foundation(foundation_pos, foundation_inner_offset))
            foundation_pos = (foundation_pos[0] + foundation_offset[0],
                              foundation_pos[1] + foundation_offset[1])
            self.add_rendered_object(self.custom_dict["foundations"][i])

        self.custom_dict["grabbed_cards_holder"] = holders.GrabbedCardsHolder(
            (0, 0), pile_inner_offset)
        self.add_rendered_object(self.custom_dict["grabbed_cards_holder"])
        self.custom_dict["owner_of_grabbed_card"] = None

        self.gui_interface.show_button(
            self.settings_json["gui"]["restart_button"], self.restart_game,
            "Restart")
示例#5
0
    def __init__(self,
                 objects_list=None,
                 gui_interface=None,
                 settings_json=None):
        super(Crazy8sController, self).__init__(objects_list, gui_interface,
                                                settings_json)

        self.opponents_json = load_opponents_json()

        # Set up the stockpile.
        pos = self.settings_json["stockpile"]["position"]
        offset = self.settings_json["stockpile"]["offset"]
        self.stockpile = deck.Deck(enums.DeckType.full, pos, offset, None)
        self.add_rendered_object(self.stockpile)

        # Set up the discard pile.
        pos = self.settings_json["discard"]["position"]
        offset = self.settings_json["discard"]["offset"]
        self.discard = card_holder.CardsHolder(pos, offset)
        self.add_rendered_object(self.discard)

        # Set up the player's hand.
        pos = self.settings_json["player_hand"]["position"]
        offset = self.settings_json["player_hand"]["offset"]
        self.player_hand = card_holder.CardsHolder(
            pos, offset, enums.GrabPolicy.can_single_grab_any)
        self.add_rendered_object(self.player_hand)

        # Other global behavior
        self.opponent_min_delay_ms = self.settings_json["opponent_behavior"][
            "min_delay_ms"]
        self.opponent_max_delay_ms = self.settings_json["opponent_behavior"][
            "max_delay_ms"]

        # Set up game state.
        self.num_opponents = 0
        self.opponents = [
        ]  # Each item in the list will be an OpponentRecord tuple.
        self.dealer = 0  # index of player who is dealer; 0 is human player
        self.turn = -1  # No one's turn yet
        self.chosen_suit = None
        self.must_choose_suit = False
        self.action_lock = False
        self.bg_pulse_animation = None

        # UI
        self.gui_interface.show_button(
            self.settings_json["gui"]["restart_button"], self.restart_game,
            "Restart")
示例#6
0
    def __init__(self,
                 objects_list=None,
                 gui_interface=None,
                 settings_json=None):
        super(WarController, self).__init__(objects_list, gui_interface,
                                            settings_json)

        self.state = GameState.paused

        # Set up the player's deck.
        pos = self.settings_json["player_deck"]["position"]
        offset = self.settings_json["player_deck"]["offset"]
        self.player_deck = card_holder.CardsHolder(pos, offset)
        self.add_rendered_object(self.player_deck)

        # Set up the AI opponent's deck.
        pos = self.settings_json["ai_deck"]["position"]
        offset = self.settings_json["ai_deck"]["offset"]
        self.ai_deck = card_holder.CardsHolder(pos, offset)
        self.add_rendered_object(self.ai_deck)

        # Set up the player's stage.
        pos = self.settings_json["player_stage"]["position"]
        offset = self.settings_json["player_stage"]["offset"]
        self.player_stage = card_holder.CardsHolder(pos, offset)
        self.add_rendered_object(self.player_stage)

        # Set up the API opponent's stage.
        pos = self.settings_json["ai_stage"]["position"]
        offset = self.settings_json["ai_stage"]["offset"]
        self.ai_stage = card_holder.CardsHolder(pos, offset)
        self.add_rendered_object(self.ai_stage)

        # Starter deck (for restarting the game; not shown on screen.)
        self.start_deck = deck.Deck(enums.DeckType.full, (0, 0), (0, 0), None)

        # Other game properties
        self.evaluate_delay_ms = self.settings_json["game_behavior"][
            "evaluate_delay_ms"]
        self.ai_min_delay_ms = self.settings_json["ai_behavior"][
            "min_delay_ms"]
        self.ai_max_delay_ms = self.settings_json["ai_behavior"][
            "max_delay_ms"]

        # UI
        self.gui_interface.show_button(
            self.settings_json["gui"]["restart_button"], self.restart_game,
            "Restart")
示例#7
0
    def build_objects(self):
        """ Create permanent game objects (deck of cards, players etc.) and
        GUI elements in this method. This method is executed during creation of GameApp object.
        """

        deck_pos = self.settings_json["deck"]["position"]
        deck_offset = self.settings_json["deck"]["offset"]
        self.custom_dict["deck"] = deck.Deck(type_=enums.DeckType.short,
                                             pos=deck_pos, offset=deck_offset)

        stack_pos = self.settings_json["stack"]["position"]
        stack_offset = self.settings_json["stack"]["offset"]
        self.custom_dict["stack"] = card_holder.CardsHolder(pos=stack_pos, offset=stack_offset)

        # All game objects should be added to self objects list
        #  with add_object method in order to be rendered.
        self.add_rendered_object((self.custom_dict["deck"], self.custom_dict["stack"]))

        # Create Restart button
        self.gui_interface.show_button(self.settings_json["gui"]["restart_button"],
                                       self.restart_game, "Restart")