def test_deck_load(): for deck_file in test_decks.keys(): deck = decks.Deck() deck.load_deck(data_dir + deck_file) assert (len(deck.main) == test_decks[deck_file]['main']) assert (len(deck.side) == test_decks[deck_file]['side']) assert (len([l for l in deck.main if 'Land' in l.cardData['types'] ]) == test_decks[deck_file['lands']])
def __init__(self, statics, screen_wt, screens): self.menu_screens_walker = urwid.SimpleFocusListWalker([]) self.menu = urwid.BoxAdapter(urwid.ListBox(self.menu_screens_walker), 100) super(GameScreen, self).__init__(statics, screen_wt, screens, [urwid.Padding(wt) for wt in [self.menu]]) self.menu_screens = [ self._build_game_screen, self._build_hand_screen, self._build_map_screen ] self.deck = decks.Deck(self.statics.EVENT_CARDS + self.statics.EVENT_CARDS + self.statics.PLAGUE_CARDS + self.statics.TRIUMPH_CARDS) self.drawn_cards_walker = urwid.SimpleFocusListWalker([]) self.drawn_cards_menu = urwid.ListBox(self.drawn_cards_walker) self.map_walker = urwid.SimpleFocusListWalker([]) self.map_menu = urwid.ListBox(self.map_walker) self.players_walker = urwid.SimpleFocusListWalker([]) self.players_menu = urwid.ListBox(self.players_walker) self.hand_cards_walker = urwid.SimpleFocusListWalker([]) self.hand_cards_menu = urwid.ListBox(self.hand_cards_walker) self.drawn_cards = [] if self.statics.CHARACTER_ID == 1: hand_ids = [8, 9, 10, 11, 12] upgraded_ids = [13, 14, 15] elif self.statics.CHARACTER_ID == 2: hand_ids = [0, 1, 2, 3, 4] upgraded_ids = [5, 6, 7] elif self.statics.CHARACTER_ID == 3: hand_ids = [16, 17, 18, 19, 20] upgraded_ids = [21, 22, 23] elif self.statics.CHARACTER_ID == 4: hand_ids = [24, 25, 26, 27, 28] upgraded_ids = [29, 30, 31] hand = [] for id in hand_ids: hand.append(self.statics.CHARACTER_CARDS[id]) for id in upgraded_ids: self.statics.UPGRADED_CARDS.append( self.statics.CHARACTER_CARDS[id]) self.statics.HAND = decks.Hand(hand) self.statics.HAND.draw(5) self.command = '' self.input_ = None self._change_to_menu_screen(0) self._start_sync()
def __init__(self): self.deck = decks.Deck() self.__grid_lines = [ # vertical line ((100, 0), (100, 459)), ((200, 0), (200, 459)), ((300, 0), (300, 459)), # horizontal line ((0, 153), (300, 153)), ((0, 306), (300, 306)), ] self.__grid = ([[0 for x in range(NUM_COLS - 2)] for y in range(NUM_ROW)]) self.__game_over = False self.__deck = self.deck.initialize_cards(2) self.deck.shuffle_cards(self.__deck) self.__selected = [] self.__select_check_ok = True self.__score = 0 self.__time_start = time.time()
def main(): import argparse parser = argparse.ArgumentParser(description='Magic game sim') parser.add_argument('--turns', type=int, metavar='T', help="Number of turns each sim game runs", default=20) parser.add_argument('--rounds', type=int, metavar='N', help="Number of sim games", default=1) parser.add_argument('--decks', metavar='D', help='Decks to play', nargs='+', required=True) # parser.add_argument('updatefile', type=argparse.FileType('wb')) args = parser.parse_args() player_decks = [] for deck_file in args.decks: d = decks.Deck() try: os.stat(deck_file) d.load_deck(deck_file) except OSError: try: os.stat(DECKS_DIR + deck_file) d.load_deck(DECKS_DIR + deck_file) except OSError: print("Could not find {} to load".format(deck_file)) player_decks.append(d) if len(player_decks) < 1 or len(player_decks) > 2: print("Please supply 1 or 2 decks instead of {}".format( len(player_decks))) run(args.turns, args.rounds, player_decks)