@@ -822,11 +822,21 @@ def handle_message(self, content: str, player_email: str) -> None:
822
822
if self .is_turn_of (player_email ):
823
823
self .handle_current_player_command (content )
824
824
else :
825
- if self .gameAdapter .is_single_player :
826
- self .broadcast ('It\' s your turn' )
825
+ self .send_current_turn_message ()
826
+ self .broadcast_current_message ()
827
+
828
+ def send_current_turn_message (self ) -> None :
829
+ if self .gameAdapter .is_single_player :
830
+ self .current_messages .append ('It\' s your turn' )
831
+ else :
832
+ user_turn_avatar = "!avatar({})" .format (self .players [self .turn ])
833
+ if self .gameAdapter .gameMessageHandler .get_player_color (self .turn ) is None :
834
+ self .current_messages .append ('{} It\' s **{}**\' s turn.' .format (
835
+ user_turn_avatar ,
836
+ self .gameAdapter .get_username_by_email (
837
+ self .players [self .turn ])))
827
838
else :
828
- user_turn_avatar = "!avatar({})" .format (self .players [self .turn ])
829
- self .broadcast ('{} It\' s **{}**\' s ({}) turn.' .format (
839
+ self .current_messages .append ('{} It\' s **{}**\' s ({}) turn.' .format (
830
840
user_turn_avatar ,
831
841
self .gameAdapter .get_username_by_email (
832
842
self .players [self .turn ]),
@@ -890,11 +900,7 @@ def same_player_turn(self, content: str, message: str, is_computer: bool) -> Non
890
900
self .end_game (game_over )
891
901
return
892
902
user_turn_avatar = "!avatar({})" .format (self .players [self .turn ])
893
- self .current_messages .append ('{} It\' s **{}**\' s ({}) turn.' .format (
894
- user_turn_avatar ,
895
- self .gameAdapter .get_username_by_email (self .players [self .turn ]),
896
- self .gameAdapter .gameMessageHandler .get_player_color (self .turn )
897
- ))
903
+ self .send_current_turn_message ()
898
904
self .broadcast_current_message ()
899
905
if self .players [self .turn ] == self .gameAdapter .email :
900
906
self .make_move ('' , True )
@@ -903,15 +909,7 @@ def next_turn(self) -> None:
903
909
self .turn += 1
904
910
if self .turn >= len (self .players ):
905
911
self .turn = 0
906
- if self .gameAdapter .is_single_player :
907
- self .current_messages .append ('It\' s your turn.' )
908
- else :
909
- user_turn_avatar = "!avatar({})" .format (self .players [self .turn ])
910
- self .current_messages .append ('{} It\' s **{}**\' s ({}) turn.' .format (
911
- user_turn_avatar ,
912
- self .gameAdapter .get_username_by_email (self .players [self .turn ]),
913
- self .gameAdapter .gameMessageHandler .get_player_color (self .turn )
914
- ))
912
+ self .send_current_turn_message ()
915
913
self .broadcast_current_message ()
916
914
if self .players [self .turn ] == self .gameAdapter .email :
917
915
self .make_move ('' , True )
0 commit comments