增加商队商品限购

This commit is contained in:
meixiongfeng 2022-11-02 15:54:49 +08:00
parent 491b2f1a70
commit b149c733ab
8 changed files with 186 additions and 101 deletions

View File

@ -27,8 +27,10 @@ func (this *apiComp) AfkSet(session comm.IUserSession, req *pb.TrollAfkSetReq) (
}
troll.Buy = req.Buy
troll.Sell = req.Sell
troll.AiCount = req.Count
update["buy"] = troll.Buy
update["sell"] = troll.Sell
update["aiCount"] = troll.AiCount
this.module.ModifyTrollData(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), TrollNpcRewardResp, &pb.TrollNpcRewardResp{Data: troll})
return

View File

@ -3,7 +3,6 @@ package troll
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"math"
"time"
@ -19,7 +18,6 @@ func (this *apiComp) BuyOrSellCheck(session comm.IUserSession, req *pb.TrollBuyO
}
func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSellReq) (code pb.ErrorCode, data proto.Message) {
var (
bSell bool // 是否有出售
gold int32 // 当次交易 获得的金币
@ -36,12 +34,10 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
code = pb.ErrorCode_DBError
return
}
for k, v := range req.Items {
if v < 0 {
if !bSell {
bSell = true
if bSell {
bSell = false
trolltrain.SellCount += 1 // 交易次数+1
if trolltrain.SellCount > 5 {
code = pb.ErrorCode_TrollMaxSellCount // 达到最大交易次数 直接返回
@ -50,13 +46,22 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
update["sellCount"] = trolltrain.SellCount
}
}
if _, ok := trolltrain.Items[k]; !ok {
trolltrain.Items[k] = v
} else {
trolltrain.Items[k] += v
}
if _, ok := trolltrain.Shop[k]; !ok {
trolltrain.Shop[k] = v
} else {
trolltrain.Shop[k] += v
}
// 校验 是否大于买入最大限制
goods := this.configure.GetTrollGoods(k)
if goods == nil {
return
}
if goods.Max < trolltrain.Items[k] { // 判断是否有效交易
if trolltrain.Shop[k] > goods.Max { // 判断是否有效交易
// 买入上限 直接返回
code = pb.ErrorCode_TrollBuyMax
return
@ -67,10 +72,13 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
// 第一次购买商品
if trolltrain.TarinPos == 0 {
if _, ok := trolltrain.Price[k]; !ok {
trolltrain.Price[k] = 0
}
trolltrain.Price[k] = goods.Goodsprice * goods.StarMoney / 1000
trolltrain.RefreshTime = time.Now().Unix()
//消耗的金币
gold = trolltrain.Price[k] * trolltrain.Items[k]
gold -= trolltrain.Price[k] * trolltrain.Items[k]
} else {
p := this.configure.GetTrollCoefficient(trolltrain.TarinPos)
if p == nil {
@ -92,8 +100,9 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
} else { // 买入 计算平均价格
totalGold := trolltrain.Items[k] * trolltrain.Price[k]
sellPrice := int32(p.Coefficient) * goods.Goodsprice / 1000
totalGold += v * goods.Goodsprice * sellPrice
totalGold += v * sellPrice
trolltrain.Price[k] = totalGold / (trolltrain.Items[k] + v)
gold -= v * sellPrice
}
}
}
@ -101,7 +110,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
grid := this.configure.GetTrollRule(comm.TrollItemCount)
for _, v := range trolltrain.Items {
if v > 0 {
gridNum += int32(math.Floor(float64(v / grid)))
gridNum += int32(math.Ceil(float64(v / grid)))
}
}
// 获取背包格子上限配置
@ -111,24 +120,11 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
code = pb.ErrorCode_TrollMaxItemCount
return
}
if gold < 0 { // 买入的金币
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{&cfg.Gameatn{
A: "attr",
T: "gold",
N: earn,
}}, true); code != pb.ErrorCode_Success {
code = this.module.ModuleUser.AddAttributeValue(session, comm.ResGold, int32(gold), true)
if code != pb.ErrorCode_Success { // 金币不足
code = pb.ErrorCode_GoldNoEnough
return
}
} else {
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
A: "attr",
T: "gold",
N: earn,
}}, true); code != pb.ErrorCode_Success {
return
}
}
// check npc level
if confLv := this.configure.GetTrollLv(trolltrain.GetNpcLv() + 1); confLv != nil {
if earn >= confLv.Money {

View File

@ -11,7 +11,12 @@ import (
//参数校验
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.TrollGetListReq) (code pb.ErrorCode) {
// sz := make(map[int32]int32, 0)
// sz[1] = -20
// sz[2] = -10
// this.BuyOrSell(session, &pb.TrollBuyOrSellReq{
// Items: sz,
// })
return
}
@ -30,6 +35,10 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
code = pb.ErrorCode_DBError
return
}
// 测试代码=====================
//this.module.TrollAI(session, trolltrain)
//===========================
maxCoefficient = this.configure.GetTrollMaxCoefficientNux() // 增长幅度的最大值
if maxCoefficient == 0 {
code = pb.ErrorCode_ConfigNoFound
@ -41,34 +50,43 @@ 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 // 经过的时间
/// 计算经过了多少个周期
sz := this.configure.GetTrollAllTrain()
var (
circletime int32 // 循环一个周期的时间
circleCount int32 // 循环的次数
leftTime int32
index int32
)
for _, v := range sz {
circletime += v
}
t := int32(time.Now().Unix() - trolltrain.RefreshTime) // 经过的时间
if t < sz[trolltrain.TarinPos-1] {
session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain})
return
}
trolltrain.Shop = make(map[int32]int32) // 清空商人的购买数据
update["shop"] = trolltrain.Shop
circleCount = (int32(t) / circletime) // 经过的周期数
leftTime = (int32(t) % circletime)
// 循环次数
trainNum := this.configure.GetTrollMaxTraintNum()
trolltrain.TarinPos += circleCount * trainNum // 计算火车的位置信息
index += circleCount * trainNum // 计算火车的位置信息
for _, v := range sz {
if leftTime <= v {
trolltrain.RefreshTime = time.Now().Unix() - int64(circleCount)
trolltrain.RangeId = (trolltrain.TarinPos % maxCoefficient)
trolltrain.RefreshTime = time.Now().Unix() + int64(leftTime-v)
trolltrain.TarinPos += index
trolltrain.RangeId += index
trolltrain.RangeId = (trolltrain.RangeId % maxCoefficient) + 1
trolltrain.TarinPos = (trolltrain.TarinPos % trainNum) + 1
update["refreshTime"] = trolltrain.RefreshTime
update["tarinPos"] = trolltrain.TarinPos
update["rangeId"] = trolltrain.RangeId
break
}
trolltrain.TarinPos += 1
index += 1
leftTime -= v
}
this.module.ModifyTrollData(session.GetUserId(), update)

View File

@ -45,6 +45,8 @@ func (this *modelTroll) getTrollList(uid string) (result *pb.DBTrollTrain, err e
TotalEarn: 0,
SellCount: 0,
RefreshTime: time.Now().Unix(),
AiCount: 0,
Shop: map[int32]int32{},
Ctime: time.Now().Unix(),
}
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {

View File

@ -51,7 +51,7 @@ func (this *Troll) ModifyTrollData(uid string, data map[string]interface{}) (cod
}
// AI 玩法
func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCode) {
func (this *Troll) TrollAI(session comm.IUserSession, troll *pb.DBTrollTrain) (code pb.ErrorCode) {
var (
trainCount int32 // 车站数量
fTime []int32 //每个车站货物刷新的时间
@ -59,10 +59,18 @@ func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCod
crossTime int32 // 经过的时间
girdNum int32 // 格子数量
leftGirdNum int32 // 购买后剩余格子数量
// 购买的货物
bugItem map[int32]int32 // 购买的数据
bugItemPrice map[int32]int32
constGold int32
curRangeId int32
)
if troll.Buy != 0 && troll.Sell != 0 {
return
}
bugItem = make(map[int32]int32, 0)
bugItemPrice = make(map[int32]int32, 0)
troll.Buy = 840
girdNum = troll.GridNum
maxGirdNum := this.configure.GetTrollRule(comm.TrollGridCount) // 获取背包最大格子数量
maxgoods := this.configure.GetTrollRule(comm.TrollItemCount) // 获取单个物品最大上限
@ -74,40 +82,45 @@ func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCod
fTime[i] = conf.Time
}
}
curRangeId = troll.RangeId
// 计算时间差
crossTime = int32(time.Now().Unix() - troll.RefreshTime)
if crossTime < 10 {
return
}
MaxRangeId := this.configure.GetTrollMaxCoefficientNux() // 随机增幅最大值
for i := 0; ; i++ {
index = int32(i) % trainCount
index = (int32(i) % trainCount)
if crossTime > fTime[index] { // 获取
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 {
curRangeId += 1
curRangeId = curRangeId%int32(MaxRangeId) + 1
if _d := this.configure.GetTrollCoefficient(curRangeId); _d != nil {
if troll.Buy <= int32(_d.Coefficient) { // 可以购买 那就尽最大的数量去买
goods := this.configure.GetTrollAllGoods() // 获取所有的货物信息
for _, v := range goods {
if leftGirdNum > 0 { // 剩余可购买格子数量
bugItemPrice[v.Id] = v.Goodsprice * _d.Coefficient / 1000 // 货物买入的价格
if troll.Items[v.Id] < v.Max { // 还可以购买的数量
// 先把这个格子填满
rd := troll.Items[v.Id] % maxgoods
buyN := v.Max - troll.Items[v.Id]
if buyN >= rd { // 只能买这个多 那就全买了
if buyN >= rd && rd != 0 { // 只能买这么多 那就全买了
troll.Items[v.Id] += rd
buyN -= rd
} else {
break
bugItem[v.Id] += rd
}
for {
if buyN >= maxgoods {
leftGirdNum -= 1
troll.Items[v.Id] += maxgoods
bugItem[v.Id] += maxgoods
if troll.Items[v.Id] >= v.Max {
break
}
}
if leftGirdNum <= 0 {
break
@ -116,13 +129,26 @@ func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCod
}
} else { // 补齐没有满的货物
rd := troll.Items[v.Id] % maxgoods
if rd != 0 {
troll.Items[v.Id] += (maxgoods - rd)
}
}
}
}
}
}
}
}
break
}
}
}
}
for k, v := range bugItem {
constGold += bugItemPrice[k] * v
}
code = this.ModuleUser.AddAttributeValue(session, comm.ResGold, -int32(constGold), true)
if code != pb.ErrorCode_Success { // 金币不足
code = pb.ErrorCode_GoldNoEnough
return
}
// 计算价格
return
}

