Skip to content

Commit

Permalink
Merge pull request #956 from tsg-ut/nmpz-achievement
Browse files Browse the repository at this point in the history
nmpz: Added achievements
  • Loading branch information
sh-mug authored Oct 23, 2024
2 parents 92ac1ea + ee11c08 commit 04cd116
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-no-hint',
difficulty: 'hard',
title: 'But I can see no hints',
condition: 'NMPZでヒントなしで国を正解する',
category: 'nmpz',
counter: 'nmpz-country-no-hint-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-no-hint-answer");
}
if (result.quiz.answer === "タイ") {
await increment(result.correctAnswerer, "nmpz-country-thailand-answer");
}
}
}
});
};

0 comments on commit 04cd116

Please sign in to comment.