Asobiai SDK
Trophies
Give trophies with AIGame.unlockAchievement(id). Earned trophies show on the game page (with how many players have them) and on the player's profile.
v2.7.0Check it from your game with window.AIGame?.version.Changelog
Usage
js
// Unlock a trophy (define the IDs on the game's edit page or in asobiai.json)
window.AIGame?.unlockAchievement("first_clear");
// List them (with whether the player has them)
const list = await window.AIGame?.getAchievements();
// => [{ id, name, description, icon, hidden, unlocked, rate }]Defining the trophies
Define the list on the game's edit page, with achievements in MCP / the API, or in asobiai.json at the top of the game files (up to 50). asobiai.json is read when you publish or update, which makes it easy to have your AI write it along with the game.
json
{
"achievements": [
{ "id": "first_clear", "name": "First clear", "description": "Clear stage 1", "icon": "🏆" },
{ "id": "no_damage", "name": "Untouchable", "description": "Clear without taking damage", "icon": "art/shield.webp" },
{ "id": "secret_room", "name": "Secret room", "description": "Find the hidden room", "icon": "🔑", "hidden": true }
]
}- icon is an emoji or the path to an image in your game files.
- Trophies with "hidden": true show as “???” until earned.
- Trophies earned as a guest are kept in the browser and recorded when the player logs in.
