refactor(chess): 重构象棋程序基础结构,使用Nullable重构核心代码

- 更新了多个文件的代码结构和类型定义,提高了代码的健壮性和可维护性
- 优化了事件处理、棋子管理和移动逻辑,为后续功能扩展打下坚实基础
- 修复了一些潜在的空指针异常问题,提高了程序的稳定性
- 修复部分bug
This commit is contained in:
ZZY
2024-11-22 23:51:32 +08:00
parent 9c619784af
commit 327c2df94d
19 changed files with 307 additions and 117 deletions

View File

@ -4,20 +4,21 @@ using Godot.Collections;
namespace RPPackage {
public class RPMessage
{
public string Type { get; set; }
public string Cmd { get; set; }
public Dictionary Data { get; set; }
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 string? Uid { get; set; }
public string? Token { get; set; }
public string? Code { get; set; }
public Dictionary ToDictionary()
{
var dict = new Dictionary();
if (Type != null)
dict.Add("type", Type);
if (Cmd != null)
dict.Add("cmd", Cmd);
var dict = new Dictionary {
// if (Type != null)
{ "type", Type },
// if (Cmd != null)
{ "cmd", Cmd }
};
if (Data != null)
dict.Add("data", Data);