Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
b39dfb89fa
@ -44,22 +44,14 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
appointmap = make(map[int32]string)
|
||||
firstGet = make(map[string]bool)
|
||||
szCards = make([]string, 0)
|
||||
heroRecord, _ = this.module.modelRecord.GetHeroRecord(session.GetUserId())
|
||||
if heroRecord.Baodi4 == nil {
|
||||
heroRecord.Baodi4 = make(map[int32]int32)
|
||||
}
|
||||
if heroRecord.Baodi5 == nil {
|
||||
heroRecord.Baodi5 = make(map[int32]int32)
|
||||
}
|
||||
if heroRecord.Count == nil {
|
||||
heroRecord.Count = make(map[int32]int32)
|
||||
}
|
||||
if heroRecord.Wish == nil {
|
||||
heroRecord.Wish = make(map[string]int64)
|
||||
}
|
||||
if heroRecord.Limit == nil {
|
||||
heroRecord.Limit = make(map[string]int64)
|
||||
if heroRecord, err = this.module.modelRecord.GetHeroRecord(session.GetUserId()); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
rsp := &pb.HeroDrawCardResp{
|
||||
Data: []*pb.AtnoData{},
|
||||
Wish: &pb.UserAtno{},
|
||||
@ -73,7 +65,6 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
var drcount int32
|
||||
//atn := this.module.ModuleTools.GetGlobalConf().ExchangeHero // 校验消耗数量
|
||||
if conf := this.module.configure.GetWishHeroReplaceConfig(); conf != nil {
|
||||
|
||||
if heroRecord.WishHero == "" { // 如果当前许愿英雄是空 则读取 默认许愿英雄
|
||||
heroRecord.WishHero = conf.InitHero
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package robot
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
@ -12,11 +11,13 @@ import (
|
||||
|
||||
//商队模块 机器人
|
||||
type ModuleRobot_Caravan struct {
|
||||
goods map[pb.ShopType][]*pb.ShopItem
|
||||
caravan *pb.DBCaravan
|
||||
curCity int32
|
||||
}
|
||||
|
||||
func (this *ModuleRobot_Caravan) Init() (err error) {
|
||||
this.goods = make(map[pb.ShopType][]*pb.ShopItem)
|
||||
this.caravan = &pb.DBCaravan{}
|
||||
this.curCity = 101
|
||||
return
|
||||
}
|
||||
|
||||
@ -24,8 +25,8 @@ func (this *ModuleRobot_Caravan) Init() (err error) {
|
||||
func (this *ModuleRobot_Caravan) Receive(robot IRobot, stype string, message proto.Message) (err error) {
|
||||
switch stype {
|
||||
case "getlist":
|
||||
resp := message.(*pb.ShopGetListResp)
|
||||
this.goods[resp.SType] = resp.Goods
|
||||
resp := message.(*pb.CaravanGetListResp)
|
||||
this.caravan = resp.Data
|
||||
break
|
||||
}
|
||||
return
|
||||
@ -34,9 +35,7 @@ func (this *ModuleRobot_Caravan) OncePipeline(robot IRobot) (err error) {
|
||||
var (
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
if _, errdata = robot.SendMessage("shop", "getlist", &pb.ShopGetListReq{
|
||||
SType: pb.ShopType_DiamondShop,
|
||||
}); errdata != nil {
|
||||
if _, errdata = robot.SendMessage("caravan", "getlist", &pb.CaravanGetListReq{}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
@ -46,71 +45,53 @@ func (this *ModuleRobot_Caravan) OncePipeline(robot IRobot) (err error) {
|
||||
//机器人执行流
|
||||
func (this *ModuleRobot_Caravan) DoPipeline(robot IRobot) (err error) {
|
||||
var (
|
||||
errdata *pb.ErrorData
|
||||
usermodule *ModuleRobot_User
|
||||
resp proto.Message
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
usermodule = robot.GetModule(comm.ModuleUser).(*ModuleRobot_User)
|
||||
for _, v := range this.goods[pb.ShopType_GoldShop] {
|
||||
if v.LeftBuyNum > 0 && usermodule.user.Gold >= int64(v.Consume[0].N) {
|
||||
if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{
|
||||
ShopType: pb.ShopType_GoldShop,
|
||||
Gid: v.Gid,
|
||||
BuyNum: 1,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
break
|
||||
if resp, errdata = robot.SendMessage("caravan", "gotocity", &pb.CaravanGotoCityReq{
|
||||
City: this.curCity,
|
||||
Ticket: 1,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
|
||||
data := resp.(*pb.CaravanGotoCityResp).Data
|
||||
if data.Eventid != 0 {
|
||||
if resp, errdata = robot.SendMessage("caravan", "getstory", &pb.CaravanGetStoryReq{
|
||||
Cid: 1,
|
||||
Citystory: 50020020, // 拒绝剧情
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
}
|
||||
for _, v := range this.goods[pb.ShopType_DiamondShop] {
|
||||
if v.LeftBuyNum > 0 && usermodule.user.Diamond >= int64(v.Consume[0].N) {
|
||||
if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{
|
||||
ShopType: pb.ShopType_DiamondShop,
|
||||
Gid: v.Gid,
|
||||
BuyNum: 1,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
//CaravanBuyOrSellReq
|
||||
var item string
|
||||
for _, v := range data.City[this.curCity].Special {
|
||||
item = v
|
||||
break
|
||||
}
|
||||
if resp, errdata = robot.SendMessage("caravan", "buyorsell", &pb.CaravanBuyOrSellReq{
|
||||
City: this.curCity,
|
||||
Items: map[string]int32{
|
||||
item: 2,
|
||||
},
|
||||
IsBuy: true,
|
||||
}); errdata != nil { //💕
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
|
||||
this.curCity += 1
|
||||
if this.curCity >= 113 {
|
||||
this.curCity = 101
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//做任务
|
||||
func (this *ModuleRobot_Caravan) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
|
||||
var (
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
switch comm.TaskType(condconf.Type) {
|
||||
case comm.Rtype104:
|
||||
var (
|
||||
usermodule *ModuleRobot_User
|
||||
)
|
||||
usermodule = robot.GetModule(comm.ModuleUser).(*ModuleRobot_User)
|
||||
if _, errdata = robot.SendMessage("shop", "getlist", &pb.ShopGetListReq{
|
||||
SType: pb.ShopType_DiamondShop,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range this.goods[pb.ShopType_DiamondShop] {
|
||||
if v.LeftBuyNum > 0 && usermodule.user.Diamond >= int64(v.Consume[0].N) {
|
||||
if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{
|
||||
ShopType: pb.ShopType_DiamondShop,
|
||||
Gid: v.Gid,
|
||||
BuyNum: 1,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user