Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 90 additions & 40 deletions dependency/proto/Message2Clients.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,36 @@ message MessageOfCharacter
CharacterState character_active_state = 5;

// 位置
int32 x = 17;
int32 y = 18;
int32 x = 6;
int32 y = 7;

double facing_direction = 19;
int32 speed = 20;
int32 view_range = 21;
double facing_direction = 8;
int32 speed = 9;
int32 view_range = 10;

int32 common_attack = 22;
int64 common_attack_cd = 23;
int32 common_attack_range = 24;
int32 common_attack = 11;
int64 common_attack_cd = 12;
int32 common_attack_range = 13;

int32 hp = 28;
int32 hp = 14;

int32 carry_capacity = 15; // 负重上限,产品数量为单位
int32 current_load = 16; // 当前负重
int32 harvest_rate_per_sec = 17; // 每秒采集量
}


message MessageOfMaterialResource
{
MaterialResourceState material_resource_state = 2;

int32 x = 3;
int32 y = 4;
MaterialResourceState material_resource_state = 1;

int32 process = 5; // 采集进度 等价于血量
int32 x = 2;
int32 y = 3;

int32 id = 6;
int32 remaining_amount = 4; // 采集进度 等价于血量

int32 id = 5;
int32 max_amount = 6;
}

message MessageOfMap
Expand All @@ -65,49 +69,95 @@ message MessageOfTeam
// int64 guid=5;
}

message MessageOfFactory
{
int64 factory_id = 1;
int64 team_id = 2;
int32 x = 3;
int32 y = 4;
int32 hp = 5;
message ProductStack
{
int32 product_type = 1;
int32 quantity = 2;
}
repeated ProductStack product_inventory = 6; //
int32 producing_line_count = 7; // 生产线数量
}

message MessageOfMarket
{
int64 market_id = 1;
int32 x = 2;
int32 y = 3;
bool high_value = 4; // 是否为高额市场
message PriceEntry
{
ProductType product_type = 1;
int32 price = 2;
}
repeated PriceEntry price_list = 5;
}

message MessageOfComputeCenter
{
int64 center_id = 1;
int32 x = 2;
int32 y = 3;
int64 owner_team_id = 4; // 0表示无人占领
int32 occupy_progress = 5; // 占领进度
}

message MessageOfObj
{
oneof message_of_obj
{
MessageOfCharacter character_message = 1;
MessageOfMaterialResource material_resource_message= 6;
MessageOfMap map_message = 8;
MessageOfNews news_message = 9;
MessageOfTeam team_message = 10;
MessageOfMaterialResource material_resource_message= 2;
MessageOfMap map_message = 3;
MessageOfNews news_message = 4;
MessageOfTeam team_message = 5;
MessageOfFactory factory_message = 6;
MessageOfMarket market_message = 7;
MessageOfComputeCenter compute_center_message = 8;
MessageOfAIEvent ai_event_message = 9; //服务器推送的AI事件/建议
}
}

message MessageOfAll
// 智慧大脑事件
message MessageOfAIEvent
{
int32 game_time = 1;

int32 team1_score=2;
int32 team2_score=3;
int32 team3_score=3;
int32 team4_score=3;
int64 team_id = 1;
int64 from_character_id = 2; // 触发来源(可选)
AIEventType event_type = 3; // 事件类型
string description = 4; // 人类可读说明
string plan_json = 5; // 结构化计划(JSON),客户端可以解析执行
int64 timestamp_ms = 6; // 事件触发时间(ms),便于回放
int64 event_id = 7; // 事件id, 便于追踪
}

int32 team1_material = 4;
int32 team2_material = 4;
int32 team3_material = 4;
int32 team4_material = 4;
message MessageOfAll
{
int32 game_time = 1;

int32 team1_computing_power = 5;
int32 team2_computing_power = 5;
int32 team3_computing_power = 5;
int32 team4_computing_power = 5;
message TeamInfo {
int32 score = 1;
int32 material = 2;
int32 computing_power = 3;
int32 factory_hp = 4;
}

int32 team1_factory_hp = 6;
int32 team2_factory_hp = 6;
int32 team3_factory_hp = 6;
int32 team4_factory_hp = 6;
repeated TeamInfo teams = 2; // teams[0] 对应 team1,teams[1] 对应 team2 ...
}

}

message MessageToClient
{
repeated MessageOfObj obj_message = 1;
GameState game_state = 2;
MessageOfAll all_message = 3;
protobuf.GameMode game_mode = 3;
MessageOfAll all_message = 4;
// MessageGameConfig config = 5; // 可用于下发对局参数
}

message MoveRes // 如果打算设计撞墙保留平行速度分量,且需要返回值则可用这个(大概没啥用)
Expand Down
68 changes: 52 additions & 16 deletions dependency/proto/Message2Server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,37 @@ message IDMsg
{
int64 character_id = 1;
int64 team_id = 2;
protobuf.GameMode mode = 3; // 客户端发起连接/请求时声明希望的游戏模式
}

/*
message CharacterMsg

message RegisterFactoryMsg
{
int64 character_id = 1;
int64 player_id = 1;
int64 team_id = 2;
CharacterType character_type = 3;
int32 side_flag = 4;
protobuf.GameMode mode = 3;
int32 preferred_spawn_index = 4; // 客户端希望的出生点索引(0表示不指定,由服务器分配)
int32 side_flag = 5; // 客户端希望的阵营标识
}
*/

