From 4adfb198933e8c00e0a4be04a753f2bc432b0bb3 Mon Sep 17 00:00:00 2001 From: Luis Rodrigues Date: Fri, 20 Sep 2024 12:50:03 +0100 Subject: [PATCH] =?UTF-8?q?adicionar=20gest=C3=A3o=20de=20erros=20=C3=A0?= =?UTF-8?q?=20fun=C3=A7=C3=A3o=20'devolveCor()'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gui.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/gui.py b/modules/gui.py index 566972a..2404478 100644 --- a/modules/gui.py +++ b/modules/gui.py @@ -1,5 +1,6 @@ import sys import random +from typing import type_check_only import pygame as pg from modules.agente import Agente from modules.mapa import Mapa @@ -9,19 +10,20 @@ flags = 0 def devolveCor(agente: Agente | None) -> tuple[int, int, int, int]: - match agente.estrategia: - case "Neutro": - return (255, 255, 255, 0) - case "Tit4Tat": - return (255, 255, 0, 0) - case "Vingativo": - return (255, 0, 0, 0) - case "Lunatico": - return (0, 0, 255, 0) - case None: - return (0, 0, 0, 0) - case _: - return (0, 0, 0, 0) + if type(agente) is None: + return (0, 0, 0, 0) + else: + match agente.estrategia: + case "Neutro": + return (255, 255, 255, 0) + case "Tit4Tat": + return (255, 255, 0, 0) + case "Vingativo": + return (255, 0, 0, 0) + case "Lunatico": + return (0, 0, 255, 0) + case _: + return (0, 0, 0, 0) def criarTabuleiro(