mirror of
https://github.com/neogeek23/Dominion-Strategy-Simulator.git
synced 2026-02-04 11:08:18 +00:00
Add files via upload
This commit is contained in:
parent
ce4eddcf72
commit
4ebe98a0a1
6
card.py
6
card.py
@ -27,9 +27,11 @@ class Card:
|
|||||||
player.add_buys(self.__buy)
|
player.add_buys(self.__buy)
|
||||||
player.add_purchase_power(self.__coin)
|
player.add_purchase_power(self.__coin)
|
||||||
player.add_reactions(self.__reaction)
|
player.add_reactions(self.__reaction)
|
||||||
self.effect()
|
player.draw_cards(self.__draw)
|
||||||
|
self.effect(player)
|
||||||
|
|
||||||
def effect(self):
|
def effect(self, player):
|
||||||
|
# This is here so that 'special' cards can override this function so that unique card effects can happen.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
|
|||||||
48
game.py
48
game.py
@ -30,11 +30,11 @@ def setup_new_game(game_list, parameter, card_info):
|
|||||||
human.draw_hand()
|
human.draw_hand()
|
||||||
t.add_player(human)
|
t.add_player(human)
|
||||||
|
|
||||||
for i in range(bots):
|
# for i in range(bots):
|
||||||
bot = Player(False, t)
|
# bot = Player(False, t)
|
||||||
bot.draw_deck(t, get_starting_deck())
|
# bot.draw_deck(t, get_starting_deck())
|
||||||
bot.draw_hand()
|
# bot.draw_hand()
|
||||||
t.add_player(bot)
|
# t.add_player(bot)
|
||||||
|
|
||||||
game_list.append(t)
|
game_list.append(t)
|
||||||
|
|
||||||
@ -49,26 +49,30 @@ def get_game_parameters():
|
|||||||
|
|
||||||
def get_card_info():
|
def get_card_info():
|
||||||
# [name, cost, cardtype, v, c, a, r, b, d, effect, count] - value to pass to Card()
|
# [name, cost, cardtype, v, c, a, r, b, d, effect, count] - value to pass to Card()
|
||||||
return [["Copper", 0, Card.CardType.Treasure, 0, 1, 0, 0, 0, 0, None, 60],
|
return [["Copper", 0, Card.CardType.Treasure, 0, 1, 0, 0, 0, 0, None, 60], # 1
|
||||||
["Silver", 3, Card.CardType.Treasure, 0, 2, 0, 0, 0, 0, None, 40],
|
["Silver", 3, Card.CardType.Treasure, 0, 2, 0, 0, 0, 0, None, 40], # 2
|
||||||
["Gold", 6, Card.CardType.Treasure, 0, 3, 0, 0, 0, 0, None, 30],
|
["Gold", 6, Card.CardType.Treasure, 0, 3, 0, 0, 0, 0, None, 30], # 3
|
||||||
["Estate", 2, Card.CardType.Victory, 1, 0, 0, 0, 0, 0, None, 24],
|
|
||||||
["Dutchy", 5, Card.CardType.Victory, 3, 0, 0, 0, 0, 0, None, 12],
|
["Estate", 2, Card.CardType.Victory, 1, 0, 0, 0, 0, 0, None, 24], # 4
|
||||||
["Province", 8, Card.CardType.Victory, 6, 0, 0, 0, 0, 0, None, 12],
|
["Dutchy", 5, Card.CardType.Victory, 3, 0, 0, 0, 0, 0, None, 12], # 5
|
||||||
["Curse", 0, Card.CardType.Curse, -1, 0, 0, 0, 0, 0, None, 30],
|
["Province", 8, Card.CardType.Victory, 6, 0, 0, 0, 0, 0, None, 12], # 6
|
||||||
["Cellar", 2, Card.CardType.Action, 0, 0, 1, 0, 0, 0, "Name", 10],
|
|
||||||
["Market", 5, Card.CardType.Action, 0, 1, 1, 0, 1, 1, None, 10],
|
["Curse", 0, Card.CardType.Curse, -1, 0, 0, 0, 0, 0, None, 30], # 7
|
||||||
["Merchant", 3, Card.CardType.Action, 0, 0, 1, 0, 0, 1, "Name", 10],
|
|
||||||
["Militia", 4, Card.CardType.Attack, 0, 2, 0, 1, 0, 0, "Name", 10],
|
["Cellar", 2, Card.CardType.Action, 0, 0, 1, 0, 0, 0, "Name", 10], # 8
|
||||||
["Mine", 5, Card.CardType.Action, 0, 0, 0, 0, 0, 0, "Name", 10],
|
["Market", 5, Card.CardType.Action, 0, 1, 1, 0, 1, 1, None, 10], # 9
|
||||||
["Moat", 2, Card.CardType.Reaction, 0, 0, 0, 0, 0, 2, "Name", 10],
|
["Merchant", 3, Card.CardType.Action, 0, 0, 1, 0, 0, 1, "Name", 10], # 10
|
||||||
["Remodel", 4, Card.CardType.Action, 0, 0, 0, 0, 0, 0, "Name", 10],
|
["Militia", 4, Card.CardType.Attack, 0, 2, 0, 1, 0, 0, "Name", 10], # 11
|
||||||
["Smithy", 4, Card.CardType.Action, 0, 0, 0, 0, 0, 3, None, 10],
|
["Mine", 5, Card.CardType.Action, 0, 0, 0, 0, 0, 0, "Name", 10], # 12
|
||||||
["Village", 3, Card.CardType.Action, 0, 0, 2, 0, 0, 1, None, 10],
|
["Moat", 2, Card.CardType.Reaction, 0, 0, 0, 0, 0, 2, "Name", 10], # 13
|
||||||
["Workshop", 4, Card.CardType.Action, 0, 0, 0, 0, 0, 0, "Name", 10]]
|
["Remodel", 4, Card.CardType.Action, 0, 0, 0, 0, 0, 0, "Name", 10], # 14
|
||||||
|
["Smithy", 4, Card.CardType.Action, 0, 0, 0, 0, 0, 3, None, 10], # 15
|
||||||
|
["Village", 3, Card.CardType.Action, 0, 0, 2, 0, 0, 1, None, 10], # 16
|
||||||
|
["Workshop", 4, Card.CardType.Action, 0, 0, 0, 0, 0, 0, "Name", 10]] # 17
|
||||||
|
|
||||||
|
|
||||||
def get_starting_deck():
|
def get_starting_deck():
|
||||||
return [["Copper", 7], ["Estate", 3]]
|
return [["Copper", 7], ["Estate", 3]]
|
||||||
|
# return [["Market", 2], ["Merchant", 2], ["Smithy", 2], ["Village", 2], ["Moat", 2]]
|
||||||
|
|
||||||
main()
|
main()
|
||||||
72
player.py
72
player.py
@ -13,7 +13,6 @@ class Player:
|
|||||||
self.__purchase_power = 0
|
self.__purchase_power = 0
|
||||||
self.__actions = Counter(0)
|
self.__actions = Counter(0)
|
||||||
self.__buys = 0
|
self.__buys = 0
|
||||||
self.__draws = 0
|
|
||||||
self.__reactions = Counter(0)
|
self.__reactions = Counter(0)
|
||||||
self.__is_human = human
|
self.__is_human = human
|
||||||
self.__table = table
|
self.__table = table
|
||||||
@ -27,9 +26,6 @@ class Player:
|
|||||||
def add_buys(self, n):
|
def add_buys(self, n):
|
||||||
self.__buys += n
|
self.__buys += n
|
||||||
|
|
||||||
def add_draws(self, n):
|
|
||||||
self.__draws += n
|
|
||||||
|
|
||||||
def add_reactions(self, n):
|
def add_reactions(self, n):
|
||||||
self.__reactions.int += n
|
self.__reactions.int += n
|
||||||
|
|
||||||
@ -41,6 +37,14 @@ class Player:
|
|||||||
|
|
||||||
def draw_cards(self, how_many):
|
def draw_cards(self, how_many):
|
||||||
spillover = how_many - self.__deck.get_remaining()
|
spillover = how_many - self.__deck.get_remaining()
|
||||||
|
lacking_cards = spillover - self.__discard.get_remaining()
|
||||||
|
|
||||||
|
if lacking_cards <= 0:
|
||||||
|
lacking_cards = 0
|
||||||
|
elif lacking_cards == 1:
|
||||||
|
print("You are lacking " + str(lacking_cards) + " card. You cannot draw anymore.")
|
||||||
|
else:
|
||||||
|
print("You are lacking " + str(lacking_cards) + " cards. You cannot draw anymore.")
|
||||||
|
|
||||||
if spillover > 0:
|
if spillover > 0:
|
||||||
for i in range(how_many - spillover):
|
for i in range(how_many - spillover):
|
||||||
@ -48,7 +52,7 @@ class Player:
|
|||||||
|
|
||||||
self.__discard.cycle_card(self.__deck)
|
self.__discard.cycle_card(self.__deck)
|
||||||
|
|
||||||
for i in range(spillover):
|
for i in range(spillover - lacking_cards):
|
||||||
self.draw_card()
|
self.draw_card()
|
||||||
else:
|
else:
|
||||||
for i in range(how_many):
|
for i in range(how_many):
|
||||||
@ -69,16 +73,29 @@ class Player:
|
|||||||
self.__hand.transfer_top_card(self.__discard)
|
self.__hand.transfer_top_card(self.__discard)
|
||||||
|
|
||||||
def __print_hand(self):
|
def __print_hand(self):
|
||||||
print("Hand:")
|
print("\nHand:")
|
||||||
self.__hand.print()
|
self.__hand.print()
|
||||||
|
print("\n")
|
||||||
|
|
||||||
def __print_discard(self):
|
def __print_discard(self):
|
||||||
print("Discard:")
|
print("\nDiscard:")
|
||||||
self.__discard.print()
|
self.__discard.print()
|
||||||
|
print("\n")
|
||||||
|
|
||||||
def __print_deck(self):
|
def __print_deck(self):
|
||||||
print("Deck")
|
print("\nDeck")
|
||||||
self.__deck.print()
|
self.__deck.print()
|
||||||
|
print("\n")
|
||||||
|
|
||||||
|
def __print(self):
|
||||||
|
print("\nPlayer:")
|
||||||
|
print("Actions: " + str(self.__actions.int))
|
||||||
|
print("Reactions: " + str(self.__reactions.int))
|
||||||
|
print("Buys: " + str(self.__buys))
|
||||||
|
print("Coin: " + str(self.__purchase_power))
|
||||||
|
self.__print_hand()
|
||||||
|
self.__print_discard()
|
||||||
|
self.__print_deck()
|
||||||
|
|
||||||
def __gain_turn_events(self):
|
def __gain_turn_events(self):
|
||||||
self.add_actions(1)
|
self.add_actions(1)
|
||||||
@ -88,15 +105,19 @@ class Player:
|
|||||||
if chances > 0 and self.__hand.contains_one_of(acceptable_card_type):
|
if chances > 0 and self.__hand.contains_one_of(acceptable_card_type):
|
||||||
hand_index = int(input("Please identify a card from hand you would like to play by providing its index: "))
|
hand_index = int(input("Please identify a card from hand you would like to play by providing its index: "))
|
||||||
|
|
||||||
if self.__hand.get_card(hand_index).get_type() in acceptable_card_type:
|
if hand_index < 0:
|
||||||
|
print("You have elected to forfeit any remaining plays.")
|
||||||
|
if counter is not None:
|
||||||
|
counter.int = 0
|
||||||
|
elif hand_index >= self.__hand.get_remaining():
|
||||||
|
print("Acceptible inputs range from 0 to " + str(self.__hand.get_remaining() - 1) + ". Try again.")
|
||||||
|
self.play_card(acceptable_card_type, chances - 1, counter)
|
||||||
|
elif self.__hand.get_card(hand_index).get_type() in acceptable_card_type:
|
||||||
self.__hand.get_card(hand_index).play(self)
|
self.__hand.get_card(hand_index).play(self)
|
||||||
self.__hand.transfer_card(hand_index, self.__discard)
|
self.__hand.transfer_card(hand_index, self.__discard)
|
||||||
if counter is not None:
|
if counter is not None:
|
||||||
counter.int -= 1
|
counter.int -= 1
|
||||||
elif hand_index < 0:
|
self.__print()
|
||||||
print("You have elected to forfeit any remaining plays.")
|
|
||||||
if counter is not None:
|
|
||||||
counter.int = 0
|
|
||||||
else:
|
else:
|
||||||
self.play_card(acceptable_card_type, chances - 1, counter)
|
self.play_card(acceptable_card_type, chances - 1, counter)
|
||||||
elif chances <= 0:
|
elif chances <= 0:
|
||||||
@ -118,15 +139,16 @@ class Player:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def take_buy(self):
|
def take_buy(self):
|
||||||
print("Please play all Treasure cards that you want to play.")
|
if self.__hand.contains_one_of([Card.CardType.Treasure]):
|
||||||
|
print("Please play all Treasure cards that you want to play.")
|
||||||
|
|
||||||
play_another = Counter(self.__hand.get_card_type_count(Card.CardType.Treasure))
|
play_another = Counter(self.__hand.get_card_type_count(Card.CardType.Treasure))
|
||||||
while play_another.int > 0:
|
while play_another.int > 0:
|
||||||
self.play_card([Card.CardType.Treasure], 3, play_another)
|
self.play_card([Card.CardType.Treasure], 3, play_another)
|
||||||
self.buy_card()
|
self.buy_card(3)
|
||||||
|
|
||||||
def buy_card(self):
|
def buy_card(self, chances):
|
||||||
while self.__buys > 0 and not self.__table.are_there_any_empty_piles():
|
while self.__buys > 0 and not self.__table.are_there_any_empty_piles() and chances > 0:
|
||||||
pile_index = int(input("Please identify a pile from the table that you'd like to purchase: "))
|
pile_index = int(input("Please identify a pile from the table that you'd like to purchase: "))
|
||||||
self.__table.get_pile(pile_index).transfer_top_card(self.__discard)
|
self.__table.get_pile(pile_index).transfer_top_card(self.__discard)
|
||||||
self.__buys -= 1
|
self.__buys -= 1
|
||||||
@ -136,10 +158,10 @@ class Player:
|
|||||||
self.__print_hand()
|
self.__print_hand()
|
||||||
self.__gain_turn_events()
|
self.__gain_turn_events()
|
||||||
self.take_action()
|
self.take_action()
|
||||||
self.__print_discard()
|
# self.__print_discard()
|
||||||
self.__print_deck()
|
# self.__print_deck()
|
||||||
# self.give_reaction()
|
# self.give_reaction()
|
||||||
self.take_buy()
|
self.take_buy()
|
||||||
# self.discard_remaining_hand()
|
self.discard_remaining_hand()
|
||||||
# self.draw_hand()
|
self.draw_hand()
|
||||||
# self.__print_hand()
|
self.__print_hand()
|
||||||
Loading…
x
Reference in New Issue
Block a user