Skip to content

Database Model

Cellmer edited this page Jan 22, 2023 · 7 revisions

Entity sets

Game

Entity representing a single game.

  • id_game: BIGSERIAL PRIMARY KEY
  • token: VARCHAR
    password which each player must type (after join command)
  • id_host: BIGINT
    id of the discord account of the host of this game
  • id_campaign: BIGINT
    it describes campaign (it is not used in the lobby), possibly it is set after going from starting to active.
  • game_state: VARCHAR
    game can be in the following states:
    lobby -> in the first phase
    starting -> when characters are created
    active -> when is played
    inactive -> when is stopped (host quitted)
    finished -> when the game is over(possibly a candidate to delete from database)
  • game_state: VARCHAR

User

Entity representing a single user in a game.

  • id_user: BIGSERIAL PRIMARY KEY
  • id_game: BIGINT
    foreign key to the Game table
  • discord_id: BIGINT
    discord id of the player

Event

Entity representing a single event in a specific game.

  • id_event: BIGSERIAL PRIMARY KEY
  • x: INTEGER
    x coordinate of the center of the event
  • y: INTEGER
    y coordinate of the center of the event
  • range: INTEGER
    maximal distance from the center in which the event can be triggered
  • status: VARCHAR event can have on of the following statuses:
    available -> event can be triggered
    not_available -> event can't be triggered
  • content: VARCHAR
    description of the event
  • id_game: BIGINT
    foreign key to the Game table

Entity

Entity representing a single object in the game (player, enemy, inanimate object etc.)

  • id_entity: BIGSERIAL PRIMARY KEY
  • name: VARCHAR
  • x: INTEGER
    x coordinate of the entity in the game world
  • y: INTEGER
    y coordinate of the entity in the game world
  • sprite: VARCHAR
    path to the sprite representing the entity
  • id_game: BIGINT
    foreign key to the Game table

Creature

Entity deriving from Entity table extending its attributes to describe a living entity in a game (player, enemy, NPC).

  • id_creature: BIGSERIAL PRIMARY KEY
  • level: INTEGER
  • HP: INTEGER
  • strength: INTEGER
  • dexterity: INTEGER
  • intelligence: INTEGER
  • charisma: INTEGER
  • perception: INTEGER
  • initiative: INTEGER
  • action_points: INTEGER
  • money: INTEGER
  • id_entity: BIGINT foreign key to the Entity table referencing the base entity object of Creature entity.

Player

Entity deriving from Creature table extending its attributes to describe a player.

  • id_player: BIGSERIAL PRIMARY KEY
  • id_user: BIGINT
    foreign key to the User table
  • alignment: VARCHAR
    a description of the player's character chosen by user at the start of the game
  • backstory: VARCHAR
    a backstory of the player created by the user at the start of the game
  • id_equipment: BIGINT
    foreign key to the Equipment table
  • id_creature: BIGINT
    foreign key to the Creature table referencing the base creature object of Player entity.

Skill

Entity describing skill

  • id_skill: BIGSERIAL PRIMARY KEY
  • name: VARCHAR

Entity_Skill

Entity realizing many to many relationship between Entity and Skill

  • id_entity_skill: BIGSERIAL PRIMARY KEY
  • id_entity: BIGINT
    foreign key to the Entity table
  • id_skill: BIGINT foreign key to the Skill table

Item

Entity describing item that can be used in any game

  • id_item: BIGSERIAL PRIMARY KEY
  • name: VARCHAR
  • HP: INTEGER
  • strength: INTEGER
  • dexterity: INTEGER
  • intelligence: INTEGER
  • charisma: INTEGER
  • perception: INTEGER
  • initiative: INTEGER
  • action_points: INTEGER
  • effect: VARCHAR
  • base_price: INTEGER

Creature_Item

Entity realizing many to many relationship between Creature and Item

  • id_creature_item: BIGSERIAL PRIMARY KEY
  • id_creature: BIGINT
    foreign key to the Creature table
  • id_item: BIGINT
    foreign key to the Item table
  • amount: INTEGER
    amount of items with id_item possessed by the creature with id_creature

Equipment

Entity which describes equipment as set of specific items

  • id_equipment: BIGSERIAL PRIMARY KEY
  • helmet: BIGINT
    foreign key to the Item table
  • chest: BIGINT
    foreign key to the Item table
  • leg_armor: BIGINT
    foreign key to the Item table
  • boots: BIGINT
    foreign key to the Item table
  • left_hand: BIGINT
    foreign key to the Item table
  • right_hand: BIGINT
    foreign key to the Item table
  • accessory: BIGINT
    foreign key to the Item table

Dialog

Entity which describes dialog between two entities

  • id_dialog: BIGSERIAL PRIMARY KEY
  • id_speaker: BIGINT
    foreign key to the Entity table
  • id_listener: BIGINT
    foreign key to the Entity table
  • content: VARCHAR
    text displayed in this dialog
  • status: enum
    available, not_available, used