增加分离器

This commit is contained in:
hahwu 2025-01-14 10:53:08 +08:00
parent 0d3b0733d2
commit 282fd732f1
3 changed files with 3279 additions and 3096 deletions

View File

@ -616,6 +616,37 @@ func ReqBuyChessBagGrid(args []interface{}) error {
return nil return nil
} }
func ReqSeparateChess(args []interface{}) error {
_, player, buf := ParseArgs(args)
req := &msg.ReqSeparateChess{}
proto.Unmarshal(buf, req)
ChessMod := player.PlayMod.getChessMod()
err := ChessMod.SeparateChess(int(req.ChessId))
if err != nil {
player.SendErrClienRes(&msg.ResSeparateChess{
Code: msg.RES_CODE_FAIL,
Msg: err.Error(),
})
return err
}
data := &PlayerChessData{}
err = data.UpdateChessData(player, req.MChessData)
if err != nil {
player.SendErrClienRes(&msg.ResSeparateChess{
Code: msg.RES_CODE_FAIL,
Msg: err.Error(),
})
return err
}
player.PlayMod.save()
player.PushClientRes(ChessMod.BackData())
player.PushClientRes(&msg.ResSeparateChess{
Code: msg.RES_CODE_SUCCESS,
})
player.UpdateUserInfo()
return nil
}
// 棋子转换 // 棋子转换
func ReqChessEx(args []interface{}) error { func ReqChessEx(args []interface{}) error {
_, player, buf := ParseArgs(args) _, player, buf := ParseArgs(args)

View File

@ -18,6 +18,7 @@ const (
ChessBoradMaxNum = 63 ChessBoradMaxNum = 63
CHESS_SOURCE_CHEST = 705 CHESS_SOURCE_CHEST = 705
CHESS_HIGH_SOURCE_CHEST = 706 CHESS_HIGH_SOURCE_CHEST = 706
CHESS_SEPARATE = 707 // 分解器
) )
type ChessBorad struct { type ChessBorad struct {
@ -509,3 +510,27 @@ func (cb *ChessBorad) SourceChest(ChessId int) ([]*item.Item, error) {
return nil, nil return nil, nil
} }
func (cb *ChessBorad) SeparateChess(ChessId int) error {
ChessLv := mergeDataCfg.GetLvById(ChessId)
if ChessLv == 1 {
return errors.New("chess lv is 1")
}
ChessType := mergeDataCfg.GetTypeById(ChessId)
if ChessType != "Product" {
return errors.New("chess type is not product")
}
err := cb.RemoveChess(ChessId)
if err != nil {
return err
}
err = cb.RemoveChess(CHESS_SEPARATE)
if err != nil {
return err
}
ChessColor := mergeDataCfg.GetColorById(ChessId)
NewChess := mergeDataCfg.GetChessIdByLvAndColor(ChessLv-1, ChessColor)
cb.AddChess(NewChess)
cb.AddChess(NewChess)
return nil
}

File diff suppressed because it is too large Load Diff