コード例 #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))
コード例 #2
0
ファイル: sorcerer.py プロジェクト: quocdat-le-insacvl/pygeon
 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
コード例 #3
0
ファイル: sorcerer.py プロジェクト: quocdat-le-insacvl/pygeon
 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))
コード例 #4
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
コード例 #5
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))
コード例 #6
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()))
コード例 #7
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))
コード例 #8
0
ファイル: sorcerer.py プロジェクト: quocdat-le-insacvl/pygeon
 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))
コード例 #9
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))
コード例 #10
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))
コード例 #11
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