opentibiabr / canary

Canary Server 13.x for OpenTibia community.
https://docs.opentibiabr.com/
GNU General Public License v2.0
384 stars 638 forks source link

refactor: split player death event handler into smaller functions #3113

Open omarcopires opened 2 weeks ago

omarcopires commented 2 weeks ago

Description

This pull request refactors the PlayerDeath event script to improve code readability and maintainability. The original function has been split into smaller, more focused functions, each handling a specific part of the player death processing logic. This includes identifying the killer, logging deaths in the database, sending messages to the guild channel, and checking guild wars.

With this refactoring, the code is more modular and easier to understand, making future modifications and maintenance more manageable. The PlayerDeath event logic remains unchanged, ensuring the system continues to function as expected.

Changes:

  1. Split the onDeath function into smaller local functions.
  2. Improved SQL query formatting using string.format for clarity and to avoid repetitive code.
  3. Renamed local variables to follow the camelCase convention.

Type of change

Checklist

sonarcloud[bot] commented 1 week ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud