LudoController

class LudoController(scope: CoroutineScope, link: LudoLink, fx: (Sfx) -> Unit, onDuelWon: () -> Unit, onGameOver: (won: Boolean) -> Unit, random: Random = Random.Default)

Runs a Ludo table on this phone.

  • Host (local play or LAN host): owns the LudoState, applies every action through Ludo.apply, drives CPU seats, and broadcasts each new state to guests.

  • Guest (LAN): mirrors the host's state and sends intents; the host decides what's legal.

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope, link: LudoLink, fx: (Sfx) -> Unit, onDuelWon: () -> Unit, onGameOver: (won: Boolean) -> Unit, random: Random = Random.Default)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
var device: Int

This phone's device number: 0 for the host, 1..3 for guests.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val linkStatus: StateFlow<LudoLinkStatus>
Link copied to clipboard

Only local tables can be resumed — a LAN table's other phones are gone.

Link copied to clipboard

Seating plan while in the lobby.

Link copied to clipboard

Functions

Link copied to clipboard
fun act(action: LudoAction)

The action a human on this phone takes.

Link copied to clipboard
Link copied to clipboard
fun beginHosting(alias: String, myName: String)
Link copied to clipboard

Whether this phone decides for color (its own human seats).

Link copied to clipboard
fun dispose()
Link copied to clipboard

Guests who connect fill open LAN seats in clockwise order; leavers free their seat again.

Link copied to clipboard
fun onWire(from: Int, m: LudoWire)

Handles a message from the network (from = sending device; 0 = host).

Link copied to clipboard
fun rematch()

Same table, same seats, fresh game.

Link copied to clipboard
fun rename(color: LudoColor, name: String)
Link copied to clipboard
fun reset(myName: String)
Link copied to clipboard
fun restore(saved: LudoState)

Resumes a saved local game (no LAN seats) exactly where it was.

Link copied to clipboard
fun setSeat(color: LudoColor, kind: SeatKind, name: String? = null)
Link copied to clipboard
fun start()