From 04036349b20bca51dac9a2986b80f170d2f5cb5e Mon Sep 17 00:00:00 2001 From: Hauke Platte Date: Thu, 14 Mar 2024 01:53:25 +0100 Subject: [PATCH 01/10] feat(UI-UX): Add chat to lobby and playfield [TTTK-16] --- UI/chat.py | 41 +++++++++++++++++++++++++++++++++++++++++ UI/field_frame.py | 11 +++++++---- UI/lib/tttk_tk.py | 3 ++- UI/multi.py | 14 +++++++++----- 4 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 UI/chat.py diff --git a/UI/chat.py b/UI/chat.py new file mode 100644 index 0000000..ff51a47 --- /dev/null +++ b/UI/chat.py @@ -0,0 +1,41 @@ +from .lib import tttk_tk as tk + +class Chat(tk.Frame): + def __init__(self, master, root, chat='', *args, **kwargs): + super().__init__(master) + self.root = root + self._create_widgets(chat) + self._display_widgets() + self.root.network_events['chat/receive'] = self._chat_receive + + def _create_widgets(self, chat): + #self.txtChat = tk.Text(self.widget, state=tk.DISABLED) + self.txtChat = tk.Text(self.widget, width=0) + self.txtScroll = tk.Scrollbar(self.widget, command=self.txtChat.yview) + self.txtChat.config(yscrollcommand=self.txtScroll.set) + self.txtChat.insert(tk.END, chat) + self.txtChat.config(state=tk.DISABLED) + self.etrMessage = tk.Entry(self.widget) + self.btnSend = tk.Button(self.widget, text="Send", command=lambda *args: self._send()) + + def _display_widgets(self): + self.widget.columnconfigure([0], weight=5) + self.widget.columnconfigure([1], weight=1) + self.widget.rowconfigure([0], weight=1) + self.widget.rowconfigure([1,2], weight=0) + self.txtChat.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=0, row=0, columnspan=2) + self.txtScroll.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=2, row=0) + self.etrMessage.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=0, row=1) + self.btnSend.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=1, row=1, columnspan=2) + + def _send(self): + self.root.out_queue.put({'message_type': 'chat/message', 'args' : {'message': self.etrMessage.val}}) + self.etrMessage.val = "" + self.txtChat.config(state=tk.NORMAL) + self.txtChat.insert(tk.END, "hallo\n") + self.txtChat.config(state=tk.DISABLED) + + def _chat_receive(self, queue): + self.txtChat.config(state=tk.NORMAL) + self.txtChat.insert(tk.END, f"{queue['sender'].display_name}: {queue['message']}\n") + self.txtChat.config(state=tk.DISABLED) \ No newline at end of file diff --git a/UI/field_frame.py b/UI/field_frame.py index b211965..832230f 100644 --- a/UI/field_frame.py +++ b/UI/field_frame.py @@ -6,6 +6,7 @@ from .gamefield import gamefield, gamefield_controller from .endscreen import EndScreen from .messages import messages +from .chat import Chat class player_type(Enum): local = auto() @@ -71,9 +72,9 @@ def error(self, queue, *args): msg.display() class Field(base_frame): - def __init__(self, master, *args, starting_player, starting_player_symbol, opponent, opponent_symbol, **kwargs): + def __init__(self, master, chat, *args, starting_player, starting_player_symbol, opponent, opponent_symbol, **kwargs): super().__init__(master) - self._create_widgets() + self._create_widgets(chat) self.controller = field_controller(self, [starting_player, opponent]) self._display_widgets() #self.bind("<>", self.controller.sub_controller.turn) @@ -83,22 +84,24 @@ def __init__(self, master, *args, starting_player, starting_player_symbol, oppon self.master.network_events['game/end'] = self.controller.end self.master.network_events['game/error'] = self.controller.error - def _create_widgets(self): + def _create_widgets(self, chat): self.heading = tk.Label(self, text="Tic Tac Toe Kojote", font=self.master.title_font) self.player = [] self.player.append(player(self, 1)) self.player.append(player(self, 2)) self.gamefield = gamefield(self) + self.chat = Chat(self, self.master, chat) self.close = tk.Button(self, text="close") def _display_widgets(self): - self.columnconfigure(1, weight=1) + self.columnconfigure([1,3], weight=1) self.rowconfigure(2, weight=1) self.heading.grid(row=0, column=0, columnspan=3) self.player[0].grid(row=1, column=0) self.player[1].grid(row=1, column=2) self.gamefield.grid(sticky=tk.N+tk.S+tk.E+tk.W, row=2, column=1) + self.chat.grid(sticky=tk.N+tk.S+tk.E+tk.W, row=1, column=3, rowspan=3) self.close.grid(row=3, column=2) def on_destroy(self): diff --git a/UI/lib/tttk_tk.py b/UI/lib/tttk_tk.py index 28f9e62..0e26abc 100644 --- a/UI/lib/tttk_tk.py +++ b/UI/lib/tttk_tk.py @@ -21,7 +21,8 @@ def __init__(self, Widget: tk.Widget, master: tk.Misc, *args, **kwargs): kwargs['defaultValues'] = { 'font': ("Arial bold", 12), 'margin': 5, - 'bg': '#FFFFFF',} | defaultValues + 'bg': '#FFFFFF', + 'width': 0,} | defaultValues if(Widget == tk.Frame): del kwargs['defaultValues']['font'] super().__init__(Widget, master, *args, **kwargs) diff --git a/UI/multi.py b/UI/multi.py index 37d6324..dfeee07 100644 --- a/UI/multi.py +++ b/UI/multi.py @@ -10,6 +10,7 @@ from Server.main import server_thread from AI.ai_context import AIContext from AI.ai_strategy import AIStrategy, WeakAIStrategy, AdvancedAIStrategy +from .chat import Chat class Join(base_frame): def __init__(self, master, *args, opponent=player_type.unknown, **kwargs): @@ -36,8 +37,9 @@ def _create_widgets(self, opponent): if opponent == player_type.local: self.btnRdy2 = tk.Button(self, text='Start', command=lambda *args: self.master.out_queue.put({'message_type': 'lobby/ready', 'args' : {'ready': True}})) self.btnExit = tk.Button(self, text='Menu', command=lambda: self.master.show_menu()) + self.chat = Chat(self, self.master) - def _display_widgets(self,): + def _display_widgets(self): self.columnconfigure([0, 6], weight=1) self.columnconfigure([1, 5], weight=2) self.columnconfigure([2, 4], weight=4) @@ -46,11 +48,13 @@ def _display_widgets(self,): self.rowconfigure([2], weight=2) self.rowconfigure([4, 6, 8, 10], weight=4) self.rowconfigure([3, 5, 7, 9, 11], weight=2) + self.grid_configure() # display the buttons created in the _create_widgets method self.lblTitle.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=2, row=2, columnspan=3) - self.btnRdy.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=4, row=10) + self.btnRdy.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=2, row=10) if hasattr(self, 'btnRdy2'): self.btnRdy2.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=2, row=10) + self.chat.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=4, row=4, columnspan=2, rowspan=7) self.btnExit.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=5, row=1) def _update_lobby(self, queue): @@ -65,13 +69,13 @@ def _update_lobby(self, queue): else: self.btnRdy.config(text="Start") for i, player in enumerate(self.playerlist): - player[0].grid(sticky=tk.E+tk.W+tk.N+tk.S, column=2, row=4+i, columnspan=2) - player[1].grid(sticky=tk.E+tk.W+tk.N+tk.S, column=4, row=4+i) + player[0].grid(sticky=tk.E+tk.W+tk.N+tk.S, column=2, row=4+i) + player[1].grid(sticky=tk.E+tk.W+tk.N+tk.S, column=3, row=4+i) def _start_game(self, queue): print(queue) - self.master.show(Field, **queue) + self.master.show(Field, self.chat.txtChat.get("1.0", tk.END+"-1c")+"Game starting\n", **queue) def on_destroy(self): del self.master.network_events['lobby/status'] From 428cf7e9a4c6495023782d0ff603082044c7bb7a Mon Sep 17 00:00:00 2001 From: Petzys <87223648+Petzys@users.noreply.github.com> Date: Thu, 14 Mar 2024 08:16:56 +0100 Subject: [PATCH 02/10] Fix(client): Fixed missing chat messages in client --- Client/ui_client.py | 2 +- UI/chat.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Client/ui_client.py b/Client/ui_client.py index dbfa112..ecf4695 100644 --- a/Client/ui_client.py +++ b/Client/ui_client.py @@ -132,7 +132,7 @@ async def await_commands(self): case "game/make_move": await self.game_make_move(**message["args"]) case "chat/message": - pass + await self.chat_message(**message["args"]) case "server/terminate": await self.terminate() case "game/gamestate": diff --git a/UI/chat.py b/UI/chat.py index ff51a47..88a3435 100644 --- a/UI/chat.py +++ b/UI/chat.py @@ -31,9 +31,6 @@ def _display_widgets(self): def _send(self): self.root.out_queue.put({'message_type': 'chat/message', 'args' : {'message': self.etrMessage.val}}) self.etrMessage.val = "" - self.txtChat.config(state=tk.NORMAL) - self.txtChat.insert(tk.END, "hallo\n") - self.txtChat.config(state=tk.DISABLED) def _chat_receive(self, queue): self.txtChat.config(state=tk.NORMAL) From a761b4106fb2b4e3746c5b0a203b994de2329bfa Mon Sep 17 00:00:00 2001 From: Hauke Platte Date: Thu, 14 Mar 2024 08:28:21 +0100 Subject: [PATCH 03/10] fix(UI-UX): delete player now works [TTTK-75] --- UI/profile.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/UI/profile.py b/UI/profile.py index 48df264..2b5e120 100644 --- a/UI/profile.py +++ b/UI/profile.py @@ -64,7 +64,7 @@ def _create_widgets(self): self.lblUUDI = tk.Label(self, text='User ID') self.lblUUIDValue = tk.Label(self, text=self.master.player.uuid) self.btnEdit = tk.Button(self, text='Edit Profile', command=lambda *args: self.master.show(NewProfile, 'edit')) - self.btnDelete = tk.Button(self, text='Delete profile', command=lambda*args : self.master.show(NewProfile, 'delete')) + self.btnDelete = tk.Button(self, text='Delete profile', command=lambda *args: self._delete()) self.btnMenu = tk.Button(self, text='Menu', command=lambda: self.master.show_menu()) def _display_widgets(self): @@ -87,4 +87,8 @@ def _display_widgets(self): self.lblUUIDValue.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=4, row=6, columnspan=5) self.btnDelete.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=2, row=8, columnspan=3) self.btnEdit.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=6, row=8, columnspan=3) - self.btnMenu.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=9, row=1) \ No newline at end of file + self.btnMenu.grid(sticky=tk.E+tk.W+tk.N+tk.S, column=9, row=1) + + def _delete(self): + self.master.player = None + self.master.show(NewProfile, 'delete') \ No newline at end of file From e8ab224f7df7de72d64cb9b606ccc67a6da6c499 Mon Sep 17 00:00:00 2001 From: Hauke Platte Date: Thu, 14 Mar 2024 08:30:36 +0100 Subject: [PATCH 04/10] fix(UI-UX): fix Main Menu Button on end screen [TTTK-76] --- UI/endscreen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/endscreen.py b/UI/endscreen.py index 18773d0..b43f82c 100644 --- a/UI/endscreen.py +++ b/UI/endscreen.py @@ -13,7 +13,7 @@ def _create_widgets(self, win:bool): message = "You won the game!" if win else "You lost the game!" self.lblWinner = tk.Label(self, width=20, height=5, bg="white", text=message) #self.btnPlayAgain = tk.Button(self, width=20, height=5, text="Play Again", command=lambda: self.master.show(Field)) - self.btnMainMenu = tk.Button(self, text="Main Menu", width=20, height=5, command=lambda: self.master.show_menu) + self.btnMainMenu = tk.Button(self, text="Main Menu", width=20, height=5, command=lambda: self.master.show_menu()) def _display_widgets(self): self.lblWinner.pack() From b0bea02b2a7476fbf12248bcff1a14ff1c5384e0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 14 Mar 2024 06:08:07 -0400 Subject: [PATCH 05/10] created the first few sequence diagrams --- AI/docs/secuence_diagrams/create_profile.puml | 15 ++++++++++++ AI/docs/secuence_diagrams/delete_profile.puml | 13 ++++++++++ AI/docs/secuence_diagrams/edit_profile.puml | 16 +++++++++++++ AI/docs/secuence_diagrams/play_vs_ai.puml | 24 +++++++++++++++++++ AI/docs/secuence_diagrams/view_profile.puml | 10 ++++++++ 5 files changed, 78 insertions(+) create mode 100644 AI/docs/secuence_diagrams/create_profile.puml create mode 100644 AI/docs/secuence_diagrams/delete_profile.puml create mode 100644 AI/docs/secuence_diagrams/edit_profile.puml create mode 100644 AI/docs/secuence_diagrams/play_vs_ai.puml create mode 100644 AI/docs/secuence_diagrams/view_profile.puml diff --git a/AI/docs/secuence_diagrams/create_profile.puml b/AI/docs/secuence_diagrams/create_profile.puml new file mode 100644 index 0000000..9910340 --- /dev/null +++ b/AI/docs/secuence_diagrams/create_profile.puml @@ -0,0 +1,15 @@ +@startuml +title Create Player Profile + +actor Player +database System + +Player->System: Click Profile Button +System->Player: Show Profile Creation Prompt +Player->System: Set Name +Player->System: Set Color +Player->System: Click Create Profile Button +System->System: Save Profile on Disk +System->Player: Show Profile + +@enduml \ No newline at end of file diff --git a/AI/docs/secuence_diagrams/delete_profile.puml b/AI/docs/secuence_diagrams/delete_profile.puml new file mode 100644 index 0000000..5d72d2a --- /dev/null +++ b/AI/docs/secuence_diagrams/delete_profile.puml @@ -0,0 +1,13 @@ +@startuml +title Delete Player Profile + +actor Player +database System + +Player->System: Click Profile Button +System->Player: Show Profile +Player->System: Click Delete Profile Button +System->System: Delete Profile from Disk +System->Player: Show Profile Creation Prompt + +@enduml \ No newline at end of file diff --git a/AI/docs/secuence_diagrams/edit_profile.puml b/AI/docs/secuence_diagrams/edit_profile.puml new file mode 100644 index 0000000..d35d89d --- /dev/null +++ b/AI/docs/secuence_diagrams/edit_profile.puml @@ -0,0 +1,16 @@ +@startuml +title Create Player Profile + +actor Player +database System + +Player->System: Click Profile Button +System->Player: Show Profile +Player->System: Click Edit Profile Button +Player->System: Change Name +Player->System: Change Color +Player->System: Click Edit Profile Button +System->System: Save Profile on Disk +System->Player: Show Profile + +@enduml \ No newline at end of file diff --git a/AI/docs/secuence_diagrams/play_vs_ai.puml b/AI/docs/secuence_diagrams/play_vs_ai.puml new file mode 100644 index 0000000..1a203d8 --- /dev/null +++ b/AI/docs/secuence_diagrams/play_vs_ai.puml @@ -0,0 +1,24 @@ +@startuml +title Play versus AI + +actor Player as p +database System +actor AI as a + +p->System: Click Singleplayer Button +System->p: Display AI Difficulty Selection +p->System: Select AI Difficulty by clicking Strong or Weak AI Button +System->System: Host Server locally +System->p: Display Game Lobby +System->a: Create AI +a->System: Connect to Server +a->System: Get Ready +System->p: Show AI is ready +p->System: Click Ready Button +p->System: Click Start Game Button +System->p: Show Playfield +p->p: Play Game +System->System: Process Game +a->a: Play Game + +@enduml diff --git a/AI/docs/secuence_diagrams/view_profile.puml b/AI/docs/secuence_diagrams/view_profile.puml new file mode 100644 index 0000000..b742526 --- /dev/null +++ b/AI/docs/secuence_diagrams/view_profile.puml @@ -0,0 +1,10 @@ +@startuml +title View Player Profile + +actor Player +database System + +Player->System: Click Profile Button +System->Player: Show Profile + +@enduml \ No newline at end of file From 873fb019e91aa8c360f4c9ada3cf41d0f54230cd Mon Sep 17 00:00:00 2001 From: Timm Weber <> Date: Fri, 15 Mar 2024 06:14:34 -0400 Subject: [PATCH 06/10] fix: docs folder was mistakenly created under AI folder --- {AI/docs => docs}/secuence_diagrams/create_profile.puml | 0 {AI/docs => docs}/secuence_diagrams/delete_profile.puml | 0 {AI/docs => docs}/secuence_diagrams/edit_profile.puml | 0 {AI/docs => docs}/secuence_diagrams/play_vs_ai.puml | 0 {AI/docs => docs}/secuence_diagrams/view_profile.puml | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {AI/docs => docs}/secuence_diagrams/create_profile.puml (100%) rename {AI/docs => docs}/secuence_diagrams/delete_profile.puml (100%) rename {AI/docs => docs}/secuence_diagrams/edit_profile.puml (100%) rename {AI/docs => docs}/secuence_diagrams/play_vs_ai.puml (100%) rename {AI/docs => docs}/secuence_diagrams/view_profile.puml (100%) diff --git a/AI/docs/secuence_diagrams/create_profile.puml b/docs/secuence_diagrams/create_profile.puml similarity index 100% rename from AI/docs/secuence_diagrams/create_profile.puml rename to docs/secuence_diagrams/create_profile.puml diff --git a/AI/docs/secuence_diagrams/delete_profile.puml b/docs/secuence_diagrams/delete_profile.puml similarity index 100% rename from AI/docs/secuence_diagrams/delete_profile.puml rename to docs/secuence_diagrams/delete_profile.puml diff --git a/AI/docs/secuence_diagrams/edit_profile.puml b/docs/secuence_diagrams/edit_profile.puml similarity index 100% rename from AI/docs/secuence_diagrams/edit_profile.puml rename to docs/secuence_diagrams/edit_profile.puml diff --git a/AI/docs/secuence_diagrams/play_vs_ai.puml b/docs/secuence_diagrams/play_vs_ai.puml similarity index 100% rename from AI/docs/secuence_diagrams/play_vs_ai.puml rename to docs/secuence_diagrams/play_vs_ai.puml diff --git a/AI/docs/secuence_diagrams/view_profile.puml b/docs/secuence_diagrams/view_profile.puml similarity index 100% rename from AI/docs/secuence_diagrams/view_profile.puml rename to docs/secuence_diagrams/view_profile.puml From 5550b2c4af404d5e8b198f96abbe88495a4efd9e Mon Sep 17 00:00:00 2001 From: Timm Weber <> Date: Sun, 17 Mar 2024 17:02:04 -0400 Subject: [PATCH 07/10] finished creation of sequence diagrams --- docs/secuence_diagrams/edit_profile.puml | 2 +- docs/secuence_diagrams/host_game.puml | 15 +++++++++++++++ docs/secuence_diagrams/join_game.puml | 21 +++++++++++++++++++++ docs/secuence_diagrams/leave_game.puml | 17 +++++++++++++++++ docs/secuence_diagrams/play_vs_ai.puml | 3 --- docs/secuence_diagrams/send_chat.puml | 17 +++++++++++++++++ 6 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 docs/secuence_diagrams/host_game.puml create mode 100644 docs/secuence_diagrams/join_game.puml create mode 100644 docs/secuence_diagrams/leave_game.puml create mode 100644 docs/secuence_diagrams/send_chat.puml diff --git a/docs/secuence_diagrams/edit_profile.puml b/docs/secuence_diagrams/edit_profile.puml index d35d89d..3b7c8ac 100644 --- a/docs/secuence_diagrams/edit_profile.puml +++ b/docs/secuence_diagrams/edit_profile.puml @@ -1,5 +1,5 @@ @startuml -title Create Player Profile +title Edit Player Profile actor Player database System diff --git a/docs/secuence_diagrams/host_game.puml b/docs/secuence_diagrams/host_game.puml new file mode 100644 index 0000000..682baf5 --- /dev/null +++ b/docs/secuence_diagrams/host_game.puml @@ -0,0 +1,15 @@ +@startuml +title Host Game + +actor Player as p +database System + +p->System: Click Multiplayer Button +System->p: Display Multiplayer Menu +p->System: Click Create a new online game Button +System->System: Host Server locally +System->p: Display Multiplayer Lobby +System->Network: Send advertisements +System->System: Wait for other players to join + +@enduml diff --git a/docs/secuence_diagrams/join_game.puml b/docs/secuence_diagrams/join_game.puml new file mode 100644 index 0000000..a7ddc91 --- /dev/null +++ b/docs/secuence_diagrams/join_game.puml @@ -0,0 +1,21 @@ +@startuml +title Join Game + +actor Player as p +database System +database Server as s + +p->System: Click Multiplayer Button +System->p: Display Multiplayer Menu +p->System: Click Join by address Button +System->p: Show IP-Address Input field +p->System: Enter IP-Address +p->System: Click Connect Button +System->s: Join Lobby +s->System: Send Server information +System->p: Display Game Lobby +p->System: Click Ready Button +System->s: Get Ready +s->s: Wait for other Player to get ready + +@enduml diff --git a/docs/secuence_diagrams/leave_game.puml b/docs/secuence_diagrams/leave_game.puml new file mode 100644 index 0000000..a63f877 --- /dev/null +++ b/docs/secuence_diagrams/leave_game.puml @@ -0,0 +1,17 @@ +@startuml +title Leave Game + +actor Player as p +database System +database Server as s +actor Player2 as p2 + +p->System: Click Menu Button +System->s: Player disconnected +System->s: Close connection +System->p: Show Main Menu +s->p2: You have won +s->p2: Close Connection +s->s: Terminate + +@enduml diff --git a/docs/secuence_diagrams/play_vs_ai.puml b/docs/secuence_diagrams/play_vs_ai.puml index 1a203d8..4f7fadb 100644 --- a/docs/secuence_diagrams/play_vs_ai.puml +++ b/docs/secuence_diagrams/play_vs_ai.puml @@ -17,8 +17,5 @@ System->p: Show AI is ready p->System: Click Ready Button p->System: Click Start Game Button System->p: Show Playfield -p->p: Play Game -System->System: Process Game -a->a: Play Game @enduml diff --git a/docs/secuence_diagrams/send_chat.puml b/docs/secuence_diagrams/send_chat.puml new file mode 100644 index 0000000..c86585e --- /dev/null +++ b/docs/secuence_diagrams/send_chat.puml @@ -0,0 +1,17 @@ +@startuml +title Send Chat Message + +actor Player as p +database System +database Server as s +actor Player2 as p2 + +p->System: Click on the message entry box +p->p: Enter message +p->System: Click Send Button +System->s: Send chat message +s->p2: Send chat message +s-> System: Send chat message +System->p: Display chat message + +@enduml From 5c1b89ac6221730313ab200c986df0c76df4d1f6 Mon Sep 17 00:00:00 2001 From: Timm Weber <> Date: Sun, 17 Mar 2024 18:45:52 -0400 Subject: [PATCH 08/10] created class diagram for ai --- AI/class_diagram.puml | 66 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 AI/class_diagram.puml diff --git a/AI/class_diagram.puml b/AI/class_diagram.puml new file mode 100644 index 0000000..c255d7d --- /dev/null +++ b/AI/class_diagram.puml @@ -0,0 +1,66 @@ +@startuml +title AI Strategy Pattern +skinparam classAttributeIconSize 0 + +class AIContext { + -_strategy: AIStrategy + +setStrategy(strategy: AIStrategy): None + +runStrategy(): Thread + +} + +abstract class AIStrategy { + -_strength: str + -_good_luck_message: str + -_good_game_message_lost: str + -_good_game_message_won: str + -_good_game_message_draw: str + -_current_uuid: str + -_rulebase: AIRulebase + -_ip: str + -_port: int + +post_init(): None + +thread_entry(): None + +run(): None + +join_game(): None + +message_handler(message_type: str): None + +wish_good_luck(): None + +say_good_game(): None + +get_empty_cells(game_status: list): list + +do_turn(): None +} + +class WeakAIStrategy { + +do_turn(): None +} + +class AdvancedAIStrategy { + +do_turn(): None + +check_winning_move(empty_cells: list, player: int): list|None +} + +class AIRuleBase{ + + +check_win(game_state: GameState): None + +} + +class ABC{ + --Python's Abstract Base Class-- +} +class GameClient{ + --The Client's GameClient-- +} +class RuleBase{ + --The Server's RuleBase-- +} + +AIContext --* AIStrategy +AIStrategy --|> ABC +AIStrategy --|> GameClient +AIStrategy --* AIRuleBase +AIRuleBase --|> RuleBase +AIStrategy <|-- WeakAIStrategy +AIStrategy <|-- AdvancedAIStrategy + +@enduml \ No newline at end of file From c81a78d82662b341c489a1ab05b2f4209d6aa835 Mon Sep 17 00:00:00 2001 From: Petzys <87223648+Petzys@users.noreply.github.com> Date: Mon, 18 Mar 2024 08:55:49 +0100 Subject: [PATCH 09/10] Docs(sequence_diagrams): Fixed typo in dir name --- docs/{secuence_diagrams => sequence_diagrams}/create_profile.puml | 0 docs/{secuence_diagrams => sequence_diagrams}/delete_profile.puml | 0 docs/{secuence_diagrams => sequence_diagrams}/edit_profile.puml | 0 docs/{secuence_diagrams => sequence_diagrams}/host_game.puml | 0 docs/{secuence_diagrams => sequence_diagrams}/join_game.puml | 0 docs/{secuence_diagrams => sequence_diagrams}/leave_game.puml | 0 docs/{secuence_diagrams => sequence_diagrams}/play_vs_ai.puml | 0 docs/{secuence_diagrams => sequence_diagrams}/send_chat.puml | 0 docs/{secuence_diagrams => sequence_diagrams}/view_profile.puml | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename docs/{secuence_diagrams => sequence_diagrams}/create_profile.puml (100%) rename docs/{secuence_diagrams => sequence_diagrams}/delete_profile.puml (100%) rename docs/{secuence_diagrams => sequence_diagrams}/edit_profile.puml (100%) rename docs/{secuence_diagrams => sequence_diagrams}/host_game.puml (100%) rename docs/{secuence_diagrams => sequence_diagrams}/join_game.puml (100%) rename docs/{secuence_diagrams => sequence_diagrams}/leave_game.puml (100%) rename docs/{secuence_diagrams => sequence_diagrams}/play_vs_ai.puml (100%) rename docs/{secuence_diagrams => sequence_diagrams}/send_chat.puml (100%) rename docs/{secuence_diagrams => sequence_diagrams}/view_profile.puml (100%) diff --git a/docs/secuence_diagrams/create_profile.puml b/docs/sequence_diagrams/create_profile.puml similarity index 100% rename from docs/secuence_diagrams/create_profile.puml rename to docs/sequence_diagrams/create_profile.puml diff --git a/docs/secuence_diagrams/delete_profile.puml b/docs/sequence_diagrams/delete_profile.puml similarity index 100% rename from docs/secuence_diagrams/delete_profile.puml rename to docs/sequence_diagrams/delete_profile.puml diff --git a/docs/secuence_diagrams/edit_profile.puml b/docs/sequence_diagrams/edit_profile.puml similarity index 100% rename from docs/secuence_diagrams/edit_profile.puml rename to docs/sequence_diagrams/edit_profile.puml diff --git a/docs/secuence_diagrams/host_game.puml b/docs/sequence_diagrams/host_game.puml similarity index 100% rename from docs/secuence_diagrams/host_game.puml rename to docs/sequence_diagrams/host_game.puml diff --git a/docs/secuence_diagrams/join_game.puml b/docs/sequence_diagrams/join_game.puml similarity index 100% rename from docs/secuence_diagrams/join_game.puml rename to docs/sequence_diagrams/join_game.puml diff --git a/docs/secuence_diagrams/leave_game.puml b/docs/sequence_diagrams/leave_game.puml similarity index 100% rename from docs/secuence_diagrams/leave_game.puml rename to docs/sequence_diagrams/leave_game.puml diff --git a/docs/secuence_diagrams/play_vs_ai.puml b/docs/sequence_diagrams/play_vs_ai.puml similarity index 100% rename from docs/secuence_diagrams/play_vs_ai.puml rename to docs/sequence_diagrams/play_vs_ai.puml diff --git a/docs/secuence_diagrams/send_chat.puml b/docs/sequence_diagrams/send_chat.puml similarity index 100% rename from docs/secuence_diagrams/send_chat.puml rename to docs/sequence_diagrams/send_chat.puml diff --git a/docs/secuence_diagrams/view_profile.puml b/docs/sequence_diagrams/view_profile.puml similarity index 100% rename from docs/secuence_diagrams/view_profile.puml rename to docs/sequence_diagrams/view_profile.puml From 9403574e087655d04ee84e9b8e4bce62294703a7 Mon Sep 17 00:00:00 2001 From: Petzys <87223648+Petzys@users.noreply.github.com> Date: Mon, 18 Mar 2024 08:57:07 +0100 Subject: [PATCH 10/10] Docs(sequence_diagrams): Renamed Server to Client to fit language in other docs --- docs/sequence_diagrams/create_profile.puml | 16 ++++++------- docs/sequence_diagrams/delete_profile.puml | 12 +++++----- docs/sequence_diagrams/edit_profile.puml | 18 +++++++-------- docs/sequence_diagrams/host_game.puml | 16 ++++++------- docs/sequence_diagrams/join_game.puml | 24 ++++++++++---------- docs/sequence_diagrams/leave_game.puml | 10 ++++----- docs/sequence_diagrams/play_vs_ai.puml | 26 +++++++++++----------- docs/sequence_diagrams/send_chat.puml | 12 +++++----- docs/sequence_diagrams/view_profile.puml | 6 ++--- 9 files changed, 70 insertions(+), 70 deletions(-) diff --git a/docs/sequence_diagrams/create_profile.puml b/docs/sequence_diagrams/create_profile.puml index 9910340..6cd1756 100644 --- a/docs/sequence_diagrams/create_profile.puml +++ b/docs/sequence_diagrams/create_profile.puml @@ -2,14 +2,14 @@ title Create Player Profile actor Player -database System +database Client -Player->System: Click Profile Button -System->Player: Show Profile Creation Prompt -Player->System: Set Name -Player->System: Set Color -Player->System: Click Create Profile Button -System->System: Save Profile on Disk -System->Player: Show Profile +Player->Client: Click Profile Button +Client->Player: Show Profile Creation Prompt +Player->Client: Set Name +Player->Client: Set Color +Player->Client: Click Create Profile Button +Client->Client: Save Profile on Disk +Client->Player: Show Profile @enduml \ No newline at end of file diff --git a/docs/sequence_diagrams/delete_profile.puml b/docs/sequence_diagrams/delete_profile.puml index 5d72d2a..c31db42 100644 --- a/docs/sequence_diagrams/delete_profile.puml +++ b/docs/sequence_diagrams/delete_profile.puml @@ -2,12 +2,12 @@ title Delete Player Profile actor Player -database System +database Client -Player->System: Click Profile Button -System->Player: Show Profile -Player->System: Click Delete Profile Button -System->System: Delete Profile from Disk -System->Player: Show Profile Creation Prompt +Player->Client: Click Profile Button +Client->Player: Show Profile +Player->Client: Click Delete Profile Button +Client->Client: Delete Profile from Disk +Client->Player: Show Profile Creation Prompt @enduml \ No newline at end of file diff --git a/docs/sequence_diagrams/edit_profile.puml b/docs/sequence_diagrams/edit_profile.puml index 3b7c8ac..f21d2d6 100644 --- a/docs/sequence_diagrams/edit_profile.puml +++ b/docs/sequence_diagrams/edit_profile.puml @@ -2,15 +2,15 @@ title Edit Player Profile actor Player -database System +database Client -Player->System: Click Profile Button -System->Player: Show Profile -Player->System: Click Edit Profile Button -Player->System: Change Name -Player->System: Change Color -Player->System: Click Edit Profile Button -System->System: Save Profile on Disk -System->Player: Show Profile +Player->Client: Click Profile Button +Client->Player: Show Profile +Player->Client: Click Edit Profile Button +Player->Client: Change Name +Player->Client: Change Color +Player->Client: Click Edit Profile Button +Client->Client: Save Profile on Disk +Client->Player: Show Profile @enduml \ No newline at end of file diff --git a/docs/sequence_diagrams/host_game.puml b/docs/sequence_diagrams/host_game.puml index 682baf5..0479241 100644 --- a/docs/sequence_diagrams/host_game.puml +++ b/docs/sequence_diagrams/host_game.puml @@ -2,14 +2,14 @@ title Host Game actor Player as p -database System +database Client -p->System: Click Multiplayer Button -System->p: Display Multiplayer Menu -p->System: Click Create a new online game Button -System->System: Host Server locally -System->p: Display Multiplayer Lobby -System->Network: Send advertisements -System->System: Wait for other players to join +p->Client: Click Multiplayer Button +Client->p: Display Multiplayer Menu +p->Client: Click Create a new online game Button +Client->Client: Host Server locally +Client->p: Display Multiplayer Lobby +Client->Network: Send advertisements +Client->Client: Wait for other players to join @enduml diff --git a/docs/sequence_diagrams/join_game.puml b/docs/sequence_diagrams/join_game.puml index a7ddc91..eb84088 100644 --- a/docs/sequence_diagrams/join_game.puml +++ b/docs/sequence_diagrams/join_game.puml @@ -2,20 +2,20 @@ title Join Game actor Player as p -database System +database Client database Server as s -p->System: Click Multiplayer Button -System->p: Display Multiplayer Menu -p->System: Click Join by address Button -System->p: Show IP-Address Input field -p->System: Enter IP-Address -p->System: Click Connect Button -System->s: Join Lobby -s->System: Send Server information -System->p: Display Game Lobby -p->System: Click Ready Button -System->s: Get Ready +p->Client: Click Multiplayer Button +Client->p: Display Multiplayer Menu +p->Client: Click Join by address Button +Client->p: Show IP-Address Input field +p->Client: Enter IP-Address +p->Client: Click Connect Button +Client->s: Join Lobby +s->Client: Send Server information +Client->p: Display Game Lobby +p->Client: Click Ready Button +Client->s: Get Ready s->s: Wait for other Player to get ready @enduml diff --git a/docs/sequence_diagrams/leave_game.puml b/docs/sequence_diagrams/leave_game.puml index a63f877..638a71b 100644 --- a/docs/sequence_diagrams/leave_game.puml +++ b/docs/sequence_diagrams/leave_game.puml @@ -2,14 +2,14 @@ title Leave Game actor Player as p -database System +database Client database Server as s actor Player2 as p2 -p->System: Click Menu Button -System->s: Player disconnected -System->s: Close connection -System->p: Show Main Menu +p->Client: Click Menu Button +Client->s: Player disconnected +Client->s: Close connection +Client->p: Show Main Menu s->p2: You have won s->p2: Close Connection s->s: Terminate diff --git a/docs/sequence_diagrams/play_vs_ai.puml b/docs/sequence_diagrams/play_vs_ai.puml index 4f7fadb..1111255 100644 --- a/docs/sequence_diagrams/play_vs_ai.puml +++ b/docs/sequence_diagrams/play_vs_ai.puml @@ -2,20 +2,20 @@ title Play versus AI actor Player as p -database System +database Client actor AI as a -p->System: Click Singleplayer Button -System->p: Display AI Difficulty Selection -p->System: Select AI Difficulty by clicking Strong or Weak AI Button -System->System: Host Server locally -System->p: Display Game Lobby -System->a: Create AI -a->System: Connect to Server -a->System: Get Ready -System->p: Show AI is ready -p->System: Click Ready Button -p->System: Click Start Game Button -System->p: Show Playfield +p->Client: Click Singleplayer Button +Client->p: Display AI Difficulty Selection +p->Client: Select AI Difficulty by clicking Strong or Weak AI Button +Client->Client: Host Server locally +Client->p: Display Game Lobby +Client->a: Create AI +a->Client: Connect to Server +a->Client: Get Ready +Client->p: Show AI is ready +p->Client: Click Ready Button +p->Client: Click Start Game Button +Client->p: Show Playfield @enduml diff --git a/docs/sequence_diagrams/send_chat.puml b/docs/sequence_diagrams/send_chat.puml index c86585e..f4d5de4 100644 --- a/docs/sequence_diagrams/send_chat.puml +++ b/docs/sequence_diagrams/send_chat.puml @@ -2,16 +2,16 @@ title Send Chat Message actor Player as p -database System +database Client database Server as s actor Player2 as p2 -p->System: Click on the message entry box +p->Client: Click on the message entry box p->p: Enter message -p->System: Click Send Button -System->s: Send chat message +p->Client: Click Send Button +Client->s: Send chat message s->p2: Send chat message -s-> System: Send chat message -System->p: Display chat message +s-> Client: Send chat message +Client->p: Display chat message @enduml diff --git a/docs/sequence_diagrams/view_profile.puml b/docs/sequence_diagrams/view_profile.puml index b742526..304efd7 100644 --- a/docs/sequence_diagrams/view_profile.puml +++ b/docs/sequence_diagrams/view_profile.puml @@ -2,9 +2,9 @@ title View Player Profile actor Player -database System +database Client -Player->System: Click Profile Button -System->Player: Show Profile +Player->Client: Click Profile Button +Client->Player: Show Profile @enduml \ No newline at end of file