def choseSkill(self): """affiche un tableau qui permet de choisir un skill""" screenS=screenSave() board=board_with_msg("chose a skill between str dex con int wis cha") s=wred(subtitle,"str ") d=wred(subtitle,"dex ") co=wred(subtitle,"con ") i=wred(subtitle,"int ") w=wred(subtitle,"wis ") ch=wred(subtitle,"cha ") board_rect=pygame.Rect(screen.get_width()//8,screen.get_height()//8,0,0) list_choice=choices_clickable(board,[s,d,co,i,w,ch],board_rect) board_rect=screen.blit(board,(screen.get_width()//8,screen.get_height()//8)) pygame.display.flip() running=True click=False while running: indice=collides(pygame.mouse.get_pos(), list_choice) running,click=basic_checkevent(click, None) if click==True: if board_rect.collidepoint(pygame.mouse.get_pos())!=True: running=False elif indice!=-1: self.skills[indice]=1 self.chose_skill=False running=False screen.blit(screenS,(0,0))
def magic_missile(self): "ce sort renvoi une liste de liste qui a la taille de son nombre de hit si le spell peut être lancé, spell lvl1" screenS = screenSave() listdeg = [] lvl_s = False running = True click = False if confirmation_board("lunch missile wich deals 1-5 dmg"): if any( [self.armor[0], self.armor[1], self.armor[2], self.armor[3]]): running = board_error("cannot lunch spell and wear armor") return False board = board_with_msg( "Choose a lvl to cast your spell, esc pour annuler") boardrect = screen.blit( board, (screen.get_width() // 4, screen.get_height() // 4)) rect_list_choice = choices_clickable(board, [lvl1, lvl2], boardrect) screen.blit(board, (screen.get_width() // 4, screen.get_height() // 4)) pygame.display.flip() while running: indice = collides(pygame.mouse.get_pos(), rect_list_choice) running, click = basic_checkevent(click) "vérifie si il reste des spells slots au joueur" if (self.spells_slots[0] != 0 or self.spells_slots[1] != 0) and self.actionP > 0: if click and indice != -1: if indice == 0: if self.spells_slots[0] == 0: running = board_error( "Not enough spell slot for this lvl") else: lvl_s = 1 self.spells_slots[0] -= 1 running = False self.actionP -= 1 elif indice == 1: if self.spells_slots[1] == 0: running = board_error( "Not enough spell slot for this lvl") else: lvl_s = 2 self.spells_slots[1] -= 1 running = False self.actionP -= 1 else: running = board_error( "no spell slot anymore or no action left") if lvl_s: """la liste prend la forme de liste de liste, chaque liste de liste est une action indépendente de la forme [montant degat/soins,type (0=soins, 1=degats), le nombre de cible (ex 1=1 carré), la zone d'effet (1 carré ou 2 cône, 0 si l'élement précédent est 1),la range du sort (cible à 4 carrées max), la type de cible (0=soit même, 1=ennemies, 2=alliées), dc (si 0 pas de saving throw possible),type de saving thow (si 0 à dc 0 au type)]""" listdeg = [[self.action.dice(5), 1, 0, 0, 24, 1, 0, 0] for n in range(lvl_s)] screen.blit(screenS, (0, 0)) if listdeg: return listdeg
def print_text(self,click=False): display = pygame.Surface((500,500)) display.blit(pygame.transform.scale(img_inventaire,(500,500)),(0,0)) display = well_print_on_display(display,self.text) screen.blit(display,(self.pos_x,self.pos_y)) if creation_img_text_click(validation_button,"Accepter",ColderWeather_small,WHITE,screen,click,self.pos_x+250,self.pos_y+480,transform=True): self.is_accept = True return 1
def board_error(message): screen.blit(board_with_msg(message), (screen.get_width() // 6, screen.get_height() // 6)) pygame.display.flip() running = True click = False while running: running, click = basic_checkevent(click) if click: running = False return running
def print_reward(self,click=False): display = pygame.Surface((500,250)) display.blit(pygame.transform.scale(img_inventaire,(500,250)),(0,0)) draw_text(str(self.reward_gold),ColderWeather_small,WHITE,display,380,180) display.blit(pygame.transform.scale(GoldCoin.wpn_img,(50,50)),(430,180)) draw_text("Recompense : ",ColderWeather_small,WHITE,display,30,20) i=0 for x in self.reward_items: display.blit(pygame.transform.scale(x.wpn_img,(50,50)),(30+i*50,70)) i+=1 screen.blit(display,(self.pos_x+500,self.pos_y))
def is_alive(self): display = pygame.Surface((screen.get_width(),screen.get_height())) display.set_colorkey((0,0,0)) if not self.monster.is_alive: self.is_accomplish = True Validation_screen("Merci Beaucoup ! Prenez la récompense",display,click) return True else: Validation_screen("Vous n'avez pas encore tue le monstre !",display,click) return False screen.blit(display,(0,0))
def got_items(self,player): if self.is_accept: click = False display = pygame.Surface((screen.get_width(),screen.get_height())) display.set_colorkey((0,0,0)) for i in range(len(player.inventaire.backpack)): if player.inventaire.backpack[i] != None: if key[player.inventaire.backpack[i]] == self.items: self.is_accomplish = True Validation_screen("Merci Beaucoup ! Prenez la récompense",display,click) return True Validation_screen("Vous n'avez pas encore le bonnes items !",display,click) return False screen.blit(display,(0,0))
def convertSpellS(self): "permet de convertir des spell slots points en sorcery points" screenS = screenSave() board = board_with_msg( "choisir spell slot a obtenir, esc pour annuler") rect_board = pygame.Rect(screen.get_width() // 8, screen.get_height() // 8, 0, 0) level1 = wbrown(subtitle, "2 sorceryP") level2 = wbrown(subtitle, "3 sorceryP") choiceList = choices_clickable(board, [level1, level2], rect_board) screen.blit(board, (screen.get_width() // 8, screen.get_height() // 8)) pygame.display.flip() running = True click = False while running: if self.spells_slots[0] != 0 or self.spells_slots[ 1] != 0 and self.bonusAction > 0: indice = collides(pygame.mouse.get_pos(), choiceList) running, click = basic_checkevent(click) if (click and indice != -1): if indice == 0: if self.level - self.sPoints < 2: running = board_error( "cannot do that to much sorcery points") elif self.spells_slots[0] == 0: running = board_error("not enough sorcery points") else: self.sPoints += 2 self.spells_slots[0] -= 1 self.bonusAction -= 1 running = False if indice == 1: if self.level - self.sPoints < 3: running = board_error( "cannot do that to much sorcery points") elif self.spells_slots[1] == 0: running = board_error("not enough sorcery points") else: self.sPoints += 3 self.spells_slots[1] -= 1 self.bonusAction -= 1 running = False else: running = board_error("not enough point") screen.blit(screenS, (0, 0))
def affichage_lvlup(self): #manage the display of the lvl up (private) temp=pygame.Surface(WINDOWS_SIZE) temp.blit(screen,(0,0)) screen.blit(self.lvl_up_img,(self.pos_x+100,self.pos_y)) time=pygame.time.get_ticks() pygame.display.flip() running=True while(pygame.time.get_ticks()<time+1000 and running): for event in pygame.event.get(): if event.type==pygame.KEYDOWN: if event.key==K_ESCAPE: running=False pygame.quit() elif event.type==pygame.MOUSEBUTTONDOWN or event.type==pygame.KEYDOWN: running=False if event.type==pygame.QUIT: running=False pygame.quit() screen.blit(temp, (0,0)) pygame.display.flip()
def fireball(self): "ce sort renvoi une liste de liste qui a la taille de son nombre de hit si le spell peut être lancé, spell lvl3" listdeg = [] if confirmation_board( "cost lvl 2 spell deals between 6-36 damage in area"): if any( [self.armor[0], self.armor[1], self.armor[2], self.armor[3]]): running = board_error("cannot lunch spell and wear armor") return False if self.spells_slots[1] > 0 and self.actionP > 0: """la liste prend la forme de liste de liste, chaque liste de liste est une action indépendente de la forme [montant degat/soins,type (0=soins, 1=degats), le nombre de cible (ex 1=1 carré de proximité, 2 tous les carrés contact a la cible), la zone d'effet (1 carré ou 2 cône,0 si l'élement précédent est 1),la range du sort (cible à 4 carrées max), la type de cible (0=soit même, 1=ennemies, 2=alliées),dc (si 0 pas de saving throw possible), type de saving thow (si 0 à dc 0 au type,1 pour dex, 2 pour con,3 pour will)]""" deg = self.action.dice(6) + self.action.dice( 6) + self.action.dice(6) + self.action.dice( 6) + self.action.dice(6) + self.action.dice(6) listdeg.append( [deg, 1, 1, 1, 24, 1, 10 + 3 + self.score("con"), 1]) self.spells_slots[1] -= 1 self.actionP -= 1 elif self.sort2 == False: running = True screenS = screenSave() while running: running = board_error("this spell is not unlock for now") screen.blit(screenS, (0, 0)) else: running = True screenS = screenSave() while running: running = board_error( "not enough spell slot or action to cast this spell") screen.blit(screenS, (0, 0)) if listdeg: return listdeg else: return False
def confirmation_board(description): screenS = screenSave() board = board_with_msg(description) s = wblack(subtitle, "CONFIRM") d = wblack(subtitle, "CANCEL") board_rect = pygame.Rect(screen.get_width() // 8, screen.get_height() // 8, 0, 0) list_choice = choices_clickable(board, [s, d], board_rect) board_rect = screen.blit( board, (screen.get_width() // 8, screen.get_height() // 8)) pygame.display.flip() running = True click = False while running: indice = collides(pygame.mouse.get_pos(), list_choice) running, click = basic_checkevent(click) if click == True: if indice == 0: screen.blit(screenS, (0, 0)) return True elif indice == 1: running = False screen.blit(screenS, (0, 0))
def convertSP(self): "permet de convertir des sorcery points en spell slots" screenS = screenSave() board = board_with_msg( "choisir spell slot a obtenir, esc pour annuler") rect_board = pygame.Rect(screen.get_width() // 8, screen.get_height() // 8, 0, 0) level1 = wbrown(subtitle, "Spell slot level1") level2 = wbrown(subtitle, "Spell slot level2") choiceList = choices_clickable(board, [level1, level2], rect_board) screen.blit(board, (screen.get_width() // 8, screen.get_height() // 8)) pygame.display.flip() running = True click = False "indice pour savoir si une action s'est réalisée" while running: if self.sPoints >= 2 and self.bonusAction > 0: indice = collides(pygame.mouse.get_pos(), choiceList) running, click = basic_checkevent(click) if (click and indice != -1): if indice == 0: self.spells_slots[0] += 1 self.sPoints -= 2 self.bonusAction -= 1 running = False if indice == 1: if self.sPoints < 3: running = board_error("not enough sorcery points") else: self.spells_slots[1] += 1 self.sPoints -= 3 self.bonusAction -= 1 running = False else: running = board_error("not enough point") screen.blit(screenS, (0, 0))
def spell_bar(self,click): screen.blit(pygame.transform.scale(img_inventaire,(500,100)),(screen.get_width()//2-250,screen.get_height()-95)) i = 0 mx,my = pygame.mouse.get_pos() for i in range(5): self.bouton_comp[i] = pygame.Rect(85*i+screen.get_width()//2-200, screen.get_height()-80, 75, 75) pygame.draw.rect(screen,(0,0,1),self.bouton_comp[i],1) if i < len(self.skill): screen.blit(pygame.transform.scale(self.skill[i].img,(75,75)),(85*i+screen.get_width()//2-200, screen.get_height()-80)) if self.bouton_comp[i].collidepoint(mx,my) and click: if i < len(self.skill): self.skill[i].cast() i=0 for i in range(len(self.competencesList)): screen.blit(pygame.transform.scale(self.competencesList[i].img,(75,75)),(85*i+screen.get_width()//2-200,screen.get_height()-80))
def board_with_text(msg): """blit a board with a text at the mouse position, word len max 30 caracter""" mots = msg.split(" ") phrase = [""] ligne = [] i = 0 for n in mots: if len(phrase[i]) + 1 + len(n) > 30: ligne.append(wbrown(subtitle, phrase[i])) phrase.append("") i += 1 phrase[i] += n + " " ligne.append(wbrown(subtitle, phrase[i])) i += 1 l = ligne[0] for n in ligne: if n.get_width() > l.get_width(): l = n board = pygame.transform.scale( board_init(), (l.get_width() + 60, ligne[0].get_height() * (i + 1))) for nb in range(len(ligne)): board.blit( ligne[nb], (30, ligne[0].get_height() * nb + ligne[0].get_height() // 2)) if board.get_height() + pygame.mouse.get_pos()[1] < screen.get_height( ) and board.get_width() + pygame.mouse.get_pos()[0] < screen.get_width(): screen.blit(board, pygame.mouse.get_pos()) elif board.get_height() + pygame.mouse.get_pos()[1] >= screen.get_height( ) and board.get_width() + pygame.mouse.get_pos()[0] < screen.get_width(): screen.blit(board, (pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1] - board.get_height())) elif board.get_height() + pygame.mouse.get_pos()[1] < screen.get_height( ) and board.get_width() + pygame.mouse.get_pos()[0] >= screen.get_width(): screen.blit(board, (pygame.mouse.get_pos()[0] - board.get_width(), pygame.mouse.get_pos()[1])) else: screen.blit(board, (pygame.mouse.get_pos()[0] - board.get_width(), pygame.mouse.get_pos()[1] - board.get_height()))
def caracter_sheet(self): screenS = screenSave() board = pygame.transform.scale(board_init(), (900, 780)) board_icon = pygame.transform.scale( board_init(), (board.get_width() // 5, board.get_height() // 5)) iconew = pygame.transform.scale( rogue_icon, (board_icon.get_width(), board_icon.get_height())) board_icon.blit( iconew, (board_icon.get_width() // 2 - iconew.get_width() // 2, 0)) board_icon2 = pygame.transform.scale( board_init(), (board.get_width() // 5, board.get_height() // 5)) iconen = pygame.transform.scale( neutre_icon, (trunc(board_icon2.get_width() // 1.2), trunc(board_icon2.get_height() // 1.2))) board_icon2.blit( iconen, (board_icon2.get_width() // 2 - iconen.get_width() // 2, board_icon2.get_height() // 2 - iconen.get_height() // 2)) draw_text("Rogue", title, "bl", board, board.get_width() // 8, board.get_height() // 20) perso = pygame.transform.scale( Rogue_img, (board.get_width() // 3, board.get_height() // 2)) board.blit(perso, (board.get_width() // 14, board.get_height() // 7)) """initialisation de tous les boards avec les choix correspondants aux 5 differents lvl""" rect_choices = list() draw_text("You can use stealth on map", text, 'bl', board, board.get_width() // 18, trunc(board.get_height() * 0.65)) rectboard = pygame.Rect( screen.get_width() // 2 - board.get_width() // 2, 20, 0, 0) board_level1 = board_with_msg("Unlock at level 1") rect_board1 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.03), 0, 0)) rect_choices.append( choices_clickable(board_level1, [image['S_Death02.png']], rect_board1)) board_level1, rect_choices[0] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level1, rect_choices[0], rect_board1) board_level2 = board_with_msg("Unlock at level 2") rect_board2 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.21), 0, 0)) rect_choices.append( choices_clickable(board_level2, [image['S_Holy07.png']], rect_board2)) board_level2, rect_choices[1] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level2, rect_choices[1], rect_board2) board_level3 = board_with_msg("Unlock at level 3") rect_board3 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.39), 0, 0)) rect_choices.append( choices_clickable(board_level3, [image['S_Death01.png']], rect_board3)) board_level3, rect_choices[2] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level3, rect_choices[2], rect_board3) board_level4 = board_with_msg("Unlock at level 4") rect_board4 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.57), 0, 0)) rect_choices.append( choices_clickable(board_level4, [image['S_Shadow07.png']], rect_board4)) board_level4, rect_choices[3] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level4, rect_choices[3], rect_board4) board_level5 = board_with_msg("Unlock at level 5") rect_board5 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.75), 0, 0)) rect_choices.append( choices_clickable(board_level5, [image['S_Death01.png'], image['W_Axe001.png']], rect_board5)) board_level5, rect_choices[4] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level5, rect_choices[4], rect_board5) board.blit(board_level1, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.03))) board.blit(board_level2, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.21))) board.blit(board_level3, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.39))) board.blit(board_level4, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.57))) board.blit(board_level5, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.75))) running = True click = False if super().caracter_sheet(): rect_icon = screen.blit( board_icon2, (rectboard.x - board_icon.get_width() // 1.5, rectboard.y + board_icon.get_height() * 0.2)) screen.blit(board, (rectboard.x, rectboard.y)) screen.blit(board_icon, (rectboard.x - board_icon.get_width() // 1.5, rectboard.y + board_icon.get_height() // 0.8)) ScreenS2 = screenSave() while running: screen.blit(ScreenS2, (0, 0)) indice1 = collides(pygame.mouse.get_pos(), rect_choices[0]) indice2 = collides(pygame.mouse.get_pos(), rect_choices[1]) indice3 = collides(pygame.mouse.get_pos(), rect_choices[2]) indice4 = collides(pygame.mouse.get_pos(), rect_choices[3]) indice5 = collides(pygame.mouse.get_pos(), rect_choices[4]) if indice1 == 0: board_with_text( "You unlock sneak attack, in battle if a monster is near a wall or an ally sneak attack increase your damage by 1d6" ) elif indice2 == 0: board_with_text( "When you take damage from a spell and you success to a dexterity saving throw the damagess are reduces to 0" ) elif indice2 == 1: board_with_text( "you could choose a skill, each time you will use an attribute reattach to your skill you will add your proficiency modifier to your score" ) elif indice3 == 0: board_with_text("Sneak attack deals 1d12 more") elif indice4 == 0: board_with_text( " Unlock uncanny dodge, when you take damages from attack they are divide par two" ) elif indice5 == 0: board_with_text("Sneak attack deals 1d12 more") elif indice5 == 1: board_with_text("proficiency bonus is now at 3") running, click = basic_checkevent(click) if click == True and rect_icon.collidepoint( pygame.mouse.get_pos()): if super().caracter_sheet() == 0: running = False pygame.display.flip() screen.blit(screenS, (0, 0))
def caracter_sheet(self): screenS = screenSave() board = pygame.transform.scale(board_init(), (900, 780)) board_icon = pygame.transform.scale( board_init(), (board.get_width() // 5, board.get_height() // 5)) iconew = pygame.transform.scale( wizard_icon, (board_icon.get_width() // 2, board_icon.get_height())) board_icon.blit( iconew, (board_icon.get_width() // 2 - iconew.get_width() // 2, 0)) board_icon2 = pygame.transform.scale( board_init(), (board.get_width() // 5, board.get_height() // 5)) iconen = pygame.transform.scale( neutre_icon, (trunc(board_icon2.get_width() // 1.2), trunc(board_icon2.get_height() // 1.2))) board_icon2.blit( iconen, (board_icon2.get_width() // 2 - iconen.get_width() // 2, board_icon2.get_height() // 2 - iconen.get_height() // 2)) draw_text("Sorcerer", title, "bl", board, board.get_width() // 8, board.get_height() // 20) perso = pygame.transform.scale( wizard_hide['idle_1.png'], (board.get_width() // 3, board.get_height() // 2)) board.blit(perso, (board.get_width() // 14, board.get_height() // 7)) """initialisation de tous les boards avec les choix correspondants aux 5 differents lvl""" rect_choices = list() draw_text("Sorcery Points : " + str(self.sPoints), text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65)) draw_text("Spells Slots lvl 1 : " + str(self.spells_slots[0]), text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65) + 50) draw_text("Spells Slots lvl 2 : " + str(self.spells_slots[1]), text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65) + 100) if self.master == False: draw_text("unlock master skill lvl 4", text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65) + 150) else: if self.masterAction: draw_text("master action : Active", text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65) + 150) else: draw_text("Master Action : Inactive", text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65) + 150) rectboard = pygame.Rect( screen.get_width() // 2 - board.get_width() // 2, 20, 0, 0) board_level1 = board_with_msg("Unlock at level 1") rect_board1 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.03), 0, 0)) rect_choices.append( choices_clickable(board_level1, [image['S_Magic01.png'], image['S_Fire01.png']], rect_board1)) board_level1, rect_choices[0] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level1, rect_choices[0], rect_board1) board_level2 = board_with_msg("Unlock at level 2") rect_board2 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.21), 0, 0)) rect_choices.append( choices_clickable(board_level2, [image['S_Shadow02.png'], image['S_Buff01.png']], rect_board2)) board_level2, rect_choices[1] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level2, rect_choices[1], rect_board2) board_level3 = board_with_msg("Unlock at level 3") rect_board3 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.39), 0, 0)) rect_choices.append( choices_clickable(board_level3, [image['S_Fire02.png']], rect_board3)) board_level3, rect_choices[2] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level3, rect_choices[2], rect_board3) board_level4 = board_with_msg("Unlock at level 4") rect_board4 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.57), 0, 0)) rect_choices.append( choices_clickable(board_level4, [image['S_Buff09.png']], rect_board4)) board_level4, rect_choices[3] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level4, rect_choices[3], rect_board4) board_level5 = board_with_msg("Unlock at level 5") rect_board5 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.75), 0, 0)) rect_choices.append( choices_clickable(board_level5, [image['S_Fire04.png'], image['W_Axe001.png']], rect_board5)) board_level5, rect_choices[4] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level5, rect_choices[4], rect_board5) board.blit(board_level1, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.03))) board.blit(board_level2, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.21))) board.blit(board_level3, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.39))) board.blit(board_level4, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.57))) board.blit(board_level5, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.75))) running = True click = False if super().caracter_sheet(): rect_icon = screen.blit( board_icon2, (rectboard.x - board_icon.get_width() // 1.5, rectboard.y + board_icon.get_height() * 0.2)) screen.blit(board, (rectboard.x, rectboard.y)) screen.blit(board_icon, (rectboard.x - board_icon.get_width() // 1.5, rectboard.y + board_icon.get_height() // 0.8)) ScreenS2 = screenSave() while running: screen.blit(ScreenS2, (0, 0)) indice1 = collides(pygame.mouse.get_pos(), rect_choices[0]) indice2 = collides(pygame.mouse.get_pos(), rect_choices[1]) indice3 = collides(pygame.mouse.get_pos(), rect_choices[2]) indice4 = collides(pygame.mouse.get_pos(), rect_choices[3]) indice5 = collides(pygame.mouse.get_pos(), rect_choices[4]) if indice1 == 0: board_with_text( "missile magic can be lunch at lvl 1 to lunch one missil or at level 2 to lunch 2 missil, it inflict between 1 and 5 damage" ) elif indice1 == 1: board_with_text( "fire bolt is a cantrip he doesn't use spell slot, it can be lunch as a bonus action, it inflicts between 1 and 10 damages" ) elif indice2 == 0: board_with_text( "Now you can use sorcery points, the amount is equal to your level you can use sorcery points to recover spell slots or use spell slots to recover sorcery points" ) elif indice2 == 1: board_with_text( "you could choose a skill, each time you will use an attribute reattach to your skill you will add your proficiency modifier to your score" ) elif indice3 == 0: board_with_text( "You unlock fire ball, this spell deals between 6 and 36 damages in a square area" ) elif indice4 == 0: board_with_text( "You unlock your mastery action quick spell, you can use this action one time between 2 rest, this bonus action allow you to lunch 2 spell in the same turn" ) elif indice5 == 0: board_with_text("firebolt lunch two firebolt now") elif indice5 == 1: board_with_text("proficiency bonus is now at 3") running, click = basic_checkevent(click) if click == True and rect_icon.collidepoint( pygame.mouse.get_pos()): if super().caracter_sheet() == 0: running = False pygame.display.flip() screen.blit(screenS, (0, 0))
def print_equipement(self,pos_x,pos_y,pos_x_inventory_player,pos_y_inventory_player,also_inventory=True,mouse=False): display = pygame.Surface((250,200)) display.set_colorkey(BLACK) display_argent = pygame.Surface((200,50)) display_argent.set_colorkey(BLACK) display_argent.blit(pygame.transform.scale(img_inventaire,(200,50)),(0,0)) draw_text("Argent : %i"%self.argent,ColderWeather_small,WHITE,display_argent,10,5) x = 125 y_ = 100 display.blit(pygame.transform.scale(img_inventaire,(250,200)),(0,0)) copy_img = pygame.Surface.copy(self.img) copy_img.set_alpha(50) display.blit(copy_img,(250//2-self.img.get_width()//2,100-self.img.get_height()//2)) bouton_arm = dict() mouse_slot = self.inventaire.nb_x * self.inventaire.nb_y mx,my = pygame.mouse.get_pos() mx_display = mx - pos_x my_display = my - pos_y for i in range(0,4): bouton_arm[i] = pygame.Rect(x-25, 50*i,50,50) pygame.draw.rect(display,(0,0,1),bouton_arm[i],1) for i in range(0,2): bouton_arm[4+i] = pygame.Rect(25+i*150,75,50,50) pygame.draw.rect(display,(0,0,1),bouton_arm[4+i],1) screen.blit(display,(pos_x,pos_y)) screen.blit(display_argent,(pos_x,pos_y+200)) for i in range(0,6): if self.armor[i] != None: screen.blit(key[self.armor[i]].wpn_img,(bouton_arm[i].x+pos_x,bouton_arm[i].y+pos_y)) i=0 if self.inventaire.have_object == False: for i in range(6): if bouton_arm[i].collidepoint((mx_display,my_display)): self.inventaire.backpack[mouse_slot] = self.armor[i] self.armor[i] = None self.inventaire.last_moove = mouse_slot+i+1 self.inventaire.have_object = True i=0 if self.inventaire.backpack[mouse_slot] != None: if any(pygame.mouse.get_pressed()): self.have_object =True #screen.blit(key[self.inventaire.backpack[mouse_slot]].wpn_img,(mx,my)) elif not(any(pygame.mouse.get_pressed())): for i in range(0,6): if bouton_arm[i].collidepoint((mx_display,my_display)) and key[self.inventaire.backpack[mouse_slot]].wpn_type == i: self.inventaire.backpack[self.inventaire.last_moove] = self.armor[i] self.armor[i] = self.inventaire.backpack[mouse_slot] self.inventaire.backpack[mouse_slot] = None self.inventaire.last_moove = mouse_slot self.inventaire.have_object = False if bouton_arm[i].collidepoint((mx_display,my_display)) and self.inventaire.backpack[mouse_slot]!= None and key[self.inventaire.backpack[mouse_slot]].wpn_type == 9: self.hp += key[self.inventaire.backpack[mouse_slot]].heal self.inventaire.backpack[self.inventaire.last_items_select] = None self.inventaire.backpack[mouse_slot] = None else: self.inventaire.have_object = False self.inventaire.last_moove = -1 if also_inventory: self.inventaire.print_inventory_bis(pos_x_inventory_player,pos_y_inventory_player,main=False,mouse=mouse) if self.inventaire.backpack[mouse_slot] != None: screen.blit(key[self.inventaire.backpack[mouse_slot]].wpn_img,(mx,my))
def display_lvl(self,surface,x,y): name = wblack(ColderWeather,str(self.level)) name = pygame.transform.scale(name,(name.get_width() // 2,name.get_height()//2)) screen.blit(name,(x,y + name.get_height()))
def display_classe(self,surface,x,y): name = wblack(ColderWeather,self.classe) name = pygame.transform.scale(name,(name.get_width() // 4,name.get_height()//4)) screen.blit(name,(x,y))
def caracter_sheet(self): screenS=screen.copy() running=True "Creer un board et y met les attributs qui ne sont pas censer bouger" board=pygame.transform.scale(board_init(),(900,780)) rectboard=pygame.Rect(screen.get_width()//2-board.get_width()//2,20,0,0) board.set_colorkey((255,255,255)) board_icon=pygame.transform.scale(board_init(),(board.get_width()//5,board.get_height()//5)) # board_icon.set_colorkey((0,0,0)) #print(self.classe) if self.classe=='sorcerer': icone=pygame.transform.scale(wizard_icon,(board_icon.get_width()//2,board_icon.get_height())) if self.classe=='fighter': icone=pygame.transform.scale(fighter_icon,(board_icon.get_width(),board_icon.get_height())) if self.classe=='rogue': icone=pygame.transform.scale(rogue_icon,(board_icon.get_width(),board_icon.get_height())) icone.set_colorkey((255,255,255)) board_icon.blit(icone,(board_icon.get_width()//2-icone.get_width()//2,0)) rect_icon=screen.blit(board_icon,(rectboard.x-board_icon.get_width()//1.5,rectboard.y+board_icon.get_height()//0.8)) board_icon2=pygame.transform.scale(board_init(),(board.get_width()//5,board.get_height()//5)) iconen=pygame.transform.scale(neutre_icon,(trunc(board_icon2.get_width()//1.2),trunc(board_icon2.get_height()//1.2))) board_icon2.blit(iconen,(board_icon2.get_width()//2-iconen.get_width()//2,board_icon2.get_height()//2-iconen.get_height()//2)) perso=pygame.transform.scale(self.img,(board.get_width()//5,board.get_height()//3)) board2=board_init() board.blit(perso,(10+board.get_width()*0.06,10)) boards=pygame.transform.scale(board_init(), (board.get_width()-10,int(board.get_height()//1.5))) board.blit(boards,(5,10+board.get_height()//3)) board2=pygame.transform.scale(board_init(), (int(board.get_width()//1.4-5),board.get_height()//3)) board.blit(board2,(perso.get_width()+board.get_width()*0.06,15)) draw_text(self.name,title,"b",board,perso.get_width()*2.5,board.get_height()//30-10) draw_text("Class : "+ self.classe,subtitle,"b",board,perso.get_width()+board.get_width()*0.06+30,70) draw_text("Level : "+str(self.level),subtitle,"b",board,perso.get_width()+board.get_width()*0.06+30,110) draw_text("Attack : "+str(self.attack),subtitle,"b",board,perso.get_width()+board.get_width()*0.06+30,150) draw_text("Hit Dice : "+str(self.hit_dice),subtitle,"b",board,perso.get_width()+board.get_width()*0.06+30,190) draw_text("HP : ",subtitle,"b",board,perso.get_width()+board.get_width()*0.06+400,70) draw_text(str(self.hp) + " / " + str(self.hp_max),subtitle,color.RED,board,perso.get_width()+board.get_width()*0.06+490,70) draw_text("AC : " + str(self.armor_class),subtitle,"b",board,perso.get_width()+board.get_width()*0.06+400,110) draw_text("Feet : " + str(self.feet),subtitle,"b",board,perso.get_width()+board.get_width()*0.06+400,150) draw_text("Nb HD : " + str(self.nb_hit_dice),subtitle,"b",board,perso.get_width()+board.get_width()*0.06+400,190) draw_text("SKILL POINTS",title2,"b",board,40,50+board.get_height()//3) draw_text("AIVABLE",title,"b",board,500,160+board.get_height()//3) draw_text("STR",title,"b",board,40,100+board.get_height()//3) draw_text("DEX",title,"b",board,40,160+board.get_height()//3) draw_text("CON",title,"b",board,40,220+board.get_height()//3) draw_text("INT",title,"b",board,40,280+board.get_height()//3) draw_text("WIL",title,"b",board,40,340+board.get_height()//3) draw_text("CHA",title,"b",board,40,400+board.get_height()//3) av=self.av_points click=False "initialise la liste de boutons cliquable" Blist=self.buttons_init(board,rectboard) rect_confirm=self.confirm(board,rectboard,av) board1=self.boardSkill(board.copy(),av) if self.chose_skill==True: self.choseSkill() screenS2=screenSave() while running: "actualise le board avec les skills points et les buttons si un changement a été fait" screen.blit(screenS2,(0,0)) board1=self.boardSkill(board.copy(),av) self.confirm(board1,rectboard,av) self.buttons_select(board1,av) indice=collides(pygame.mouse.get_pos(),Blist) "ici on vérifie si le joueur a fait un click et où" if click and indice!=-1: self.buttons_select(board1,av,indice) if av>0 and indice%2==0 and self.stats[indice//2]+self.stats_eph[indice//2]<18: av-=1 self.points_eph[(indice+1)//2]+=1 self.stats_eph=[8+self.points_eph[n]+self.points[n]-self.stats[n] if self.stats[n]+self.stats_eph[n]<14 else 14-self.stats[n]+ (self.points_eph[n]+self.points[n]-6)//2 if 14<=self.stats[n]+self.stats_eph[n]<16 else 16-self.stats[n]+(self.points_eph[n]+ self.points[n]-10)//3 for n in range(6)] elif indice%2==1 and self.stats_eph[indice//2]!=0: av+=1 self.points_eph[indice//2]-=1 self.stats_eph=[8+self.points_eph[n]+self.points[n]-self.stats[n] if self.stats[n]+self.stats_eph[n]<14 else 14-self.stats[n]+ (self.points_eph[n]+self.points[n]-6)//2 if 14<=self.stats[n]+self.stats_eph[n]<16 else 16-self.stats[n]+(self.points_eph[n]+ self.points[n]-10)//3 for n in range(6)] elif click and rect_confirm.collidepoint(pygame.mouse.get_pos()): self.confirm(board1,rectboard,av,True) elif click and rect_icon.collidepoint(pygame.mouse.get_pos()): self.stats_eph=[0,0,0,0,0,0] self.points_eph=[0,0,0,0,0,0] return 1 screen.blit(board1,(screen.get_width()//2-board.get_width()//2,20)) screen.blit(board_icon2,(rectboard.x-board_icon.get_width()//1.5,rectboard.y+board_icon.get_height()*0.2)) pygame.display.flip() running,click=basic_checkevent(click,None) self.stats_eph=[0,0,0,0,0,0] self.points_eph=[0,0,0,0,0,0] screen.blit(screenS,(0,0)) return 0
def caracter_sheet(self): screenS = screenSave() board = pygame.transform.scale(board_init(), (900, 780)) board_icon = pygame.transform.scale( board_init(), (board.get_width() // 5, board.get_height() // 5)) iconew = pygame.transform.scale( fighter_icon, (board_icon.get_width(), board_icon.get_height())) board_icon.blit( iconew, (board_icon.get_width() // 2 - iconew.get_width() // 2, 0)) board_icon2 = pygame.transform.scale( board_init(), (board.get_width() // 5, board.get_height() // 5)) iconen = pygame.transform.scale( neutre_icon, (trunc(board_icon2.get_width() // 1.2), trunc(board_icon2.get_height() // 1.2))) board_icon2.blit( iconen, (board_icon2.get_width() // 2 - iconen.get_width() // 2, board_icon2.get_height() // 2 - iconen.get_height() // 2)) draw_text("Fighter", title, "bl", board, board.get_width() // 8, board.get_height() // 20) perso = pygame.transform.scale( fighter_img, (board.get_width() // 3, board.get_height() // 2)) board.blit(perso, (board.get_width() // 14, board.get_height() // 7)) """initialisation de tous les boards avec les choix correspondants aux 5 differents lvl""" rect_choices = list() if self.SW: draw_text("Second Wind : Active", text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65)) else: draw_text("Second Wind : Inactive", text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65)) if self.master == False: draw_text("unlock master skill lvl 4", text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65) + 50) else: if self.masterAction: draw_text("master action : Active", text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65) + 50) else: draw_text("Master Action : Inactive", text, 'b', board, board.get_width() // 18, trunc(board.get_height() * 0.65) + 50) rectboard = pygame.Rect( screen.get_width() // 2 - board.get_width() // 2, 20, 0, 0) board_level1 = board_with_msg("Unlock at level 1") rect_board1 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.03), 0, 0)) rect_choices.append( choices_clickable(board_level1, [image['S_Holy02.png']], rect_board1)) board_level1, rect_choices[0] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level1, rect_choices[0], rect_board1) board_level2 = board_with_msg("Unlock at level 2") rect_board2 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.21), 0, 0)) rect_choices.append( choices_clickable(board_level2, [image['W_Sword007.png'], image['S_Buff01.png']], rect_board2)) board_level2, rect_choices[1] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level2, rect_choices[1], rect_board2) board_level3 = board_with_msg("Unlock at level 3") rect_board3 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.39), 0, 0)) rect_choices.append( choices_clickable(board_level3, [image['S_Holy05.png']], rect_board3)) board_level3, rect_choices[2] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level3, rect_choices[2], rect_board3) board_level4 = board_with_msg("Unlock at level 4") rect_board4 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.57), 0, 0)) rect_choices.append( choices_clickable(board_level4, [image['S_Buff08.png']], rect_board4)) board_level4, rect_choices[3] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level4, rect_choices[3], rect_board4) board_level5 = board_with_msg("Unlock at level 5") rect_board5 = replace_rect( rectboard, pygame.Rect(trunc(board.get_width() * 0.45), trunc(board.get_height() * 0.75), 0, 0)) rect_choices.append( choices_clickable(board_level5, [image['W_Axe001.png']], rect_board5)) board_level5, rect_choices[4] = replace_rects_scale( (trunc(board.get_width() * 0.5), trunc(board.get_height() * 0.2)), board_level5, rect_choices[4], rect_board5) board.blit(board_level1, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.03))) board.blit(board_level2, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.21))) board.blit(board_level3, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.39))) board.blit(board_level4, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.57))) board.blit(board_level5, (trunc( board.get_width() * 0.45), trunc(board.get_height() * 0.75))) running = True click = False if super().caracter_sheet(): rect_icon = screen.blit( board_icon2, (rectboard.x - board_icon.get_width() // 1.5, rectboard.y + board_icon.get_height() * 0.2)) screen.blit(board, (rectboard.x, rectboard.y)) screen.blit(board_icon, (rectboard.x - board_icon.get_width() // 1.5, rectboard.y + board_icon.get_height() // 0.8)) ScreenS2 = screenSave() while running: screen.blit(ScreenS2, (0, 0)) indice1 = collides(pygame.mouse.get_pos(), rect_choices[0]) indice2 = collides(pygame.mouse.get_pos(), rect_choices[1]) indice3 = collides(pygame.mouse.get_pos(), rect_choices[2]) indice4 = collides(pygame.mouse.get_pos(), rect_choices[3]) indice5 = collides(pygame.mouse.get_pos(), rect_choices[4]) if indice1 == 0: board_with_text( "You unlock Second Wind, you can use it to recover between 1 and 10 hp" ) elif indice2 == 0: board_with_text( "Now when you wear an armor, the bonus armor is increase by 1, the damage of your weapons are increase by one too" ) elif indice2 == 1: board_with_text( "you could choose a skill, each time you will use an attribute reattach to your skill you will add your proficiency modifier to your score" ) elif indice3 == 0: board_with_text( "Second wind can heal up to 3 allies now and the amount of hp recovered is equal to your level" ) elif indice4 == 0: board_with_text( "You unlock your Master Action, you can use it one time between 2 rest, when you use it youcan do 2 actions in the same turn" ) elif indice5 == 0: board_with_text("proficiency bonus is now at 3") running, click = basic_checkevent(click) if click == True and rect_icon.collidepoint( pygame.mouse.get_pos()): if super().caracter_sheet() == 0: running = False pygame.display.flip() screen.blit(screenS, (0, 0))
def print_monster(self): draw_text("Monstre : ",ColderWeather_small,WHITE,screen,self.pos_x+100,self.pos_y+400) screen.blit(self.monster.avata,(225,400))
def print_items(self): draw_text("Item : ",ColderWeather_small,WHITE,screen,self.pos_x+100,self.pos_y+400) screen.blit(self.items.wpn_img,(225,400))