Skip to content

Planes of Tlessa: Backend Break Down

AdamBalan edited this page Mar 27, 2024 · 2 revisions

Development Overview

Planes of Tlessa is developed in PHP with the Laravel framework.

The backend is divided into three major sections: Flare, Game, and Admin, with a minor "module" known as app\Http\, which holds authentication and minor bits that don't fit elsewhere.

This document will provide a high-level overview of each, with appropriate links to other pages that break down the sections into their respective modules.

You will notice throughout this document, that as of September 2023, I have been contemplating major refactoring to clean up and reorganize the code for improved modularity.

Feel free to open PRs for any of the issues mentioned below. As these matters are addressed, the document will also be updated to reflect these changes.

Flare

Flare houses the core logic of the game, making it usable across multiple modules inside of Game.

Flare contains three modules that are used by commands:

  • Affix Generator
  • Map Generator
  • Game Importer

Other aspects of Flare include:

  • Server Fight
    • Consists of services to handle:
      • Raid Fights (Bosses and Critters)
      • Regular Monster Fights
      • PVP Battles
      • Celestial Fights
  • Models
    • All the database models reside here.
      • Note: Ideally, these would reside within each module in the app\Game\ folder.
  • Builders
    • Contains logic for building character details such as attack, attributes, defense, and so on based on equipment, quest items, skills, and other aspects of the game.
      • We must be careful adding logic here, ensuring that the job CreateCharacterAttackData in app\Flare\Jobs does not take longer than 1-2 seconds. In most cases, it runs in milliseconds, but as characters start equipping better and stronger gear and have other items such as quest items or alchemy, this can slow down.

Flare also includes code used in various Game modules.

Attention

This aspect of the codebase, aside from the four mentioned modules, is currently undergoing cleanup.

There is too much happening here, and new code should only be added here if it generates something or is used in a module in Game that abstracts a large aspect of logic, e.g., ServerFight.

Flare was designed to be the game's core logic folder where the logic placed here can either generate aspects of the game or abstract logic that can be used in multiple areas or does not fit in its own module within Game.

Game

Game comprises multiple modules that make up the different features of the actual game itself.

Each module is generally self-isolated, although some modules may communicate between themselves, making them co-dependent.

Attention

As the developer, I am not satisfied with this aspect of the current codebase and am striving to make each module inside of Game much more isolated from each other. Thus, any time one needs to communicate with another, there should be some kind of "bridge."

Admin

The Admin section consists of all the aspects of the admin section, broken up into controllers with logic for exporting and importing game-related data.

Admin is not separated into modules; instead, each controller affects each aspect of the Admin section.

Attention!

While exploring the admin section, you will notice that none of the forms have any kind of validation aside from backend request validation.

The forms should utilize old() in Laravel when the form is redirected back due to server-side validation.

Admin also handles the export and import of various pieces of data.

Other Aspects

Other aspects such as app/Http/ contain controllers for:

  • Registration/Login/Password Reset
  • Marketing Features: e.g., site.com/features page.
  • Information (Help I'm stuck section)
  • Releases Page
  • Requesting to be unbanned.

Final Thoughts

As of September 2023, I am working on tests for all of these areas, starting with the service tests and then progressing towards the controller tests.

You can find the tests being written in the tests/ directory under unit/. While I do have other tests written, I am currently rewriting many of them to ensure thorough testing of the game in all its important areas.