def __init__(self, name=''): # initialize name, score, and card lists self.name = name self.actions = 0 self.gold = 0 self.buys = 0 self._deck = cards.Cards() self._hand = cards.Cards() self._discard_pile = cards.Cards() self._cards_in_play = cards.Cards() self._card_dict = { 'hand': self._hand, 'deck': self._deck, 'discard': self._discard_pile, 'in play': self._cards_in_play, } # a player starts with three Estates and seven Coppers in deck estates = [cards.Card('Estate', 'Victory', 2) for amount in range(3)] coppers = [cards.Card('Copper', 'Treasure', 0) for amount in range(7)] self.add_cards('deck', estates) self.add_cards('deck', coppers) # shuffle deck and draw five cards self.shuffle() self.draw_hand()
def __init__(self, player_names=None): # initializes the decks and supply piles self.info_list = [] self.resolved = True self.coro = None player_count = len(player_names) assert player_count in {2, 3, 4} self._players = [] for p in player_names: self._players.append(player.Player(p)) # initialize the treasure, victory, and kingdom cards self.init_treasure_cards(player_count) self.init_victory_cards(player_count) self.init_kingdom_cards() # the trash pile is empty self._trash = cards.Cards() # 10 curses for a 2 player game, 20 for 3 players, 30 for 4 players self._curses = cards.Cards() curse_amount = {2: 10, 3: 20, 4: 30} for amount in range(curse_amount[player_count]): self._curses.add_cards(cards.Card('Curse', 'Curse', 0))
def init_victory_cards(self, player_count): # initializes the victory cards self._victories = [] # 8 of each victory card for a 2 player game, 12 for 3 or 4 players estates = cards.Cards() duchies = cards.Cards() provinces = cards.Cards() victory_amount = {2: 8, (3, 4): 12} for amount in range(victory_amount[player_count]): estates.add_cards(cards.Card('Estate', 'Victory', 2)) duchies.add_cards(cards.Card('Duchy', 'Victory', 5)) provinces.add_cards(cards.Card('Province', 'Victory', 8)) self._victories.extend([estates, duchies, provinces])
def home(help=None, name=None, card=None, type=None, card1=None): #help参数如果是在页面内被调用的话,无须赋值 type = request.values.get('type', '') card = request.values.get('cardname', '') detail = request.values.get('detail', '') help = request.values.get('help', '') task = cards.Cards() help2 = task.guide() randomcard = request.values.get('random', '') if request.values.get('add', '') == 'add': result = task.insert_card(card, type, detail) return render_template('index.html', result=result, cardname=card, type=type, detail=detail) #名字全部都改成cardname,直接使用name之类的容易与默认名称冲突 elif help == name: #测试帮助页面 return render_template('index.html', help=help2, name=name) elif randomcard != None: card1 = task.random_card(randomcard) return render_template('show.html', card1=card1) elif card == None: return render_template('index.html', name='card') else: return render_template('index.html', cardname=card, type=type, detail=detail)
def setup_game(start_money): p_list = prompts.get_players() # creates list of players b = bets.Bets(p_list, start_money) # instance of Bets class c = cards.Cards(len(p_list)) # instance of Cards class print('\nThe table is set!\n') return b, c
def __init__(self, name, amount): ''' Constructor ''' self.name = name self.money = amount self.hand = cards.Cards() # initialize with an empty hand of cards
def serverReceive(): # Next 9 lines made with help from the lecture 7 powerpoint: "Lecture 7: Network Programming", by Jesper Rindom Jensen s = socket.socket() port = 20001 print("PORT CREATED SERVER_RECEIVING") s.connect(('127.0.0.1', port)) msg = s.recv(1024) msg = msg.decode() splitMsg = msg.split(' ') print("[CLIENT]:", splitMsg) # Server loads the card numbers and sends back the name of the card numbers, # once the server have identifies them in the database nameOutputHold = [] # Creates a new card object for each card the client sends to the server for i in range(5): strHold = cards.Cards() typeHold = str(splitMsg[i]) # Initializes the card objects with new data based on the card number strHold.searchData(splitMsg[i]) # Appends the card name to the array, which is later sent back nameOutputHold.append(str(strHold.get_name())) # Appends the card object to a public array, which can be accessed when running the game on the server playerCards[0].append(strHold) boardArray.append(typeHold) # Same content as the previous for-loop, but instead of specific card numbers, they are randomized by the computer # From the players perspective; this is the opponent cards being created for i in range(5): strHold = cards.Cards() typeHold = random.randint(0, 10) strHold.searchData(typeHold) playerCards[1].append(strHold) boardArray.append(typeHold) sendEnemyBoardInfo = ("EnemyBoard " + str(boardArray[5]) + " " + str(boardArray[6]) + " " + str(boardArray[7]) + " " + str(boardArray[8]) + " " + str(boardArray[9])) serverSend(sendEnemyBoardInfo) print("PlayerObjects:", playerCards) outputMsg = ("Players Sent To Server:", nameOutputHold) return outputMsg, splitMsg, playerCards
def setUp(self): self.cards_obj = cards.Cards() self.all_cards = [ "rd1", "rd2", "rd3", "ro1", "ro2", "ro3", "rp1", "rp2", "rp3", "yd1", "yd2", "yd3", "yo1", "yo2", "yo3", "yp1", "yp2", "yp3", "gd1", "gd2", "gd3", "go1", "go2", "go3", "gp1", "gp2", "gp3", "bd1", "bd2", "bd3", "bo1", "bo2", "bo3", "bp1", "bp2", "bp3" ] self.all_cards.sort()
def init_treasure_cards(self, player_count): # initializes the treasure cards self._treasures = [] # 46 coppers for a 2 player game, 39 for 3 players, 32 for 4 players coppers = cards.Cards() copper_amount = {2: 46, 3: 39, 4: 32} for amount in range(copper_amount[player_count]): coppers.add_cards(cards.Card('Copper', 'Treasure', 0)) # 40 silvers silvers = cards.Cards() for amount in range(40): silvers.add_cards(cards.Card('Silver', 'Treasure', 3)) # 30 golds golds = cards.Cards() for amount in range(30): golds.add_cards(cards.Card('Gold', 'Treasure', 6)) self._treasures.extend([coppers, silvers, golds])
def __init__(self, player_count=2): # initializes the decks and supply piles assert player_count in {2, 3, 4} self._players = [] for idx in range(player_count): self._players.append(player.Player('Player {}'.format(idx + 1))) # initialize the treasure, victory, and kingdom cards self.init_treasure_cards(player_count) self.init_victory_cards(player_count) self.init_kingdom_cards() # the trash pile is empty self._trash = cards.Cards() # 10 curses for a 2 player game, 20 for 3 players, 30 for 4 players self._curses = cards.Cards() curse_amount = {2: 10, 3: 20, 4: 30} for amount in range(curse_amount[player_count]): self._curses.add_cards(cards.Card('Curse', 'Curse', 0))
def init_kingdom_cards(self): # the kingdom cards has 10 supply piles. # each supply pile has 10 of the same card from the randomizers list self._kingdoms = [] randomizers = [ cards.Card('Cellar', 'Action', 2), cards.Card('Chapel', 'Action', 2), cards.Card('Moat', 'Action', 2), cards.Card('Chancellor', 'Action', 3), cards.Card('Village', 'Action', 3), cards.Card('Woodcutter', 'Action', 3), cards.Card('Workshop', 'Action', 3), cards.Card('Bureaucrat', 'Action', 4), cards.Card('Feast', 'Action', 4), cards.Card('Gardens', 'Victory', 4), cards.Card('Militia', 'Action', 4), cards.Card('Moneylender', 'Action', 4), cards.Card('Remodel', 'Action', 4), cards.Card('Smithy', 'Action', 4), cards.Card('Spy', 'Action', 4), cards.Card('Thief', 'Action', 4), cards.Card('Throne Room', 'Action', 4), cards.Card('Council Room', 'Action', 5), cards.Card('Festival', 'Action', 5), cards.Card('Laboratory', 'Action', 5), cards.Card('Library', 'Action', 5), cards.Card('Market', 'Action', 5), cards.Card('Mine', 'Action', 5), cards.Card('Witch', 'Action', 5), cards.Card('Adventurer', 'Action', 6), ] # randomly select 10 cards to be the kingdom cards of the supply pile shuffle(randomizers) for pile_num in range(10): pile = cards.Cards() if randomizers[pile_num].name == 'Gardens': if len(self._players) == 2: card_copies = [ copy(randomizers[pile_num]) for amount in range(8) ] else: card_copies = [ copy(randomizers[pile_num]) for amount in range(12) ] else: card_copies = [ copy(randomizers[pile_num]) for amount in range(10) ] pile.add_cards(card_copies) self._kingdoms.append(pile)
def reset(self, set): self.UI = UI.UserInterface() self.gameState = cards.Cards(set) self.currentTeam = cards.Type.BLUE self.guessedWords = [] self.correctBlue = 9 self.correctRed = 8 self.gameStarted = False self.teams_dict = {} self.spymasters = [] self.num_players = 100 self.roundStarted = False self.channel = None self.guesses = 100
def __init__(self, set): self.UI = UI.UserInterface() self.image_location = 'screenshot.jpg' self.gameState = cards.Cards(set) self.currentTeam = cards.Type.BLUE self.guessedWords = [] self.correctBlue = 9 self.correctRed = 8 self.gameStarted = False self.teams_dict = {} self.spymasters = [] self.num_players = 100 self.roundStarted = False self.channel = None self.guesses = 100
def reset(self, numDecks=4): self.set_game_state("START") self.players = [] self.turn = 0 self.dealer = player.Dealer("Dealer") self.deck = cards.Cards(numDecks) self.set_game_state("WAITING_ON_PLAYERS") # Set a cooldown time if it doesn't exist # This allows for it to set the first run, but not allow players to # bypass the cooldown period by doing !stopBJ followed by !startBJ try: self.cooldownTime except AttributeError: self.cooldownTime = 0
def __init__(self): self.Application = wx.App(redirect=True,filename="ws.log") self.BaseDirectory = os.getcwd() self.SkinsDirectory = os.path.join(self.BaseDirectory, 'skins') self.ImagesDirectory = os.path.join(self.BaseDirectory, 'images') self.DecksDirectory = os.path.join(self.BaseDirectory, 'decks') self._ip = '' self.CardDict = cards.Cards() self.Deck = deck.Deck() self.DeckPath = '' self.Frame = deckbuilder.MainFrame(engine=self, parent=None, title="Weib Schwarz Deck Builder", size=(1300, 800)) self.Frame.Show() self.Application.MainLoop()
def show(name=None, card=None, type=None, card1=None): type = request.values.get('type', '') card = request.values.get('cardname', '') detail = request.values.get('detail', '') help = request.values.get('help', '') task = cards.Cards() help2 = task.guide() randomcard = request.values.get('random', '') if help == 'help': return home(help) elif randomcard != None: card1 = task.random_card(randomcard) return render_template('show.html', card1=card1) elif card == None: return render_template('index.html', name='card') else: return render_template('index.html', name=card, type=type, detail=detail)
def clientServerReceive(): # Next 7 lines made with help from the lecture 7 powerpoint: "Lecture 7: Network Programming", by Jesper Rindom Jensen s = socket.socket() port = 20000 s.connect(('127.0.0.1', port)) messageRecv = s.recv(1024) messageRecv = messageRecv.decode() splitMsg = messageRecv.split(' ') time.sleep(0.0001) print("[SERVER]:", messageRecv) if splitMsg[0] == "combat": queueEvents.append(splitMsg) moveCard() if splitMsg[0] == "EnemyBoard": print("[SYSTEM]: Received enemy board from server") for c in range(5, 10): if (boardArray[c] == ""): cardPlaceStrHold = cards.Cards() cardPlaceStrHold.searchData(str(splitMsg[c - 4])) playerCards[c].configure( image=Assets.cardImg[int(splitMsg[c - 4])]) playerCards[c].configure(text="\n\n\n\n\n\n\n\n\n\n\n" + str(cardPlaceStrHold.get_damage()) + " " + str(cardPlaceStrHold.get_health())) boardArray[c] = splitMsg[c - 4] if len(cardObjects) > c: cardObjects[c] = cardPlaceStrHold cardObjects.append(cardPlaceStrHold) if messageRecv == "Close": print("System message: Closing serverReceive()...") s.close() if messageRecv != "Close": clientServerReceiveStart()
def shopBuy(shopNumber): # Updates the server board depending on the shop number the player bought if len(cardObjects) < 5: for i in range(cardImgLen + 1): # Checks if the shopNumber is equal to a number from the data base to identify the shop number if shopArray[shopNumber] == i: for c in range(5): # Checks if the space is empty if (boardArray[c] == ""): # Loads data into the game board cardPlaceStrHold = cards.Cards() cardPlaceStrHold.searchData(str(i)) playerCards[c].configure(image=Assets.cardImg[i]) playerCards[c].configure( text="\n\n\n\n\n\n\n\n\n\n\n" + str(cardPlaceStrHold.get_damage()) + " " + str(cardPlaceStrHold.get_health())) boardArray[c] = i if len(cardObjects) > c: cardObjects[c] = cardPlaceStrHold cardObjects.append(cardPlaceStrHold) return
def tossHand(self): self.hand = cards.Cards()
def card_show_card(self): npc = cards.Cards() result = npc.show_card(["Aces", [1, 11], "A"]) self.assertEqual( result, ["- - - -", "| |", f"| A |", "| |", "- - - -"])
def __init__(self, name, amount): self.name = name self.money = amount self.hand = cards.Cards()
client = discord.Client() response_history = [] cracks = [ 'Ok', 'Okay', 'Ack', 'Ah', 'Ehem', 'Oh', 'Uh', 'Um', 'Right', 'Wait', 'Well then' ] stuttering = cracks[:] stuttering += cracks[:] stuttering += [w + '...' for w in cracks] stuttering += [w + '!' for w in cracks] stuttering += [w[0] + '-' + w.lower() for w in cracks] deck = cards.Cards() @client.event async def on_ready(): print(BLU + 'Successfully logged in as {} ({})'.format( client.user.name, client.user.id) + WHI) @client.event async def on_message(message): logMessage(message) if message.author == client.user: return # whatis (alt) #content = message.content
def run(self): g.init() if not self.journal: utils.load() else: g.ok = self.ok g.rule = self.rule self.cards = cards.Cards() self.cards.ok = g.ok self.cards.rule = g.rule self.cards.redeal() bx = g.sx(17.4) by1 = g.sy(15.5) by2 = g.sy(18.5) self.yes_bu = [] self.no_bu = [] for i in range(3): bu = buttons.Button("yes", (bx, by1), True) bu.active = False self.yes_bu.append(bu) bu = buttons.Button("no", (bx, by2), True) bu.active = False self.no_bu.append(bu) bx += self.cards.width + g.sy(.5) bx = g.sx(29.9) by = g.sy(14.2) buttons.Button("redeal", (bx, by), True) if self.journal: # Sugar only a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm', 'my_cursor_mask.xbm') pygame.mouse.set_cursor(a, b, c, d) going = True while going: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: g.ok = self.cards.ok g.rule = self.cards.rule utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.redraw = True elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 2: # centre button if not self.journal: g.version_display = not g.version_display break bu = buttons.check() if bu <> '': self.button(bu) break self.click() if not going: break self.update() if g.redraw: self.display() if g.version_display: utils.version_display() pygame.display.flip() g.redraw = False tf = False if pygame.mouse.get_focused(): tf = True pygame.mouse.set_visible(tf) g.clock.tick(40) # be ready for xo quit at any time self.ok = self.cards.ok self.rule = self.cards.rule
if user.bot: continue sorted = False for role in user.roles: if role.name in breakdown: breakdown[role.name] += 1 sorted = True if not sorted: breakdown["Unsorted"] += 1 string = "House Members\n" for i in breakdown: string += f"> {i}: {breakdown[i]}\n" await ctx.send(string) c = cards.Cards() b.add_cog(c) b.add_cog(ficwriter.FicWriter(c)) b.add_cog(episodes.Episodes()) b.add_cog(bingo.Bingo()) b.add_cog(randomfic.RandomFic()) b.add_cog(stories.Stories()) with open('secret') as s: token = s.read()[:-1] # Read the Discord bot token from a soup or secret file print("Card Bot is going live!") b.run(token) # Start the bot, finally!
def setCards(self): self.CARDS = cards.Cards(self.USERS) self.ACOMPANHAMENTOS = cards.Cards(self.USERS) self.AUDIENCIAS = cards.Cards(self.USERS)