-
Notifications
You must be signed in to change notification settings - Fork 7
/
api.proto
115 lines (85 loc) · 3.17 KB
/
api.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package CodeBattle.Api;
import "marine.proto";
// Error Code
//
// 10 - Invalid Message
// 11 - Not Supported Command (such as you send `createmarine` command)
// 12 - You have already create a room [NOT FOR AI]
// 13 - You have already join a room
// 14 - Can not found the room which you wanna join in
// 15 - The room has no place to join in
// 16 - You can't create marine before create/join a room [NOT IN USE]
// 17 - Create marine NOT in your create/join room [NOT IN USE]
// 18 - Create marine limits [NOT IN USE]
// 19 - Can not operate marine before join room
// 20 - Operate a marine which not belongs to you
// 21 - Operate a marine which already dead
// 22 - This marine's GunAttack in Cooldown
// 23 - This marine's Flares were run out
// 24 - Operate marine, targetPosition out of map's size
// 25 - Operate marine before startbattle
enum CmdEnum {
joinroom = 1;
createmarine = 2; // This command NOT in use right now.
marineoperate = 3;
}
enum MessageEnum {
cmdresponse = 0;
senceupdate = 1;
startbattle = 2; // you can not operate your marine before recevie startbattle message
endbattle = 3;
}
// You send this `Cmd` to Server
message Cmd {
required CmdEnum cmd = 1;
optional JoinRoom jrm = 2;
optional CreateMarine cme = 3;
optional MarineOperate opt = 4;
}
// And got `Message` back from Server
message Message {
required MessageEnum msg = 1;
optional CmdResponse response = 2;
optional SenceUpdate update = 3;
optional EndBattle endbattle = 4;
}
message JoinRoom {
required int32 roomid = 1;
optional string color = 2; // your marine color, default is red
}
message JoinRoomResponse {
required int32 id = 1; // room id
required Vector2Int size = 2; // map size, (x, z)
repeated Marine marines = 3; // your marines, created automatic when you join room.
}
// this command not in use
message CreateMarine {
required int32 roomid = 1; // you MUST create/join room first
// and you will got a roomid.
required Vector2 position = 2; // your marine birth point (MUST in the map area).
}
message CreateMarineResponse {
required Marine marine = 1; // your marine
}
message MarineOperate {
required int32 id = 1; // marine id
required Status status = 2; // new status
optional Vector2 targetPostion = 3; // ONLY need this when status is Run or GunAttack
}
// `CmdResponse` NOT contains a message such as `MarineOperateResponse`.
// Due to all marines state changes will notify you via `SenceUpdate`
message CmdResponse {
required int32 ret = 1; // 0 for success, others see top of this file.
optional CmdEnum cmd = 2; // what cmd response for
optional JoinRoomResponse jrmResponse = 3;
optional CreateMarineResponse cmeResponse = 4;
}
// `SenceUpdate` only contains Marine so far.
message SenceUpdate {
repeated Marine own = 1;
repeated Marine others = 2;
}
message EndBattle {
required string reason = 1;
required bool win = 2;
}