Your First iOS and SwiftUI App: Polishing the App, Episode 15: Challenge: Start a New Round | Kodeco

This content was released on Dec 16 2020. The official support period is 6-months from this date.

Try adding a new method to your Game data model that you can use to start a new round of the game.


This is a companion discussion topic for the original entry at https://www.kodeco.com/18176818-your-first-ios-and-swiftui-app-polishing-the-app/lessons/15

To start a new round in your game, you need to add a method to reset relevant properties, ensuring the game state is preserved. Here’s a simplified version:
class Game:
def init(self):
self.total_score = 0
self.current_round = 0

def start_new_round(self):
    self.current_round += 1
    self.reset_round_data()
    print(f"Round {self.current_round} has started!")

def reset_round_data(self):
    # Reset round-specific data

Usage

game = Game()
game.start_new_round()

This method increments the round counter and resets necessary data for a fresh start while maintaining the overall game state. Does that make sense?