mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-02 19:05:55 +02:00
New Crowdin updates (#7046)
* New translations ja-JP.yml (German) * New translations ja-JP.yml (English) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Simplified) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations aiscript.md (German) * New translations theme.md (German) * New translations reaction.md (German) * New translations theme.md (German) * New translations theme.md (German) * New translations ja-JP.yml (German) * New translations theme.md (German) * New translations timelines.md (German) * New translations ja-JP.yml (German) * New translations mute.md (German) * New translations timelines.md (German) * New translations mute.md (German) * New translations reaction.md (German) * New translations pages.md (German) * New translations reaction.md (German) * New translations follow.md (German) * New translations pages.md (German) * New translations custom-emoji.md (German) * New translations follow.md (German) * New translations custom-emoji.md (English) * New translations deck.md (German) * New translations mfm.md (German) * New translations create-plugin.md (German) * New translations deck.md (German) * New translations create-plugin.md (German) * New translations create-plugin.md (English) * New translations create-plugin.md (German) * New translations keyboard-shortcut.md (German) * New translations keyboard-shortcut.md (German) * New translations create-plugin.md (German) * New translations keyboard-shortcut.md (German) * New translations create-plugin.md (German) * New translations create-plugin.md (German) * New translations reversi-bot.md (German) * New translations create-plugin.md (English) * New translations reversi-bot.md (English) * New translations create-plugin.md (German) * New translations reversi-bot.md (German) * New translations reversi-bot.md (German) * New translations stream.md (German) * New translations reversi-bot.md (English) * New translations reversi-bot.md (German) * New translations reversi-bot.md (German) * New translations reversi-bot.md (German) * New translations reversi-bot.md (English) * New translations reversi-bot.md (German) * New translations reversi-bot.md (English) * New translations reversi-bot.md (German) * New translations reversi-bot.md (German) * New translations reversi-bot.md (German) * New translations pages.md (Chinese Simplified) * New translations pages.md (Chinese Simplified) * New translations pages.md (Chinese Simplified) * New translations pages.md (Chinese Simplified) * New translations reaction.md (Chinese Simplified) * New translations reaction.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations ja-JP.yml (German) * New translations api.md (German) * New translations keyboard-shortcut.md (German) * New translations api.md (German) * New translations stream.md (German) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations ja-JP.yml (German) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations stream.md (German) * New translations ja-JP.yml (German) * New translations reversi-bot.md (German) * New translations stream.md (German) * New translations stream.md (German) * New translations stream.md (German) * New translations ja-JP.yml (Chinese Traditional) * New translations stream.md (German) * New translations ja-JP.yml (Chinese Traditional) * New translations stream.md (German) * New translations ja-JP.yml (Chinese Traditional) * New translations stream.md (German) * New translations ja-JP.yml (Chinese Traditional) * New translations stream.md (English) * New translations stream.md (German) * New translations ja-JP.yml (Chinese Traditional) * New translations stream.md (German) * New translations stream.md (German) * New translations stream.md (German) * New translations stream.md (English) * New translations stream.md (German) * New translations api.md (German) * New translations api.md (English) * New translations api.md (German) * New translations api.md (German) * New translations api.md (English) * New translations api.md (German) * New translations api.md (German) * New translations api.md (German) * New translations ja-JP.yml (Chinese Traditional) * New translations create-plugin.md (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations reversi-bot.md (Chinese Simplified) * New translations reversi-bot.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations stream.md (Chinese Simplified) * New translations ja-JP.yml (Kabyle) * New translations ja-JP.yml (Korean) * New translations ja-JP.yml (Spanish) * New translations ja-JP.yml (Russian) * New translations ja-JP.yml (German) * New translations ja-JP.yml (English) * New translations ja-JP.yml (Chinese Simplified) * New translations ja-JP.yml (Polish) * New translations custom-emoji.md (Polish) * New translations mute.md (Polish) * New translations ja-JP.yml (Polish) * New translations ja-JP.yml (Polish) * New translations follow.md (Polish) * New translations ja-JP.yml (Polish) * New translations create-plugin.md (Polish) * New translations reaction.md (Polish) * New translations theme.md (Polish) * New translations timelines.md (Polish) * New translations ja-JP.yml (English) * New translations ja-JP.yml (Polish) * New translations ja-JP.yml (Polish) * New translations ja-JP.yml (Polish) * New translations aiscript.md (Polish) * New translations keyboard-shortcut.md (Polish) * New translations pages.md (Polish) * New translations reversi-bot.md (Polish) * New translations stream.md (Polish) * New translations theme.md (Polish) * New translations ja-JP.yml (Polish) * New translations timelines.md (Polish) * New translations deck.md (Polish) * New translations ja-JP.yml (Indonesian) * New translations aiscript.md (Indonesian) * New translations api.md (Indonesian) * New translations create-plugin.md (Indonesian) * New translations custom-emoji.md (Indonesian) * New translations follow.md (Indonesian) * New translations keyboard-shortcut.md (Indonesian) * New translations mute.md (Indonesian) * New translations pages.md (Indonesian) * New translations reaction.md (Indonesian) * New translations reversi-bot.md (Indonesian) * New translations stream.md (Indonesian) * New translations theme.md (Indonesian) * New translations timelines.md (Indonesian) * New translations deck.md (Indonesian) * New translations mfm.md (Indonesian) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Indonesian) * New translations keyboard-shortcut.md (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations reaction.md (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations mute.md (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations custom-emoji.md (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations ja-JP.yml (Indonesian) * New translations ja-JP.yml (Indonesian)
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
# MisskeyリバーシBotの開発
|
||||
Misskeyのリバーシ機能に対応したBotの開発方法をここに記します。
|
||||
# Misskey的黑白棋Bot开发
|
||||
本页会说明如何为Misskey的黑白棋功能开发一个Bot机器人。
|
||||
|
||||
1. `games/reversi`ストリームに以下のパラメータを付けて接続する:
|
||||
* `i`: botアカウントのAPIキー
|
||||
1. 使用以下参数来连接`games/reversi`流式API:
|
||||
* `i`: bot账号的API key
|
||||
|
||||
2. 対局への招待が来たら、ストリームから`invited`イベントが流れてくる
|
||||
* イベントの中身に、`parent`という名前で対局へ誘ってきたユーザーの情報が含まれている
|
||||
2. 当出现对局邀请时,流中会触发`invited`事件
|
||||
* 事件内容中包含邀请您参加游戏的用户信息,名字为`parent`。
|
||||
|
||||
3. `games/reversi/match`へ、`user_id`として`parent`の`id`が含まれたリクエストを送信する
|
||||
3. 向`games/reversi/match`发送请求,其中`user_id`包含`parent`的`id`
|
||||
|
||||
4. 上手くいくとゲーム情報が返ってくるので、`games/reversi-game`ストリームへ、以下のパラメータを付けて接続する:
|
||||
* `i`: botアカウントのAPIキー
|
||||
* `game`: `game`の`id`
|
||||
4. 请求成功时将返回游戏信息,然后可以使用以下参数连接到`games/reversi-game`流:
|
||||
* `i`: bot账号的API key
|
||||
* `game`: `game`的`id`
|
||||
|
||||
5. この間、相手がゲームの設定を変更するとその都度`update-settings`イベントが流れてくるので、必要であれば何かしらの処理を行う
|
||||
5. 与此同时,每次对手更改游戏设置时,都会触发`update-settings`事件,如果有必要的话,需要对其进行处理。
|
||||
|
||||
6. 設定に満足したら、`{ type: 'accept' }`メッセージをストリームに送信する
|
||||
6. 一旦符合设置,则向流发送`{ type: 'accept' }`消息
|
||||
|
||||
7. ゲームが開始すると、`started`イベントが流れてくる
|
||||
* イベントの中身にはゲーム情報が含まれている
|
||||
7. 游戏开始时会触发`started`事件
|
||||
* 游戏状态信息会包含在该事件中
|
||||
|
||||
8. 石を打つには、ストリームに`{ type: 'set', pos: <位置> }`を送信する(位置の計算方法は後述)
|
||||
8. 要放置棋子,向流发送`{ type: 'set', pos: <位置> }`(后面会说明位置的计算方法)
|
||||
|
||||
9. 相手または自分が石を打つと、ストリームから`set`イベントが流れてくる
|
||||
* `color`として石の色が含まれている
|
||||
* `pos`として位置情報が含まれている
|
||||
9. 当对方或者您放置棋子时,会触发`set`事件
|
||||
* `color`中包含该棋子的颜色
|
||||
* `pos`中包含该棋子的位置
|
||||
|
||||
## 位置の計算法
|
||||
8x8のマップを考える場合、各マスの位置(インデックスと呼びます)は次のようになっています:
|
||||
## 位置计算方法
|
||||
当棋盘尺寸为8x8时,每个方格的位置(称为索引)如下所示:
|
||||
```
|
||||
+--+--+--+--+--+--+--+--+
|
||||
| 0| 1| 2| 3| 4| 5| 6| 7|
|
||||
@@ -38,29 +38,29 @@ Misskeyのリバーシ機能に対応したBotの開発方法をここに記し
|
||||
...
|
||||
```
|
||||
|
||||
### X,Y座標 から インデックス に変換する
|
||||
### 从X,Y坐标转换为索引
|
||||
```
|
||||
pos = x + (y * mapWidth)
|
||||
```
|
||||
`mapWidth`は、ゲーム情報の`map`から、次のようにして計算できます:
|
||||
`mapWidth`可以根据游戏信息中的`map`,通过如下方法计算出来:
|
||||
```
|
||||
mapWidth = map[0].length
|
||||
```
|
||||
|
||||
### インデックス から X,Y座標 に変換する
|
||||
### 从索引转换为X,Y坐标
|
||||
```
|
||||
x = pos % mapWidth
|
||||
y = Math.floor(pos / mapWidth)
|
||||
```
|
||||
|
||||
## マップ情報
|
||||
マップ情報は、ゲーム情報の`map`に入っています。 文字列の配列になっており、ひとつひとつの文字がマス情報を表しています。 それをもとにマップのデザインを知る事が出来ます:
|
||||
* `(スペース)` ... マス無し
|
||||
* `-` ... マス
|
||||
* `b` ... 初期配置される黒石
|
||||
* `w` ... 初期配置される白石
|
||||
## 棋盘信息
|
||||
棋盘信息包含在游戏信息的`map`中。 它是一个字符串数组,每个字符代表一块格子的信息。 您可以根据这些来了解地图如何设计:
|
||||
* `(空)` ... 没有格子
|
||||
* `-` ... 格子
|
||||
* `b` ... 黑子先下
|
||||
* `w` ... 白子先下
|
||||
|
||||
例えば、4*4の次のような単純なマップがあるとします:
|
||||
以下面这个4*4的简单棋盘为例:
|
||||
```text
|
||||
+---+---+---+---+
|
||||
| | | | |
|
||||
@@ -73,23 +73,23 @@ y = Math.floor(pos / mapWidth)
|
||||
+---+---+---+---+
|
||||
```
|
||||
|
||||
この場合、マップデータはこのようになります:
|
||||
这种情况下,棋盘数据是这样的:
|
||||
```javascript
|
||||
['----', '-wb-', '-bw-', '----']
|
||||
```
|
||||
|
||||
## ユーザーにフォームを提示して対話可能Botを作成する
|
||||
ユーザーとのコミュニケーションを行うため、ゲームの設定画面でユーザーにフォームを提示することができます。 例えば、Botの強さをユーザーが設定できるようにする、といったシナリオが考えられます。
|
||||
## 能和用户互动的交互式Bot机器人的创建
|
||||
要和用户交互,您可以在游戏设置屏幕上向用户显示对话框。 例如,可以让用户选择Bot机器人的难度。
|
||||
|
||||
フォームを提示するには、`reversi-game`ストリームに次のメッセージを送信します:
|
||||
要显示提示框,需要向`reversi-game`流发送下列消息:
|
||||
```javascript
|
||||
{
|
||||
type: 'init-form',
|
||||
body: [フォームコントロールの配列]
|
||||
body: [表单控件数组]
|
||||
}
|
||||
```
|
||||
|
||||
フォームコントロールの配列については今から説明します。 フォームコントロールは、次のようなオブジェクトです:
|
||||
下面说明表单控件数组的结构。 表单控件指的是如下面所示的对象:
|
||||
```javascript
|
||||
{
|
||||
id: 'switch1',
|
||||
@@ -98,10 +98,10 @@ y = Math.floor(pos / mapWidth)
|
||||
value: false
|
||||
}
|
||||
```
|
||||
`id` ... コントロールのID。 `type` ... コントロールの種類。後述します。 `label` ... コントロールと一緒に表記するテキスト。 `value` ... コントロールのデフォルト値。
|
||||
`id` ... 控件ID。 `type` ... 控件类型。说明详见后文。 `label` ... 控件元素上显示的文字。 `value` ... 控件元素的默认值。
|
||||
|
||||
### フォームの操作を受け取る
|
||||
ユーザーがフォームを操作すると、ストリームから`update-form`イベントが流れてきます。 イベントの中身には、コントロールのIDと、ユーザーが設定した値が含まれています。 例えば、上で示したスイッチをユーザーがオンにしたとすると、次のイベントが流れてきます:
|
||||
### 控件行为的处理
|
||||
当用户与对话框交互时将会触发流的`update-form`事件。 事件的内容包含控件的ID和用户设置的值。 例如,如果用户将上面显示的开关控件打开,则将触发以下事件:
|
||||
```javascript
|
||||
{
|
||||
id: 'switch1',
|
||||
@@ -109,18 +109,18 @@ y = Math.floor(pos / mapWidth)
|
||||
}
|
||||
```
|
||||
|
||||
### フォームコントロールの種類
|
||||
### 表单控件的类型
|
||||
#### 开关
|
||||
type: `switch` スイッチを表示します。何かの機能をオン/オフさせたい場合に有用です。
|
||||
type: `switch` 显示一个开关。当您想要打开/关闭某些功能时非常有用。
|
||||
|
||||
##### プロパティ
|
||||
`label` ... スイッチに表記するテキスト。
|
||||
##### 属性
|
||||
`label` ... 开关上显示的文字。
|
||||
|
||||
#### ラジオボタン
|
||||
type: `radio` ラジオボタンを表示します。選択肢を提示するのに有用です。例えば、Botの強さを設定させるなどです。
|
||||
#### 单选按钮
|
||||
type: `radio` 显示一个单选按钮。用来表示单项选择。例如,可以选择Bot机器人的难度。
|
||||
|
||||
##### プロパティ
|
||||
`items` ... ラジオボタンの選択肢。例:
|
||||
##### 属性
|
||||
`items` ... 单元按钮的选择项。例:
|
||||
```javascript
|
||||
items: [{
|
||||
label: '弱',
|
||||
@@ -129,32 +129,32 @@ items: [{
|
||||
label: '中',
|
||||
value: 2
|
||||
}, {
|
||||
label: '強',
|
||||
label: '强',
|
||||
value: 3
|
||||
}]
|
||||
```
|
||||
|
||||
#### スライダー
|
||||
type: `slider` スライダーを表示します。
|
||||
#### 滑块
|
||||
type: `slider` 显示一个滑块。
|
||||
|
||||
##### プロパティ
|
||||
`min` ... スライダーの下限。 `max` ... スライダーの上限。 `step` ... 入力欄で刻むステップ値。
|
||||
##### 属性
|
||||
`min` ... 滑块最小值。 `max` ... 滑块最大值。 `step` ... 滑块值的步长。
|
||||
|
||||
#### テキストボックス
|
||||
type: `textbox` テキストボックスを表示します。ユーザーになにか入力させる一般的な用途に利用できます。
|
||||
#### 文本框
|
||||
type: `textbox` 显示一个文本框。可以在各种需要用户输入的地方使用。
|
||||
|
||||
## ユーザーにメッセージを表示する
|
||||
設定画面でユーザーと対話する、フォーム以外のもうひとつの方法がこれです。ユーザーになにかメッセージを表示することができます。 例えば、ユーザーがBotの対応していないモードやマップを選択したとき、警告を表示するなどです。 メッセージを表示するには、次のメッセージをストリームに送信します:
|
||||
## 向用户显示消息
|
||||
设置屏幕上与用户交互,是除了对话框外的另一种方法。您可以向用户显示一条消息。 例如,当用户选择Bot机器人不支持的模式或棋盘时显示警告。 要显示消息,请将以下消息发送到流:
|
||||
```javascript
|
||||
{
|
||||
type: 'message',
|
||||
body: {
|
||||
text: 'メッセージ内容',
|
||||
type: 'メッセージの種類'
|
||||
text: '消息内容',
|
||||
type: '消息类型'
|
||||
}
|
||||
}
|
||||
```
|
||||
メッセージの種類: `success`, `info`, `warning`, `error`。
|
||||
消息类型:`success`, `info`, `warning`, `error`。
|
||||
|
||||
## 投了する
|
||||
投了をするには、<a href="./api/endpoints/games/reversi/games/surrender">このエンドポイント</a>にリクエストします。
|
||||
## 认输
|
||||
要认输,请发送请求到这个终端。
|
||||
|
||||
Reference in New Issue
Block a user