elbojoloco/runescape-hiscores

一个用于与OSRS和RS3积分排行榜通信的简单易用的包装器。

v1.2.1 2020-07-26 13:33 UTC

This package is auto-updated.

Last update: 2024-09-20 15:56:25 UTC


README

Packagist Version Packagist Downloads

要求

  • PHP 7.1 或更高版本

安装

  • composer require elbojoloco/runescape-hiscores

基本用法

从RS3 / OSRS积分排行榜获取数据非常简单。获取玩家所有统计数据所需的只是这一行:(请确保使用 use Elbojoloco\RunescapeHiscores\Runescape;

  • OSRS: $player = Runescape::oldschool('Lynx Titan');
  • RS3: $player = Runescape::rs3('le me');

要动态传递要使用的积分排行榜,应使用 get($type, $rsn) 方法

$hiscoreType = $_GET['hiscore_type'];
$rsn = $_GET['rsn'];

$player = Runescape::get($hiscoreType, $rsn);

$type 仅接受 rs3oldschool 的值,不区分大小写。$rsn 也必须至少有 1 个字符,以防止无意义的 API 调用。

您还可以在 Elbojoloco\RunescapeHiscores\RunescapeClient 类上使用预定义的常量

Runescape::get(RunescapeClient::TYPE_OLDSCHOOL, 'Lynx Titan');
Runescape::get(RunescapeClient::TYPE_RS3, 'le me');

玩家对象

静态方法 rs3()oldschool()get() 都将返回一个 Elbojoloco\RunescapeHiscores\Player 实例。此 Player 类提供了一些方便的方法来与积分排行榜数据交互,如下所示

检索 RSN

  • $player->name()

检索技能等级,或多个技能

  • $player->level('Runecrafting') // 返回作为字符串的等级
  • $player->level(['Runecrafting', 'Mining', 'Construction']) // 返回 "技能" => "等级" 的关联数组

检索技能,或多个技能的经验

  • $player->experience('Overall') // 返回作为字符串的经验
  • $player->experience(['Runecrafting', 'Mining', 'Construction']) // 返回 "技能" => "经验" 的关联数组

检索技能、BOSS或迷你游戏的排名

  • $player->rank('Runecrafting') // 返回作为字符串的排名
  • $player->rank(['Runecrafting', 'Zulrah', 'Construction']) // 返回 "统计" => "排名" 的关联数组

检索技能、BOSS或迷你游戏的全部指标

  • $player->stats('Overall') // 返回包含 "rank"、"level" 和 "experience" 的技能条目
  • $player->stats('Zulrah') // 返回包含 "rank" 和 "count" 的 BOSS/迷你游戏条目
  • $player->stats(['Hitpoints', 'Strength']) // 返回技能条目的数组
  • $player->miniGames(['Clue scrolls (beginner)', 'Vorkath']) // 返回 BOSS/迷你游戏的数组。有关接受的键的完整列表,请参阅 RunescapeClient.php
  • $player->bosses()$player->miniGames() 的别名
  • $player->stats() // 返回所有统计条目的数组

贡献

拉取请求

从仓库分叉并提交到 "master" 分支的拉取请求。请确保遵循现有源代码中显示的编码规范。

问题

尽可能详细地描述问题并提供示例。欢迎并非常感谢一般反馈 :)