卡牌图鉴
This commit is contained in:
parent
7146014b0f
commit
01f1009473
@ -640,7 +640,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
||||
//Gm命令
|
||||
RegisterMsgProcessFunc("ReqGmCommand", ReqGmCommand) // Gm命令
|
||||
|
||||
//卡牌
|
||||
// #region 卡牌
|
||||
RegisterMsgProcessFunc("ReqCardInfo", ReqCardInfo) // 请求卡牌信息
|
||||
RegisterMsgProcessFunc("ReqCardCollectReward", ReqCardCollectReward) //领取卡牌系列收集奖励
|
||||
RegisterMsgProcessFunc("ReqExStarReward", ReqExStarReward) // 兑换收集星星奖励
|
||||
@ -657,6 +657,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
||||
RegisterMsgProcessFunc("ReqCardSend", ReqCardSend) // 直接赠送卡牌
|
||||
RegisterMsgProcessFunc("ReqGetFriendCard", ReqGetFriendCard) // 领取好友赠送的卡牌
|
||||
RegisterMsgProcessFunc("ReqMasterCard", ReqMasterCard) // 万能卡兑换
|
||||
RegisterMsgProcessFunc("ReqCardHandbookReward", ReqCardHandbookReward) // 卡牌图鉴
|
||||
|
||||
// 日常任务
|
||||
RegisterMsgProcessFunc("ReqGetDailyTaskReward", ReqGetDailyTaskReward) // 领取日常任务奖励
|
||||
|
||||
@ -3286,3 +3286,32 @@ func ReqKafkaLog(args []interface{}) error {
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReqCardHandbookReward(args []interface{}) error {
|
||||
_, player, buf := ParseArgs(args)
|
||||
req := &msg.ReqCardHandbookReward{}
|
||||
proto.Unmarshal(buf, req)
|
||||
CardMod := player.PlayMod.getCardMod()
|
||||
Items, err := CardMod.GetHandbookReward(int(req.CardId))
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResCardHandbookReward{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: err.Error(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
err = player.HandleItem(Items, msg.ITEM_POP_LABEL_CardHandbookReward.String())
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResCardHandbookReward{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: err.Error(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(CardMod.NotifyCard())
|
||||
player.PushClientRes(&msg.ResCardHandbookReward{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -23,11 +23,13 @@ type CardMod struct {
|
||||
ExCard map[int]*CardInfo // 交换卡牌
|
||||
Cache Cache // 缓存卡牌
|
||||
Round int // 轮次
|
||||
Handbook map[int]int // 图鉴
|
||||
}
|
||||
|
||||
type Cache struct {
|
||||
Card map[int]int
|
||||
Master map[int]int
|
||||
Handbook map[int]int
|
||||
ExStar int
|
||||
}
|
||||
|
||||
@ -83,12 +85,18 @@ func (c *CardMod) InitData() {
|
||||
if c.ExCard == nil {
|
||||
c.ExCard = make(map[int]*CardInfo)
|
||||
}
|
||||
if c.Handbook == nil {
|
||||
c.Handbook = make(map[int]int)
|
||||
}
|
||||
if c.Cache.Card == nil {
|
||||
c.Cache.Card = make(map[int]int)
|
||||
}
|
||||
if c.Cache.Master == nil {
|
||||
c.Cache.Master = make(map[int]int)
|
||||
}
|
||||
if c.Cache.Handbook == nil {
|
||||
c.Cache.Handbook = make(map[int]int)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CardMod) Login(ServerOpenTime int64) {
|
||||
@ -124,6 +132,11 @@ func (c *CardMod) AddCard(Id int) {
|
||||
} else {
|
||||
c.CardList[Id] = 1
|
||||
}
|
||||
_, ok = c.Handbook[Id]
|
||||
if !ok {
|
||||
c.Handbook[Id] = 1
|
||||
c.Cache.Handbook[Id] = 1
|
||||
}
|
||||
c.Cache.Card[Id]++
|
||||
}
|
||||
|
||||
@ -439,12 +452,14 @@ func (c *CardMod) NotifyCard() *msg.ResNotifyCard {
|
||||
m := &msg.ResNotifyCard{
|
||||
Card: GoUtil.MapIntToInt32(c.Cache.Card),
|
||||
Master: GoUtil.MapIntToInt32(c.Cache.Master),
|
||||
Handbook: GoUtil.MapIntToInt32(c.Cache.Handbook),
|
||||
ExStar: int32(c.Cache.ExStar),
|
||||
}
|
||||
// log.Debug("NotifyCard %v", c.Cache.Card)
|
||||
c.Cache = Cache{
|
||||
Card: make(map[int]int),
|
||||
Master: make(map[int]int),
|
||||
Handbook: make(map[int]int),
|
||||
ExStar: 0,
|
||||
}
|
||||
return m
|
||||
@ -500,3 +515,14 @@ func (c *CardMod) AddGoldTimes() {
|
||||
c.GoldTimes++
|
||||
c.GoldTimes = min(2, c.GoldTimes)
|
||||
}
|
||||
|
||||
func (c *CardMod) GetHandbookReward(CardId int) ([]*item.Item, error) {
|
||||
if v, ok := c.Handbook[CardId]; ok {
|
||||
if v == 2 {
|
||||
return nil, fmt.Errorf("GetHandbookReward already get")
|
||||
}
|
||||
Star := cardCfg.GetStarById(CardId)
|
||||
return []*item.Item{item.NewItem(item.ITEM_ENERGY_ID, Star)}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("GetHandbookReward not find card")
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user