(Python)How can I organize a round-basing gamesystem with strikt series and flexible start-player best? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

(Python)How can I organize a round-basing gamesystem with strikt series and flexible start-player best?

For example 4 Player, every new round starts with winner of the round before. I was thinking of 2 different ways: 1) For each of the 4 possible startplayers its own paths of player-series which ends with the evaluation of the winner 2) class Player with the attribute "next" to define the following player and a recursiv function "play_card() ". "play_card()" includes "player.next.play_card()" to start recursion and an if-statment to break when the round is finished.

28th Jun 2022, 8:38 PM
Python-Fakir
Python-Fakir - avatar
1 Answer
0
I think it's a good idea to use player classes, but also a game state class. The game state class will keep track of winners of rounds and all that stuff. The player will keep all the info needed for the specific player. Then you can also use the player instance as reference for the winner, so you can access the winner directly through the game state. This will give the flexibility to add players at a later time. The game state class will also give the freedom to change rules and stuff freely without the need to change the player classes.
30th Jun 2022, 11:17 PM
Leo Hemmingsson
Leo Hemmingsson - avatar