def blit_info(self): # blitting info for floating mana. index = 0 for civilization in player.floating_mana: if player.floating_mana[civilization] > 0: self.window.blit( sprite_loader.civilization_ikons[civilization], (percent_of_screen_width(45 + index), percent_of_screen_height(87))) index += 2.5 text = self.font_for_mana_info.render( str(player.floating_mana[civilization]), 1, (0, 0, 0)) self.window.blit(text, (percent_of_screen_width(45 + index), percent_of_screen_height(87))) index += 2.5 text = self.font_for_phase_info.render(player.current_phase, 1, (0, 0, 0)) self.window.blit( text, (percent_of_screen_width(88), percent_of_screen_height(87))) text = self.font_for_phase_info.render(npc.current_phase, 1, (0, 0, 0)) self.window.blit( text, (percent_of_screen_width(88), percent_of_screen_height(20))) text = self.font_for_phase_info.render(player.current_phase, 1, (0, 0, 0)) self.window.blit( text, (percent_of_screen_width(88), percent_of_screen_height(87)))
def __init__(self): # Mana zone self.pos_xy = percent_of_screen_width( 31), percent_of_screen_height(74) self.height = percent_of_screen_height(12.5) self.width = percent_of_screen_width(31) self.rect = (self.pos_xy[0], self.pos_xy[1], self.width, self.height)
def is_in_battle_zone(self): self.set_all_zones_to_false() self.img_width = percent_of_screen_width(5.3) self.img_height = percent_of_screen_height(12.7) self.width = percent_of_screen_width(5.3) self.height = percent_of_screen_height(12.7) self.in_battle_zone = True self.location = self.owner.cards_in_battle_zone
def __init__(self, name): # card info self.name = name self.civilization = cards_dict_class.civilization_by_name(name) self.card_type = card_dict[self.civilization][self.name]['Card Type'] self.card_text = card_dict[self.civilization][self.name]['Card Text'] self.mana_cost = card_dict[self.civilization][self.name]["Mana Cost"] self.power = card_dict[self.civilization][self.name]["Power"] self.race = card_dict[self.civilization][self.name]["Race"] # card properties. self.img = card_dict[self.civilization][self.name]["img"] self.info_img = pygame.transform.scale( self.img, (percent_of_screen_width(15.9), percent_of_screen_height(38.1))) self.card_back_img = sprite_loader.card_back self.pos_xy = (0, 0) self.pos_index = 0 # card img size self.img_width = percent_of_screen_width(5.3) self.img_height = percent_of_screen_height(12.7) # card size self.width = percent_of_screen_width(5.3) self.height = percent_of_screen_height(12.7) # if the card i clicked by the mouse and can be picked up. self.is_picked_up = False # when the mouse is hovering over the card will show info. self.hover_over = False # if the card is used, it cant be used before next turn. (for attacking or for floating mana) self.is_used = False # blitting the card at a 90 angle if tapped. self.is_tapped = False # using bools for logic. self.in_graveyard = False self.in_battle_zone = False self.in_hand = False self.in_mana_zone = False self.in_shield_zone = False self.is_selected_bool = False self.is_clicked_bool = False # check how owns the card. self.owner = None self.location = None self.summoning_sickness = True self.triggers = []
def __init__(self): # Battle zone # creating positions for cards in players battlezone self.pos_xy = (percent_of_screen_width(31), percent_of_screen_height(46)) self.height = percent_of_screen_height(12.5) self.width = percent_of_screen_width(31) self.rect = (self.pos_xy[0], self.pos_xy[1], self.width, self.height)
def tap(self): if not self.is_tapped: self.is_tapped = True self.width = percent_of_screen_height(3.5) self.height = percent_of_screen_width(5.3) else: self.is_tapped = False self.width = percent_of_screen_width(5.3) self.height = percent_of_screen_height(3.5)
def is_in_mana_zone(self): print("card is in mana zone") self.set_all_zones_to_false() # makes the image smaller, will fit better in manazone self.img = pygame.transform.chop(self.img, (0, 45, 0, 325)) self.img_width = percent_of_screen_width(5.3) self.img_height = percent_of_screen_height(3.5) self.width = percent_of_screen_width(5.3) self.height = percent_of_screen_height(3.5) self.in_mana_zone = True self.location = self.owner.cards_in_mana_zone
def untap_cards(self): for card in (self.cards_in_battle_zone + self.cards_in_mana_zone): card.is_tapped = False card.is_used = False card.summoning_sickness = False card.width = percent_of_screen_width(5.3) card.height = percent_of_screen_height(3.5) self.if_charged_mana = False
def __init__(self): self.name = "noName" self.in_game = True # player input self.mouse_pos = pygame.mouse.get_pos # mouse self.saved_deck = ['WrithingBoneGhoul', 'WrithingBoneGhoul', 'WrithingBoneGhoul', 'WrithingBoneGhoul', 'DeathSmoke', 'DeathSmoke', 'MieleVizierofLightning', 'MieleVizierofLightning', 'MieleVizierofLightning', 'LaUraGigaSkyGuardian', 'LaUraGigaSkyGuardian', 'ToelVizierofHope', 'SzubsKinTwilightGuardian', 'SenatineJadeTree', 'RubyGrass', 'CreepingPlague', 'BoneSpider', 'SuperExplosiveVolcanodon', 'Stonesaur', 'ScarletSkyterror', 'RothusTheTraveler', 'SteelSmasher', 'GoldenWingStriker', 'BronzeArmTribe'] # saving the deck two places, will help when resetting. # creates a list of card objects with the "ACard" class. self.deck_list = [card_classes.ACard(name) for name in self.saved_deck] self.cards_in_hand = [] self.cards_in_shields = [] self.cards_in_mana_zone = [] self.cards_in_graveyard = [] self.cards_in_battle_zone = [] self.battlezone = zones_class.battlezone self.battlezone_position = (percent_of_screen_width(6.25), percent_of_screen_height(46)) self.battlezone_slots = [] self.manazone = zones_class.manazone self.manazone_position = (percent_of_screen_width(6.25), percent_of_screen_height(74)) self.manazone_slots = [] self.graveyard = zones_class.graveyard self.graveyard_position = (percent_of_screen_width(65), percent_of_screen_height(80)) self.graveyard.set_position(self.graveyard_position) self.shield_zone = zones_class.shieldzone self.shield_zone_position = (percent_of_screen_width(6.25), percent_of_screen_height(60.2)) self.shield_slots = [] self.hand_pos_x = (0.465, 0.29) self.hand_pos_y = 0.91
def position_cards_in_hand(self): for i, card in zip(itertools.count(), self.cards_in_hand): card.pos_index = i hand_size = len(self.cards_in_hand) screen_width = screen_size[0] screen_height = screen_size[1] positions_in_hand = [] # as long as hand size is less then 7 there will be no card overlapping if hand_size < 7: positions_in_hand = [ ((int(screen_size[0] * (self.hand_pos_x[0] - (0.025 * hand_size)) + x * int(screen_size[0] * 0.051))), int(screen_size[1] * self.hand_pos_y)) for x in range(hand_size)] # creats a list of positions according to hand img_width and hand size. else: max_hand_width = screen_width * 0.3125 # the width of the hand is max 31 % of the screen. hand_spot_size = int(max_hand_width / hand_size) # the size of the spots are determent by hand size- # overlap is how much the cards overlap. overlap = percent_of_screen_width(5.3) - hand_spot_size for card in self.cards_in_hand: # reduce the card box my overlap size. card.width = percent_of_screen_width(5.3) - overlap if card == self.cards_in_hand[-1]: # if its the last card in hand, no need to make the box smaller. card.width = percent_of_screen_width(5.3) for x in range(hand_size): # create a list the size of the hand. # the position of the hand on x-axes move_hand_left = int(screen_width * self.hand_pos_x[1] + (hand_spot_size / 3)) card_pos_x = move_hand_left + hand_spot_size * x positions_in_hand.append((card_pos_x, int(screen_height * self.hand_pos_y))) for card in self.cards_in_hand: card.set_position_to(positions_in_hand[card.pos_index])
def __init__(self): super().__init__() self.saved_deck = ['DeadlyFighterBraidClaw', 'ArmoredWalkerUrherion', 'ArmoredWalkerUrherion', 'ArtisanPicora', 'ArtisanPicora', 'BolshackDragon', 'BrawlerZyler', 'BrawlerZyler', 'BrawlerZyler', 'DeadlyFighterBraidClaw', 'FatalAttackerHorvath', 'FatalAttackerHorvath', 'FatalAttackerHorvath', 'FatalAttackerHorvath', 'FireSweeperBurningHellion', 'FireSweeperBurningHellion', 'FireSweeperBurningHellion', 'ImmortalBaronVorg', 'ImmortalBaronVorg', 'ImmortalBaronVorg', 'ImmortalBaronVorg'] self.deck_list = [card_classes.ACard(name) for name in self.saved_deck] self.battlezone_position = (percent_of_screen_width(6.25), percent_of_screen_height(30)) self.manazone_position = (percent_of_screen_width(6.25), percent_of_screen_height(5.2)) self.graveyard_position = (percent_of_screen_width(25), percent_of_screen_height(15)) self.shield_zone_position = (percent_of_screen_width(6.25), percent_of_screen_height(20)) self.hand_pos_x = (0.665, 0.29) self.hand_pos_y = 0.05 self.turn_counter = 1
def blit_card(self, window): # getting the img to blit, and resizing it. card_img = pygame.transform.scale(self.img, (self.img_width, self.img_height)) if self.is_clicked_bool: if not self.in_mana_zone: pygame.draw.rect(window, (250, 0, 0), (self.pos_xy[0] - 5, self.pos_xy[1] - 5, self.width + 10, self.height + 10)) window.blit(self.info_img, (percent_of_screen_width(82.5), percent_of_screen_height(36.3))) if not self.in_shield_zone: if self.in_mana_zone: card_img = pygame.transform.flip(card_img, False, True) if self.is_tapped: # rotating the card 90 degrees if the card is tapped. card_img = pygame.transform.rotate(card_img, -90) # if the card is clicked it will be highlighted. if self.is_picked_up: # if that card is picked up, the card will get mouse pos. window.blit(card_img, self.set_position_to(self.owner.mouse_pos())) if self.hover_over: window.blit(self.info_img, (percent_of_screen_width(62.5), percent_of_screen_height(30))) window.blit(card_img, self.pos_xy) else: window.blit(self.card_back_img, self.pos_xy)
def __init__(self): self.font_for_phase_info = pygame.font.SysFont('comicsand', 30, True) self.font_for_info = pygame.font.SysFont('comicsand', 30, True) self.font_for_mana_info = pygame.font.SysFont('comicsand', 30, True) infos = pygame.display.Info() self.screen_size = (infos.current_w, infos.current_h) self.font_for_info = pygame.font.SysFont('comicsand', 30, True) self.fullscreen = True self.playingfield_resized = \ pygame.transform.scale(sprite_loader.playing_field, (percent_of_screen_width(100), percent_of_screen_height(100))) infos = pygame.display.Info() self.screen_size = (infos.current_w, infos.current_h) self.window = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) pygame.display.set_caption('Duel Masters')
def __init__(self): self.cards_dict = card_dict self.playing_field = pygame.image.load("Sprits/playingfield.png") self.card_back_raw = pygame.image.load("Sprits/pic43176.jpg") self.civilization_ikons = {} self.darkness_small = pygame.image.load("Sprits/darkness_small.png") self.fire_small = pygame.image.load("Sprits/fire_small.png") self.light_small = pygame.image.load("Sprits/light_small.png") self.nature_small = pygame.image.load("Sprits/nature_small.png") self.water_small = pygame.image.load("Sprits/water_small.png") self.civilization_ikons = {'Darkness': self.darkness_small, 'Fire': self.fire_small, 'Light': self.light_small, 'Nature': self.nature_small, 'Water': self.water_small} self.card_back = pygame.transform.scale(self.card_back_raw, (percent_of_screen_width(5.2), percent_of_screen_height(13)))
def __init__(self): self.pos_xy = (0, 0) # size of a card. self.width = percent_of_screen_width(5.3) self.height = percent_of_screen_height(12.7)