Ejemplo n.º 1
0
 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))
Ejemplo n.º 2
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
Ejemplo n.º 3
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))
Ejemplo n.º 4
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))
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
 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))
Ejemplo n.º 7
0
def board_with_msg(message):
    #take a message as argument (string) and creat a board wich is returned
    assert (len(message) < 60
            and type(message) == str), "message invalid in boarb_with_message"
    text2 = subtitle.render(message, True, color.BROWN)
    text2 = pygame.transform.scale(
        text2, (screen.get_width() // 2, trunc(text2.get_height() * 2)))
    board = pygame.transform.scale(
        pygame.image.load(r"Addon\Menu\UI board Small  parchment.png"),
        (int(text2.get_width() * 1.2), text2.get_width() // 2))
    board.blit(text2, (board.get_width() // 2 - text2.get_width() // 2,
                       text2.get_height() // 2))
    return board
Ejemplo n.º 8
0
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()))
Ejemplo n.º 9
0
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))
Ejemplo n.º 10
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))
Ejemplo n.º 11
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))
Ejemplo n.º 12
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))
Ejemplo n.º 13
0
from settings.screen import screen
from settings.color import BLUE, WHITE
from map import Map
from personnage import Perso
import pygame
import pickle

WIDTH = screen.get_width()
HEIGHT = screen.get_height()
MINIMAP_SCALE = 300


class Minimap:
    def __init__(self, map, fog, display_with_nature, list_entity, player):
        #self.game = game
        self.list_mooving_entity = list_entity
        self.player = player
        self.display_with_nature = display_with_nature
        self.screen = screen
        self.map = map
        self.fog = fog
        self.map_height = len(self.map)
        self.map_width = len(self.map[0])
        self.TOP_LEFT_X = WIDTH - MINIMAP_SCALE
        self.TOP_LEFT_Y = HEIGHT - MINIMAP_SCALE
        self.surface = pygame.Surface((MINIMAP_SCALE, MINIMAP_SCALE))
        self.surface.set_alpha(50)  # alpha level
        self.surface.fill(BLUE)
        SCALE = 10 * MINIMAP_SCALE
        self.SCALE = SCALE
        self.scale = SCALE / 2
Ejemplo n.º 14
0
 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
Ejemplo n.º 15
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))
Ejemplo n.º 16
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(
         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))