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 65 commits into
base: develop
Choose a base branch
from
Draft

feat: 麻雀 #13112

wants to merge 65 commits into from

Conversation

syuilo
Copy link
Member

@syuilo syuilo commented Jan 30, 2024

What

#1876

Why

Resolve #1876

Additional info (optional)

TODO

  • 各種役
  • 流し満貫
  • 四風連打

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
@@ -76072,6 +76072,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": {
@@ -81224,6 +81682,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 40.60150% with 948 lines in your changes missing coverage. Please review.

Project coverage is 66.24%. Comparing base (a6edd50) to head (4597d5d).

Files Patch % Lines
packages/backend/src/core/MahjongService.ts 24.79% 538 Missing and 14 partials ⚠️
...end/src/server/api/stream/channels/mahjong-room.ts 8.12% 179 Missing and 2 partials ⚠️
.../backend/src/server/api/endpoints/mahjong/games.ts 0.00% 63 Missing and 1 partial ⚠️
...backend/src/server/api/endpoints/mahjong/verify.ts 0.00% 63 Missing and 1 partial ⚠️
...d/src/server/api/endpoints/mahjong/cancel-match.ts 0.00% 43 Missing and 1 partial ⚠️
...kend/src/server/api/endpoints/mahjong/join-room.ts 71.42% 15 Missing and 1 partial ⚠️
...kend/src/server/api/endpoints/mahjong/show-room.ts 74.07% 13 Missing and 1 partial ⚠️
...nd/src/server/api/endpoints/mahjong/create-room.ts 79.54% 8 Missing and 1 partial ⚠️
packages/backend/src/core/GlobalEventService.ts 96.42% 2 Missing ⚠️
...s/backend/src/server/api/stream/ChannelsService.ts 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #13112      +/-   ##
===========================================
+ Coverage    61.94%   66.24%   +4.29%     
===========================================
  Files         1004     1016      +12     
  Lines       115259   121460    +6201     
  Branches      4594     5650    +1056     
===========================================
+ Hits         71399    80459    +9060     
+ Misses       43828    39539    -4289     
- Partials        32     1462    +1430     

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

syuilo and others added 21 commits February 5, 2024 10:58
* 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
Member

tai-cha commented Jul 15, 2024

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

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

@syuilo
Copy link
Member Author

syuilo commented Jul 15, 2024

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

無いわね

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

好き

@tai-cha
Copy link
Member

tai-cha commented Jul 15, 2024

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

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

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

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

* タイポ修正

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

This reverts commit c349cdf.

* misskey-jsのビルドによる自動更新
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