mirror of
https://github.com/neogeek23/Dominion-Strategy-Simulator.git
synced 2026-02-04 02:58:16 +00:00
Add files via upload
This commit is contained in:
parent
3604e666a5
commit
03fb263288
5
card/basic/card_action.py
Normal file
5
card/basic/card_action.py
Normal file
@ -0,0 +1,5 @@
|
||||
from card.basic.card_kingdom import Kingdom
|
||||
|
||||
|
||||
class Action(Kingdom):
|
||||
pass
|
||||
5
card/basic/card_attack.py
Normal file
5
card/basic/card_attack.py
Normal file
@ -0,0 +1,5 @@
|
||||
from card.basic.card_kingdom import Kingdom
|
||||
|
||||
|
||||
class Attack(Kingdom):
|
||||
pass
|
||||
10
card/basic/card_curse.py
Normal file
10
card/basic/card_curse.py
Normal file
@ -0,0 +1,10 @@
|
||||
from card.card import Card
|
||||
|
||||
|
||||
class Curse(Card):
|
||||
@staticmethod
|
||||
def pile_setup(player_count):
|
||||
if player_count % Card.normal_full_table < Card.normal_full_table/2:
|
||||
return Card.pile_player_rate
|
||||
else:
|
||||
return (player_count - 1) * Card.pile_player_rate
|
||||
10
card/basic/card_kingdom.py
Normal file
10
card/basic/card_kingdom.py
Normal file
@ -0,0 +1,10 @@
|
||||
from card.card import Card
|
||||
from math import floor
|
||||
|
||||
|
||||
class Kingdom(Card):
|
||||
pile_player_rate = 10
|
||||
|
||||
@staticmethod
|
||||
def pile_setup(player_count):
|
||||
return (floor(player_count/Card.normal_full_table) + 1) * Card.pile_player_rate
|
||||
5
card/basic/card_reaction.py
Normal file
5
card/basic/card_reaction.py
Normal file
@ -0,0 +1,5 @@
|
||||
from card.basic.card_kingdom import Kingdom
|
||||
|
||||
|
||||
class Reaction(Kingdom):
|
||||
pass
|
||||
8
card/basic/card_treasure.py
Normal file
8
card/basic/card_treasure.py
Normal file
@ -0,0 +1,8 @@
|
||||
from card.card import Card
|
||||
from math import floor
|
||||
|
||||
|
||||
class Treasure(Card):
|
||||
@classmethod
|
||||
def pile_setup(cls, player_count):
|
||||
return (floor(player_count/Card.normal_full_table) + 1) * cls.pile_player_rate
|
||||
21
card/basic/card_victory.py
Normal file
21
card/basic/card_victory.py
Normal file
@ -0,0 +1,21 @@
|
||||
from card.card import Card
|
||||
from math import floor
|
||||
|
||||
|
||||
class Victory(Card):
|
||||
two_player_count = 8
|
||||
four_player_count = 12
|
||||
five_player_count = 15
|
||||
six_player_count = 18
|
||||
|
||||
@classmethod
|
||||
def pile_setup(cls, player_count):
|
||||
if 0 < player_count % Card.normal_full_table < Card.normal_full_table/2:
|
||||
supplement = cls.two_player_count
|
||||
elif Card.normal_full_table/2 <= player_count % Card.normal_full_table < Card.normal_full_table - 1:
|
||||
supplement = cls.four_player_count
|
||||
elif player_count % Card.normal_full_table == Card.normal_full_table - 1:
|
||||
supplement = cls.five_player_count
|
||||
else:
|
||||
supplement = cls.six_player_count
|
||||
return (floor(player_count/Card.normal_full_table) * cls.six_player_count) + supplement
|
||||
@ -1,7 +1,7 @@
|
||||
from card.card import Card
|
||||
from card.basic.card_action import Action
|
||||
|
||||
|
||||
class Cellar(Card):
|
||||
class Cellar(Action):
|
||||
def effect(self):
|
||||
hand_index = 0
|
||||
cards_discarded = 0
|
||||
|
||||
5
card/named/copper.py
Normal file
5
card/named/copper.py
Normal file
@ -0,0 +1,5 @@
|
||||
from card.basic.card_treasure import Treasure
|
||||
|
||||
|
||||
class Copper(Treasure):
|
||||
pile_player_rate = 60
|
||||
8
card/named/estate.py
Normal file
8
card/named/estate.py
Normal file
@ -0,0 +1,8 @@
|
||||
from card.basic.card_victory import Victory
|
||||
|
||||
|
||||
class Estate(Victory):
|
||||
two_player_count = 14
|
||||
four_player_count = 18
|
||||
five_player_count = 21
|
||||
six_player_count = 24
|
||||
5
card/named/gold.py
Normal file
5
card/named/gold.py
Normal file
@ -0,0 +1,5 @@
|
||||
from card.basic.card_treasure import Treasure
|
||||
|
||||
|
||||
class Gold(Treasure):
|
||||
pile_player_rate = 30
|
||||
@ -1,7 +1,7 @@
|
||||
from card.card import Card
|
||||
from card.basic.card_action import Action
|
||||
|
||||
|
||||
class Merchant(Card):
|
||||
class Merchant(Action):
|
||||
def effect(self):
|
||||
silver_card_index = self._Card__owner.get_hand().get_index_of_card_by_name("Silver")
|
||||
if silver_card_index >= 0:
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
from card.card import Card
|
||||
from card.basic.card_attack import Attack
|
||||
from card.basic.card_action import Action
|
||||
from random import randint
|
||||
|
||||
|
||||
class Militia(Card):
|
||||
class Militia(Action, Attack):
|
||||
def effect(self):
|
||||
for player in self._Card__owner.get_table().get_players():
|
||||
if self._Card__owner != player and not player.get_hand().blocks_attack(self.get_name()):
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
from card.card import Card
|
||||
from card.card_gain_trash import CardGainTrash
|
||||
from card.basic.card_action import Action
|
||||
from card.basic.card_treasure import Treasure
|
||||
from card.special.card_gain_trash import CardGainTrash
|
||||
|
||||
|
||||
class Mine(CardGainTrash):
|
||||
class Mine(Action, CardGainTrash):
|
||||
coin_gain = 3
|
||||
trashable_type_restriction = [Card.CardType.Treasure]
|
||||
gainable_type_restriction = [Card.CardType.Treasure]
|
||||
trashable_type_restriction = Treasure
|
||||
gainable_type_restriction = Treasure
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from card.card import Card
|
||||
from card.basic.card_action import Action
|
||||
from card.basic.card_reaction import Reaction
|
||||
|
||||
|
||||
class Moat(Card):
|
||||
class Moat(Action, Reaction):
|
||||
prevent_attack = True
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from card.card_gain_trash import CardGainTrash
|
||||
from card.basic.card_action import Action
|
||||
from card.special.card_gain_trash import CardGainTrash
|
||||
|
||||
|
||||
class Remodel(CardGainTrash):
|
||||
class Remodel(Action, CardGainTrash):
|
||||
coin_gain = 2
|
||||
|
||||
6
card/named/silver.py
Normal file
6
card/named/silver.py
Normal file
@ -0,0 +1,6 @@
|
||||
from card.basic.card_treasure import Treasure
|
||||
|
||||
|
||||
class Silver(Treasure):
|
||||
pile_player_rate = 40
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
from card.card_gain import CardGain
|
||||
from card.basic.card_action import Action
|
||||
from card.special.card_gain import CardGain
|
||||
|
||||
|
||||
class Workshop(CardGain):
|
||||
class Workshop(Action, CardGain):
|
||||
coin_gain = 4
|
||||
|
||||
def effect(self):
|
||||
|
||||
@ -6,9 +6,9 @@ class CardGain(Card):
|
||||
|
||||
def gain_card(self, spending_limit):
|
||||
gainable_cards = self.__get_gainable_cards(spending_limit)
|
||||
self._Card__print_card_list(gainable_cards, "Gainable Cards: ")
|
||||
self.print_card_list(gainable_cards, "Gainable Cards: ")
|
||||
index = 0
|
||||
chances = self._Card__owner.get_std_chances()
|
||||
chances = self.get_owner().get_std_chances()
|
||||
|
||||
while len(gainable_cards) > 0 and 0 <= index < len(gainable_cards) - 1 and chances > 0:
|
||||
index = self.__get_gain_card()
|
||||
@ -18,24 +18,24 @@ class CardGain(Card):
|
||||
index = 0
|
||||
chances -= 1
|
||||
else:
|
||||
pile_index = self._Card__owner.get_table().get_pile_index_of_card(gainable_cards[index].get_name())
|
||||
print("Player " + str(self._Card__owner.get_player_index()) + " 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())
|
||||
self._Card__owner.claim_top_card(self._Card__owner.get_hand())
|
||||
pile_index = self.get_owner().get_table().get_pile_index_of_card(gainable_cards[index].get_name())
|
||||
print("Player " + str(self.get_owner().get_player_index()) + " drawing "
|
||||
+ self.get_owner().get_table().get_pile(pile_index).get_card_group().get_name() + " to hand.")
|
||||
self.get_owner().get_table().get_pile(pile_index).transfer_top_card(self.get_owner().get_hand())
|
||||
self.get_owner().claim_top_card(self.get_owner().get_hand())
|
||||
chances = 0
|
||||
|
||||
def __get_gain_card(self):
|
||||
return self.__Card_owner.get_general_input("\nPlease identify the index of which card you would like to "
|
||||
return self.get_owner().get_general_input("\nPlease identify the index of which card you would like to "
|
||||
"obtain: ", int)
|
||||
|
||||
def __get_gainable_cards(self, spending_limit):
|
||||
result = list()
|
||||
|
||||
for p in self._Card__owner.get_table().get_piles():
|
||||
for p in self.get_owner().get_table().get_piles():
|
||||
if p.get_card_group().get_cost() <= spending_limit:
|
||||
if self.gainable_type_restriction is None:
|
||||
result.append(p.get_card_group())
|
||||
elif p.get_card_group().get_type() in self.gainable_type_restriction:
|
||||
elif isinstance(p.get_card_group(), self.gainable_type_restriction):
|
||||
result.append(p.get_card_group())
|
||||
return result
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from card.card_trash import CardTrash
|
||||
from card.card_gain import CardGain
|
||||
from card.special.card_trash import CardTrash
|
||||
from card.special.card_gain import CardGain
|
||||
|
||||
|
||||
class CardGainTrash(CardTrash, CardGain):
|
||||
|
||||
@ -6,10 +6,10 @@ class CardTrash(Card):
|
||||
|
||||
def trash_card_get_cost(self):
|
||||
tc = self.__get_trashable_cards()
|
||||
self._Card__print_card_list(tc, " Trashable Cards: ")
|
||||
self.print_card_list(tc, " Trashable Cards: ")
|
||||
index = 0
|
||||
bonus = 0
|
||||
chances = self._Card__owner.get_std_chances()
|
||||
chances = self.get_owner().get_std_chances()
|
||||
|
||||
while 0 < len(tc) and 0 <= index < len(tc) - 1 and chances > 0:
|
||||
index = self.__get_card_to_trash()
|
||||
@ -19,9 +19,9 @@ class CardTrash(Card):
|
||||
index = 0
|
||||
chances -= 1
|
||||
else:
|
||||
print("Player " + str(self._Card__owner.get_player_index()) + " trashing " + tc[index].get_name() + ".")
|
||||
print("Player " + str(self.get_owner().get_player_index()) + " trashing " + tc[index].get_name() + ".")
|
||||
bonus = tc[index].get_cost()
|
||||
self._Card__owner.get_hand().transfer_card_by_card(tc[index], self._Card__owner.get_table().get_trash())
|
||||
self.get_owner().get_hand().transfer_card_by_card(tc[index], self.get_owner().get_table().get_trash())
|
||||
chances = 0
|
||||
return bonus
|
||||
|
||||
@ -29,15 +29,15 @@ class CardTrash(Card):
|
||||
self.trash_card_get_cost()
|
||||
|
||||
def __get_card_to_trash(self):
|
||||
return self.__Card_owner.get_general_input("\nPlease identify the index of the desired card to trash: ", int)
|
||||
return self.get_owner().get_general_input("\nPlease identify the index of the desired card to trash: ", int)
|
||||
|
||||
def __get_trashable_cards(self):
|
||||
result = list()
|
||||
|
||||
for c in self._Card__owner.get_hand().get_supply():
|
||||
for c in self.get_owner().get_hand().get_supply():
|
||||
if c != self:
|
||||
if self.trashable_type_restriction is None:
|
||||
result.append(c)
|
||||
elif c.get_type() in self.trashable_type_restriction:
|
||||
elif isinstance(c, self.trashable_type_restriction):
|
||||
result.append(c)
|
||||
return result
|
||||
|
||||
71
game.py
71
game.py
@ -1,14 +1,20 @@
|
||||
from table.table import Table
|
||||
from player.human import Human
|
||||
from player.bots.pure_big_money import Pure_Big_Money
|
||||
from card.card import Card
|
||||
from card.militia import Militia
|
||||
from card.moat import Moat
|
||||
from card.cellar import Cellar
|
||||
from card.merchant import Merchant
|
||||
from card.mine import Mine
|
||||
from card.remodel import Remodel
|
||||
from card.workshop import Workshop
|
||||
from card.basic.card_action import Action
|
||||
from card.basic.card_curse import Curse
|
||||
from card.basic.card_victory import Victory
|
||||
from card.named.estate import Estate
|
||||
from card.named.copper import Copper
|
||||
from card.named.silver import Silver
|
||||
from card.named.gold import Gold
|
||||
from card.named.militia import Militia
|
||||
from card.named.moat import Moat
|
||||
from card.named.cellar import Cellar
|
||||
from card.named.merchant import Merchant
|
||||
from card.named.mine import Mine
|
||||
from card.named.remodel import Remodel
|
||||
from card.named.workshop import Workshop
|
||||
|
||||
|
||||
def main():
|
||||
@ -31,14 +37,15 @@ def setup_new_game(game_list, parameter, card_info):
|
||||
index = 0
|
||||
for p in parameter[2:]:
|
||||
if p:
|
||||
for i in range(card_info[index][9]):
|
||||
card = card_info[index][8](card_info[index][0], card_info[index][1], card_info[index][2],
|
||||
for i in range(card_info[index][7].pile_setup(humans + bots)):
|
||||
card = card_info[index][7](card_info[index][0], card_info[index][1], card_info[index][2],
|
||||
card_info[index][3], card_info[index][4], card_info[index][5],
|
||||
card_info[index][6], card_info[index][7], None)
|
||||
card_info[index][6], None)
|
||||
if i == 0:
|
||||
t.create_pile(card)
|
||||
else:
|
||||
t.get_pile(t.get_pile_index_of_card(card_info[index][0])).add_card(card)
|
||||
card_info[index][7].setup()
|
||||
index += 1
|
||||
|
||||
for i in range(humans):
|
||||
@ -62,25 +69,25 @@ def get_game_parameters():
|
||||
|
||||
|
||||
def get_card_info():
|
||||
# 0 1 2 3 4 5 6 7 8 9
|
||||
# [name, cost, cardtype, v, c, a, b, d, class, count] - values to pass to Card()
|
||||
return [["Copper", 0, Card.CardType.Treasure, 0, 1, 0, 0, 0, Card, 60], # 1
|
||||
["Silver", 3, Card.CardType.Treasure, 0, 2, 0, 0, 0, Card, 40], # 2
|
||||
["Gold", 6, Card.CardType.Treasure, 0, 3, 0, 0, 0, Card, 30], # 3
|
||||
["Estate", 2, Card.CardType.Victory, 1, 0, 0, 0, 0, Card, 40], # 4
|
||||
["Dutchy", 5, Card.CardType.Victory, 3, 0, 0, 0, 0, Card, 12], # 5
|
||||
["Province", 8, Card.CardType.Victory, 6, 0, 0, 0, 0, Card, 12], # 6
|
||||
["Curse", 0, Card.CardType.Curse, -1, 0, 0, 0, 0, Card, 10], # 7
|
||||
["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
|
||||
["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, 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, Remodel, 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, Workshop, 10]] # 17
|
||||
# 0 1 2 3 4 5 6 7
|
||||
# [name, cost, v, c, a, b, d, class] - values to pass to Card()
|
||||
return [["Copper", 0, 0, 1, 0, 0, 0, Copper], # 0
|
||||
["Silver", 3, 0, 2, 0, 0, 0, Silver], # 1
|
||||
["Gold", 6, 0, 3, 0, 0, 0, Gold], # 2
|
||||
["Estate", 2, 1, 0, 0, 0, 0, Estate], # 3
|
||||
["Dutchy", 5, 3, 0, 0, 0, 0, Victory], # 4
|
||||
["Province", 8, 6, 0, 0, 0, 0, Victory], # 5
|
||||
["Curse", 0, -1, 0, 0, 0, 0, Curse], # 6
|
||||
["Cellar", 2, 0, 0, 1, 0, 0, Cellar], # 7
|
||||
["Market", 5, 0, 1, 1, 1, 1, Action], # 8
|
||||
["Merchant", 3, 0, 0, 1, 0, 1, Merchant], # 9
|
||||
["Militia", 4, 0, 2, 0, 0, 0, Militia], # 10
|
||||
["Mine", 5, 0, 0, 0, 0, 0, Mine], # 11
|
||||
["Moat", 2, 0, 0, 0, 0, 2, Moat], # 12
|
||||
["Remodel", 4, 0, 0, 0, 0, 0, Remodel], # 13
|
||||
["Smithy", 4, 0, 0, 0, 0, 3, Action], # 14
|
||||
["Village", 3, 0, 0, 2, 0, 1, Action], # 15
|
||||
["Workshop", 4, 0, 0, 0, 0, 0, Workshop]] # 16
|
||||
# Big Money
|
||||
# ["Adventurer",
|
||||
# ["Bureaucrat",
|
||||
@ -107,8 +114,8 @@ def get_card_info():
|
||||
|
||||
|
||||
def get_starting_deck():
|
||||
# return [["Copper", 7], ["Estate", 3]]
|
||||
return [["Market", 2], ["Merchant", 2], ["Smithy", 2], ["Village", 2], ["Moat", 2]]
|
||||
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", 4], ["Mine", 2], ["Remodel", 2], ["Workshop", 2]]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user