From 6f962386a3d7b588cce7ac54e04a82b0850e7de5 Mon Sep 17 00:00:00 2001 From: sh-mug <52068539+sh-mug@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:03:23 +0000 Subject: [PATCH] nmpz: Added achievements --- achievements/achievements.ts | 48 ++++++++++++++++++++++++++++++++++++ nmpz/index.ts | 11 +++++++++ 2 files changed, 59 insertions(+) diff --git a/achievements/achievements.ts b/achievements/achievements.ts index 0b6d28b1..a8e41858 100644 --- a/achievements/achievements.ts +++ b/achievements/achievements.ts @@ -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 { diff --git a/nmpz/index.ts b/nmpz/index.ts index 4764350e..3975c2d2 100644 --- a/nmpz/index.ts +++ b/nmpz/index.ts @@ -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"; @@ -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"); + } + } } }); };