mirror of
https://github.com/neogeek23/Dominion-Strategy-Simulator.git
synced 2026-02-04 19:18:18 +00:00
Add files via upload
added functionality for mine
This commit is contained in:
parent
ba27b02aee
commit
67db950879
9
card.py
9
card.py
@ -54,4 +54,11 @@ class Card:
|
||||
return self.__owner
|
||||
|
||||
def identify(self):
|
||||
return self.__name + ", " + str(self.__type) + ", " + str(self.__cost)
|
||||
return self.__name + ", " + str(self.__type) + ", " + str(self.__cost)
|
||||
|
||||
def __get_index_not_self(self):
|
||||
result = -1
|
||||
for c in self._Card__owner.get_hand().get_supply():
|
||||
if c != self:
|
||||
result = self._Card__owner.get_hand().get_supply().index(c)
|
||||
return result
|
||||
@ -19,13 +19,8 @@ class Cellar(Card):
|
||||
self._Card__owner.print_hand()
|
||||
cards_discarded += 1
|
||||
# in case last card is discarded as that will kill loop & set to itself
|
||||
hand_index = self.__get_last_non_cellar_card()
|
||||
hand_index = self.__get_index_not_self()
|
||||
have_not_run_yet = False
|
||||
self._Card__owner.add_actions(cards_discarded)
|
||||
|
||||
def __get_last_non_cellar_card(self):
|
||||
result = -1
|
||||
for c in self._Card__owner.get_hand().get_supply():
|
||||
if "Cellar" not in type(c).__name__:
|
||||
result = self._Card__owner.get_hand().get_supply().index(c)
|
||||
return result
|
||||
|
||||
|
||||
30
game.py
30
game.py
@ -5,7 +5,7 @@ from militia import Militia
|
||||
from moat import Moat
|
||||
from cellar import Cellar
|
||||
from merchant import Merchant
|
||||
|
||||
from mine import Mine
|
||||
|
||||
|
||||
def main():
|
||||
@ -72,19 +72,43 @@ def get_card_info():
|
||||
["Market", 5, Card.CardType.Action, 0, 1, 1, 1, 1, Card, 10], # 9
|
||||
["Merchant", 3, Card.CardType.Action, 0, 0, 1, 0, 1, Merchant, 10], # 10
|
||||
["Militia", 4, Card.CardType.Attack, 0, 2, 0, 0, 0, Militia, 10], # 11
|
||||
["Mine", 5, Card.CardType.Action, 0, 0, 0, 0, 0, Card, 10], # 12*
|
||||
["Mine", 5, Card.CardType.Action, 0, 0, 0, 0, 0, Mine, 10], # 12*
|
||||
["Moat", 2, Card.CardType.Reaction, 0, 0, 0, 0, 2, Moat, 10], # 13
|
||||
["Remodel", 4, Card.CardType.Action, 0, 0, 0, 0, 0, Card, 10], # 14*
|
||||
["Smithy", 4, Card.CardType.Action, 0, 0, 0, 0, 3, Card, 10], # 15
|
||||
["Village", 3, Card.CardType.Action, 0, 0, 2, 0, 1, Card, 10], # 16
|
||||
["Workshop", 4, Card.CardType.Action, 0, 0, 0, 0, 0, Card, 10]] # 17*
|
||||
# Big Money
|
||||
# ["Adventurer",
|
||||
# ["Bureaucrat",
|
||||
# ["Chancellor",
|
||||
# ["Chapel",
|
||||
# ["Feast",
|
||||
# ["Laboratory",
|
||||
# ["Moneylender",
|
||||
# ["Throne Room",
|
||||
# Interaction
|
||||
# ["Council Room",
|
||||
# ["Festival",
|
||||
# ["Library",
|
||||
# ["Spy",
|
||||
# ["Thief",
|
||||
# Size Distortion
|
||||
# ["Gardens",
|
||||
# ["Woodcuter",
|
||||
# ["Witch",
|
||||
# Villiage Square
|
||||
# Trash Heap
|
||||
# http://dominioncg.wikia.com/wiki/Pre-set_Sets_of_10
|
||||
# http://www.dominiondeck.com/games/popular
|
||||
|
||||
|
||||
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]]
|
||||
# return [["Militia", 4], ["Cellar", 3], ["Moat", 3]]
|
||||
# return [["Silver", 7], ["Merchant", 3]]
|
||||
return [["Copper", 6], ["Mine", 4]]
|
||||
|
||||
|
||||
main()
|
||||
|
||||
81
mine.py
Normal file
81
mine.py
Normal file
@ -0,0 +1,81 @@
|
||||
from card import Card
|
||||
|
||||
|
||||
class Mine(Card):
|
||||
def effect(self):
|
||||
treasure_cards = self.__get_Treasures()
|
||||
self.__print_Treasures(treasure_cards)
|
||||
trash_card = 0
|
||||
chances = self._Card__owner.get_std_chances()
|
||||
|
||||
while len(treasure_cards) > 0 and 0 <= trash_card < len(treasure_cards) - 1 and chances > 0:
|
||||
trash_card = int(input("\nPlayer " + str(self._Card__owner.get_table()
|
||||
.get_players().index(self._Card__owner))
|
||||
+ ", input the index of the treasure card you want to trash to gain another treasure "
|
||||
"card from the table's piles that costs up to 3 coins more than the trashed card: "))
|
||||
|
||||
if trash_card < 0 or trash_card >= len(treasure_cards):
|
||||
print("Acceptable inputs range from 0 to " + str(len(treasure_cards) - 1) + ". 1 chance lost.")
|
||||
trash_card = 0
|
||||
chances -= 1
|
||||
else:
|
||||
print("Player " + str(self._Card__owner.get_table().get_players().index(self._Card__owner))
|
||||
+ " trashing " + treasure_cards[trash_card].get_name() + ".")
|
||||
self.__gain_treasure(treasure_cards[trash_card].get_cost() + 3)
|
||||
self._Card__owner.get_hand().transfer_card_by_card(treasure_cards[trash_card],
|
||||
self._Card__owner.get_table().get_trash())
|
||||
self._Card__owner.claim_top_card(self._Card__owner.get_hand())
|
||||
# self._Card__owner.get
|
||||
chances = 0
|
||||
|
||||
def __gain_treasure(self, spending_limit):
|
||||
treasures_I_can_buy = self.__get_affordable_treasures(spending_limit)
|
||||
self.__print_affordable_treasures(treasures_I_can_buy)
|
||||
buy_card = 0
|
||||
chances = self._Card__owner.get_std_chances()
|
||||
|
||||
while len(treasures_I_can_buy) > 0 and 0 <= buy_card < len(treasures_I_can_buy) - 1 and chances > 0:
|
||||
buy_card = int(input("\nPlease identify the index of which treasure you would like to obtain: "))
|
||||
|
||||
if buy_card < 0 or buy_card >= len(treasures_I_can_buy):
|
||||
print("Acceptable inputs range from 0 to " + str(len(treasures_I_can_buy) - 1) + ". 1 chance lost.")
|
||||
buy_card = 0
|
||||
chances -= 1
|
||||
else:
|
||||
pile_index = self._Card__owner.get_table().get_piles().index(treasures_I_can_buy[buy_card])
|
||||
print("Player " + str(self._Card__owner.get_table().get_players().index(self._Card__owner))
|
||||
+ " drawing " + self._Card__owner.get_table().get_pile(pile_index).get_card_group().get_name()
|
||||
+ " to hand.")
|
||||
self._Card__owner.get_table().get_pile(pile_index).transfer_top_card(self._Card__owner.get_hand())
|
||||
|
||||
def __print_affordable_treasures(self, affordable_treasure):
|
||||
print("\nPlayer " + str(self._Card__owner.get_table().get_players().index(self._Card__owner))
|
||||
+ " Affordable Treasures: ")
|
||||
counter = 0
|
||||
for t in affordable_treasure:
|
||||
print(str(counter) + ": " + t.get_card_group().identify())
|
||||
counter += 1
|
||||
|
||||
def __get_affordable_treasures(self, spending_limit):
|
||||
result = list()
|
||||
|
||||
for p in self._Card__owner.get_table().get_piles():
|
||||
if p.get_card_group().get_cost() <= spending_limit \
|
||||
and p.get_card_group().get_type() == Card.CardType.Treasure:
|
||||
result.append(p)
|
||||
return result
|
||||
|
||||
def __get_Treasures(self):
|
||||
result = list()
|
||||
for c in self._Card__owner.get_hand().get_supply():
|
||||
if c.get_type() == Card.CardType.Treasure:
|
||||
result.append(c)
|
||||
return result
|
||||
|
||||
def __print_Treasures(self, Treasure):
|
||||
print("\nPlayer " + str(self._Card__owner.get_table().get_players().index(self._Card__owner)) + " Treasures:")
|
||||
index = 0
|
||||
for c in Treasure:
|
||||
print(str(index) + ": " + c.identify())
|
||||
index += 1
|
||||
|
||||
@ -73,7 +73,7 @@ class Player:
|
||||
index = table.get_pile_index_of_card(ds[0])
|
||||
for i in range(ds[1]):
|
||||
table.get_pile(index).transfer_top_card(self.__deck)
|
||||
self.__claim_top_card(self.__deck)
|
||||
self.claim_top_card(self.__deck)
|
||||
self.__deck.shuffle()
|
||||
|
||||
def draw_hand(self):
|
||||
@ -149,7 +149,7 @@ class Player:
|
||||
print("Player " + str(self.get_table().get_players().index(self)) + " buying card " +
|
||||
self.__table.get_pile(pile_index).get_card_group().get_name())
|
||||
self.__table.get_pile(pile_index).transfer_top_card(self.__discard)
|
||||
self.__claim_top_card(self.__discard)
|
||||
self.claim_top_card(self.__discard)
|
||||
self.__buys -= 1
|
||||
|
||||
def take_turn(self):
|
||||
@ -162,7 +162,7 @@ class Player:
|
||||
self.draw_hand()
|
||||
self.print_hand()
|
||||
|
||||
def __claim_top_card(self, supply):
|
||||
def claim_top_card(self, supply):
|
||||
supply.get_top_card().set_owner(self)
|
||||
|
||||
def print_hand(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user