mirror of
https://github.com/neogeek23/Dominion-Strategy-Simulator.git
synced 2026-02-04 11:08:18 +00:00
Add files via upload
Added merchant functionality. Updated hand, player, and supply consequently.
This commit is contained in:
parent
284cfdd9f4
commit
a65c6b682f
7
game.py
7
game.py
@ -4,6 +4,8 @@ from card import Card
|
|||||||
from militia import Militia
|
from militia import Militia
|
||||||
from moat import Moat
|
from moat import Moat
|
||||||
from cellar import Cellar
|
from cellar import Cellar
|
||||||
|
from merchant import Merchant
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -68,8 +70,8 @@ def get_card_info():
|
|||||||
["Curse", 0, Card.CardType.Curse, -1, 0, 0, 0, 0, Card, 30], # 7
|
["Curse", 0, Card.CardType.Curse, -1, 0, 0, 0, 0, Card, 30], # 7
|
||||||
["Cellar", 2, Card.CardType.Action, 0, 0, 1, 0, 0, Cellar, 10], # 8
|
["Cellar", 2, Card.CardType.Action, 0, 0, 1, 0, 0, Cellar, 10], # 8
|
||||||
["Market", 5, Card.CardType.Action, 0, 1, 1, 1, 1, Card, 10], # 9
|
["Market", 5, Card.CardType.Action, 0, 1, 1, 1, 1, Card, 10], # 9
|
||||||
["Merchant", 3, Card.CardType.Action, 0, 0, 1, 0, 1, Card, 10], # 10*
|
["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
|
["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, Card, 10], # 12*
|
||||||
["Moat", 2, Card.CardType.Reaction, 0, 0, 0, 0, 2, Moat, 10], # 13
|
["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*
|
["Remodel", 4, Card.CardType.Action, 0, 0, 0, 0, 0, Card, 10], # 14*
|
||||||
@ -82,6 +84,7 @@ 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 [["Market", 2], ["Merchant", 2], ["Smithy", 2], ["Village", 2], ["Moat", 2]]
|
||||||
# return [["Militia", 4], ["Cellar", 3], ["Moat", 3]]
|
# return [["Militia", 4], ["Cellar", 3], ["Moat", 3]]
|
||||||
|
# return [["Silver", 7], ["Merchant", 3]]
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
14
merchant.py
Normal file
14
merchant.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from card import Card
|
||||||
|
|
||||||
|
|
||||||
|
class Merchant(Card):
|
||||||
|
def effect(self):
|
||||||
|
silver_card_index = self._Card__owner.get_hand().get_index_of_card_by_name("Silver")
|
||||||
|
if silver_card_index >= 0:
|
||||||
|
yes_no = input("Player " + str(self._Card__owner.get_table().get_players().index(self._Card__owner)) + ", "
|
||||||
|
+ "input 'Y' if you'd like to play a silver card and gain an extra coin: ")
|
||||||
|
|
||||||
|
if yes_no:
|
||||||
|
self._Card__owner.get_hand().transfer_card_by_card(
|
||||||
|
self._Card__owner.get_hand().get_card(silver_card_index), self._Card__owner.get_discard())
|
||||||
|
self._Card__owner.add_purchase_power(3)
|
||||||
13
player.py
13
player.py
@ -35,6 +35,9 @@ class Player:
|
|||||||
def get_hand(self):
|
def get_hand(self):
|
||||||
return self.__hand
|
return self.__hand
|
||||||
|
|
||||||
|
def get_discard(self):
|
||||||
|
return self.__discard
|
||||||
|
|
||||||
def get_score(self):
|
def get_score(self):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -81,7 +84,7 @@ class Player:
|
|||||||
self.__hand.transfer_top_card(self.__discard)
|
self.__hand.transfer_top_card(self.__discard)
|
||||||
|
|
||||||
def discard_from_hand(self, n):
|
def discard_from_hand(self, n):
|
||||||
self.__hand.transfer_card(n, self.__discard)
|
self.__hand.transfer_card_by_index(n, self.__discard)
|
||||||
|
|
||||||
def play_card(self, acceptable_card_type, chances, counter):
|
def play_card(self, acceptable_card_type, chances, counter):
|
||||||
if chances > 0 and self.__hand.contains_one_of(acceptable_card_type):
|
if chances > 0 and self.__hand.contains_one_of(acceptable_card_type):
|
||||||
@ -95,10 +98,10 @@ class Player:
|
|||||||
print("Acceptable inputs range from 0 to " + str(self.__hand.get_remaining() - 1) + ". 1 chance lost.")
|
print("Acceptable inputs range from 0 to " + str(self.__hand.get_remaining() - 1) + ". 1 chance lost.")
|
||||||
self.play_card(acceptable_card_type, chances - 1, counter)
|
self.play_card(acceptable_card_type, chances - 1, counter)
|
||||||
elif self.__hand.get_card(hand_index).get_type() in acceptable_card_type:
|
elif self.__hand.get_card(hand_index).get_type() in acceptable_card_type:
|
||||||
print("Player " + str(self.get_table().get_players().index(self)) + " playing: " +
|
card = self.__hand.get_card(hand_index)
|
||||||
self.__hand.get_card(hand_index).get_name())
|
print("Player " + str(self.get_table().get_players().index(self)) + " playing: " + card.get_name())
|
||||||
self.__hand.get_card(hand_index).play()
|
card.play()
|
||||||
self.__hand.transfer_card(hand_index, self.__discard)
|
self.__hand.transfer_card_by_card(card, self.__discard)
|
||||||
if counter is not None:
|
if counter is not None:
|
||||||
counter.int -= 1
|
counter.int -= 1
|
||||||
self.__print()
|
self.__print()
|
||||||
|
|||||||
26
supply.py
26
supply.py
@ -12,13 +12,33 @@ class Supply:
|
|||||||
def get_supply(self):
|
def get_supply(self):
|
||||||
return self.__card
|
return self.__card
|
||||||
|
|
||||||
def transfer_top_card(self, recipient_supply):
|
def get_index_of_card_by_name(self, name):
|
||||||
self.transfer_card(len(self.__card) - 1, recipient_supply)
|
for c in self.__card:
|
||||||
|
if c.get_name() == name:
|
||||||
|
return self.__card.index(c)
|
||||||
|
return -1
|
||||||
|
|
||||||
def transfer_card(self, n, recipient_supply):
|
def get_index_of_card_by_card(self, card):
|
||||||
|
for c in self.__card:
|
||||||
|
if c == card:
|
||||||
|
return self.__card.index(c)
|
||||||
|
return -1
|
||||||
|
|
||||||
|
def transfer_top_card(self, recipient_supply):
|
||||||
|
self.transfer_card_by_index(len(self.__card) - 1, recipient_supply)
|
||||||
|
|
||||||
|
def transfer_card_by_index(self, n, recipient_supply):
|
||||||
transfer_card = self.__card.pop(n)
|
transfer_card = self.__card.pop(n)
|
||||||
recipient_supply.add_card(transfer_card)
|
recipient_supply.add_card(transfer_card)
|
||||||
|
|
||||||
|
def transfer_card_by_card(self, card, recipient_supply):
|
||||||
|
card_index = self.get_index_of_card_by_card(card)
|
||||||
|
|
||||||
|
if card_index >= 0:
|
||||||
|
self.transfer_card_by_index(card_index, recipient_supply)
|
||||||
|
else:
|
||||||
|
raise ValueError('Card not found in hand during attempt to transfer card.')
|
||||||
|
|
||||||
def get_card(self, n):
|
def get_card(self, n):
|
||||||
return self.__card[n]
|
return self.__card[n]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user