Artifact的介面功能詳解
Artifact 正式發售之後,社區熱火朝天的開發出各種工具來支持這款遊戲。 Value為了支持社區的工作,開放了一些構建工具的公共 API, 由以下兩個部分組成:
- CardSet WebAPI,支持直接獲取所有已發行卡牌的所有圖片和文本。
- 可在 GitHub 上查看的牌組代碼 API 和源代碼,讓玩家和社區站點分享牌組代碼更為簡便。 任何有效牌組代碼均可直接粘貼至客戶端,或在我們的在線牌組查看器上在線查看。
V社希望這些 API 發布後不僅有助於工具創造者一展身手,也便於所有玩家分享精彩新牌組和鑽研新策略。
下面是介面的中文說明:
如果你正在開發一個網站需要顯示卡片信息,比如名稱和卡片文本,卡片圖片,則需要向伺服器發起2次請求。 第一個請求是請求卡組的信息。 當前支持的設置為00和01.你同時需要兩者才能獲得所有當前可用的卡。
首先,發起請求獲取信息,請求信息和返回信息如下:
https://playartifact.com/cardset/<setid>/
{
"cdn_root": "https://<some host>/",
"url": "/<some path>/somefile.json",
"expire_time": <unix timestamp>
}
第二步,組裝上面獲取到的鏈接發起請求,必須在有效時間內請求,不然url會失效。請求和返回信息如下:
請求URL:https://somehost/some path/somefile.json
返回數據格式:
{
"card_set": {
"version": 1,
"set_info": {
"set_id": 0,
"pack_item_def": 0,
"name": {
"english": "Base Set"
}
},
"card_list": [{
"card_id": 4000,
"base_card_id": 4000,
"card_type": "Hero",
"card_name": {
"english": "Farvhan the Dreamer"
},
"card_text": {
"english": "Pack Leadership<BR>
Farvhan the Dreamers allied neighbors have +1 Armor."
},
"mini_image": {
"default": "<url to png>"
},
"large_image": {
"default": "<url to png>"
},
"ingame_image": {
"default": "<url to png>"
},
"is_green": true,
"attack": 4,
"hit_points": 10,
"references": [{
"card_id": 4002,
"ref_type": "includes",
"count": 3
},
{
"card_id": 4001,
"ref_type": "passive_ability"
}
]
},
..... more cards ....
]
}
}
關於數據格式的說明
- Text fields (card_name, card_text and the name on set_info) will contain english and additional languages.
- Image fields (mini-image, large-image, ingame-image) provide a default image and keys for each supported language.
- ref_type indicates a type of card reference:
- "includes" - indicates a secondary card which will be automatically included into decks when the card is added. These should NOT be sent to the deck encoder. The ref_type block will include the total count of these cards that will be added.
- "references" - indicates that the card text mentions the specified card.
- "passive_ability" - a passive ability
- "active_ability" - an ability which is activated by clicking on it.
推薦閱讀: