Пример #1
0
def main():
	deck1 = random_draft(hero=MAGE)
	deck2 = random_draft(hero=WARRIOR)
	player1 = Player(name="Player1")
	player1.prepare_deck(deck1, MAGE)
	player2 = Player(name="Player2")
	player2.prepare_deck(deck2, WARRIOR)

	game = Game(players=(player1, player2))
	game.start()

	while True:
		heropower = game.current_player.hero.power
		# always play the hero power, just for kicks
		if heropower.is_playable():
			if heropower.has_target():
				heropower.play(target=random.choice(heropower.targets))
			else:
				heropower.play()
		# iterate over our hand and play whatever is playable
		for card in game.current_player.hand:
			if card.is_playable():
				if card.has_target():
					card.play(target=random.choice(card.targets))
				else:
					card.play()
			else:
				print("Not playing", card)

		# Randomly attack with whatever can attack
		for character in game.current_player.characters:
			if character.can_attack():
				character.attack(random.choice(character.targets))

		game.end_turn()
Пример #2
0
def prepare_empty_game(game_class=BaseTestGame):
    player1 = Player(name="Player1")
    player1.prepare_deck([], random.choice(_heroes))
    player1.cant_fatigue = True
    player2 = Player(name="Player2")
    player2.prepare_deck([], random.choice(_heroes))
    player2.cant_fatigue = True
    game = game_class(players=(player1, player2))
    game.start()

    return game
Пример #3
0
def prepare_empty_game(game_class=BaseTestGame):
	player1 = Player(name="Player1")
	player1.prepare_deck([], random.choice(_heroes))
	player1.cant_fatigue = True
	player2 = Player(name="Player2")
	player2.prepare_deck([], random.choice(_heroes))
	player2.cant_fatigue = True
	game = game_class(players=(player1, player2))
	game.start()

	return game
Пример #4
0
def play_full_game():
	deck1 = random_draft(hero=MAGE)
	deck2 = random_draft(hero=WARRIOR)
	player1 = Player(name="Player1")
	player1.prepare_deck(deck1, MAGE)
	player2 = Player(name="Player2")
	player2.prepare_deck(deck2, WARRIOR)

	game = Game(players=(player1, player2))
	game.start()

	for player in game.players:
		print("Can mulligan %r" % (player.choice.cards))
		mull_count = random.randint(0, len(player.choice.cards))
		cards_to_mulligan = random.sample(player.choice.cards, mull_count)
		player.choice.choose(*cards_to_mulligan)

	while True:
		player = game.current_player

		heropower = player.hero.power
		if heropower.is_usable() and random.random() < 0.1:
			if heropower.has_target():
				heropower.use(target=random.choice(heropower.targets))
			else:
				heropower.use()
			continue

		# iterate over our hand and play whatever is playable
		for card in player.hand:
			if card.is_playable() and random.random() < 0.5:
				target = None
				if card.choose_cards:
					card = random.choice(card.choose_cards)
				if card.has_target():
					target = random.choice(card.targets)
				print("Playing %r on %r" % (card, target))
				card.play(target=target)
				continue

		# Randomly attack with whatever can attack
		for character in player.characters:
			if character.can_attack():
				character.attack(random.choice(character.targets))
			continue

		if player.choice:
			choice = random.choice(player.choice.cards)
			print("Choosing card %r" % (choice))
			player.choice.choose(choice)
			continue

		game.end_turn()
Пример #5
0
def play_full_game():
    deck1 = random_draft(hero=MAGE)
    deck2 = random_draft(hero=WARRIOR)
    player1 = Player(name="Player1")
    player1.prepare_deck(deck1, MAGE)
    player2 = Player(name="Player2")
    player2.prepare_deck(deck2, WARRIOR)

    game = Game(players=(player1, player2))
    game.start()

    for player in game.players:
        print("Can mulligan %r" % (player.choice.cards))
        mull_count = random.randint(0, len(player.choice.cards))
        cards_to_mulligan = random.sample(player.choice.cards, mull_count)
        player.choice.choose(*cards_to_mulligan)

    while True:
        player = game.current_player

        heropower = player.hero.power
        if heropower.is_usable() and percent_chance(10):
            if heropower.has_target():
                heropower.use(target=random.choice(heropower.targets))
            else:
                heropower.use()
            continue

        # iterate over our hand and play whatever is playable
        for card in player.hand:
            if card.is_playable() and percent_chance(50):
                target = None
                if card.choose_cards:
                    card = random.choice(card.choose_cards)
                if card.has_target():
                    target = random.choice(card.targets)
                print("Playing %r on %r" % (card, target))
                card.play(target=target)
                continue

        # Randomly attack with whatever can attack
        for character in player.characters:
            if character.can_attack():
                character.attack(random.choice(character.targets))
            continue

        if player.choice:
            choice = random.choice(player.choice.cards)
            print("Choosing card %r" % (choice))
            player.choice.choose(choice)
            continue

        game.end_turn()
