adicionago type hint para parametro 'agente'

This commit is contained in:
2024-09-19 17:40:54 +01:00
parent 1cd656c3f8
commit a0cb7db3ad

View File

@ -4,10 +4,11 @@ import pygame as pg
from modules.agente import Agente from modules.agente import Agente
from modules.mapa import Mapa from modules.mapa import Mapa
import modules.estrategia as ModEstrategia import modules.estrategia as ModEstrategia
flags = 0 flags = 0
def devolveCor(agente: Agente) -> tuple[int, int, int, int]: def devolveCor(agente: Agente | None) -> tuple[int, int, int, int]:
match agente.estrategia: match agente.estrategia:
case "Neutro": case "Neutro":
return (255, 255, 255, 0) return (255, 255, 255, 0)
@ -17,6 +18,8 @@ def devolveCor(agente: Agente) -> tuple[int, int, int, int]:
return (255, 0, 0, 0) return (255, 0, 0, 0)
case "Lunatico": case "Lunatico":
return (0, 0, 255, 0) return (0, 0, 255, 0)
case None:
return (0, 0, 0, 0)
case _: case _:
return (0, 0, 0, 0) return (0, 0, 0, 0)
@ -24,7 +27,7 @@ def devolveCor(agente: Agente) -> tuple[int, int, int, int]:
def criarTabuleiro( def criarTabuleiro(
surface: pg.Surface, surface: pg.Surface,
dimensao_tabuleiro: tuple[int, int], dimensao_tabuleiro: tuple[int, int],
mapa: Mapa, mapa: Mapa | None,
) -> None: ) -> None:
dimensoes_surface_principal: tuple[int, int] = surface.get_size() dimensoes_surface_principal: tuple[int, int] = surface.get_size()
max_altura: int = int( max_altura: int = int(
@ -119,4 +122,4 @@ def main(mapa: Mapa | None):
if __name__ == '__main__': if __name__ == '__main__':
mapa_mundo: Mapa = Mapa((10, 10)) mapa_mundo: Mapa = Mapa((10, 10))
app = App(mapa_mundo) app = main(mapa_mundo)