owned this note
                
                
                     
                     owned this note
                
                
                     
                    
                
                
                     
                    
                
                
                     
                    
                        
                            
                            Published
                        
                        
                            
                                
                                Linked with GitHub
                            
                            
                                
                                
                            
                        
                     
                
            
            
                
                    
                    
                
                
                    
                
                
                
                    
                        
                    
                    
                    
                
                
                
                    
                
            
            
         
        
        # 2017 C++ 課程 project
###### tags: `PD2`
## Time (Game loop)
- 1/100 ~ 1/10
- Ping 50
## 打架
- 用 Log 檔做紀錄(對戰還原),限制時間內完成回應
- 同一組隊戰組合不重複
## Debug 方式
- (offline) 一個接收的 test server,接收後看使用者回復時間
- (online) GUI (for grading)
### Judge message at execution time
* Via stderr
* Choose 8 card
	* Success: `Card choose success`
	* Fail: `Card choose fail`
* Interact with server
	* Success: `Interact success`
	* Fail: `Interact fail`
* Finish normally
	* P1 process halted: `Player 1 fault`
	* P2 process halted: `Player 2 fault`
	* Normally finish will not produce message
* Result
	* P1 Win: `Player 1 win`
	* P2 Win: `Player 2 win`
	* Tie: `Tie`
### Judge System execute command
./forever start app.js -o out.log -e error.log
### Contact with Render server
- Battle Command
    - Request (http)
        - start: 由yee那邊的玩家選擇battle後重新導向至`http://<pathname>:<port>/game_start?p1=<player1>&p2=<player2>`
    - 而 battle command 內容採用的是 json 格式做傳輸,並且分為幾項:
        - 目前設定 pathname : `localhost` , port : `3001`
        - 進行中: `http://<pathname>:<port>/game_cmd?p1=<player1>&p2=<player2>&cmd=<content>`
        - 結束: `http://<pathname>:<port>/game_end?p1=<player1>&p2=<player2>` => 作為錄影結束
        - (最新): 改採用 post method 做 command delivery
    - 以下是內容的部分
        - (2/28) 更新 - 加入 buildings (Json Array)
        - (3/7) 
            - 需要額外加入結束時,雙方資訊;( render server 保存 )
            - 額外再 battle cmd 時,加入雙方目前現有的排組( 4 張 )
        - (3/19)
            - 結束時,使用 post method 傳送
            - 包含要顯示的資料 (winner),詳細補在下面欄位
            - (3/20 補充) 額外加上雙方塔數
        - (3/20)
            - 更新 cmd prototype,加入 **現在有哪四張卡** (current_hand_player) 
            - (考慮在前端實作紀錄哪八張卡,就不必多一個手續傳送)
```javascript=json
// content
var cmd_prototype = {
    'cmd': 'battle',
    'current_minion' : [
        {
            'belong': 'p1/p2'
            'name': 'orge1',
            'type': 'orge',
            'status': '50',
            'move': '2',
            'loc_x': '20',
            'loc_y': '10'
        }
    ] ,
    'new_minion': [
        {
            'belong': 'p1/p2'
            'name': 'orge1',
            'type': 'orge',
            'move': '1',
            'loc_x': '30',
            'loc_y': '10'
        }
    ] , 
    'buildings': [
        {
            'name': '誰的塔_塔的類型',
            'status': '加減損的量(一樣以百分比為單位)'
        }
    ] ,
    'current_hand_p1':[
        {
            'name': "<force>_<minion>"
        },
        ... (共四張)
    ] ,
    'current_hand_p2':[
        {
            'name': "<force>_<minion>"
        },
        ... (共四張)
    ] ,
    'current_time': 180,
    'current_mana_p1: 8,
    'current_mana_p2: 7
}
// End package (3/19)
var end_package = {
    'p1': p1name,
    'p2': p2name,
    'winner': winner_player,
    'p1_destroy': p1_destroy_tower_number,
    'p2_destroy': p2_destroy_tower_number
}
```
- cmd: (字串)指令,目前暫時都是 battle
- current_minion: (Json Object Array),儲存目前在戰場上的手下及其狀態
    - belong: 用來標記物件所屬玩家
    - name: 用來標記物件
    - type: 小兵的種類
    - status: 血量減少或是增加(有正有負),為百分比
    - move: 該物件目前行進的方向
        - 0: left
        - 1: right
        - 2: top
        - 3: down
        - 4: left+top
        - 5: left+down
        - 6: right+top
        - 7: right+down
        - 8: attack (left)
        - 9 (更正): attack (right)
        - 10(更正): stop (face right)
        - 11(更正): stop (face left)
    - loc_x , loc_y : x,y座標
        - x: 介於 0~50
        - y: 介於 0~20
        - 我這邊會做圖片上面的速度比例調整,直接給位置即可
        - 在 current 內部的位置資訊是用來做回復用的
- new_minion: (Json Object Array),為這次 tick 中新增進來的物件
    - 和 current minion 中屬性相同,status 去除
- buildings : (3/8 更新)
    - p1_top : p1 的上塔
    - p1_down : p1 的下塔
    - p1_main : p1 的中塔
    - p2_top : p2 的上塔
    - p2_down : p2 的下塔
    - p2_main : p2 的中塔
### 地圖
- 比例地圖:

    - 水平方向為 x
    - 垂直方向為 y
- 修正大小
    - 橋的 height 長度由 4 增長到 7
    - 位置由 
        - Top: (22,3) -> (22,2)
        - Down: (22,13) -> (22,11)
    - 增加和諧感
### 角色
(考慮到牌組自由搭配,所以覺得不需要每個種族都依照坦補打的規格)
- 人類
    - 坦 : 人類騎士,形象為重裝騎兵,偏好以歐洲的盔甲騎兵的形象為主(主流的正義形象+衝鋒陷陣的不屈之姿)
    - Decode : 1
    - Range : 3
        - 
        - 
    - 補 : 牧師、祭司的形象 (原本想採用和尚,但看起來有點像武僧) (已完成!)
    - Decode : 2
    - Range : 5
        - 
        - Q版
            - 
        - 
    - 打 : 人類火槍兵,採用明朝神機營的形象;抑或是女忍的遠(手裡劍)/近(武士刀)距離攻擊 (目前正在 working - 女槍手)
        - 
        - 
    - 盜賊 (已完工)
    - Decode : 3
    - Range : 3
        - 
        - 
- 精靈
    - 坦 : 石巨人的形象
    - Decode : 4
    - Range : 2
        - 
        - 
    - 補 : 以幽光的型態出現,為周圍的單位提供治療
    - Range : 4
        - 
        - 
    - 打 (弓手)簡單來說就是一般精靈女弓手
    - Range : 5
        - 已完成
        - 
        - 
- 矮人
    - 坦 : 主要以矮人王的形象,重武裝+石錘的硬漢
        - 
    - 補 : 矮人這邊沒有補,改以攻城器代替
    - Range : 2x
        - 
    - 打 : 採用迫擊砲班的形象,強調矮人的工藝
        - 
- 不死族
    - 坦 : 骷髏巨人 
    - 補 : 死亡法師,看是不是也沒有補師,成為AOE的法師
        - 
    - 打 : 死亡騎士,生命少於人類的騎士,但攻擊力高於人類騎士
        - 
### 建築物