View File

@ -226,6 +226,7 @@ const (
ErrorCode_SociatyBelongTo ErrorCode = 30025 //已是公会成员
ErrorCode_SociatyApplied ErrorCode = 30026 //已申请
ErrorCode_SociatyAppyLvNoEnough ErrorCode = 30027 //申请等级不满足
ErrorCode_SociatyTaskValidation ErrorCode = 30028 //任务未完成
// arena
ErrorCode_ArenaTicketBuyUp ErrorCode = 3101 //票据上限
ErrorCode_ArenaTicketNotEnough ErrorCode = 3102 //票据不足
@ -431,6 +432,7 @@ var (
30025: "SociatyBelongTo",
30026: "SociatyApplied",
30027: "SociatyAppyLvNoEnough",
30028: "SociatyTaskValidation",
3101: "ArenaTicketBuyUp",
3102: "ArenaTicketNotEnough",
3103: "ArenaTicketNpcInCd",
@ -629,6 +631,7 @@ var (
"SociatyBelongTo": 30025,
"SociatyApplied": 30026,
"SociatyAppyLvNoEnough": 30027,
"SociatyTaskValidation": 30028,
"ArenaTicketBuyUp": 3101,
"ArenaTicketNotEnough": 3102,
"ArenaTicketNpcInCd": 3103,
@ -675,7 +678,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0xb1, 0x22, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0xce, 0x22, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
@ -932,26 +935,28 @@ var file_errorcode_proto_rawDesc = []byte{
0x6f, 0x6e, 0x67, 0x54, 0x6f, 0x10, 0xc9, 0xea, 0x01, 0x12, 0x14, 0x0a, 0x0e, 0x53, 0x6f, 0x63,
0x69, 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x64, 0x10, 0xca, 0xea, 0x01, 0x12,
0x1b, 0x0a, 0x15, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x79, 0x4c, 0x76,
0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xcb, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x10,
0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x75, 0x79, 0x55, 0x70,
0x10, 0x9d, 0x18, 0x12, 0x19, 0x0a, 0x14, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b,
0x65, 0x74, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0x9e, 0x18, 0x12, 0x17,
0x0a, 0x12, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x4e, 0x70, 0x63,
0x49, 0x6e, 0x43, 0x64, 0x10, 0x9f, 0x18, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, 0x6c, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x4c, 0x65, 0x61, 0x72, 0x6e, 0x10, 0x81, 0x19, 0x12,
0x12, 0x0a, 0x0d, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x45, 0x72, 0x72, 0x44, 0x61, 0x74, 0x61,
0x10, 0x82, 0x19, 0x12, 0x19, 0x0a, 0x14, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x4c,
0x6f, 0x63, 0x6b, 0x65, 0x72, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x10, 0x83, 0x19, 0x12, 0x15,
0x0a, 0x10, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x65, 0x74, 0x53, 0x74, 0x61,
0x74, 0x65, 0x10, 0x84, 0x19, 0x12, 0x10, 0x0a, 0x0b, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x42, 0x75,
0x79, 0x4d, 0x61, 0x78, 0x10, 0xe5, 0x19, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x72, 0x6f, 0x6c, 0x6c,
0x53, 0x65, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x10, 0xe6, 0x19, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x72,
0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x6c, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10,
0xe7, 0x19, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x49, 0x74,
0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0xe8, 0x19, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f,
0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x4e, 0x6f, 0x74, 0x54, 0x75, 0x72, 0x6e, 0x65, 0x64,
0x4f, 0x6e, 0x10, 0xc9, 0x1a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xcb, 0xea, 0x01, 0x12, 0x1b, 0x0a, 0x15,
0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x54, 0x61, 0x73, 0x6b, 0x56, 0x61, 0x6c, 0x69, 0x64,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0xcc, 0xea, 0x01, 0x12, 0x15, 0x0a, 0x10, 0x41, 0x72, 0x65,
0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x75, 0x79, 0x55, 0x70, 0x10, 0x9d, 0x18,
0x12, 0x19, 0x0a, 0x14, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x4e,
0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0x9e, 0x18, 0x12, 0x17, 0x0a, 0x12, 0x41,
0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x4e, 0x70, 0x63, 0x49, 0x6e, 0x43,
0x64, 0x10, 0x9f, 0x18, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x65,
0x70, 0x65, 0x61, 0x74, 0x4c, 0x65, 0x61, 0x72, 0x6e, 0x10, 0x81, 0x19, 0x12, 0x12, 0x0a, 0x0d,
0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x45, 0x72, 0x72, 0x44, 0x61, 0x74, 0x61, 0x10, 0x82, 0x19,
0x12, 0x19, 0x0a, 0x14, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b,
0x65, 0x72, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x10, 0x83, 0x19, 0x12, 0x15, 0x0a, 0x10, 0x54,
0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x10,
0x84, 0x19, 0x12, 0x10, 0x0a, 0x0b, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x42, 0x75, 0x79, 0x4d, 0x61,
0x78, 0x10, 0xe5, 0x19, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x53, 0x65, 0x6c,
0x6c, 0x4d, 0x61, 0x78, 0x10, 0xe6, 0x19, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x72, 0x6f, 0x6c, 0x6c,
0x4d, 0x61, 0x78, 0x53, 0x65, 0x6c, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0xe7, 0x19, 0x12,
0x16, 0x0a, 0x11, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x49, 0x74, 0x65, 0x6d, 0x43,
0x6f, 0x75, 0x6e, 0x74, 0x10, 0xe8, 0x19, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f, 0x72, 0x6f, 0x73,
0x63, 0x6f, 0x70, 0x65, 0x4e, 0x6f, 0x74, 0x54, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x4f, 0x6e, 0x10,
0xc9, 0x1a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (

View File

@ -40,7 +40,9 @@ type DBTrollTrain struct {
TotalEarn int64 `protobuf:"varint,12,opt,name=totalEarn,proto3" json:"totalEarn" bson:"totalEarn"` //累计赚的钱
SellCount int32 `protobuf:"varint,13,opt,name=sellCount,proto3" json:"sellCount" bson:"sellCount"` //今天已经卖出次数
RefreshTime int64 `protobuf:"varint,14,opt,name=refreshTime,proto3" json:"refreshTime" bson:"refreshTime"` //最后一次刷新的时间 通过这个计算下一次刷新时间
Ctime int64 `protobuf:"varint,15,opt,name=ctime,proto3" json:"ctime"`
AiCount int32 `protobuf:"varint,15,opt,name=aiCount,proto3" json:"aiCount"` //@go_tags(`bson:"aiCount"` AI 交易次数
Shop map[int32]int32 `protobuf:"bytes,16,rep,name=shop,proto3" json:"shop" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 商人的限购数量
Ctime int64 `protobuf:"varint,17,opt,name=ctime,proto3" json:"ctime"`
}
func (x *DBTrollTrain) Reset() {
@ -173,6 +175,20 @@ func (x *DBTrollTrain) GetRefreshTime() int64 {
return 0
}
func (x *DBTrollTrain) GetAiCount() int32 {
if x != nil {
return x.AiCount
}
return 0
}
func (x *DBTrollTrain) GetShop() map[int32]int32 {
if x != nil {
return x.Shop
}
return nil
}
func (x *DBTrollTrain) GetCtime() int64 {
if x != nil {
return x.Ctime
@ -184,7 +200,7 @@ var File_troll_troll_db_proto protoreflect.FileDescriptor
var file_troll_troll_db_proto_rawDesc = []byte{
0x0a, 0x14, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5f, 0x64, 0x62,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfe, 0x04, 0x0a, 0x0c, 0x44, 0x42, 0x54, 0x72, 0x6f,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfe, 0x05, 0x0a, 0x0c, 0x44, 0x42, 0x54, 0x72, 0x6f,
0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2e, 0x0a, 0x05, 0x69, 0x74, 0x65,
@ -212,16 +228,24 @@ var file_troll_troll_db_proto_rawDesc = []byte{
0x28, 0x05, 0x52, 0x09, 0x73, 0x65, 0x6c, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x20, 0x0a,
0x0b, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01,
0x28, 0x03, 0x52, 0x0b, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x12,
0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05,
0x63, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a,
0x38, 0x0a, 0x0a, 0x50, 0x72, 0x69, 0x63, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a,
0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4e, 0x70, 0x63,
0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x18, 0x0a, 0x07, 0x61, 0x69, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05,
0x52, 0x07, 0x61, 0x69, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x73, 0x68, 0x6f,
0x70, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f, 0x6c,
0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x52, 0x04, 0x73, 0x68, 0x6f, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18,
0x11, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x38, 0x0a, 0x0a,
0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x38, 0x0a, 0x0a, 0x50, 0x72, 0x69, 0x63, 0x65, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
0x1a, 0x3c, 0x0a, 0x0e, 0x4e, 0x70, 0x63, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x37,
0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
@ -240,22 +264,24 @@ func file_troll_troll_db_proto_rawDescGZIP() []byte {
return file_troll_troll_db_proto_rawDescData
}
var file_troll_troll_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_troll_troll_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_troll_troll_db_proto_goTypes = []interface{}{
(*DBTrollTrain)(nil), // 0: DBTrollTrain
nil, // 1: DBTrollTrain.ItemsEntry
nil, // 2: DBTrollTrain.PriceEntry
nil, // 3: DBTrollTrain.NpcRewardEntry
nil, // 4: DBTrollTrain.ShopEntry
}
var file_troll_troll_db_proto_depIdxs = []int32{
1, // 0: DBTrollTrain.items:type_name -> DBTrollTrain.ItemsEntry
2, // 1: DBTrollTrain.price:type_name -> DBTrollTrain.PriceEntry
3, // 2: DBTrollTrain.npcReward:type_name -> DBTrollTrain.NpcRewardEntry
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
4, // 3: DBTrollTrain.shop:type_name -> DBTrollTrain.ShopEntry
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_troll_troll_db_proto_init() }
@ -283,7 +309,7 @@ func file_troll_troll_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_troll_troll_db_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 5,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -210,6 +210,7 @@ type TrollAfkSetReq struct {
Buy int32 `protobuf:"varint,1,opt,name=buy,proto3" json:"buy"`
Sell int32 `protobuf:"varint,2,opt,name=sell,proto3" json:"sell"`
Count int32 `protobuf:"varint,3,opt,name=count,proto3" json:"count"` // 挂机次数
}
func (x *TrollAfkSetReq) Reset() {
@ -258,6 +259,13 @@ func (x *TrollAfkSetReq) GetSell() int32 {
return 0
}
func (x *TrollAfkSetReq) GetCount() int32 {
if x != nil {
return x.Count
}
return 0
}
type TrollAfkSetResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -422,21 +430,23 @@ var file_troll_troll_msg_proto_rawDesc = []byte{
0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x42, 0x75, 0x79, 0x4f, 0x72, 0x53, 0x65, 0x6c, 0x6c, 0x52, 0x65,
0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0d, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x41, 0x66,
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x4c, 0x0a, 0x0e, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x41, 0x66,
0x6b, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x75, 0x79, 0x18, 0x01,
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x62, 0x75, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x6c,
0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x65, 0x6c, 0x6c, 0x22, 0x34, 0x0a,
0x0f, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x41, 0x66, 0x6b, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70,
0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x65, 0x6c, 0x6c, 0x12, 0x14, 0x0a,
0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f,
0x75, 0x6e, 0x74, 0x22, 0x34, 0x0a, 0x0f, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x41, 0x66, 0x6b, 0x53,
0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x54, 0x72,
0x61, 0x69, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2f, 0x0a, 0x11, 0x54, 0x72, 0x6f,
0x6c, 0x6c, 0x4e, 0x70, 0x63, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a,
0x0a, 0x08, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x08, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x12, 0x54, 0x72,
0x6f, 0x6c, 0x6c, 0x4e, 0x70, 0x63, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70,
0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d,
0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x04, 0x64,
0x61, 0x74, 0x61, 0x22, 0x2f, 0x0a, 0x11, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4e, 0x70, 0x63, 0x52,
0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x77, 0x61,
0x72, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x77, 0x61,
0x72, 0x64, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x12, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4e, 0x70, 0x63,
0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61,
0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f,
0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (