Skip to content

Commit

Permalink
Add highlighting in code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed May 14, 2024
1 parent 548c4f6 commit ebf1365
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/home/350-game-node-api/2-achievements.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const achievements: Promise<AchievementMetadata> = Promise.resolve({
});

export default RegisterRoutes; // The usual default export.
// highlight-next-line
export { achievements }; // Include this to enable the achievement API.
```

Expand Down Expand Up @@ -67,16 +68,19 @@ Paima SDK exports `pgtyped` queries to store and retrieve achievement progress.
They can be imported and used in your API or a state transition function:

```js
// highlight-next-line
import { getAchievementProgress, setAchievementProgress } from '@paima/db';
// ... other imports ...

async function wonBattle(wallet: number, blockTime: Date, dbConn: Pool): Promise<SQLUpdate[]> {
// Get user's current achievement progress.
// highlight-next-line
const row = (await getAchievementProgress.run({ wallet, names: ['win-10-battles'] }, dbConn))[0];
if (!row?.completed_date) {
// Not complete yet. Add one, mark completed if needed, and store it back.
const newProgress = (row?.progress ?? 0) + 1;
return [
// highlight-next-line
[setAchievementProgress, {
name: 'win-10-battles',
wallet,
Expand Down

0 comments on commit ebf1365

Please sign in to comment.