Merge branches 'dev' and 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev

This commit is contained in:
meixiongfeng 2022-11-01 19:44:37 +08:00
commit fd4391b596
7 changed files with 90 additions and 51 deletions

View File

@ -4,20 +4,20 @@
"name": "右屏商人", "name": "右屏商人",
"information": "这是一位熊猫商人", "information": "这是一位熊猫商人",
"ico": "action_11001", "ico": "action_11001",
"time": 300 "time": 10
}, },
{ {
"id": 2, "id": 2,
"name": "上屏商人", "name": "上屏商人",
"information": "这是一位波比商人再此", "information": "这是一位波比商人再此",
"ico": "action_11003", "ico": "action_11003",
"time": 300 "time": 10
}, },
{ {
"id": 3, "id": 3,
"name": "左屏商人", "name": "左屏商人",
"information": "这是一位滑板鞋王子", "information": "这是一位滑板鞋王子",
"ico": "ytx_js_14007", "ico": "ytx_js_14007",
"time": 300 "time": 10
} }
] ]

View File

@ -59,6 +59,8 @@ type (
CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero) CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero)
// 跨服查询英雄详细信息 // 跨服查询英雄详细信息
QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error)
GetHeroListByUse(uid string) []*pb.DBHero // 非初始状态的英雄列表
} }
//玩家 //玩家

View File

@ -369,3 +369,14 @@ func (this *Hero) QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) {
return 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
}

View File

@ -79,30 +79,6 @@ func (this *ModelRank) getPagodaRankList(uid string) []*pb.DBPagodaRecord {
return pagodaRank 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) { func (this *ModelRank) addPagodaRankList(session comm.IUserSession, data *pb.DBSeasonPagoda, Leadpos int32, line []*pb.LineUp, costTime int32) {
uid := session.GetUserId() uid := session.GetUserId()

View File

@ -15,7 +15,6 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.TrollGetLis
return return
} }
///获取美食城基本信息
func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
update map[string]interface{} update map[string]interface{}
@ -42,32 +41,35 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
update["sellCount"] = trolltrain.SellCount update["sellCount"] = trolltrain.SellCount
this.module.ModifyTrollData(session.GetUserId(), update) this.module.ModifyTrollData(session.GetUserId(), update)
} }
// 重新计算刷新时间 t := time.Now().Unix() - trolltrain.RefreshTime // 经过的时间
t := time.Now().Unix() - trolltrain.RefreshTime
/// 计算经过了多少个周期 /// 计算经过了多少个周期
sz := this.configure.GetTrollAllTrain() sz := this.configure.GetTrollAllTrain()
var ( var (
circle int32 // 循环一个周期的时间 circletime int32 // 循环一个周期的时间
curTime int32 circleCount int32 // 循环的次数
leftTime int32
) )
for _, v := range sz { 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() trainNum := this.configure.GetTrollMaxTraintNum()
trolltrain.TarinPos += index trolltrain.TarinPos += circleCount * trainNum // 计算火车的位置信息
for pos, v := range sz { for _, v := range sz {
trolltrain.TarinPos++ if leftTime <= v {
if curTime < v { trolltrain.RefreshTime = time.Now().Unix() - int64(circleCount)
trolltrain.RefreshTime = time.Now().Unix() - int64(curTime)
trolltrain.TarinPos = int32(pos) // 设置火车位置
trolltrain.RangeId = (trolltrain.TarinPos % maxCoefficient) trolltrain.RangeId = (trolltrain.TarinPos % maxCoefficient)
trolltrain.TarinPos = (trolltrain.TarinPos % trainNum) + 1
update["refreshTime"] = trolltrain.RefreshTime update["refreshTime"] = trolltrain.RefreshTime
update["tarinPos"] = trolltrain.TarinPos update["tarinPos"] = trolltrain.TarinPos
update["rangeId"] = trolltrain.RangeId update["rangeId"] = trolltrain.RangeId
break break
} }
trolltrain.TarinPos += 1
leftTime -= v
} }
this.module.ModifyTrollData(session.GetUserId(), update) this.module.ModifyTrollData(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain}) session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain})

View File

@ -152,3 +152,15 @@ func (this *configureComp) GetTrollMaxTraintNum() int32 {
} }
return 1 // 至少有1个车站 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
}

View File

@ -53,15 +53,21 @@ func (this *Troll) ModifyTrollData(uid string, data map[string]interface{}) (cod
// AI 玩法 // AI 玩法
func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCode) { func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCode) {
var ( var (
trainCount int32 // 车站数量 trainCount int32 // 车站数量
fTime []int32 //每个车站货物刷新的时间 fTime []int32 //每个车站货物刷新的时间
index int32 // 当前位置索引 index int32 // 当前位置索引
crossTime int32 // 经过的时间 crossTime int32 // 经过的时间
girdNum int32 // 格子数量
leftGirdNum int32 // 购买后剩余格子数量
) )
if troll.Buy != 0 && troll.Sell != 0 { if troll.Buy != 0 && troll.Sell != 0 {
return return
} }
girdNum = troll.GridNum
maxGirdNum := this.configure.GetTrollRule(comm.TrollGridCount) // 获取背包最大格子数量
maxgoods := this.configure.GetTrollRule(comm.TrollItemCount) // 获取单个物品最大上限
trainCount = this.configure.GetTrollMaxTraintNum() trainCount = this.configure.GetTrollMaxTraintNum()
leftGirdNum = maxGirdNum - girdNum
fTime = make([]int32, trainCount) fTime = make([]int32, trainCount)
for i := 0; i < int(trainCount); i++ { for i := 0; i < int(trainCount); i++ {
if conf := this.configure.GetTrollTrain(int32(i) + 1); conf != nil { 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) crossTime = int32(time.Now().Unix() - troll.RefreshTime)
MaxRangeId := this.configure.GetTrollMaxCoefficientNux() // 随机增幅最大值
for i := 0; ; i++ { for i := 0; ; i++ {
index = int32(i) % trainCount index = int32(i) % trainCount
if crossTime > fTime[index] { // 获取 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] crossTime -= fTime[index]
if crossTime < 0 { if crossTime < 0 {
break 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 return