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