xenokore/osrs-stats-generator

OSRS统计图片生成库

0.2 2022-05-24 16:39 UTC

This package is auto-updated.

Last update: 2024-09-25 00:31:31 UTC


README

PHP的OSRS统计图片生成库。

安装

composer require xenokore/osrs-stats-generator

图片生成使用PHP扩展 gd

包含一个端点脚本,该脚本使用 cURL 扩展来查询高分排行榜中的用户。如果您直接在项目中使用库,则不需要cURL。

使用方法

您可以使用端点脚本来从您的浏览器中查询高分排行榜中的用户

/public/index.php?user=noize

或者传递您想要设置的技能的 GET 参数

/public/index.php?hitpoints=50,90&attack=80,75&mining=99

您可以通过一个 , 来分隔当前等级和最大等级。这对于显示增强统计或当前生命值非常有用。

下面是一个技能名称列表。总等级会自动计算。

库的使用

// Either set skills using (array)[(int)<current_lvl>, (int)<max_lvl>] or (int)<level>.
// Skills are defaulted to their lowest lvl (10 for hitpoints and 1 for others) and are not required to be set.
$skills = new \Xenokore\OSRS\StatsGenerator\Skills([
        'hitpoints' => [5, 10],
        'attack' => 10
    ]
);

$img_gen = new \Xenokore\OSRS\StatsGenerator\ImageGenerator($skills);

// Set image headers:
\header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
\header('Last-Modified: ' . \gmdate("D, d M Y H:i:s") . ' GMT');
\header('Cache-Control: no-store, no-cache, must-revalidate');
\header('Cache-Control: post-check=0, pre-check=0', false);
\header('Pragma: no-cache');
\header('Content-type: image/png');

// Output image
echo $img_gen->generate();

技能名称

attack
defence
strength
hitpoints
ranged
prayer
magic
cooking
woodcutting
fletching
fishing
firemaking
crafting
smithing
mining
herblore
agility
thieving
slayer
farming
runecraft
hunter
construction

总等级会自动计算。

注意,这里使用的是 runecraft 而不是 runecrafting

示例输出

image

许可证

MIT