Exemplo n.º 1
0
    def start(self):

        print "game " + str(self.id) + " starting"

        output = ABOutput(self)

        self.game = Game(output)
        self.game.create()

        c1 = []
        for count, name in self.players[0].deck:
            for i in range(count):
                card = g_cards.get(name)
                if card is not None:
                    cardObject = createCardObject(self.game, card)
                    c1.append(cardObject)
                else:
                    print ("Card %s doesn't exist!" % name)

        random.shuffle(c1)

        self.game.create_player(self.players[0].user.login, c1)

        c2 = []
        for count, name in self.players[1].deck:
            for i in range(count):
                card = g_cards.get(name)
                if card is not None:
                    cardObject = createCardObject(self.game, card)
                    c2.append(cardObject)
                else:
                    print ("Card %s doesn't exist!" % name)

        random.shuffle(c2)
        self.game.create_player(self.players[1].user.login, c2)

        self.game.process_push(MainGameProcess())

        self.current_actions = self.game.next(None)

        self.current_state = ab_game_state(self.game, self.current_actions)

        # Get the current ab_player by the role
        self.current_player = None
        for ab_player in self.players:
            if ab_player.role == self.current_state["player"]:
                self.current_player = ab_player

        g_factory.dispatch("http://manaclash.org/game/" + str(self.id) + "/state", self.current_state)
Exemplo n.º 2
0
            cards[card.name] = card

        oracleFile.close()

    output = Output()
    g = Game(output)
    g.create()

#    ig = input_generator(g)

    c1 = []
    for count, name in parse_deckfile(sys.argv[1]):
        for i in range(count):
            card = cards.get(name)
            if card is not None:
                cardObject = createCardObject(g, card)
                c1.append(cardObject)
            else:
                print ("Card %s doesn't exist!" % name)

    random.shuffle(c1)
    g.create_player("Player1", c1)

    c2 = []
    for count, name in parse_deckfile(sys.argv[2]):
        for i in range(count):
            card = cards.get(name)
            if card is not None:
                cardObject = createCardObject(g, card)
                c2.append(cardObject)
            else: