def getValueMatrix(attArmies, defArmies, mapper, hasTrench): values = zeros((len(defArmies),len(attArmies))) for i,defender in enumerate(defArmies): for j,attacker in enumerate(attArmies): values[i,j] = mapper(BattleState(attacker, defender, hasTrench)) return values
def setup_loop(): setup = True pygame.mixer.music.load("audio/music/prep_music_placeholder.wav") pygame.mixer.music.play(-1) cardDict = cards.getCardDict() # card dictionary to map card IDs onto card names playerCards = [] # list that contains the five cards displayed on the screen oppOrder = [] # list that contains the predetermined randomized order of the opponent's cards for i in range(0, 5): # randomizes cards (without repetition) cardID = random.randint(1, 7) while cardID in playerCards: cardID = random.randint(1, 7) cardID2 = random.randint(1, 7) while cardID2 in oppOrder: cardID2 = random.randint(1, 7) playerCards.append(cardID) oppOrder.append(cardID2) playerOrder = [] # list that contains the player's selected cards in order selections = [0, 0, 0, 0, 0] # each element will change from zero to display the order in which cards have been selected while setup: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() screen.fill((0, 0, 0)) reset = miscButton("RESET", screen_width * 0.02, screen_height * 0.85, screen_width * 0.13, screen_height * 0.1, (0, 0, 100), (0, 0, 200)) if reset: # removes all selections to allow the player to start over reset = False playerOrder = [] selections = [0, 0, 0, 0, 0] confirm = miscButton("CONFIRM", screen_width * 0.85, screen_height * 0.85, screen_width * 0.13, screen_height * 0.1, (0, 100, 0), (0, 200, 0)) if confirm and len(playerOrder) == 5: # exits loop if the right number of selections has been made setup = False text = pygame.font.Font('SourceSansPro-Regular.ttf', 60) TextSurf, TextRect = text_objects("SHOOT PREPARATION", text) TextRect.center = ((screen_width / 2), (screen_height * 0.1)) screen.blit(TextSurf, TextRect) text2 = pygame.font.Font('SourceSansPro-Regular.ttf', 35) TextSurf2, TextRect2 = text_objects("Select the order of your ability cards!", text2) TextRect2.center = ((screen_width / 2), (screen_height * 0.9)) screen.blit(TextSurf2, TextRect2) current = 0.025 # value will increment to space cards out across the screen for i in range(0, 5): selections[i] = cardButton(selections[i], len(playerOrder), cardDict[playerCards[i]], screen_width * current, screen_height * 0.25, screen_width * 0.15, screen_height * 0.1, (100, 0, 0), (255, 0, 0)) if selections[i] > 0: # card has been selected - add it to the player's card order if playerCards[i] not in playerOrder: playerOrder.append(playerCards[i]) buttonImage = pygame.image.load("images/buttons/" + str(selections[i]) + ".png") # adds the button image to show selection screen.blit(buttonImage, (screen_width * current + 8, screen_height * 0.14)) charImage = pygame.image.load('images/descriptions/' + str(playerCards[i]) + '.png') # shows description underneath each card screen.blit(charImage, (screen_width * current, screen_height * 0.38)) current = current + 0.2 pygame.display.update() # creates new player objects with their starting attributes (HP and card order) player = Player("Player", 10, playerOrder) opponent = Player("Lord Mike", 10, oppOrder) battle = BattleState(player, opponent) # starts new battle with the two players screen.fill((0, 0, 0)) pygame.mixer.music.stop() select_sound = pygame.mixer.Sound("audio/sfx/card_confirm.wav") pygame.mixer.Sound.play(select_sound) time.sleep(1) pygame.event.clear() pygame.mixer.music.load("audio/music/battle_music_placeholder.wav") pygame.mixer.music.play(-1) rps_loop(battle, player, opponent)