feat: 新增CDK兑换冠名接口
This commit is contained in:
@@ -70,13 +70,6 @@ type ChangeTitleInboundInfo struct {
|
||||
|
||||
// C2S_GET_GIFT_COMPLETE 定义请求或响应数据结构。
|
||||
type C2S_GET_GIFT_COMPLETE struct {
|
||||
Head common.TomeeHeader `cmd:"2801" struc:"skip"`
|
||||
PassText string `struc:"[16]byte"`
|
||||
Type uint32
|
||||
ServerID uint32
|
||||
ServerName string `struc:"[16]byte"`
|
||||
}
|
||||
|
||||
type C2S_GET_DONATION_SERVER_IDS struct {
|
||||
Head common.TomeeHeader `cmd:"2802" struc:"skip"`
|
||||
Head common.TomeeHeader `cmd:"2801" struc:"skip"`
|
||||
PassText string `struc:"[16]byte"`
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/cool"
|
||||
logicplayer "blazing/logic/service/player"
|
||||
"blazing/logic/service/user"
|
||||
configservice "blazing/modules/config/service"
|
||||
@@ -11,16 +10,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// DonationServerIDs 返回当前可用于捐赠冠名的服务器ID列表。
|
||||
func (h Controller) DonationServerIDs(data *C2S_GET_DONATION_SERVER_IDS, player *logicplayer.Player) (result *user.S2C_GET_DONATION_SERVER_IDS, err errorcode.ErrorCode) {
|
||||
return &user.S2C_GET_DONATION_SERVER_IDS{
|
||||
ServerIDs: configservice.NewServerService().GetDonationAvailableServerIDs(),
|
||||
}, 0
|
||||
}
|
||||
|
||||
// CDK 处理控制器请求。
|
||||
func (h Controller) CDK(data *C2S_GET_GIFT_COMPLETE, player *logicplayer.Player) (result *user.S2C_GET_GIFT_COMPLETE, err errorcode.ErrorCode) {
|
||||
result = &user.S2C_GET_GIFT_COMPLETE{Type: data.Type}
|
||||
result = &user.S2C_GET_GIFT_COMPLETE{}
|
||||
|
||||
cdkCode := strings.Trim(data.PassText, "\x00")
|
||||
cdkService := configservice.NewCdkService()
|
||||
@@ -39,32 +31,6 @@ func (h Controller) CDK(data *C2S_GET_GIFT_COMPLETE, player *logicplayer.Player)
|
||||
if !player.Service.Cdk.CanGet(uint32(r.ID)) {
|
||||
return
|
||||
}
|
||||
|
||||
if r.CDKType == configservice.CDKTypeServerNaming {
|
||||
if data.Type != configservice.CDKTypeServerNaming {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
serverName := cool.Filter.Replace(strings.Trim(data.ServerName, "\x00"), '*')
|
||||
if data.ServerID == 0 || serverName == "" {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
serverInfo, useErr := cdkService.UseServerNamingCDK(nil, cdkCode, data.Head.UserID, data.ServerID, serverName)
|
||||
if useErr != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
result.Flag = 1
|
||||
result.ServerID = serverInfo.OnlineID
|
||||
result.ServerName = serverInfo.Name
|
||||
player.Service.Cdk.Log(uint32(r.ID))
|
||||
return result, 0
|
||||
}
|
||||
|
||||
if data.Type == configservice.CDKTypeServerNaming {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
if !cdkService.Set(cdkCode) {
|
||||
return nil, errorcode.ErrorCodes.ErrMolecularCodeGiftsGone
|
||||
}
|
||||
|
||||
@@ -5,32 +5,21 @@ import "blazing/logic/service/common"
|
||||
// C2S_GET_GIFT_COMPLETE 礼品兑换完成协议
|
||||
// 前端到后端
|
||||
type C2S_GET_GIFT_COMPLETE struct {
|
||||
Head common.TomeeHeader `cmd:"2801" struc:"skip"`
|
||||
PassText string `struc:"[16]byte"`
|
||||
Type uint32
|
||||
ServerID uint32
|
||||
ServerName string `struc:"[16]byte"`
|
||||
Head common.TomeeHeader `cmd:"2801" struc:"skip"`
|
||||
PassText string `struc:"[16]byte"`
|
||||
}
|
||||
|
||||
// S2C_GET_GIFT_COMPLETE 礼品兑换完成协议
|
||||
// 后端到前端
|
||||
type S2C_GET_GIFT_COMPLETE struct {
|
||||
Flag uint32 `json:"flag"`
|
||||
Type uint32 `json:"type"`
|
||||
Tile uint32 `json:"tile"`
|
||||
ServerID uint32 `json:"server_id"`
|
||||
ServerName string `struc:"[16]byte" json:"server_name"`
|
||||
GiftListLen uint32 `struc:"sizeof=GiftList"`
|
||||
GiftList []GiftInfo `json:"giftList"`
|
||||
PetGiftLen uint32 `struc:"sizeof=PetGift"`
|
||||
PetGift []PetGiftInfo `json:"petGiftList"`
|
||||
}
|
||||
|
||||
type S2C_GET_DONATION_SERVER_IDS struct {
|
||||
ServerIDsLen uint32 `struc:"sizeof=ServerIDs" json:"server_ids_len"`
|
||||
ServerIDs []uint32 `json:"server_ids"`
|
||||
}
|
||||
|
||||
// GiftInfo 礼品信息
|
||||
type GiftInfo struct {
|
||||
GiftID int64 `struc:"uint32"`
|
||||
|
||||
Reference in New Issue
Block a user