scalata.application.usecases.playerusecases

Members list

Type members

Classlikes

Executes a player attack in the chosen direction.

Executes a player attack in the chosen direction.

==== Algorithm ====

  • Compute a reach vector whose length equals the player’s reach stat.

  • Build the inclusive line of points from the player’s position to the target tile (rangeTo).

  • For every enemy in the current room:

  • If the enemy is alive and its position lies on the line, apply player.attack.

  • Return an updated GameSession wrapped in GameResult.success.

Failure modes If the room referenced by GameState.currentRoom is missing, an IllegalStateException is thrown (world corruption guard).

Attributes

Supertypes
class Object
trait Matchable
class Any

Handles the “interact” command (pick up / open / read whatever lies on the tile immediately in front of the player).

Handles the “interact” command (pick up / open / read whatever lies on the tile immediately in front of the player).

==== Flow ====

  • Compute the target coordinate by adding direction.vector to the player’s current position.
  • If an item is present, delegate to its interact(GameSession) method and propagate the result.
  • If the tile is empty, return GameResult.error(GameError.ItemNotPresent).

The method is pure: all updates are returned in a new GameSession; no in-place mutation occurs.

Attributes

Supertypes
class Object
trait Matchable
class Any

Handles the “use item” command.

Handles the “use item” command.

  • Looks up the item by itemName in the player’s inventory.
  • Delegates to the Usable type-class to apply the effect (Potion, Weapon, Dust, …).
  • Updates the player inside the World and returns a GameResult.success wrapping the new GameSession.
  • If the player does not own the item, returns GameResult.Error(GameError.ItemNotOwned).

Attributes

Supertypes
class Object
trait Matchable
class Any

Handles a single movement command issued by the player.

Handles a single movement command issued by the player.

==== Decision tree ====

  • Simple step – if the target tile lies inside the current room and is free of living enemies/items, update the player’s position.

  • Door transition – when the tile matches the current door and the room contains an exit in that direction, move the player to the neighbouring room, advance GameState.currentRoom and push any enemy standing on the entrance one tile inward.

  • Invalid – in all other cases return GameError.InvalidInput.

Attributes

Supertypes
class Object
trait Matchable
class Any