Package-level declarations

Overview

Core game logic and game orchestration components.

Key Components

  • Game — Main game class that coordinates gameplay

  • GameLogic — Pure functions for move validation and board transformations

  • GameUtils — Helper utilities for game operations

  • GameService — Interface for game service implementations

  • EmptyGameService — No-op implementation for local games

  • FakeGameService — Mock implementation for testing

  • GameServiceImpl — Real implementation for networked/multiplayer games

Responsibilities

  • Managing game state and flow

  • Validating and executing moves

  • Computing available plays

  • Handling game endings

  • Coordinating with external game services (multiplayer)

Types

Link copied to clipboard
data class Game(val target: Boolean = false, val currGameName: String? = null, val lastModified: Long? = null, val gameState: GameState? = null, val countPass: Int = 0, val myPiece: PieceType? = null, val config: CoreConfig = loadCoreConfig(), val service: GameServiceImpl)

Represents a Reversi game, managing the game state, player turns, and interactions with storage. The game has two modes: local and not local.

Link copied to clipboard
internal object GameLogic

Contains the core game logic for Reversi, including methods to play a piece, check for valid moves, and find capturable pieces.

Functions

Link copied to clipboard
suspend fun loadAndEntryGame(gameName: String, playerName: String? = null, desiredType: PieceType?, service: GameServiceImpl): Game

Loads an existing game from storage. It is recommended to use this method only connecting to a not local game. Ensures that the player with the specified piece type is included in the loaded game. Removes the player from storage to avoid conflicts in future loads.

Link copied to clipboard
fun newGameForTest(board: Board, players: MatchPlayers, myPiece: PieceType, currGameName: String? = null, service: GameServiceImpl): Game

Creates a new game instance for testing purposes with specified board and player configuration.

Link copied to clipboard
suspend fun startNewGame(side: Int, players: MatchPlayers, firstTurn: PieceType, currGameName: String? = null, service: GameServiceImpl): Game

Starts a new game. It is recommended to use this method only to create a not local game. If is not a local game makes available the opponent player in storage for future loads.

Link copied to clipboard

Converts the game board to a string representation with row/column labels and target markers. If target mode is enabled, available plays are marked with the target character.