This commit is contained in:
syuilo 2024-01-21 14:21:48 +09:00
parent fd50dc790f
commit 37f94bc0c1
6 changed files with 36 additions and 6 deletions

View file

@ -3,7 +3,7 @@
"type": "module",
"main": "./built/index.js",
"scripts": {
"start": "node ./built",
"start": "nodemon ./built",
"build": "tspc",
"test": "jest"
},
@ -23,6 +23,7 @@
"lokijs": "1.5.12",
"memory-streams": "0.1.3",
"misskey-reversi": "0.0.5",
"nodemon": "3.0.3",
"promise-retry": "2.0.1",
"random-seed": "0.3.0",
"reconnecting-websocket": "4.4.0",
@ -68,5 +69,8 @@
"^@/(.+)": "<rootDir>/src/$1",
"^#/(.+)": "<rootDir>/test/$1"
}
},
"nodemonConfig": {
"ignore": ["memory.json"]
}
}

View file

@ -15,6 +15,7 @@ export type FriendDoc = {
perModulesData?: any;
married?: boolean;
transferCode?: string;
reversiStrength?: number | null;
};
export default class Friend {
@ -154,6 +155,20 @@ export default class Friend {
this.save();
}
@bindThis
public updateReversiStrength(strength: number | null) {
if (strength == null) {
this.doc.reversiStrength = null;
this.save();
return;
}
if (strength < 0) strength = 0;
if (strength > 5) strength = 5;
this.doc.reversiStrength = strength;
this.save();
}
@bindThis
public save() {
this.ai.friends.update(this.doc);

View file

@ -66,7 +66,7 @@ export default class extends Module {
if (!msg.text.includes('って呼んで')) return false;
if (msg.text.startsWith('って呼んで')) return false;
const name = msg.text.match(/^(.+?)って呼んで/)![1];
const name = msg.text.match(/^(.+?)って呼んで/g)![1];
if (name.length > 10) {
msg.reply(serifs.core.tooLong);

View file

@ -1,4 +1,4 @@
import * as gen from 'random-seed';
import gen from 'random-seed';
import { CellType } from './maze.js';
const cellVariants = {

View file

@ -1,4 +1,4 @@
import * as gen from 'random-seed';
import gen from 'random-seed';
import { createCanvas } from 'canvas';
import { CellType } from './maze.js';

View file

@ -54,6 +54,10 @@ export default class extends Module {
if (config.reversiEnabled) {
msg.reply(serifs.reversi.ok);
if (msg.includes(['接待'])) {
msg.friend.updateReversiStrength(0);
}
this.ai.api('reversi/match', {
userId: msg.userId
});
@ -85,6 +89,13 @@ export default class extends Module {
@bindThis
private onReversiGameStart(game: any) {
let strength = 4;
const friend = this.ai.lookupFriend(game.user1Id !== this.ai.account.id ? game.user1Id : game.user2Id)!;
if (friend != null) {
strength = friend.doc.reversiStrength ?? 4;
friend.updateReversiStrength(null);
}
this.log(`enter reversi game room: ${game.id}`);
// ゲームストリームに接続
@ -102,7 +113,7 @@ export default class extends Module {
id: 'strength',
type: 'radio',
label: '強さ',
value: 4,
value: strength,
items: [{
label: '接待',
value: 0