Merge branch 'main' of https://cnb.cool/blzing/blazing
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/rpc"
|
||||
"blazing/cool"
|
||||
"blazing/logic/service/common"
|
||||
"bytes"
|
||||
@@ -29,6 +30,10 @@ type Controller struct {
|
||||
Kick func(uint32) error
|
||||
|
||||
RegisterLogic func(uint32, uint32) error
|
||||
|
||||
MatchJoinOrUpdate func(rpc.PVPMatchJoinPayload) error
|
||||
|
||||
MatchCancel func(uint32) error
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/rpc"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight"
|
||||
@@ -21,11 +22,35 @@ func (h Controller) JoINtop(data *PetTOPLEVELnboundInfo, c *player.Player) (resu
|
||||
if err != 0 {
|
||||
return nil, err
|
||||
}
|
||||
if Maincontroller.RPCClient == nil || Maincontroller.RPCClient.MatchJoinOrUpdate == nil {
|
||||
pvp.CancelPeakQueue(c)
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusyTryLater
|
||||
}
|
||||
fightMode, status, err := pvp.NormalizePeakMode(data.Mode)
|
||||
if err != 0 {
|
||||
pvp.CancelPeakQueue(c)
|
||||
return nil, err
|
||||
}
|
||||
joinPayload := rpc.PVPMatchJoinPayload{
|
||||
RuntimeServerID: h.UID,
|
||||
UserID: c.Info.UserID,
|
||||
Nick: c.Info.Nick,
|
||||
FightMode: fightMode,
|
||||
Status: status,
|
||||
CatchTimes: pvp.AvailableCatchTimes(c.GetPetInfo(0)),
|
||||
}
|
||||
if callErr := Maincontroller.RPCClient.MatchJoinOrUpdate(joinPayload); callErr != nil {
|
||||
pvp.CancelPeakQueue(c)
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusyTryLater
|
||||
}
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
// CancelPeakQueue 处理控制器请求。
|
||||
func (h Controller) CancelPeakQueue(data *PeakQueueCancelInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
if Maincontroller.RPCClient != nil && Maincontroller.RPCClient.MatchCancel != nil {
|
||||
_ = Maincontroller.RPCClient.MatchCancel(c.Info.UserID)
|
||||
}
|
||||
pvp.CancelPeakQueue(c)
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
@@ -28,12 +28,15 @@ func (h Controller) AcceptTask(data *AcceptTaskInboundInfo, c *player.Player) (r
|
||||
}
|
||||
|
||||
c.Info.SetTask(int(data.TaskId), model.Accepted)
|
||||
c.Service.Task.Exec(uint32(data.TaskId), func(t *model.Task) bool {
|
||||
t.Data = []uint32{}
|
||||
taskData, taskErr := c.Service.Task.GetTask(uint32(data.TaskId))
|
||||
if taskErr != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
taskData.Data = []uint32{}
|
||||
if taskErr = c.Service.Task.SetTask(taskData); taskErr != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
})
|
||||
result = &task.AcceptTaskOutboundInfo{}
|
||||
result.TaskId = data.TaskId
|
||||
return result, 0
|
||||
@@ -48,10 +51,14 @@ func (h Controller) AddTaskBuf(data *AddTaskBufInboundInfo, c *player.Player) (r
|
||||
if c.Info.GetTask(int(data.TaskId)) != model.Accepted {
|
||||
return result, errorcode.ErrorCodes.ErrAwardAlreadyClaimed
|
||||
}
|
||||
c.Service.Task.Exec(data.TaskId, func(taskEx *model.Task) bool {
|
||||
taskEx.Data = data.TaskList
|
||||
return true
|
||||
})
|
||||
taskData, taskErr := c.Service.Task.GetTask(data.TaskId)
|
||||
if taskErr != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
taskData.Data = data.TaskList
|
||||
if taskErr = c.Service.Task.SetTask(taskData); taskErr != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
return result, 0
|
||||
}
|
||||
|
||||
@@ -105,11 +112,12 @@ func (h Controller) GetTaskBuf(data *GetTaskBufInboundInfo, c *player.Player) (r
|
||||
result = &task.GetTaskBufOutboundInfo{
|
||||
TaskId: data.TaskId,
|
||||
}
|
||||
c.Service.Task.Exec(data.TaskId, func(te *model.Task) bool {
|
||||
|
||||
result.TaskList = te.Data
|
||||
return false
|
||||
})
|
||||
taskData, taskErr := c.Service.Task.GetTask(data.TaskId)
|
||||
if taskErr != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
result.TaskList = taskData.Data
|
||||
|
||||
return result, 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user