refactor: 优化代码结构和逻辑
This commit is contained in:
@@ -4,20 +4,25 @@ import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/nono"
|
||||
"blazing/logic/service/player"
|
||||
)
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
const (
|
||||
nonoFuncValue = 255
|
||||
nonoDefaultNum = 1
|
||||
nonoDefaultPower = 0
|
||||
nonoDefaultLevel = 12
|
||||
nonoPetCureCost int64 = 50
|
||||
)
|
||||
|
||||
func (h Controller) NonoFollowOrHome(data *nono.NonoFollowOrHomeInInfo, c *player.Player) (result *nono.NonoFollowOutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
c.Info.NONO.Flag = data.Flag
|
||||
result = &nono.NonoFollowOutInfo{
|
||||
|
||||
UserID: data.Head.UserID,
|
||||
SuperStage: data.Flag,
|
||||
Flag: data.Flag,
|
||||
Nick: "",
|
||||
Color: c.Info.NONO.NonoColor,
|
||||
Power: 0,
|
||||
Power: nonoDefaultPower,
|
||||
}
|
||||
|
||||
return
|
||||
@@ -25,22 +30,26 @@ func (h Controller) NonoFollowOrHome(data *nono.NonoFollowOrHomeInInfo, c *playe
|
||||
|
||||
// GetNonoInfo 获取nono信息
|
||||
func (h *Controller) GetNonoInfo(data *nono.NonoInboundInfo, c *player.Player) (result *nono.NonoOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
_ = data
|
||||
|
||||
result = &nono.NonoOutboundInfo{}
|
||||
copier.Copy(result, &c.Info.NONO)
|
||||
result.UserID = c.Info.UserID
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
result.Func[i] = 255
|
||||
result = &nono.NonoOutboundInfo{
|
||||
UserID: c.Info.UserID,
|
||||
Nick: c.Info.NONO.Nick,
|
||||
SuperNono: nonoDefaultNum,
|
||||
Color: c.Info.NONO.NonoColor,
|
||||
Num: nonoDefaultNum,
|
||||
SuperLevel: nonoDefaultLevel,
|
||||
SuperStage: c.Info.NONO.Flag,
|
||||
Power: nonoDefaultPower,
|
||||
SuperEnergy: nonoDefaultPower,
|
||||
}
|
||||
for i := range result.Func {
|
||||
result.Func[i] = nonoFuncValue
|
||||
}
|
||||
result.Num = 1
|
||||
result.SuperNono = 1
|
||||
result.SuperLevel = 12
|
||||
return
|
||||
}
|
||||
|
||||
func (h *Controller) SwitchFlying(data *nono.SwitchFlyingInboundInfo, c *player.Player) (result *nono.SwitchFlyingOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
result = &nono.SwitchFlyingOutboundInfo{
|
||||
UserId: data.Head.UserID,
|
||||
Type: data.Type,
|
||||
@@ -51,16 +60,16 @@ func (h *Controller) SwitchFlying(data *nono.SwitchFlyingInboundInfo, c *player.
|
||||
}
|
||||
|
||||
func (h *Controller) PlayerPetCure(data *nono.PetCureInboundInfo, c *player.Player) (result *nono.PetCureOutboundEmpty, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
_ = data
|
||||
if c.GetSpace().Owner.UserID == c.Info.UserID {
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotHeal
|
||||
}
|
||||
if !c.GetCoins(50) {
|
||||
if !c.GetCoins(nonoPetCureCost) {
|
||||
return result, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
||||
}
|
||||
for i := 0; i < len(c.Info.PetList); i++ {
|
||||
for i := range c.Info.PetList {
|
||||
c.Info.PetList[i].Cure()
|
||||
|
||||
}
|
||||
c.Info.Coins -= 50
|
||||
c.Info.Coins -= nonoPetCureCost
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user