Ejemplo n.º 1
0
 def print_all(self):
     logging.info('-------------------------------------')
     logging.info('%s status:' % self.name)
     logging.info('-------------------------------------')
     logging.info('Library  : ' + str(self.library))
     logging.info('Discard  : ' + str(self.discard))
     logging.info('Hand     : ' + str(self.hand))
     logging.info('In Play  : ' + str(self.in_play))
     logging.info('Actions : ' + str(self.actions_left))
     DUtilities.print_zone_nicely(self.hand)
     logging.info('-------------------------------------')
Ejemplo n.º 2
0
 def __init__(
     self,
     name="Player One",
 ):
     self.name = name
     self.hand = []
     self.library = [DCard.card_dict['Copper']]*7 + [DCard.card_dict['Estate']]*3
     self.discard = []
     self.in_play = []
     self.actions_left = 0
     logging.info('New player: %s' % self.name)
     DUtilities.shuffle(self.library)
Ejemplo n.º 3
0
 def draw_card(self):
     logging.debug('%s: Drawing one card.' % self.name)
     try:
         self.hand.append(self.library.pop(0))
     except IndexError: # throws if empty
         logging.debug('%s: Library is empty. Shuffling in discard pile.' % self.name)
         self.library.extend(self.discard)
         self.discard=[]
         DUtilities.shuffle(self.library)
         try:
             self.hand.append(self.library.pop(0))
         except IndexError:
             logging.info('%s: Cannot draw card. Library is empty.' % self.name)
Ejemplo n.º 4
0
def main() :
  logging.info('--> Starting the game. Shuffle the library and draw 5 cards.')

  players = []

  player_one = DPlayer.Player('Player 1')
  player_one.draw_hand()
  player_one.print_all()
  players.append(player_one)

  player_two = DPlayer.Player('Player 2')
  player_two.draw_hand()
  player_two.print_all()
  players.append(player_two)

  n_players = len(players)
  n_turns = 20;
  for i in range(n_turns):  
    
    # A turn has the following actions in order:
    #  - Play action cards
    #  - Play money in any order
    #  - Buy cards, placing them in the discard pile
    #  - Discard remaining cards in hand
    #  - Draw a new hand of 5 cards
    logging.info('\n === Turn ' + str(i+1) + ' === ')

    active_player_index = i % n_players
    active_player = players[active_player_index]

    #print_all()
    logging.info('Stockpile:')
    DUtilities.print_zone_nicely(stockpile)

    dumb_buy_CE_only(active_player)
    active_player.discard_hand()
    active_player.draw_hand()
    active_player.print_all()

    if is_game_over(): break 

  for player in players:
      logging.info('%s: %i victory points' % (
          player.name,
          player.count_victory_points(),
      ))
Ejemplo n.º 5
0
 def count_victory_points(self):
     return DUtilities.count_victory_points(
         self.hand + self.library + self.discard
     )
Ejemplo n.º 6
0
 def count_money(self):
     return DUtilities.count_money(self.hand)
Ejemplo n.º 7
0

        
           

if __name__ == '__main__':

    logging.basicConfig(level=logging.DEBUG, format='%(message)s') 

    test_player = Player('Testy McTesterson')
    logging.warning('Adding a Village to the standard starting cards!')
    test_player.library = \
      [DCard.card_dict['Village']]*1 + \
      [DCard.card_dict['Estate']]*3 + \
      [DCard.card_dict['Copper']]*7
    DUtilities.shuffle(test_player.library)
    test_player.print_all()

    test_player.draw_hand()
    test_player.print_all()

    test_player.discard_hand()
    test_player.print_all()

    test_player.draw_hand()
    test_player.print_all()

    test_player.draw_card()
    test_player.print_all()

    test_player.add_action()