Python UNO -Kartenspielmethoden next_game () & slip_next_player () nicht richtig funktionieren [geschlossen]Python

Python-Programme
Anonymous
 Python UNO -Kartenspielmethoden next_game () & slip_next_player () nicht richtig funktionieren [geschlossen]

Post by Anonymous »

Ich erstelle also ein UNO -Kartenspiel in Python Ich habe 4 Datei Player.py, card.py, GameBoard.py & Game.py (der Hauptantrieb) und ich kann ein Problem im Spiel haben. Keine, jetzt, wenn Next_player aufgerufen wird, wenn Current_player keiner ist, gibt es zurück. Es gibt nur die dosierte Aktualisierung von Current_player_index zurück und gibt nur die [0] zurück.

Code: Select all

def next_player(self) -> Player:
"""
Method to get the next player

Args:
None

Returns:
Player: The next player

Complexity:
Best Case Complexity:
Worst Case Complexity:
"""
print(self.current_player_index)

if self.current_player_index == None:
return self.players[0]
return self.players[(self.current_player_index + 1) % len(self.players)]
< /code>
In ähnlicher Weise sollte es für cip_next_player, wenn current_player_index keine ist, Alice überspringen und current_player_index = bob die [1] in Array und wenn nicht keine dann machen, sollte es Current_player_index als nächstes für den nächsten Spieler ändern. (Dieses Mal müssen wir current_player_index nicht nur zurückgeben) < /p>
def skip_next_player(self) -> None:
"""
Method to skip the next player in the game

Args:
None

Returns:
None

Complexity:
Best Case Complexity:
Worst Case Complexity:
"""
if self.current_player_index == None:
self.current_player = self.players[1]
else:
self.current_player = (self.current_player_index + 2) % len(self.players)
< /code>
Aber das [url=viewtopic.php?t=19220]Problem[/url] ist, ob es keine ist, dann funktioniert es gut, aber wenn es keine ist, dann ist es nicht! Wo mache ich den Fehler?class Game:
"""
Game class to play the game
"""

def __init__(self) -> None:
"""
Constructor for the Game class

Args:
None

Returns:
None

Complexity:
Best Case Complexity:
Worst Case Complexity:
"""

self.players = ArrayList()
self.current_player_index = None
self.turn_direction = 1
self.current_player = None
self.current_color = None
self.current_label = None
self.game_board = GameBoard(ArrayList())

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post