Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Game Objects

Alexandru Dan edited this page Aug 30, 2017 · 19 revisions

The avatar is an interface between the worker and the managers in the simulation. It also provides a nice abstraction for what the simulation perceives as a 'user'. The avatar related functionality is grouped inside the avatar folder.

Actions

An action is a pair (avatar, location). The action is register onto the WorldMap by being appended to a cell.

The action is processed by calling the apply function.

  • if the action is legal it is applied
  • if not it is rejected

The exposed interface is:

  • apply
    • has to return true if application succeeded
    • attaches an event to the avatar
  • is_legal
    • returns if an action is legal from the point of view of the map
    • the action gets applied or rejected accordingly
  • reject
    • attaches a (failed) event to the avatar

Each of the 3 elements of the interface are implemented differently by different types of actions.

The current types of actions as:

  • WaitAction
    • wait is always legal
    • no actions get attached to the avatar
  • MoveAction
    • is_legal
      • the responsibility is passed to world_map
    • apply
      • adds a move event to the avatar
      • change the avatar's world view
      • updates the map accordingly
    • reject
      • the failed event is added to the avatar
    • overrides the processing of the action
  • AttackAction
    • is_legal
      • attacking is legal is the avatar is attackable
    • attack
      • attaches the event to the attacker avatar
      • attaches the event to the attacked avatar
      • if the attacked avatar dies it is respawned

Pickups and Effects

A pickup is an object that is automatically grabbed by avatars in the same cell as the pickup. The pickup gets destroyed and generates an effect it is grabbed. An effect is an object that encapsulates a function that gets applied to an avatar on each turn. (see Turn Manager)

Clone this wiki locally