Skip to content

Highscores customization#302

Draft
slawkens wants to merge 2 commits into
mainfrom
feature/highscores-customize
Draft

Highscores customization#302
slawkens wants to merge 2 commits into
mainfrom
feature/highscores-customize

Conversation

@slawkens
Copy link
Copy Markdown
Owner

@slawkens slawkens commented May 16, 2025

I've made it to allow for customization of the highscores page.

What you can do with this:

  • Add/remove/modify categories
    • example: remove skills
  • Use completely custom queries

I will post an example I've made, maybe you have some better ideas how we can approach this?

Maybe there is simpler way for allowing customisations of the highscores page?

Maybe it could be done with just 1 hook?

I'm waiting for your ideas, how can we make this better!

Example with reborns:

plugin.json

	"hooks": {
		"reborn-highscores-list": {
			"type": "FILTER_HIGHSCORES_LIST",
			"file": "plugins/reborn-test/hooks/highscores-list.php"
		},
		"reborn-highscores": {
			"type": "FILTER_HIGHSCORES",
			"file": "plugins/reborn-test/hooks/highscores.php"
		}
	}

plugins/reborn-test/hooks/highscores-list.php

<?php
defined('MYAAC') or die('Direct access not allowed!');

const SKILL_REBORNS = 25;

/**
 * @var array $args
 */
switch ($args['list'])
{
	case 'reborns':
		$args['skill'] = SKILL_REBORNS;
		break;
}

$insert = [
	'reborns' => 'Reborns',
];

$args['categories'] = array_merge($insert, $args['categories']);

plugins/reborn-test/hooks/highscores.php

<?php
defined('MYAAC') or die('Direct access not allowed!');

/**
 * @var array $args
 */

if ($args['skill'] == SKILL_REBORNS) {
	$args['query']
		->addSelect('players.reborns as value');

	$args['skillName'] = 'Reborns';
}
Example with charms points & boss points (canary):

plugin.json

		"canary-highscores-list": {
			"type": "FILTER_HIGHSCORES_LIST",
			"file": "plugins/theme-canary/hooks/highscores-list.php"
		},
		"canary-highscores": {
			"type": "FILTER_HIGHSCORES",
			"file": "plugins/theme-canary/hooks/highscores.php"
		}

plugins/theme-canary/hooks/highscores-list.php

<?php
defined('MYAAC') or die('Direct access not allowed!');

/**
 * @var array $args
 */
const SKILL_BOSS_POINTS = 21;
const SKILL_CHARMS_POINTS = 22;

/**
 * @var array $args
 */
switch ($args['list'])
{
	case 'boss':
		$args['skill'] = SKILL_BOSS_POINTS;
		break;

	case 'charms':
		$args['skill'] = SKILL_CHARMS_POINTS;
		break;
}

$args['categories']['boss'] = 'Boss Points';
$args['categories']['charms'] = 'Charms Points';

plugins/theme-canary/hooks/highscores.php

<?php
defined('MYAAC') or die('Direct access not allowed!');

/**
 * @var array $args
 */

if ($args['skill'] == SKILL_CHARMS_POINTS) {
	$args['query']
		->join('player_charms', 'player_charms.player_id', '=', 'players.id')
		->addSelect('player_charms.charm_points as value');
}
else if ($args['skill'] == SKILL_BOSS_POINTS) {
	$args['query']
		->addSelect('players.boss_points as value');
}

if($args['skill'] == SKILL_BOSS_POINTS) {
	$args['skillName'] = 'Boss Points';
}
else if($args['skill'] == SKILL_CHARMS_POINTS) {
	$args['skillName'] = 'Charms Points';
}

@slawkens slawkens marked this pull request as draft May 16, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant