diff --git a/bin/json/game_trolltrain.json b/bin/json/game_trolltrain.json index f0b1873b5..d776fd32f 100644 --- a/bin/json/game_trolltrain.json +++ b/bin/json/game_trolltrain.json @@ -4,20 +4,20 @@ "name": "右屏商人", "information": "这是一位熊猫商人", "ico": "action_11001", - "time": 300 + "time": 10 }, { "id": 2, "name": "上屏商人", "information": "这是一位波比商人再此", "ico": "action_11003", - "time": 300 + "time": 10 }, { "id": 3, "name": "左屏商人", "information": "这是一位滑板鞋王子", "ico": "ytx_js_14007", - "time": 300 + "time": 10 } ] \ No newline at end of file diff --git a/comm/imodule.go b/comm/imodule.go index 210e62a63..49e8e13d5 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -59,6 +59,8 @@ type ( CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero) // 跨服查询英雄详细信息 QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) + + GetHeroListByUse(uid string) []*pb.DBHero // 非初始状态的英雄列表 } //玩家 diff --git a/modules/hero/module.go b/modules/hero/module.go index ddde208f0..00dbaa26d 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -369,3 +369,14 @@ func (this *Hero) QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) { return } + +// 获取非叠加英雄信息 +func (this *Hero) GetHeroListByUse(uid string) []*pb.DBHero { + tmp := make([]*pb.DBHero, 0) + for _, v := range this.modelHero.getHeroList(uid) { + if !v.IsOverlying { + tmp = append(tmp, v) + } + } + return tmp +} diff --git a/modules/pagoda/model_rank.go b/modules/pagoda/model_rank.go index 11da1234f..421afef6b 100644 --- a/modules/pagoda/model_rank.go +++ b/modules/pagoda/model_rank.go @@ -79,30 +79,6 @@ func (this *ModelRank) getPagodaRankList(uid string) []*pb.DBPagodaRecord { return pagodaRank } -// func (this *ModelRank) addPagodaList(session comm.IUserSession, data *pb.DBPagoda, Leadpos int32, line []*pb.LineUp, costTime int32) { -// userinfo := this.modulePagoda.ModuleUser.GetUser(session.GetUserId()) -// new := &pb.DBPagodaRecord{ -// Id: primitive.NewObjectID().Hex(), -// Uid: session.GetUserId(), -// PagodaId: data.PagodaId, -// Type: data.Type, -// Nickname: userinfo.Name, -// Icon: "", // icon 暂无 -// Lv: userinfo.Lv, -// CostTime: costTime, -// Line: line, -// } -// this.AddList(session.GetUserId(), new.Id, new) //写爬塔记录 -// // 查询本层是否上榜 -// rankData, ilen, err1 := this.GetFloorLastRankData(data.PagodaId) -// if err1 == nil { -// if ilen < comm.MaxRankNum || rankData.CostTime < costTime { -// this.ChangeFloorRankList(session, data.PagodaId, new) -// } -// } -// return -// } - // 插入新的排行数据 func (this *ModelRank) addPagodaRankList(session comm.IUserSession, data *pb.DBSeasonPagoda, Leadpos int32, line []*pb.LineUp, costTime int32) { uid := session.GetUserId() diff --git a/modules/troll/api_getlist.go b/modules/troll/api_getlist.go index 9c955a4b9..1eecccc47 100644 --- a/modules/troll/api_getlist.go +++ b/modules/troll/api_getlist.go @@ -15,7 +15,6 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.TrollGetLis return } -///获取美食城基本信息 func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq) (code pb.ErrorCode, data proto.Message) { var ( update map[string]interface{} @@ -42,32 +41,35 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq) update["sellCount"] = trolltrain.SellCount this.module.ModifyTrollData(session.GetUserId(), update) } - // 重新计算刷新时间 - t := time.Now().Unix() - trolltrain.RefreshTime + t := time.Now().Unix() - trolltrain.RefreshTime // 经过的时间 /// 计算经过了多少个周期 sz := this.configure.GetTrollAllTrain() var ( - circle int32 // 循环一个周期的时间 - curTime int32 + circletime int32 // 循环一个周期的时间 + circleCount int32 // 循环的次数 + leftTime int32 ) for _, v := range sz { - circle += v + circletime += v } - curTime = (int32(t) % circle) + circleCount = (int32(t) / circletime) // 经过的周期数 + leftTime = (int32(t) % circletime) // 循环次数 - index := int32((int32(t) / circle)) * this.configure.GetTrollMaxTraintNum() - trolltrain.TarinPos += index - for pos, v := range sz { - trolltrain.TarinPos++ - if curTime < v { - trolltrain.RefreshTime = time.Now().Unix() - int64(curTime) - trolltrain.TarinPos = int32(pos) // 设置火车位置 + trainNum := this.configure.GetTrollMaxTraintNum() + trolltrain.TarinPos += circleCount * trainNum // 计算火车的位置信息 + for _, v := range sz { + if leftTime <= v { + trolltrain.RefreshTime = time.Now().Unix() - int64(circleCount) trolltrain.RangeId = (trolltrain.TarinPos % maxCoefficient) + trolltrain.TarinPos = (trolltrain.TarinPos % trainNum) + 1 + update["refreshTime"] = trolltrain.RefreshTime update["tarinPos"] = trolltrain.TarinPos update["rangeId"] = trolltrain.RangeId break } + trolltrain.TarinPos += 1 + leftTime -= v } this.module.ModifyTrollData(session.GetUserId(), update) session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain}) diff --git a/modules/troll/comp_configure.go b/modules/troll/comp_configure.go index 17a84b4af..bb669e495 100644 --- a/modules/troll/comp_configure.go +++ b/modules/troll/comp_configure.go @@ -152,3 +152,15 @@ func (this *configureComp) GetTrollMaxTraintNum() int32 { } return 1 // 至少有1个车站 } + +func (this *configureComp) GetTrollAllGoods() (data []*cfg.GameTrollGoodsData) { + if v, err := this.GetConfigure(game_trollgoods); err == nil { + if configure, ok := v.(*cfg.GameTrollGoods); ok { + data = configure.GetDataList() + return + } + } else { + log.Errorf("get GameTrollGoodsData conf err:%v", err) + } + return +} diff --git a/modules/troll/module.go b/modules/troll/module.go index fa23f0055..facf6a243 100644 --- a/modules/troll/module.go +++ b/modules/troll/module.go @@ -53,15 +53,21 @@ func (this *Troll) ModifyTrollData(uid string, data map[string]interface{}) (cod // AI 玩法 func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCode) { var ( - trainCount int32 // 车站数量 - fTime []int32 //每个车站货物刷新的时间 - index int32 // 当前位置索引 - crossTime int32 // 经过的时间 + trainCount int32 // 车站数量 + fTime []int32 //每个车站货物刷新的时间 + index int32 // 当前位置索引 + crossTime int32 // 经过的时间 + girdNum int32 // 格子数量 + leftGirdNum int32 // 购买后剩余格子数量 ) if troll.Buy != 0 && troll.Sell != 0 { return } + girdNum = troll.GridNum + maxGirdNum := this.configure.GetTrollRule(comm.TrollGridCount) // 获取背包最大格子数量 + maxgoods := this.configure.GetTrollRule(comm.TrollItemCount) // 获取单个物品最大上限 trainCount = this.configure.GetTrollMaxTraintNum() + leftGirdNum = maxGirdNum - girdNum fTime = make([]int32, trainCount) for i := 0; i < int(trainCount); i++ { if conf := this.configure.GetTrollTrain(int32(i) + 1); conf != nil { @@ -71,21 +77,51 @@ func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCod // 计算时间差 crossTime = int32(time.Now().Unix() - troll.RefreshTime) + MaxRangeId := this.configure.GetTrollMaxCoefficientNux() // 随机增幅最大值 for i := 0; ; i++ { index = int32(i) % trainCount if crossTime > fTime[index] { // 获取 - troll.RangeId += 1 - if _d := this.configure.GetTrollCoefficient(troll.RangeId); _d != nil { - if troll.Buy <= int32(_d.Coefficient) { // - } - } + crossTime -= fTime[index] if crossTime < 0 { break } + troll.RangeId += 1 + troll.RangeId = troll.RangeId%int32(MaxRangeId) + 1 + if _d := this.configure.GetTrollCoefficient(troll.RangeId); _d != nil { + if troll.Buy <= int32(_d.Coefficient) { // 可以购买 那就尽最大的数量去买 + goods := this.configure.GetTrollAllGoods() // 获取所有的货物信息 + for _, v := range goods { + if leftGirdNum > 0 { // 剩余可购买格子数量 + if troll.Items[v.Id] < v.Max { // 还可以购买的数量 + // 先把这个格子填满 + rd := troll.Items[v.Id] % maxgoods + buyN := v.Max - troll.Items[v.Id] + if buyN >= rd { // 只能买这个多 那就全买了 + troll.Items[v.Id] += rd + buyN -= rd + } else { + break + } + for { + if buyN >= maxgoods { + leftGirdNum -= 1 + troll.Items[v.Id] += maxgoods + } + if leftGirdNum <= 0 { + break + } + } + } + } else { // 补齐没有满的货物 + rd := troll.Items[v.Id] % maxgoods + troll.Items[v.Id] += (maxgoods - rd) + } + } + } + } } - } return