Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 麻雀 #13112

Draft
wants to merge 67 commits into
base: develop
Choose a base branch
from
Draft

feat: 麻雀 #13112

wants to merge 67 commits into from

Conversation

syuilo
Copy link
Member

@syuilo syuilo commented Jan 30, 2024

What

#1876

Why

Resolve #1876

Additional info (optional)

TODO

  • 各種役
  • AIのロジックを別クラスに切り出す
  • 流し満貫
  • 四風連打
  • さんま

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions github-actions bot added packages/frontend Client side specific issue/PR packages/backend Server side specific issue/PR packages/misskey-js labels Jan 30, 2024
Copy link
Contributor

github-actions bot commented Jan 30, 2024

このPRによるapi.jsonの差分

差分はこちら
--- base
+++ head
@@ -76097,6 +76097,464 @@
           }
         }
       }
+    },
+    "/mahjong/create-room": {
+      "post": {
+        "operationId": "mahjong___create-room",
+        "summary": "mahjong/create-room",
+        "description": "No description provided.\n\n**Credential required**: *Yes* / **Permission**: *write:account*",
+        "externalDocs": {
+          "description": "Source code",
+          "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/mahjong/create-room.ts"
+        },
+        "security": [
+          {
+            "bearerAuth": []
+          }
+        ],
+        "responses": {
+          "200": {
+            "description": "OK (with results)",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "$ref": "#/components/schemas/MahjongRoomDetailed"
+                }
+              }
+            }
+          },
+          "400": {
+            "description": "Client error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "INVALID_PARAM": {
+                    "value": {
+                      "error": {
+                        "message": "Invalid param.",
+                        "code": "INVALID_PARAM",
+                        "id": "3d81ceae-475f-4600-b2a8-2bc116157532"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "401": {
+            "description": "Authentication error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "CREDENTIAL_REQUIRED": {
+                    "value": {
+                      "error": {
+                        "message": "Credential required.",
+                        "code": "CREDENTIAL_REQUIRED",
+                        "id": "1384574d-a912-4b81-8601-c7b1c4085df1"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "403": {
+            "description": "Forbidden error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "AUTHENTICATION_FAILED": {
+                    "value": {
+                      "error": {
+                        "message": "Authentication failed. Please ensure your token is correct.",
+                        "code": "AUTHENTICATION_FAILED",
+                        "id": "b0a7f5f8-dc2f-4171-b91f-de88ad238e14"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "418": {
+            "description": "I'm Ai",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "I_AM_AI": {
+                    "value": {
+                      "error": {
+                        "message": "You sent a request to Ai-chan, Misskey's showgirl, instead of the server.",
+                        "code": "I_AM_AI",
+                        "id": "60c46cd1-f23a-46b1-bebe-5d2b73951a84"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "500": {
+            "description": "Internal server error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "INTERNAL_ERROR": {
+                    "value": {
+                      "error": {
+                        "message": "Internal error occurred. Please contact us if the error persists.",
+                        "code": "INTERNAL_ERROR",
+                        "id": "5d37dbcb-891e-41ca-a3d6-e690c97775ac"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/mahjong/join-room": {
+      "post": {
+        "operationId": "mahjong___join-room",
+        "summary": "mahjong/join-room",
+        "description": "No description provided.\n\n**Credential required**: *Yes* / **Permission**: *write:account*",
+        "externalDocs": {
+          "description": "Source code",
+          "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/mahjong/join-room.ts"
+        },
+        "security": [
+          {
+            "bearerAuth": []
+          }
+        ],
+        "requestBody": {
+          "required": true,
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "properties": {
+                  "roomId": {
+                    "type": "string",
+                    "format": "misskey:id"
+                  }
+                },
+                "required": [
+                  "roomId"
+                ]
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "OK (with results)",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "$ref": "#/components/schemas/MahjongRoomDetailed"
+                }
+              }
+            }
+          },
+          "400": {
+            "description": "Client error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "NO_SUCH_ROOM": {
+                    "value": {
+                      "error": {
+                        "message": "No such room.",
+                        "code": "NO_SUCH_ROOM",
+                        "id": "370e42b0-2a67-4306-9328-51c5f568f110"
+                      }
+                    }
+                  },
+                  "INVALID_PARAM": {
+                    "value": {
+                      "error": {
+                        "message": "Invalid param.",
+                        "code": "INVALID_PARAM",
+                        "id": "3d81ceae-475f-4600-b2a8-2bc116157532"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "401": {
+            "description": "Authentication error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "CREDENTIAL_REQUIRED": {
+                    "value": {
+                      "error": {
+                        "message": "Credential required.",
+                        "code": "CREDENTIAL_REQUIRED",
+                        "id": "1384574d-a912-4b81-8601-c7b1c4085df1"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "403": {
+            "description": "Forbidden error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "AUTHENTICATION_FAILED": {
+                    "value": {
+                      "error": {
+                        "message": "Authentication failed. Please ensure your token is correct.",
+                        "code": "AUTHENTICATION_FAILED",
+                        "id": "b0a7f5f8-dc2f-4171-b91f-de88ad238e14"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "418": {
+            "description": "I'm Ai",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "I_AM_AI": {
+                    "value": {
+                      "error": {
+                        "message": "You sent a request to Ai-chan, Misskey's showgirl, instead of the server.",
+                        "code": "I_AM_AI",
+                        "id": "60c46cd1-f23a-46b1-bebe-5d2b73951a84"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "500": {
+            "description": "Internal server error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "INTERNAL_ERROR": {
+                    "value": {
+                      "error": {
+                        "message": "Internal error occurred. Please contact us if the error persists.",
+                        "code": "INTERNAL_ERROR",
+                        "id": "5d37dbcb-891e-41ca-a3d6-e690c97775ac"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/mahjong/show-room": {
+      "post": {
+        "operationId": "mahjong___show-room",
+        "summary": "mahjong/show-room",
+        "description": "No description provided.\n\n**Credential required**: *Yes* / **Permission**: *read:account*",
+        "externalDocs": {
+          "description": "Source code",
+          "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/mahjong/show-room.ts"
+        },
+        "security": [
+          {
+            "bearerAuth": []
+          }
+        ],
+        "requestBody": {
+          "required": true,
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "properties": {
+                  "roomId": {
+                    "type": "string",
+                    "format": "misskey:id"
+                  }
+                },
+                "required": [
+                  "roomId"
+                ]
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "OK (with results)",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "$ref": "#/components/schemas/MahjongRoomDetailed"
+                }
+              }
+            }
+          },
+          "400": {
+            "description": "Client error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "NO_SUCH_ROOM": {
+                    "value": {
+                      "error": {
+                        "message": "No such room.",
+                        "code": "NO_SUCH_ROOM",
+                        "id": "d77df68f-06f3-492b-9078-e6f72f4acf23"
+                      }
+                    }
+                  },
+                  "INVALID_PARAM": {
+                    "value": {
+                      "error": {
+                        "message": "Invalid param.",
+                        "code": "INVALID_PARAM",
+                        "id": "3d81ceae-475f-4600-b2a8-2bc116157532"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "401": {
+            "description": "Authentication error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "CREDENTIAL_REQUIRED": {
+                    "value": {
+                      "error": {
+                        "message": "Credential required.",
+                        "code": "CREDENTIAL_REQUIRED",
+                        "id": "1384574d-a912-4b81-8601-c7b1c4085df1"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "403": {
+            "description": "Forbidden error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "AUTHENTICATION_FAILED": {
+                    "value": {
+                      "error": {
+                        "message": "Authentication failed. Please ensure your token is correct.",
+                        "code": "AUTHENTICATION_FAILED",
+                        "id": "b0a7f5f8-dc2f-4171-b91f-de88ad238e14"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "418": {
+            "description": "I'm Ai",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "I_AM_AI": {
+                    "value": {
+                      "error": {
+                        "message": "You sent a request to Ai-chan, Misskey's showgirl, instead of the server.",
+                        "code": "I_AM_AI",
+                        "id": "60c46cd1-f23a-46b1-bebe-5d2b73951a84"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          },
+          "500": {
+            "description": "Internal server error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "INTERNAL_ERROR": {
+                    "value": {
+                      "error": {
+                        "message": "Internal error occurred. Please contact us if the error persists.",
+                        "code": "INTERNAL_ERROR",
+                        "id": "5d37dbcb-891e-41ca-a3d6-e690c97775ac"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
     }
   },
   "components": {
@@ -81282,6 +81740,123 @@
           "name",
           "method"
         ]
+      },
+      "MahjongRoomDetailed": {
+        "type": "object",
+        "properties": {
+          "id": {
+            "type": "string",
+            "format": "id"
+          },
+          "createdAt": {
+            "type": "string",
+            "format": "date-time"
+          },
+          "startedAt": {
+            "type": [
+              "string",
+              "null"
+            ],
+            "format": "date-time"
+          },
+          "endedAt": {
+            "type": [
+              "string",
+              "null"
+            ],
+            "format": "date-time"
+          },
+          "isStarted": {
+            "type": "boolean"
+          },
+          "isEnded": {
+            "type": "boolean"
+          },
+          "user1Id": {
+            "type": "string",
+            "format": "id"
+          },
+          "user2Id": {
+            "type": "string",
+            "format": "id"
+          },
+          "user3Id": {
+            "type": "string",
+            "format": "id"
+          },
+          "user4Id": {
+            "type": "string",
+            "format": "id"
+          },
+          "user1": {
+            "type": "object",
+            "$ref": "#/components/schemas/User"
+          },
+          "user2": {
+            "type": "object",
+            "$ref": "#/components/schemas/User"
+          },
+          "user3": {
+            "type": "object",
+            "$ref": "#/components/schemas/User"
+          },
+          "user4": {
+            "type": "object",
+            "$ref": "#/components/schemas/User"
+          },
+          "user1Ai": {
+            "type": "boolean"
+          },
+          "user2Ai": {
+            "type": "boolean"
+          },
+          "user3Ai": {
+            "type": "boolean"
+          },
+          "user4Ai": {
+            "type": "boolean"
+          },
+          "user1Ready": {
+            "type": "boolean"
+          },
+          "user2Ready": {
+            "type": "boolean"
+          },
+          "user3Ready": {
+            "type": "boolean"
+          },
+          "user4Ready": {
+            "type": "boolean"
+          },
+          "timeLimitForEachTurn": {
+            "type": "number"
+          }
+        },
+        "required": [
+          "id",
+          "createdAt",
+          "startedAt",
+          "endedAt",
+          "isStarted",
+          "isEnded",
+          "user1Id",
+          "user2Id",
+          "user3Id",
+          "user4Id",
+          "user1",
+          "user2",
+          "user3",
+          "user4",
+          "user1Ai",
+          "user2Ai",
+          "user3Ai",
+          "user4Ai",
+          "user1Ready",
+          "user2Ready",
+          "user3Ready",
+          "user4Ready",
+          "timeLimitForEachTurn"
+        ]
       }
     },
     "securitySchemes": {

Get diff files from Workflow Page

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: Patch coverage is 17.96130% with 3010 lines in your changes missing coverage. Please review.

Project coverage is 41.21%. Comparing base (865b303) to head (bf818a6).
Report is 69 commits behind head on develop.

Files Patch % Lines
packages/frontend/src/pages/mahjong/room.game.vue 0.00% 1213 Missing and 1 partial ⚠️
packages/backend/src/core/MahjongService.ts 24.79% 552 Missing ⚠️
packages/frontend/src/pages/mahjong/hand-tiles.vue 0.00% 183 Missing and 1 partial ⚠️
...end/src/server/api/stream/channels/mahjong-room.ts 8.12% 181 Missing ⚠️
packages/frontend/src/pages/mahjong/index.vue 0.00% 165 Missing and 1 partial ⚠️
...ckages/frontend/src/pages/mahjong/room.setting.vue 0.00% 164 Missing and 1 partial ⚠️
packages/frontend/src/pages/mahjong/room.vue 0.00% 112 Missing and 1 partial ⚠️
packages/frontend/src/scripts/mahjong.ts 0.00% 82 Missing and 1 partial ⚠️
packages/frontend/src/pages/mahjong/tile.vue 0.00% 77 Missing and 1 partial ⚠️
.../backend/src/server/api/endpoints/mahjong/games.ts 0.00% 63 Missing and 1 partial ⚠️
... and 10 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #13112      +/-   ##
===========================================
+ Coverage    40.18%   41.21%   +1.03%     
===========================================
  Files         1524     1567      +43     
  Lines       188816   200223   +11407     
  Branches      3466     2746     -720     
===========================================
+ Hits         75875    82530    +6655     
- Misses      112369   117119    +4750     
- Partials       572      574       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

syuilo and others added 19 commits February 5, 2024 15:02
* add daisangen test

* add suanko test

* add suanko-tanki test

* add tsuiso test

* fix typo

* add test-shosushi

* add test-daisushi

* add ryuiso-test

* add chinroto-test

* add sukantsu-test

* add kokushi-13-test
* fix typo

* add letter-tiles tests

* add ippatsu test

* add tanyao and pinfu test

* fix ippatsu test

* add wind tests

* add iipeko and chitoitsu test

* add sanshoku-doujunn sanshoku-doo ittsu junchan tests

* add toitoi sananko test

* add ryanpeko test

* add honroto sankantsu honitsu chintisu tests

* add shosangen test
@syuilo
Copy link
Member Author

syuilo commented Feb 20, 2024

40%くらい終わってる

@syuilo
Copy link
Member Author

syuilo commented Jul 14, 2024

四風連打とか今までなったことないし存在を知らなかった

@tai-cha
Copy link
Contributor

tai-cha commented Jul 15, 2024

なんとなく今の進捗を見てて気づいたけど東風戦、半荘戦の区別がまだない?

あと3人麻雀というのもあるわね

@syuilo
Copy link
Member Author

syuilo commented Jul 15, 2024

東風戦、半荘戦の区別がまだない?

無いわね

あと3人麻雀というのもあるわね

好き

@tai-cha
Copy link
Contributor

tai-cha commented Jul 15, 2024

3麻に対応する予定があるならuser4はnullの可能性を考慮する必要がありそう(当分先だろうけど)

takejohn and others added 3 commits July 25, 2024 17:09
* ビルドによる自動的なソース更新

* 麻雀関連のキーバリューペアを追加

* 役の定義をまとめてエクスポート

* タイポ修正

* Revert "麻雀関連のキーバリューペアを追加"

This reverts commit c349cdf.

* misskey-jsのビルドによる自動更新
* ビルドによる自動的なソース更新

* 麻雀関連のキーバリューペアを追加

* 役の定義をまとめてエクスポート

* タイポ修正

* Revert "麻雀関連のキーバリューペアを追加"

This reverts commit c349cdf.

* misskey-jsのビルドによる自動更新

* 型エラーに対処

* riichiがtrueの場合に門前であるかを確認

* EnvForCalcYakuのhouseプロパティを廃止

* 風牌の役の共通部分をクラスで定義

* タイポ修正

* 役牌をクラスで共通化

* 一盃口と二盃口のテストを通す

* 一盃口・二盃口判定関数の調整

* 一気通貫の判定にチーによる順子も考慮する

* 混全帯幺九の実装

* 純全帯幺九の実装

* 七対子の実装とテストの修正

* tsumoTileまたはronTileを必須に

* 待ちを確認して平和の判定を可能に

* 三暗刻と四暗刻、四暗刻単騎の実装

* 四暗刻であるために通常の役を判定できない牌姿のテストを修正

* 混老頭と清老頭を実装

* 三槓子と四槓子を実装

* 平和の実装とテストを修正

* 小三元のテストを修正

* 国士無双に対子の確認を追加

* 国士無双十三面待ちを実装し、テストを修正

* 一部の役の七対子形を認め、テストを追加

* 手牌の数を確認

* 役の定義をカプセル化して型エラーの対処

* ツモ・ロンの判定を修正

* calcYakusの引数のhandTilesを修正

* calcYakusに渡す風をseatWindに修正

* 嶺上開花の実装

* 海底摸月の実装

* FourMentsuOneJyantouWithWait型の作成

* 河底撈魚の実装

* ダブル立直の実装

* 天和・地和の実装

* エンジンのテストを作成

* エンジンによる地和のテストを追加

* 嶺上開花のテスト

* ライセンスの記述を追加

* ダブル立直一発ツモのテスト

* ダブル立直海底ツモのテスト

* ダブル立直河底のテスト

* 役満も処理できるように

* 点数のテスト

* 打牌時にrinshanFlags[house]をfalseに

* 七対子形の字一色を認める

* typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages/backend Server side specific issue/PR packages/frontend Client side specific issue/PR packages/misskey-js
Projects
None yet
Development

Successfully merging this pull request may close these issues.

麻雀
5 participants