buildwars / gw-skilldata
《公会战争》技能数据
1.0.0
2024-06-13 16:31 UTC
Requires
- php: ^8.1
- ext-mbstring: *
Requires (Dev)
- chillerlan/php-httpinterface: ^6.0
- monolog/monolog: ^3.6
- phan/phan: ^5.4
- phpmd/phpmd: ^2.15
- phpunit/phpunit: ^10.5
- squizlabs/php_codesniffer: ^3.10
Suggests
- buildwars/gw-templates: A en/decoder for Guild Wars templates
README
《公会战争》技能数据及技能描述,用于模板解码器,例如BBCode、维基等。
概述
功能
- 《公会战争》技能数据
- 英文和德文的技能描述
- 添加其他翻译的工具集(希望可能)
要求
- PHP 8.1+
快速入门
PHP
use Buildwars\GWSkillData\SkillDataAwareInterface; use Buildwars\GWSkillData\SkillDataAwareTrait; class MyClass implements SkillDataAwareInterface{ use SkillDataAwareTrait public function __construct(string $lang){ // set the language and initialize $this->skillData $this->setSkillDataLanguage($lang); } public function getSkill(int $skillID):mixed{ // $this->skillData is now available $data = $this->skillData->get($skillID); // do stuff with the $data array // the available array keys are in $this->skillData->keys } }
从 SkillDataInterface::get(979)
返回的技能数据数组如下
$data = [ 'id' => 979, 'campaign' => 3, 'profession' => 5, 'attribute' => 2, 'type' => 24, 'is_elite' => false, 'is_rp' => false, 'is_pvp' => false, 'pvp_split' => true, 'split_id' => 3191, 'upkeep' => 0, 'energy' => 10, 'activation' => 2, 'recharge' => 12, 'adrenaline' => 0, 'sacrifice' => 0, 'overcast' => 0, 'name' => 'Mistrust', 'description' => 'For 6 seconds, the next spell that target foe casts on one of your allies fails and deals 10...100 damage to that foe and all nearby foes.', 'concise' => '(6 seconds.) The next spell that target foe casts on one of your allies fails and deals 10...100 damage to target and nearby foes.', 'campaign_name' => 'Nightfall', 'profession_name' => 'Mesmer', 'profession_abbr' => 'Me', 'attribute_name' => 'Domination Magic', 'type_name' => 'Hex Spell', ];
JavaScript ☕
JavaScript 没有特性,所以您需要自行实现该部分
class MyClass{ _languages = { de: SkillLangGerman, en: SkillLangEnglish, }; skillData; constructor(lang){ this.setSkillDataLanguage(lang); } setSkillDataLanguage(lang){ if(!this._languages[lang]){ throw new Error('invalid language'); } this.skillData = new this._languages[lang](); return this; } getSkill(skillID){ // this.skillData is now available let data = this.skillData.get(skillID); // do stuff with the data array } }
输出如下
let data = { id: 979, campaign: 3, profession: 5, attribute: 2, type: 24, is_elite: false, is_rp: false, is_pvp: false, pvp_split: true, split_id: 3191, upkeep: 0, energy: 10, activation: 2, recharge: 12, adrenaline: 0, sacrifice: 0, overcast: 0, name: 'Mistrust', description: 'For 6 seconds, the next spell that target foe casts on one of your allies fails and deals 10...100 damage to that foe and all nearby foes.', concise: '(6 seconds.) The next spell that target foe casts on one of your allies fails and deals 10...100 damage to target and nearby foes.', campaign_name: 'Nightfall', profession_name: 'Mesmer', profession_abbr: 'Me', attribute_name: 'Domination Magic', type_name: 'Hex Spell' }
PvP 技能重定向
当 $pvp
参数设置为 true
时,SkillDataInterface::get(979, true)
将重定向到给定技能的 PvP 版本(如果可用,pvp_split
和 split_id
)
$data = [ 'id' => 3191, 'campaign' => 3, 'profession' => 5, 'attribute' => 2, 'type' => 24, 'is_elite' => false, 'is_rp' => false, 'is_pvp' => true, 'pvp_split' => false, 'split_id' => 0, 'upkeep' => 0, 'energy' => 10, 'activation' => 2, 'recharge' => 12, 'adrenaline' => 0, 'sacrifice' => 0, 'overcast' => 0, 'name' => 'Mistrust (PvP)', 'description' => 'For 6 seconds, the next spell that target foe casts on one of your allies fails and deals 10...75 damage to that foe and all nearby foes.', 'concise' => '(6 seconds.) The next spell that target foe casts on one of your allies fails and deals 10...75 damage to target and nearby foes.', 'campaign_name' => 'Nightfall', 'profession_name' => 'Mesmer', 'profession_abbr' => 'Me', 'attribute_name' => 'Domination Magic', 'type_name' => 'Hex Spell', ];
描述中的 HTML 标签
技能描述可能包含自定义 HTML 标签 <gray>...</gray>
和 <sic/>
,您可以替换它们或使用它们进行样式化,例如
<gray>No effect unless hexed foe attacks.</gray> Each attack that hits deals +13...30 Holy damage <sic/>
API
SkillDataInterface
(API 对于 JavaScript 版本类似)
免责声明
自行承担风险!