refactor(logic): 重构服务器启动逻辑与任务状态管理

- 移除了 `gcmd` 包在 controller 中的直接使用,改为通过参数传递端口和服务器类型
- 统一使用 `GetTask` 和 `SetTask` 方法替代直接访问 `TaskList` 数组,提升代码可维护性
- 修改了战斗逻辑中部分调试打印语句,并优化战斗循环结束日志输出
- 调整了新手玩家初始化流程,默认完成新手任务4
- 更新了数据库模型字段及结构定义,如增加 `max_ts` 字段、扩展 `TaskList` 长度等
- 改进了宠物添加逻辑,采用 SQL 方式确保捕捉时间唯一递增
- 清理了无用或注释掉的旧代码块
This commit is contained in:
2025-12-08 17:03:43 +08:00
parent 7005c1047f
commit 8983222dcb
21 changed files with 341 additions and 177 deletions

View File

@@ -19,8 +19,9 @@ func (h Controller) AcceptTask(data *task.AcceptTaskInboundInfo, c *player.Playe
// //isdaliy = true
// }
if c.Info.TaskList[data.TaskId-1] == 0 {
c.Info.TaskList[data.TaskId-1] = 1
if c.GetTask(int(data.TaskId)) == player.Unaccepted {
c.SetTask(int(data.TaskId), player.Accepted)
}
c.Service.Task.Exec(uint32(data.TaskId), func(t *model.TaskEX) bool {
t.Data = []uint32{}
@@ -54,13 +55,13 @@ func (h Controller) AddTaskBuf(data *task.AddTaskBufInboundInfo, c *player.Playe
* 完成任务
*/
func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player.Player) (result *task.CompleteTaskOutboundInfo, err errorcode.ErrorCode) {
if c.Info.TaskList[data.TaskId-1] != 1 { //如果任务没有接受或者已经完成Complete_Task
if c.GetTask(int(data.TaskId)) != player.Accepted { //如果任务没有接受或者已经完成Complete_Task
return result, 0
}
c.Info.TaskList[data.TaskId-1] = 3
c.SetTask(int(data.TaskId), player.Completed)
result = &task.CompleteTaskOutboundInfo{
TaskId: data.TaskId,
ItemList: make([]model.ItemInfo, 0),
@@ -111,10 +112,9 @@ func (h Controller) Get_Task_Buf(data *task.GetTaskBufInboundInfo, c *player.Pla
*/
func (h Controller) Delete_Task(data *task.DeleteTaskInboundInfo, c *player.Player) (result *task.DeleteTaskOutboundInfo, err errorcode.ErrorCode) {
if c.Info.TaskList[data.TaskId-1] == 1 {
c.Info.TaskList[data.TaskId-1] = 0
if c.GetTask(int(data.TaskId)) == player.Accepted {
c.SetTask(int(data.TaskId), player.Unaccepted)
return &task.DeleteTaskOutboundInfo{TaskId: data.TaskId}, 0
}
return &task.DeleteTaskOutboundInfo{}, 0