message CreatCharacterMsg
{
CharacterType character_type = 1;
int64 team_id = 2;
int32 birthpoint_index = 3;
protobuf.GameMode mode = 4; // 创建角色时可以指明模式
}


message MaterialResourceMsg
{
int64 character_id = 1;
int64 team_id = 1;
int32 process = 2;
MaterialResourceType material_resource_type = 3;
int64 team_id = 2;
int64 resource_id = 3;
int32 target_x = 4; // 目标坐标,或许可用
int32 target_y = 5;
int32 amount = 6; // 采集数量
//HarvestAction action = 7; // 采集动作类型
}

message MoveMsg
Expand Down Expand Up @@ -80,13 +93,6 @@ message RepairFactory
int32 team_id = 2;
}

message CreatCharacterMsg
{
CharacterType character_type = 1;
int64 team_id = 2;
int32 birthpoint_index = 3;
}

message ProduceProductMeg
{
ProductType product_type = 1;
Expand Down Expand Up @@ -116,4 +122,34 @@ message SellMeg
int32 costume_num = 6;
int32 food_num = 7;
int32 marketindex = 8;
}


// 智慧大脑相关
message AskAIRequest
{
int64 team_id = 1;
int64 character_id = 2;
string model = 3; // 模型标识
string prompt = 4; // 自然语言提示
int32 timeout_ms = 5; // 超时时间
bool prefer_structured = 6; // 是否优先返回结构化计划
}

message AIAction
{
AIActionType type = 1;
int64 character_id = 2; // 执行者
string target = 3; // 目标说明
string payload_json = 4; // 额外参数(JSON)
int64 eta_ms = 5; // 建议在多少毫秒后执行
}

message AskAIResponse
{
bool act_success = 1;
string answer_text = 2; // 自然语言回答
string plan_json = 3; // 结构化计划(JSON),便于引擎解析执行
repeated AIAction actions = 4; // 可直接执行的动作列表(结构化)
string error_msg = 5; //
}
37 changes: 36 additions & 1 deletion dependency/proto/MessageType.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
syntax = "proto3";
package protobuf;

enum GameMode {
NULL_GAME_MODE = 0;
GAME_MODE_PVE = 1;
GAME_MODE_PVP = 2;
}


enum GameState //
{
NULL_GAME_STATE = 0;
Expand Down Expand Up @@ -79,6 +86,15 @@ enum MaterialResourceState //
BEING_HARVESTED = 2;
HARVESTED = 3;
}
/*
enum HarvestAction // 采集动作类型
{
NULL_HARVEST_ACTION = 0;
START_HARVEST = 1;
STOP_HARVEST = 2;
QUERY_HARVEST = 3; // 查询采集状态
}
*/

enum NewsType // 用于角色间通信?或许咱们需要
{
Expand All @@ -87,7 +103,7 @@ enum NewsType // 用于角色间通信?或许咱们需要
BINARY = 2;
}

cnum ProductType
enum ProductType
{
NULL_PRODUCT_TYPE = 0;

Expand All @@ -96,4 +112,23 @@ cnum ProductType
HANDIWORK = 3;
COSTUME = 4;
FOOD = 5;
}

enum AIEventType {
NULL_AI_EVENT = 0; // 默认值,未指定事件类型
AI_SUGGESTION = 1; // 推荐性建议
AI_EXPLANATION = 2; // 解释性信息
AI_ALERT = 3; // 警告,需要注意的紧急事件
}

enum AIActionType {
UNKNOWN = 0; // 未知或未定义动作
PRODUCE = 1;
HARVEST = 2;
MOVE = 3;
ATTACK = 4;
REPAIR = 5;
SELL = 6;
OCCUPY = 7;
CUSTOM = 100; // 自定义动作:使用 payload_json 等字段描述任意扩展动作
}
10 changes: 7 additions & 3 deletions dependency/proto/Services.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ service AvailableService
rpc TryConnection(IDMsg) returns (BoolRes);

// 游戏开局调用一次的服务
rpc AddCharacter(CharacterMsg) returns (stream MessageToClient); // 连接上后等待游戏开始,server会定时通过该服务向所有client发送消息
rpc RegisterFactory(RegisterFactoryMsg) returns (stream MessageToClient); // 连接上后等待游戏开始,server会定时通过该服务向所有client发送消息
rpc GetMap(NullRequest) returns (MessageOfMap);

// 游戏过程中普通角色执行操作的服务
Expand All @@ -25,7 +25,11 @@ service AvailableService
rpc Sell(SellMeg) returns (BoolRes); // 出售产品

// 游戏过程中核心角色(工厂)可以另外执行操作的服务
rpc CreatCharacter(CreatCharacterMsg) returns (BoolRes); // 创建角色
rpc CreatCharacter(CreatCharacterMsg) returns (BoolRes); // 创建角色
rpc CreatCharacterRID(CreatCharacterMsg) returns (CreatCharacterRes); // 获取角色编号
rpc EndAllAction(IDMsg) returns (BoolRes); // 结束所有动作
rpc EndAllAction(IDMsg) returns (BoolRes); // 结束所有动作

// 智慧大脑相关 RPC
rpc AskAI(AskAIRequest) returns (AskAIResponse); // 客户端请求AI建议
rpc AskAIStream(AskAIRequest) returns (stream AskAIResponse); // 客户端请求AI建议(流式响应)
}
Loading