chinese_chess/Scripts/Lib/RPMessage.cs
ZZY 327c2df94d refactor(chess): 重构象棋程序基础结构,使用Nullable重构核心代码
- 更新了多个文件的代码结构和类型定义,提高了代码的健壮性和可维护性
- 优化了事件处理、棋子管理和移动逻辑,为后续功能扩展打下坚实基础
- 修复了一些潜在的空指针异常问题,提高了程序的稳定性
- 修复部分bug
2024-11-22 23:51:32 +08:00

34 lines
851 B
C#

using Godot;
using Godot.Collections;
namespace RPPackage {
public class RPMessage
{
public string Type { get; set; } = string.Empty;
public string Cmd { get; set; } = string.Empty;
public Dictionary? Data { get; set; }
public string? Uid { get; set; }
public string? Token { get; set; }
public string? Code { get; set; }
public Dictionary ToDictionary()
{
var dict = new Dictionary {
// if (Type != null)
{ "type", Type },
// if (Cmd != null)
{ "cmd", Cmd }
};
if (Data != null)
dict.Add("data", Data);
if (Uid != null)
dict.Add("uid", Uid);
if (Token != null)
dict.Add("token", Token);
if (Code != null)
dict.Add("code", Code);
return dict;
}
}
}