Пример #6
0
def play_game(hero1, hero2):
    deck1 = decks[hero1]
    player1 = Player(name="Player1")
    player1.prepare_deck(deck1, hero1)

    deck2 = decks[hero2]
    player2 = Player(name="Player2")
    player2.prepare_deck(deck2, hero2)

    game = Game(players=(player1, player2))
    game.start()

    player1.choice.choose(*[])
    player2.choice.choose(*[])

    while game.state != State.COMPLETE:
        try:
            heropower = game.current_player.hero.power
            if heropower.is_usable():
                if heropower.has_target():
                    heropower.use(target=random.choice(heropower.targets))
                else:
                    heropower.use()

            for card in game.current_player.hand:
                if card.is_playable():
                    target = None
                    if card.choose_cards:
                        card = random.choice(card.choose_cards)
                    if card.has_target():
                        target = random.choice(card.targets)
                    card.play(target=target)

            for character in game.current_player.characters:
                if character.can_attack():
                    character.attack(random.choice(character.targets))

            game.end_turn()
        except GameOver:
            pass

    if player1.playstate == PlayState.TIED:
        return None

    if player1.playstate == PlayState.WON:
        return player1

    return player2
Пример #7
0
def prepare_game(hero1=None, hero2=None, exclude=(), game_class=BaseTestGame):
    print("Initializing a new game")
    if hero1 is None:
        hero1 = random.choice(_heroes)
    if hero2 is None:
        hero2 = random.choice(_heroes)
    deck1 = _draft(hero=hero1, exclude=exclude)
    deck2 = _draft(hero=hero2, exclude=exclude)
    player1 = Player(name="Player1")
    player1.prepare_deck(deck1, hero1)
    player2 = Player(name="Player2")
    player2.prepare_deck(deck2, hero2)
    game = game_class(players=(player1, player2))
    game.start()

    return game
Пример #8
0
def main():
	deck1 = random_draft(hero=MAGE)
	deck2 = random_draft(hero=WARRIOR)
	player1 = Player(name="Player1")
	player1.prepare_deck(deck1, MAGE)
	player2 = Player(name="Player2")
	player2.prepare_deck(deck2, WARRIOR)

	game = Game(players=(player1, player2))
	game.start()

	for player in game.players:
		print("Can mulligan %r" % (player.choice.cards))
		mull_count = random.randint(0, len(player.choice.cards))
		cards_to_mulligan = random.sample(player.choice.cards, mull_count)
		player.choice.choose(*cards_to_mulligan)

	while True:
		heropower = game.current_player.hero.power
		# always play the hero power, just for kicks
		if heropower.is_usable():
			if heropower.has_target():
				heropower.use(target=random.choice(heropower.targets))
			else:
				heropower.use()
		# iterate over our hand and play whatever is playable
		for card in game.current_player.hand:
			if card.is_playable():
				target = None
				choice = None
				if card.has_target():
					target = random.choice(card.targets)
				if card.data.choose_cards:
					choice = random.choice(card.data.choose_cards)
				card.play(target=target, choose=choice)
			else:
				print("Not playing", card)

		# Randomly attack with whatever can attack
		for character in game.current_player.characters:
			if character.can_attack():
				character.attack(random.choice(character.targets))

		game.end_turn()
