Skip to content

Commit

Permalink
nmpz: Added achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-mug committed Oct 22, 2024
1 parent eb00077 commit 6f96238
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
48 changes: 48 additions & 0 deletions achievements/achievements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4351,6 +4351,54 @@ const achievements: Achievement[] = [
value: 1,
},

// nmpz

{
id: 'nmpz-country-1',
difficulty: 'easy',
title: 'Guessing where I am on Google Maps',
condition: 'NMPZで国を1回正解する',
category: 'nmpz',
counter: 'nmpz-country-answer',
value: 1,
},
{
id: 'nmpz-country-100',
difficulty: 'hard',
title: 'Nice.',
condition: 'NMPZで国を100回正解する',
category: 'nmpz',
counter: 'nmpz-country-answer',
value: 100,
},
{
id: 'nmpz-country-1000',
difficulty: 'professional',
title: 'Next.',
condition: 'NMPZで国を1000回正解する',
category: 'nmpz',
counter: 'nmpz-country-answer',
value: 1000,
},
{
id: 'nmpz-country-30sec',
difficulty: 'hard',
title: 'in 0.5 minutes',
condition: 'NMPZでヒントなしで国を正解する',
category: 'nmpz',
counter: 'nmpz-country-30sec-answer',
value: 1,
},
{
id: 'nmpz-country-thailand',
difficulty: 'hard',
title: 'No, this is Thailand.',
condition: 'NMPZでタイを正解する',
category: 'nmpz',
counter: 'nmpz-country-thailand-answer',
value: 1,
},

// achievements

{
Expand Down
11 changes: 11 additions & 0 deletions nmpz/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fs from "fs";
import path from "path";
import puppeteer from "puppeteer";
import sqlite3 from "sqlite3";
import { increment } from '../achievements';
import { AteQuizProblem } from "../atequiz";
import logger from "../lib/logger";
import type { SlackInterface } from "../lib/slack";
Expand Down Expand Up @@ -378,6 +379,16 @@ export default async ({ eventClient, webClient: slack }: SlackInterface) => {
return [null, null];
});
if (!result) return;

if (result.state === "solved") {
await increment(result.correctAnswerer, "nmpz-country-answer");
if (result.hintIndex === 0) {
await increment(result.correctAnswerer, "nmpz-country-30sec-answer");
}
if (result.quiz.answer === "タイ") {
await increment(result.correctAnswerer, "nmpz-country-thailand-answer");
}
}
}
});
};

0 comments on commit 6f96238

Please sign in to comment.