Basilisk Logo
BasiliskDocs

Advanced BDL

Master advanced features and patterns in BDL

Overview

Advanced BDL features enable you to create complex, maintainable data structures. These features help you model sophisticated game systems and maintain clean, reusable definitions.

Entity Inheritance

Entities can extend other entities to inherit their variables, creating hierarchies and reducing code duplication.

entity BaseItem {
  id: string,
  name: string,
  description: string,
  rarity: ItemRarity
}

entity Weapon extends BaseItem {
  id: string,
  name: string,
  description: string,
  rarity: ItemRarity,
  damage: int,
  attackSpeed: float,
  weaponType: WeaponType
}

entity Armor extends BaseItem {
  id: string,
  name: string,
  description: string,
  rarity: ItemRarity,
  defense: int,
  armorType: ArmorType
}

Inheritance allows you to define common properties once and reuse them across related entities.

Subentities

Subentities allow you to nest data structures within entities, creating complex hierarchical data models.

subentity Stats {
  health: float,
  attack: float,
  defense: float,
  speed: float
}

subentity Position {
  x: float,
  y: float,
  z: float
}

entity Character {
  id: string,
  name: string,
  stats: Stats,
  spawnPosition: Position
}

Subentities are useful for grouping related properties together and creating more organized data structures.

Complex References

References can be used to create complex relationships between entities, including many-to-one and one-to-many relationships.

entity Quest {
  id: string,
  title: string,
  description: string,
  rewardItemId: {
    type: string,
    references: Item
  }
}

entity QuestObjective {
  id: string,
  questId: {
    type: string,
    references: Quest
  },
  description: string,
  targetId: {
    type: string,
    optional
  },
  targetType: ObjectiveType
}

Complex references enable you to model relationships like quests with multiple objectives, or items that belong to categories.

Arrays

Arrays allow you to store multiple values of the same type in a single variable.

entity Character {
  id: string,
  name: string,
  skillIds: string[],
  tags: string[],
  stats: StatValue[]
}

subentity StatValue {
  statType: StatType,
  value: float
}

Arrays are useful for storing lists of related data, such as inventory items, skill lists, or achievement requirements.

Multiple Indexes

You can define multiple indexes for the same entity to enable different lookup patterns.

index {
  charactersById: {
    sheet: "characters",
    entity: Character
  },
  charactersByName: {
    sheet: "characters",
    entity: Character
  }
}

Multiple indexes allow you to efficiently look up entities by different keys, such as by ID or by name.

Composite Keys

Composite keys use multiple variables to uniquely identify an entity, useful for entities that need multiple identifiers.

entity PlayerProgress {
  playerId: string,
  levelId: string,
  completed: boolean,
  bestTime: {
    type: float,
    optional
  }
}

Composite keys are useful for junction tables or entities that represent relationships between other entities.

Bundle Composition

Data bundles can include multiple datasets and can be organized to share common data across different bundles.

databundle base {
  gameConfig: gameConfig
  currencies: currencies
}

databundle client extends base {
  characters: characters
  weapons: weapons
  items: items
}

databundle server extends base {
  quests: quests
  events: events
}

Bundle composition helps you organize data efficiently and avoid duplication across different deployment targets.

Nested Structures

You can create deeply nested structures using subentities within subentities to model complex game systems.

subentity Address {
  street: string,
  city: string,
  country: string
}

subentity ContactInfo {
  email: string,
  phone: string,
  address: Address
}

entity Player {
  id: string,
  name: string,
  contact: ContactInfo
}

Nested structures allow you to model complex real-world relationships and game systems with multiple levels of hierarchy.