Exemplo n.º 1
0
    def test_HitAi_RandomPartOfPlaneHit_CellTypeChangedToX(self):
        player_table = PlayTable()
        AI_table = PlayTable()
        service = ServiceGame(player_table,AI_table)
        service.InitializeTable("ui", "white", "AI")
        service.InitializeTable("ui","grey","NAI")
        service.AddAiPlane(3, 0, "ui")
        service.HitAi(1, 1)
        
        correct_table = []
        for i in range(8):
            row = []
            for j in range(8):
                if ((i == 2 and j == 1) or (i == 2 and j == 3)) or (i == 3 and ( j == 1 or j == 2 or j == 3)) or ((i == 4 and j == 1) or (i == 4 and j == 3)) or (i == 5 and j == 1):
                    cell = ButtonForRepo("1",i,j,"blue","AI")
                elif i == 1 and j == 1:
                    cell = ButtonForRepo("X",i,j,"X","AI")
                elif i == 3 and j == 0:
                    cell = ButtonForRepo("1",i,j,"pink","AI")
                else:
                    cell = ButtonForRepo("0",i,j,"white","AI")
                row.append(cell)
            correct_table.append(row)

        table = service.GetAiTable()
        self.assertEqual(table, correct_table)
Exemplo n.º 2
0
 def test_Reset_ValidInput_TablesReseted(self):
     player_table = PlayTable()
     AI_table = PlayTable()
     service = ServiceGame(player_table,AI_table)
     service.InitializeTable("ui", "grey", "NAI")
     service.AddPlayerPlane(3, 0, "ui", "blue", "NAI")
     table = service.GetPlayerTable()
     copy_of_table = copy.deepcopy(table)
     service.Reset("ui")
     table_after_reset = service.GetPlayerTable()
     self.assertNotEqual(copy_of_table, table_after_reset)
Exemplo n.º 3
0
 def test_InitializeTable_ValidInput_TableInitilizedCorectly(self):
     player_table = PlayTable()
     AI_table = PlayTable()
     service = ServiceGame(player_table,AI_table)
     service.InitializeTable("ui", "grey", "NAI")
     table = service.GetPlayerTable()
     correct_table = []
     for i in range(8):
         row = []
         for j in range(8):
             cell = ButtonForRepo("0",i,j,"grey","NAI")
             row.append(cell)
         correct_table.append(row)
     self.assertEqual(table, correct_table)
Exemplo n.º 4
0
 def test_AddAiPlane_ValidInput_PlaneAddedOnTheTable(self):
     player_table = PlayTable()
     AI_table = PlayTable()
     service = ServiceGame(player_table,AI_table)
     service.InitializeTable("ui", "white", "AI")
     service.AddAiPlane(3, 0, "ui")
     correct_table = []
     for i in range(8):
         row = []
         for j in range(8):
             if (i == 1 and j == 1) or ((i == 2 and j == 1) or (i == 2 and j == 3)) or (i == 3 and ( j == 1 or j == 2 or j == 3)) or ((i == 4 and j == 1) or (i == 4 and j == 3)) or (i == 5 and j == 1):
                 cell = ButtonForRepo("1",i,j,"blue","AI")
             elif i == 3 and j == 0:
                 cell = ButtonForRepo("1",i,j,"pink","AI")
             else:
                 cell = ButtonForRepo("0",i,j,"white","AI")
             row.append(cell)
         correct_table.append(row)
     table = service.GetAiTable()
     self.assertEqual(table, correct_table)
Exemplo n.º 5
0
from UserInterfaces import UI, GUI
from Services import ServiceGame
from Repositories import PlayTable
from Tests import Tests

tests = Tests()
tests.RunAllTests()

Players_Table = PlayTable()
Computers_Table = PlayTable()

Service = ServiceGame(Players_Table, Computers_Table)

User_Interface = UI(Service)
Grafic_User_Interface = GUI(Service)

while True:
    UserInterface = input("Choose an interface between UI and GUI : ")
    if UserInterface.upper() == "UI":
        User_Interface.start()
        break
    elif UserInterface.upper() == "GUI":
        Grafic_User_Interface.start()
        break
    else:
        print("choose a valid user interface")