更新消卡逻辑
This commit is contained in:
parent
989cc98065
commit
094c47885f
@ -17,9 +17,10 @@ var (
|
||||
subType: task.TaskSubTypeList,
|
||||
req: &pb.TaskListReq{
|
||||
//设置任务类型
|
||||
TaskTag: int32(comm.TASK_DAILY), //每天任务
|
||||
// TaskTag: int32(comm.TASK_DAILY), //每天任务
|
||||
// TaskTag: int32(comm.TASK_WEEKLY), //周任务
|
||||
// TaskTag: int32(comm.TASK_ACHIEVE),
|
||||
TaskTag: int32(comm.TASK_STRATEGY),
|
||||
},
|
||||
rsp: &pb.TaskListResp{},
|
||||
print: func(rsp proto.Message) {
|
||||
@ -28,7 +29,7 @@ var (
|
||||
fmt.Printf("%v \n", v)
|
||||
}
|
||||
},
|
||||
// enabled: true,
|
||||
enabled: true,
|
||||
next: func(robot *Robot, rsp proto.Message) {
|
||||
tcs := []*TestCase{}
|
||||
if v, ok := rsp.(*pb.TaskListResp); ok {
|
||||
@ -41,8 +42,8 @@ var (
|
||||
TaskTag: int32(comm.TASK_DAILY),
|
||||
Id: tt.Id,
|
||||
},
|
||||
rsp: &pb.TaskReceiveResp{},
|
||||
enabled: true,
|
||||
rsp: &pb.TaskReceiveResp{},
|
||||
// enabled: true,
|
||||
}
|
||||
tcs = append(tcs, tc)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ var user_builders = []*TestCase{
|
||||
},
|
||||
},
|
||||
rsp: &pb.UserAddResResp{},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
|
||||
// 删除经验卡
|
||||
for k, v := range req.ExpCards {
|
||||
err1 := this.module.modelHero.consumeOneHeroCard(session.GetUserId(), k, v)
|
||||
err1 := this.module.modelHero.consumeHeroCard(session.GetUserId(), k, v)
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_HeroNoEnough
|
||||
this.module.Errorf("delete err failed err:%T!", err1)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package hero
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -193,15 +194,32 @@ func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero {
|
||||
return hero
|
||||
}
|
||||
|
||||
//消耗一张英雄卡
|
||||
func (this *ModelHero) consumeOneHeroCard(uid, heroId string, count int32) (err error) {
|
||||
for i := 0; i < int(count); i++ {
|
||||
//消耗英雄卡
|
||||
func (this *ModelHero) consumeHeroCard(uid, heroId string, count int32) (err error) {
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
hero := this.getOneHero(uid, heroId)
|
||||
if hero == nil {
|
||||
return errors.New("hero no exist")
|
||||
}
|
||||
|
||||
if hero.SameCount < count {
|
||||
return errors.New("hero card no enough")
|
||||
}
|
||||
|
||||
if hero.SameCount-count == 0 {
|
||||
if err := this.moduleHero.modelHero.DelListlds(uid, heroId); err != nil {
|
||||
this.moduleHero.Errorf("%v", err)
|
||||
break
|
||||
}
|
||||
this.moduleHero.Debugf("删除一张卡牌uid:%s,卡牌ID:%s", uid, heroId)
|
||||
} else {
|
||||
update := map[string]interface{}{
|
||||
"sameCount": hero.SameCount - count,
|
||||
}
|
||||
err = this.modifyHeroData(uid, heroId, update)
|
||||
}
|
||||
this.moduleHero.Debugf("删除一张卡牌uid:%s,卡牌ID:%s", uid, heroId)
|
||||
return
|
||||
}
|
||||
|
||||
@ -225,6 +243,9 @@ func (this *ModelHero) getHeroList(uid string) []*pb.DBHero {
|
||||
|
||||
//更新装备
|
||||
func (this *ModelHero) setEquipment(uid, heroId string, equipIds []string) error {
|
||||
if len(equipIds) == 0 {
|
||||
return nil
|
||||
}
|
||||
update := map[string]interface{}{
|
||||
"equipID": equipIds,
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ func (this *Hero) AddCardExp(uid string, heroId string, exp int32) (code pb.Erro
|
||||
|
||||
// 删除指定卡牌
|
||||
func (this *Hero) DelCard(udi string, cardid string, amount int32) (code pb.ErrorCode) {
|
||||
err := this.modelHero.consumeOneHeroCard(udi, cardid, amount)
|
||||
err := this.modelHero.consumeHeroCard(udi, cardid, amount)
|
||||
if err != nil {
|
||||
return pb.ErrorCode_DBError
|
||||
}
|
||||
|
@ -176,3 +176,13 @@ func (this *ModelTask) clearTask(uid string, taskTag comm.TaskTag) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//初始化攻略任务
|
||||
// func (this *ModelTask) initStrategyTask(uid string, taskTag comm.TaskTag) error {
|
||||
// ids, err := this.Redis.HGetAllToMapString(fmt.Sprintf("task:%v_%v", uid, comm.TASK_STRATEGY))
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
@ -1,6 +1,7 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
@ -82,3 +83,13 @@ func (this *ModuleTask) SendToTask(uid string, taskType comm.TaskType, taskPram
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//创建玩家攻略任务
|
||||
func (this *ModuleTask) CreateTaskForStrategy(uid string, heroCfgId int32) {
|
||||
//
|
||||
ids := make(map[string]string)
|
||||
ids, _ = this.modelTask.Redis.HGetAllToMapString(fmt.Sprintf("task:%v_%v", uid, comm.TASK_STRATEGY))
|
||||
fmt.Println(ids)
|
||||
//
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user