ItemFactory

scalata.application.services.factories.ItemFactory

Factory that produces every kind of in-game item.

==== Responsibilities ====

  • Loot box generationcreateBox decides at runtime whether the chest contains a potion, a weapon or plain dust, using weighted randomness that scales with the difficulty parameter.
  • Direct creationcreate instantiates a concrete item from the scalata.domain.util.ItemClasses discriminator.

All methods are pure; they return fresh instances and never mutate shared state.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def create(entityType: ItemClasses, id: String): Item

Build a single item given its ItemClasses tag.

Build a single item given its ItemClasses tag.

Value parameters

entityType

enumeration value selecting the concrete item

id

unique identifier

Attributes

Definition Classes
def createBox(difficulty: Int, id: String): Item

Create a random loot box whose contents depend on difficulty.

Create a random loot box whose contents depend on difficulty.

  • With probability POTION_WEIGHT, call createPotion (healing item).
  • Otherwise call createWeaponBox (weapon or dust).

Attributes