依重要程度排序(分工)
===
:::danger
核心功能
:::
- 忘記密碼
- 用戶登入~~(+載入玩家服裝、技能、xp、變數要宣告哪些~~
- token
- ~~抽卡(包含伺服器驗證~~
- 用戶註冊
:::warning
重要功能
:::
- 換裝系統
- 用戶設定儲存(修改設定時觸發
- 玩家統計數據(場數、勝率等等
- 背包賣出系統
- 升級系統
- 成就系統
:::info
加分功能
:::
- 錯誤回報(傳訊息給開發者
- 檢查更新(沒更新不給玩
- 通知功能(更新內容等等
- 優惠代碼
_____________
討論結果
===
### 9/19
- PM:所有現有提出功能先盡量寫,大致寫出實作邏輯,不需要寫出程式
交出去的規格書依詳細、重要程度再決定要不要報告
- 設計UI部分除了 input 和 output,要稍微幫忙,例如畫面安排、動畫顯示
- 寫出給伺服器的 input 和 output 就好
### 9/21
+ 9/20開會加入的要求:
- 背包:賣出卡牌換金幣
+ 升級系統:相同卡牌可以合併升級
+ 成就系統:
- 有功能的成就:E.g. 新手玩家
- 沒功能的成就:E.g. 革命家
+ 決定資料庫儲存方式?
+ 還有哪些資料要加入資料庫中,資料庫的設計方式?
+ 用戶識別token怎麼發布、儲存
+ 9/21 上課老師的建議:
+ 是否要加入不同登入方式 (e.g., Google, Meta)
+ (行動應用資安聯盟--檢測項目):功能要滿足要求
:::success
:mega: 開會結果
Before 2023/9/24 (Sun) :
- 決定 Database 要存放的項目 (e.g., user_name)
- 決定 Database 項目的類型 (e.g., user_name -> type : string)
- 決定 Database 的設計架構
- (需要和外部討論確定) 用哪一種 Database 、 後端語言
Before 2023/9/26 (Tue) :
- 美化自己原本負責的部份
- 流程圖要包含 成功 / 失敗 的處理方式或輸出
- 加入 9/20 新增的重要功能:
- 胡竣棋 => 升級系統
- 林春輝、許鳳芹 => 成就系統
- 小松崎祐司 => 背包賣出系統
:::
抽籤結果
===
胡竣棋
---
### 技能升級系統
想法:在資料庫中,用低等級的 skill 換高等級的 skill
(e.g., Skill_1_Lv1 numbers:3->1; Skill1_Lv2 numbers:0->1)
```mermaid
sequenceDiagram
participant UI
participant Upgrade System
participant Server
UI->>UI: 選擇想要升級的卡牌
UI->>Upgrade System: 發出升級請求
Upgrade System->>Upgrade System: 檢查內部變數是否符合條件
note left of Upgrade System: 特定 Skills 數目不足,無法升級
Upgrade System-->>UI: Fail: Not enough skills for upgrade
note left of Upgrade System: 特定 Skills 不可以升級
Upgrade System-->>UI: Fail: This skills can NOT upgrade
note right of Upgrade System: 符合升級條件
Upgrade System->>Server: 傳送要用戶升級的資訊
Server->>Server: 檢查資料庫中玩家特定技能數量
note left of Server: 特定技能數量不足
Server-->>UI: Fail: NOT enough numbers of certain skills
note right of Server: 特定技能數量正確
Server->>Server: 將資料庫中舊技能的數目扣除
Server->>Server: 將資料庫中新技能的數目增加
Server->>Upgrade System: 傳送用戶目前擁有的道具變數
Upgrade System->>Upgrade System: 更新遊戲內道具變數
Upgrade System->>UI: Success / new skill = skill_id
```
- 升級系統 - UI Input
- skill_id:想要升級的技能id
- HandleLoginResult:回調函數
- 升級系統 - UI Output
- Status:動作結果 (Fail/Success)
- new_skill: 新獲得skill的skill_id (If status = Success)
- 升級系統 - Server Input
- Token:用戶Token
- Upgrade_Skill_ID:用戶想要升級的卡片ID
- 升級系統 - Server Output
- Status:Success / Fail , Reasons
- Skill_Data:更新過後的Player skill data
---
### 用戶登入
```mermaid
sequenceDiagram
participant UI
participant LoginManerger
participant Server
UI->>UI : 輸入帳號、密碼
UI->>LoginManerger : 點擊登入按鈕
LoginManerger->>LoginManerger : 檢查連線狀況
note left of LoginManerger: 沒有連線到網路
LoginManerger-->>UI: Status:Poor Network
note right of LoginManerger: 有連線到網路
LoginManerger->>LoginManerger: 檢查帳號密碼輸入是否合法
note left of LoginManerger: 帳號密碼不合法
LoginManerger-->>UI: Status: Invalid Password or Account
LoginManerger-->>UI: Status: Invalid Account
note right of LoginManerger: 帳號密碼合法
LoginManerger->>Server: 傳送帳號、密碼
Server->>Server: 檢查帳號、密碼格式與內容
note left of Server: 格式不合法
Server-->>UI: Status: Invalid Input
note right of Server: 格式合法
Server->>Server: 帳號、密碼 hash 處理
Server->>Server: 資料庫驗證帳號密碼
note left of Server: 登入失敗
Server-->>UI: Status: Wrong Password or Account
note right of Server: 登入成功
Server->>Server: 產生用戶識別 Token
Server->>Server: 紀錄 Tokne 於 Database
Server->>LoginManerger: Status: Success / Token = ...
LoginManerger->>LoginManerger: 紀錄玩家取得的 Token
LoginManerger-->>UI: Status: Success
```
- 用戶登入 - UI Input
- account:用戶帳號
- password:用戶密碼
- HandleLoginResult:回調函數
- 用戶登入 - UI Output
- Status:登入結果
- Token:(登入成功) 用戶識別token
- 用戶登入 - Server Input
- account:用戶帳號
- password:用戶密碼
- 用戶登入 - Server Output
- Status:登入結果
- Token:(登入成功) 用戶識別token
---
### 換裝系統--換造型
```mermaid
sequenceDiagram
participant UI
participant EquipmentManerger
participant Server
UI->>UI: 選擇想要更換的造型
UI->>EquipmentManerger: 按下更換造型按鈕
EquipmentManerger->>EquipmentManerger: 檢查內部變數是否符合條件
note left of EquipmentManerger: 使用者沒有此造型,無法裝備
EquipmentManerger-->>UI: Fail: User do NOT have this Item.
note right of EquipmentManerger: 使用者有此造型
EquipmentManerger->>Server: 檢查使用者是否擁有造型
Server->>Server: 資料庫數據比對
note left of Server: 使用者沒有此造型,無法裝備
Server-->>UI: Fail: User do NOT have this Item.
note right of Server: 使用者有此造型
Server->>Server: 資料庫儲存使用者目前使用的造型
Server->>EquipmentManerger: Success: User do have this Item
EquipmentManerger->>EquipmentManerger: 更改裝備造型變數
EquipmentManerger->>UI: Success
```
```EquipmentManerger.change_card_style``` --- 用來換造型
- **UI Input**
- Style_Id:造型辨識碼
- Result:回調函數
- **UI Output**
- Status:是否成功更換造型 (Success / Fail)
- **Server Input**
- Token:用戶識別token
- Style_Id:造型辨識碼
- **Server Output**
- Result:玩家是否成功更換造型
- **內部**
- 修改”玩家目前使用造型“ 的變數
---
### 換裝系統--換技能
``EquipmentManerger.change_skills``--- 用來換攜帶技能
```mermaid
sequenceDiagram
participant UI
participant EquipmentManerger
participant Server
UI->>UI: 選擇想要更換的技能
UI->>EquipmentManerger: 按下更換技能按鈕
EquipmentManerger->>EquipmentManerger: 檢查內部變數是否符合條件
note left of EquipmentManerger: 使用者沒有此技能,無法裝備
EquipmentManerger-->>UI: Fail: User do NOT have this Item.
note right of EquipmentManerger: 使用者有此技能
EquipmentManerger->>Server: 檢查使用者是否擁有技能
Server->>Server: 資料庫數據比對
note left of Server: 使用者沒有此技能,無法裝備
Server-->>UI: Fail: User do NOT have this Item.
note right of Server: 使用者有此技能
Server->>Server: 資料庫儲存使用者目前使用的技能
Server->>EquipmentManerger: Success: User do have this Item
EquipmentManerger->>EquipmentManerger: 更改裝備技能變數
EquipmentManerger->>UI: Success
```
```EquipmentManerger.change_card_style``` --- 用來換技能
- **UI Input**
- Style_Id:技能辨識碼
- Result:回調函數
- **UI Output**
- Status:是否成功更換技能 (Success / Fail)
- **Server Input**
- Token:用戶識別token
- Style_Id:技能辨識碼
- **Server Output**
- Result:玩家是否成功更換技能
- **內部**
- 修改”玩家目前使用技能“ 的變數
---
林春輝
--
- 忘記密碼
```mermaid
sequenceDiagram
participant 前端
participant APP
participant Server
前端->>前端: 輸入username和email
前端->>APP: 按忘記密碼按鈕,送出username和email
APP->>APP: 檢查username和email輸入是否合法
alt 輸入不合法
APP-->>前端: 輸入不合法,改密碼失敗!
else 輸入合法
APP->>Server: 輸入合法,送出username和email
Server->>Server: 搜尋username
alt 找不到username
Server-->>前端: 忘記密碼失敗
else 找得到username
Server->>Server: 檢查user輸入的email與資料庫裏記錄的userEmail是否相等
alt 不相等
Server-->>Server: 改密碼失敗
else 相等
Server->>Server: 發驗證碼到user的email
alt 驗證失敗
APP-->>前端: 驗證失敗,忘記密碼失敗
else 驗證成功
APP->>前端: 驗證成功
前端->>前端: 輸入新的密碼
前端->>前端: 輸入確認新密碼
前端->>APP: 送出新密碼和確認新密碼
APP->>APP: 檢查新密碼是否跟確認新密碼相等
alt 新密碼和確認密碼不相等
APP-->>前端: 新密碼!=確認新密碼,改密碼失敗
else 新密碼和確認密碼相等
APP->>APP: 檢查密碼輸入是否合法
alt 新密碼輸入不合法
APP-->>前端: 密碼不合法,改密碼失敗
else 新密碼輸入合法
APP->>Server: 送出新密碼
Server->>Server: 新密碼hash處理,存新密碼
Server->>前端: 改密碼成功
end
end
end
end
end
end
```
**前端使用方法:**
Input: username, 新密碼,確認新密碼
Output: 是否成功改密碼
**Server需要的功能:**
Input: username, 新密碼
Output: username是否存在,email, 是否成功改密碼
- 玩家統計數據
玩家升級系統
```mermaid
sequenceDiagram
participant 前端
participant APP
participant Server
APP->>APP: 檢查token是否還有效
alt token已過期
APP-->>前端: 請從新登入
else token還有效
APP->>Server: 送出user's token
Server->>APP: 送出user目前的等級,exp,total match played, total match won
APP->>APP: total match played++
opt 勝者
APP->>APP: total match won++
APP->>Server: 送出新的total match won
Server->>Server: 更新total match won記錄
Server->>Server: user金幣增加
end
APP->>APP: exp+=游戲結束後所得的exp
APP->>APP: 判斷user有沒有升級
opt 有升級
APP->>前端: 送出升級的通知
APP->>Server: 送出新的等級
Server->>Server: 更新等級記錄
end
APP->>Server: 送出新的exp,total match played
Server->>Server: 更新exp, total match played記錄
end
```
**前端使用方法:**
(若有升級)Output: 升級通知
**Server需要的功能:**
Input: user's token
Output: user的等級, exp, total match played, total match won
更新數據
顯示玩家統計數據
```mermaid
sequenceDiagram
participant 前端
participant APP
participant Server
APP->>APP: 檢查token是否還有效
alt token已過期
APP-->>前端: 請從新登入
else token還有效
APP->>Server: 送出user's token
Server->>Server: 搜尋token
Server->>APP: 送出等級,排名,total match played, total match won
APP->>APP: 計算勝率
APP->>前端: 送出等級,排名,total match played, total match won, 勝率
end
```
**前端使用方法:**
Output: user的數據
**Server需要的功能:**
Input: user's token
Output: user是否存在,user的數據
---
許鳳芹
--
用戶註冊
```mermaid
sequenceDiagram
participant front end
participant signUp manager
participant Server
front end->>front end: enter username,pass,email
front end->>signUp manager: signUp button clicked
signUp manager->>Server: send username,email,password
Server->>Server: check account eligibity
Note right of Server: go through database<br/>to check duplicates
Note over Server: check username & email
opt if not eligible
Server-->>front end: send sign Up failed notification
Note over signUp manager,Server: case 1: Username is already used<br/>case 2: email is already registered<br/>case 3: password too short
end
Server->>Server: generate & send verification code to user email
Note over front end: user receive verification<br/>code from email
front end->>front end: enter verification code
front end->>signUp manager: confirm verification code
signUp manager->>Server: send verification code
Server->>Server: check verification code
alt if verCode wrong
Server-->>front end: code doesnt match notification
else if verCode right
Server->>Server: username & password hashing
Server->>Server: add account to the database
Server->>Server: generate user identification token
end
Server->>signUp manager: (sign up succesfull) notification
Server->>signUp manager: send user identification token
signUp manager->>signUp manager: record player token
signUp manager-->>front end: return sign Up result
```
**front end**
Input :
- user email
- username
- password
(user will receive a verification code through email)
Output :
- registration status (username has been used, email is already registered, password too short)
- sign up status : success -> logged in (with token)
**Server**
Input :
- user email
- username
- password
(server will sent a verification code to verify email)
Output :
- account verification code
- account identification token
- status : sign up successfull
### 成就系統
```mermaid
sequenceDiagram
participant 前端
participant APP
participant Server
APP->>APP: 檢查token是否還有效
alt token已過期
APP-->>前端: 請從新登入
else token還有效
APP->>Server: 送出user's token
Server->>Server: 搜尋user's token
Server->>APP: 送出user所得的成就名單
APP->>APP: 成就分類
note over APP: 1. 有功能:協助遊戲進行<br/>ex: 新手玩家 ( 配對機制友善 )<br/>2. 無功能:增加遊戲趣味姓<br/>ex: 革命家 ( 連續三場以平民打敗王 )<br/>3. 顯示於玩家資料
APP->>前端: 送出結果
end
```
---
小松崎祐司
--
### 抽卡
#### 流程
```mermaid
sequenceDiagram
participant UI
participant APP
participant Server
UI->>APP : 按抽卡
APP->>Server: 傳送帳號,等級,抽卡分類
Server->>Server: 按照抽卡的分類進行抽卡(服裝,卡片,技能等)
Server->>Server: 執行抽卡
note right of Server: 若需檢查(是否抽到不可以重複擁有的事物)
Server->>Server: 儲存抽到的事物和其數量
Server->>APP: 傳送抽到的事物與數量
APP->>UI : 顯示抽到的事物
```
#### 輸入
- **APP** 按抽卡
- **Server** 帳號,等級,抽卡分類(AccountId, Class, LotteryType)
#### 輸出
- **Server** 抽到的事物,數量
- **APP** 抽到的事物,數量,特效?
### 用戶設定儲存
背景音樂、音量、背景主題等等用戶偏好設定的儲存
#### 更改名字(nickname)
#### 輸入
- **UI** 新的名字
- **APP** 帳號,新的名字
#### 輸出
- **Server** 通知儲存成功
```mermaid
sequenceDiagram
participant UI
participant APP
participant Server
UI->>UI : 按更改名字
UI->>UI : 輸入新的名字
note right of UI: 檢查不可以使用的字
UI->>APP : 檢證過的新的名字
APP->>Server: 傳送帳號,新的名字
Server->>Server: 儲存新的名字
Server->>APP: 通知儲存成功
Server-->>APP: 通知儲存失敗
APP->>UI : 顯示新的名字
APP-->>UI : 顯示錯誤訊息
```
#### 更改背景音樂(background music)
```mermaid
sequenceDiagram
participant UI
participant APP
UI->>UI : 按背景音樂
UI->>APP : 音量分類ID
APP->>APP: 更改播放背景音樂ID
APP->>UI : 播放
```
#### 調整音量(system volume, Voice volume, etc)
```mermaid
sequenceDiagram
participant UI
participant APP
UI->>UI : 按調整音量
UI->>APP : 音量分類ID,數值
APP->>APP: 更改音量變數的數值
APP->>UI : 播放
```
#### 更改背景主題(background theme)
```mermaid
sequenceDiagram
participant UI
participant APP
UI->>UI : 按背景主題
UI->>APP : 背景主題ID
APP->>APP: 更改背景主題ID
APP->>UI : 換背景主題
```
#### 背包賣出系統(item trade)
該功能可將背包裡的物品兌換成虛擬金幣
```mermaid
sequenceDiagram
participant UI
participant APP
participant Server
UI->>UI : 按背包賣出
UI->>APP : 選擇物品和數量
APP->>APP: 計算每個物品的價值
APP->>UI: 顯示總價值
UI->>APP: 確定
APP->>Server: 傳送帳號,物品,數量
Server->>Server: 計算&兌換
Server->>Server: 更改該帳號的物品數量和金幣資訊
Server->>APP: 通知成功
Server-->>APP: 通知失敗
APP->>UI : 顯示兌換的金幣
APP-->>UI : 顯示錯誤訊息
```
### DATABASE設計
ER diagram
變數型的部分因為還沒確定變數的大小,所以只有int型。
字串的部分也一樣,所以我先統一用varchar型。
還有關於intermediate table的primary key,我統一用一個primary key的id。沒有使用composite primary key的概念(比如說account_items table的account_id和item_id設定為PK,用這兩個attribute來特定某一個record)。
```mermaid
erDiagram
account ||--o{ account_card_styles : ""
account ||--o{ account_skills : ""
account ||--o{ account_items : ""
account ||--o{ account_achievement : ""
account ||--o{ account_data: ""
account_card_styles }o--|| card_style : ""
account_skills }o--|| skill : ""
account_items }o--|| item : ""
account_achievement }o--|| achievement : ""
account{
int id PK "Player ID"
varchar name
varchar email
varchar password
varchar token_id "UniqueKey"
int token_validity
varchar game_title
int class
int coin
}
account_card_styles{
int id PK
int account_id FK
int card_style_id FK
}
card_style{
int id PK
int name
}
account_skills{
int id PK
int account_id FK
int skill_id FK
}
skill {
int id PK
varchar name
varchar description
}
item {
int id PK
varchar name
varchar description
}
account_items{
int id PK
int account_id FK
int item_id FK
int quantity
}
account_achievement{
int id PK
int account_id FK
int achievement_id FK
}
achievement{
int id PK
varchar achievement_name
varchar achievement_description
}
account_data{
int account_id FK
int level
int experience
varchar rank
int total_match
int total_win
}
```
DB 討論區
===
目前先在下面列出希望加入資料庫的資料
再麻煩 @小松崎祐司 看看能不能幫我們加到 ER diagram 中!
#### 背包功能需要存放的資料
- account Table
- 主鍵 (PK):Player_ID (Int)
- 其他玩家相關資訊...
- Items Table
- 主鍵 (PK):Item_ID (Int)
- 道具名稱:Item_Name (String)
- 道具描述:Item_Description (String)
- PlayerItems Table
- 外鍵1 (FK):Player ID (Int)
- 外鍵2 (FK):Item ID (Int)
- 道具數量:Quantity (Int)
- Skills Table
- 主鍵 (PK):Skill_ID (Int)
- 道具名稱:Skill_Name (String)
- 道具描述:Skill_Description (String)
- PlayerSkills Table
- 外鍵1 (FK):Player ID (Int)
- 外鍵2 (FK):Skill ID (Int)
- 道具數量:Quantity (Int) <- skill(技能)也有數量嗎?