Пример #9
0
def main():
	deck1 = random_draft(hero=MAGE)
	deck2 = random_draft(hero=WARRIOR)
	player1 = Player(name="Player1")
	player1.prepare_deck(deck1, MAGE)
	player2 = Player(name="Player2")
	player2.prepare_deck(deck2, WARRIOR)

	game = Game(players=(player1, player2))
	game.start()

	for player in game.players:
		print("Can mulligan %r" % (player.choice.cards))
		mull_count = random.randint(0, len(player.choice.cards))
		cards_to_mulligan = random.sample(player.choice.cards, mull_count)
		player.choice.choose(*cards_to_mulligan)

	while True:
		heropower = game.current_player.hero.power
		# always play the hero power, just for kicks
		if heropower.is_usable():
			if heropower.has_target():
				heropower.use(target=random.choice(heropower.targets))
			else:
				heropower.use()
		# iterate over our hand and play whatever is playable
		for card in game.current_player.hand:
			if card.is_playable():
				target = None
				if card.choose_cards:
					card = random.choice(card.choose_cards)
				if card.has_target():
					target = random.choice(card.targets)
				print("Playing %r on %r" % (card, target))
				card.play(target=target)
			else:
				print("Not playing", card)

		# Randomly attack with whatever can attack
		for character in game.current_player.characters:
			if character.can_attack():
				character.attack(random.choice(character.targets))

		game.end_turn()
Пример #10
0
def play_game(hero1, hero2):
    open(log_file, 'w').close()

    deck1 = random_draft(hero=hero1)
    deck1[0] = "EX1_160a"
    player1 = Player(name="Player1")
    player1.prepare_deck(deck1, hero1)

    deck2 = random_draft(hero=hero2)
    deck2[0] = "EX1_160a"
    player2 = Player(name="Player2")
    player2.prepare_deck(deck2, hero2)

    game = Game(players=(player1, player2))
    game.start()

    player1.choice.choose(*[])
    player2.choice.choose(*[])

    while game.state != State.COMPLETE:
        try:
            heropower = game.current_player.hero.power
            if heropower.is_usable():
                if heropower.has_target():
                    heropower.use(target=random.choice(heropower.targets))
                else:
                    heropower.use()

            for card in game.current_player.hand:
                if card.is_playable():
                    target = None
                    if card.choose_cards:
                        card = random.choice(card.choose_cards)
                    if card.has_target():
                        target = random.choice(card.targets)
                    card.play(target=target)

            for character in game.current_player.characters:
                if character.can_attack():
                    character.attack(random.choice(character.targets))

            game.end_turn()
        except GameOver:
            pass
Пример #11
0
def prepare_game(hero1=None, hero2=None, exclude=(), game_class=BaseTestGame):
	print("Initializing a new game")
	if hero1 is None:
		hero1 = random.choice(_heroes)
	if hero2 is None:
		hero2 = random.choice(_heroes)
	deck1 = _draft(hero=hero1, exclude=exclude)
	deck2 = _draft(hero=hero2, exclude=exclude)
	player1 = Player(name="Player1")
	player1.prepare_deck(deck1, hero1)
	player2 = Player(name="Player2")
	player2.prepare_deck(deck2, hero2)
	game = game_class(players=(player1, player2))
	game.start()

	# Do empty mulligans
	for player in game.players:
		if player.choice:
			player.choice.choose()

	return game
Пример #12
0
	def create_game(self, payload):
		# self.game_id = payload["GameID"]
		player_data = payload["Players"]
		players = []
		for player in player_data:
			p = Player(player["Name"])
			# Shuffle the cards to prevent information leaking
			cards = player["Cards"]
			random.shuffle(cards)
			p.prepare_deck(cards, player["Hero"])
			players.append(p)

		INFO("Initializing a Kettle game with players=%r", players)
		game = Game(players=players)
		manager = KettleManager(game)
		game.manager.register(manager)
		game.current_player = game.players[0]  # Dumb.
		game.start()

		# Skip mulligan
		for player in game.players:
			player.choice = None

		return manager
Пример #13
0
    def create_game(self, payload):
        # self.game_id = payload["GameID"]
        player_data = payload["Players"]
        players = []
        for player in player_data:
            p = Player(player["Name"])
            # Shuffle the cards to prevent information leaking
            cards = player["Cards"]
            random.shuffle(cards)
            p.prepare_deck(cards, player["Hero"])
            players.append(p)

        INFO("Initializing a Kettle game with players=%r", players)
        game = Game(players=players)
        manager = KettleManager(game)
        game.manager.register(manager)
        game.current_player = game.players[0]  # Dumb.
        game.start()

        # Skip mulligan
        for player in game.players:
            player.choice = None

        return manager
Пример #14
0
def _prepare_player(name, hero, deck=[]):
	player = Player(name)
	player.prepare_deck(deck, hero)
	return player
Пример #15
0
def _prepare_player(name, hero, deck=[]):
    player = Player(name)
    player.prepare_deck(deck, hero)
    return player