Abstraction: Entities, Items, Game Objects

Data structures which store the primitives...

Before talking about the essentials of Darkan development, it is very helpful explain the reason for why the Player, NPC, GroundItem and World Object classes extend from a parent. In essence every Java class is a data structure of primitives and functions containing the processing of primitives.

These data structures contain specific protocols for different clumps of primitives, called classes, which can be used to manipulate the world of Darkan. Below are some examples of abstraction by classes:

From Entity you can see NPC which has many many custom NPCs as well as generic ones. There needs to be a distinction between these entity classes, item classes and world objects classes. Otherwise, we would not be able to operate the server effectively.

Something to note, each of these classes hold other classes so basically you can have a say Bank class in a Player or WorldTile, saying where an NPC, GameObject or Item is located.

Here are some examples of classes within classes:

public class NPC extends Entity {
  private String name;
  private int id;
  private WorldTile respawnTile;
  private boolean randomWalk;
  private Map<Skill, Integer> combatLevels;  
  //etc...
}
public class Item {
    private transient int slot;
    private short id;
    protected int amount;
    private Map<String, Object> metaData;
  //etc...
}
public class WorldObject {
    protected WorldTile tile;
    protected int id;
    protected ObjectType type;
    protected int rotation;
  //etc...
}