This commit is contained in:
liwei 2022-10-31 12:05:07 +08:00
parent 825889c867
commit 8c017bff27
19 changed files with 474 additions and 222 deletions

View File

@ -1,50 +1,50 @@
[
{
"id": 1,
"coefficient": "1012"
"coefficient": 1012
},
{
"id": 2,
"coefficient": "1024"
"coefficient": 1024
},
{
"id": 3,
"coefficient": "1036"
"coefficient": 1036
},
{
"id": 4,
"coefficient": "1048"
"coefficient": 1048
},
{
"id": 5,
"coefficient": "1060"
"coefficient": 1060
},
{
"id": 6,
"coefficient": "1072"
"coefficient": 1072
},
{
"id": 7,
"coefficient": "900"
"coefficient": 900
},
{
"id": 8,
"coefficient": "888"
"coefficient": 888
},
{
"id": 9,
"coefficient": "876"
"coefficient": 876
},
{
"id": 10,
"coefficient": "864"
"coefficient": 864
},
{
"id": 11,
"coefficient": "852"
"coefficient": 852
},
{
"id": 12,
"coefficient": "840"
"coefficient": 840
}
]

View File

@ -1,38 +1,38 @@
[
{
"id": 1,
"quantity": "5"
"quantity": 5
},
{
"id": 2,
"quantity": "20"
"quantity": 20
},
{
"id": 3,
"quantity": "40"
"quantity": 40
},
{
"id": 4,
"quantity": "20"
"quantity": 20
},
{
"id": 5,
"quantity": "300"
"quantity": 300
},
{
"id": 6,
"quantity": "1020"
"quantity": 1020
},
{
"id": 7,
"quantity": "980"
"quantity": 980
},
{
"id": 8,
"quantity": "5"
"quantity": 5
},
{
"id": 9,
"quantity": "1500"
"quantity": 1500
}
]

View File

@ -32,38 +32,39 @@ const (
//模块名定义处
const (
ModuleSys core.M_Modules = "sys" //系统
ModuleGate core.M_Modules = "gateway" //gate模块 网关服务模块
ModuleWeb core.M_Modules = "web" //后台模块
ModuleUser core.M_Modules = "user" //用户模块
ModulePack core.M_Modules = "pack" //背包模块
ModuleMail core.M_Modules = "mail" //邮件模块
ModuleFriend core.M_Modules = "friend" //好友模块
ModuleMgoLog core.M_Modules = "mgolog" //日志模块
ModuleEquipment core.M_Modules = "equipment" //装备模块
ModuleHero core.M_Modules = "hero" //英雄模块
ModuleForum core.M_Modules = "forum" //论坛模块
ModuleItems core.M_Modules = "items" //道具模块
ModuleShop core.M_Modules = "shop" //商店模块
ModuleTask core.M_Modules = "task" //任务模块
ModuleMainline core.M_Modules = "mainline" //主线模块
ModuleNotify core.M_Modules = "notify" //公告模块
ModuleChat core.M_Modules = "chat" //聊天模块
ModuleGM core.M_Modules = "gm" //gm模块
ModulePagoda core.M_Modules = "pagoda" //魔塔模块
ModuleMartialhall core.M_Modules = "martialhall" //武馆模块
ModuleGourmet core.M_Modules = "gourmet" //美食馆
ModuleRtask core.M_Modules = "rtask" //随机任务
ModuleSmithy core.M_Modules = "smithy" //铁匠铺
ModuleTimer core.M_Modules = "timer" //定时任务模块
ModuleViking core.M_Modules = "viking" //维京远征
ModuleMoonfantasy core.M_Modules = "moonfantasy" //月之秘境模块
ModuleHunting core.M_Modules = "hunting" //狩猎
ModuleLinestory core.M_Modules = "linestory" //支线剧情
ModuleBattle core.M_Modules = "battle" //战斗
ModuleLibrary core.M_Modules = "library" //藏书馆
ModuleArena core.M_Modules = "arena" //竞技场
ModuleTroll core.M_Modules = "troll" //巨怪商队
ModuleSys core.M_Modules = "sys" //系统
ModuleGate core.M_Modules = "gateway" //gate模块 网关服务模块
ModuleWeb core.M_Modules = "web" //后台模块
ModuleUser core.M_Modules = "user" //用户模块
ModulePack core.M_Modules = "pack" //背包模块
ModuleMail core.M_Modules = "mail" //邮件模块
ModuleFriend core.M_Modules = "friend" //好友模块
ModuleMgoLog core.M_Modules = "mgolog" //日志模块
ModuleEquipment core.M_Modules = "equipment" //装备模块
ModuleHero core.M_Modules = "hero" //英雄模块
ModuleForum core.M_Modules = "forum" //论坛模块
ModuleItems core.M_Modules = "items" //道具模块
ModuleShop core.M_Modules = "shop" //商店模块
ModuleTask core.M_Modules = "task" //任务模块
ModuleMainline core.M_Modules = "mainline" //主线模块
ModuleNotify core.M_Modules = "notify" //公告模块
ModuleChat core.M_Modules = "chat" //聊天模块
ModuleGM core.M_Modules = "gm" //gm模块
ModulePagoda core.M_Modules = "pagoda" //魔塔模块
ModuleMartialhall core.M_Modules = "martialhall" //武馆模块
ModuleGourmet core.M_Modules = "gourmet" //美食馆
ModuleRtask core.M_Modules = "rtask" //随机任务
ModuleSmithy core.M_Modules = "smithy" //铁匠铺
ModuleTimer core.M_Modules = "timer" //定时任务模块
ModuleViking core.M_Modules = "viking" //维京远征
ModuleMoonfantasy core.M_Modules = "moonfantasy" //月之秘境模块
ModuleHunting core.M_Modules = "hunting" //狩猎
ModuleLinestory core.M_Modules = "linestory" //支线剧情
ModuleBattle core.M_Modules = "battle" //战斗
ModuleLibrary core.M_Modules = "library" //藏书馆
ModuleArena core.M_Modules = "arena" //竞技场
ModuleTroll core.M_Modules = "troll" //巨怪商队
ModuleConstellation core.M_Modules = "constellation" //星座图
//ModuleFetter core.M_Modules = "herofetter" //好友模块
)

View File

@ -0,0 +1,30 @@
package constellation
import (
"go_dreamfactory/modules"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
)
/*
API
*/
type apiComp struct {
modules.MCompGate
service base.IRPCXService
module *Constellation
}
//组件初始化接口
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompGate.Init(service, module, comp, options)
this.module = module.(*Constellation)
this.service = service.(base.IRPCXService)
return
}
func (this *apiComp) Start() (err error) {
err = this.MCompGate.Start()
return
}

View File

@ -0,0 +1,29 @@
package constellation
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
)
/*
模块名:星座图
描述:全局属性增幅器
开发:李伟
*/
func NewModule() core.IModule {
m := new(Constellation)
return m
}
type Constellation struct {
modules.ModuleBase
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
options *Options
}
//模块名
func (this *Constellation) GetType() core.M_Modules {
return comm.ModuleChat
}

View File

@ -0,0 +1,40 @@
package constellation
import (
"errors"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/utils/mapstructure"
"go_dreamfactory/modules"
)
type (
IOptions interface {
modules.IOptions
}
Options struct {
modules.Options
}
)
func (this *Options) GetDebug() bool {
return this.Debug
}
func (this *Options) GetLog() log.ILogger {
return this.Log
}
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
if settings != nil {
if err = mapstructure.Decode(settings, &this.Options); err != nil {
return
}
if err = mapstructure.Decode(settings, this); err != nil {
return
}
}
if this.Log = log.NewTurnlog(true, log.Clone("", 4)); this.Log == nil {
err = errors.New("log is nil")
}
return
}

View File

@ -1,13 +1,10 @@
package pagoda
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/redis/pipe"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto"
@ -15,50 +12,7 @@ import (
//参数校验
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.PagodaGetListReq) (code pb.ErrorCode) {
uid := session.GetUserId()
if !this.module.IsCross() {
if conn, err := db.Cross(); err == nil {
//userinfo := this.module.ModuleUser.GetUser(session.GetUserId())
// newData := &pb.DBPagodaRecord{
// Id: primitive.NewObjectID().Hex(),
// Uid: session.GetUserId(),
// PagodaId: 111,
// Type: 201,
// Nickname: userinfo.Name,
// Icon: "", // icon 暂无
// Lv: userinfo.Lv,
// CostTime: 1002,
// }
//conn.Mgo.InsertOne(comm.TablePagodaRecord, newData)
var (
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
menbers *redis.Z
)
menbers = &redis.Z{Score: float64(500), Member: uid}
if cmd := pipe.ZAdd("pagodaList", menbers); cmd != nil {
this.module.Errorln(err)
dock, err1 := cmd.Result()
this.module.Errorln(dock, err1)
}
if _, err = pipe.Exec(); err != nil {
this.module.Errorln(err)
return
}
//rd := pipe.ZRevRank("pagodaList", "dfmxf_6358f3f1375f6a340a12e2ab01234567")
rd := pipe.ZRange("pagodaList", 1, 5)
if _, err = pipe.Exec(); err != nil {
this.module.Errorln(err)
return
}
_data3 := rd.Val()
_data, err2 := rd.Result()
this.module.Errorln(_data, err2, _data3)
}
}
return
}

View File

@ -118,7 +118,17 @@ func TestXxx(t *testing.T) {
// menbers[i] = &redis.Z{Score: float64(i), Member: uid}
// }
// if cmd := pipe.ZAdd("pagodaList", menbers...); cmd != nil {
// uid := session.GetUserId()
// if !this.module.IsCross() {
// if conn, err := db.Cross(); err == nil {
// var (
// pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
// menbers *redis.Z
// )
// menbers = &redis.Z{Score: float64(500), Member: uid}
// if cmd := pipe.ZAdd("pagodaList", menbers); cmd != nil {
// this.module.Errorln(err)
// dock, err1 := cmd.Result()
@ -128,8 +138,8 @@ func TestXxx(t *testing.T) {
// this.module.Errorln(err)
// return
// }
// rd := pipe.ZRevRank("pagodaList", "dfmxf_6358f3f1375f6a340a12e2ab01234567")
// //rd := pipe.ZRange("pagodaList", 1, 5)
// //rd := pipe.ZRevRank("pagodaList", "dfmxf_6358f3f1375f6a340a12e2ab01234567")
// rd := pipe.ZRange("pagodaList", 1, 5)
// if _, err = pipe.Exec(); err != nil {
// this.module.Errorln(err)
// return
@ -139,35 +149,4 @@ func TestXxx(t *testing.T) {
// this.module.Errorln(_data, err2, _data3)
// }
// }
// if !this.module.IsCross() {
// if conn, err := db.Cross(); err == nil {
// userinfo := this.module.ModuleUser.GetUser(session.GetUserId())
// newData := &pb.DBPagodaRecord{
// Id: primitive.NewObjectID().Hex(),
// Uid: session.GetUserId(),
// PagodaId: 100,
// Type: 201,
// Nickname: userinfo.Name,
// Icon: "", // icon 暂无
// Lv: userinfo.Lv,
// CostTime: 1001,
// }
// menbers := make([]*redis.Z, 2)
// menbers[0] = &redis.Z{Score: float64(123), Member: "dfmxf_001"}
// menbers[1] = &redis.Z{Score: float64(13), Member: "dfmxf_002"}
// pipe := conn.Redis.RedisPipe(context.TODO())
// if cmd := pipe.ZAdd("ranklist", menbers...); err != nil {
// this.module.Errorln(err)
// } else {
// if _, err = cmd.Result(); err != nil {
// this.module.Errorln(err)
// return
// }
// }
// conn.Mgo.InsertOne(comm.TablePagodaRecord, newData)
// }
// }
}

View File

@ -7,6 +7,7 @@ import (
const (
TrollGetListResp = "getlist"
TrollBuyOrSellResp = "buyorsell"
GourmetCreateOrderResp = "createorder"
GourmetSkillLvResp = "skilllv"
TrollNpcRewardResp = "npcreward"

View File

@ -0,0 +1,108 @@
package troll
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) BuyOrSellCheck(session comm.IUserSession, req *pb.TrollBuyOrSellReq) (code pb.ErrorCode) {
if len(req.Items) == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
///获取美食城基本信息
func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSellReq) (code pb.ErrorCode, data proto.Message) {
var (
//bSell bool // 是否有出售
gold int32 // 当次交易 获得的金币
earn int32 // 只统计赚的金币
update map[string]interface{}
)
update = make(map[string]interface{})
if code = this.BuyOrSellCheck(session, req); code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
trolltrain, err := this.module.modelTroll.getTrollList(session.GetUserId())
if err != nil {
code = pb.ErrorCode_DBError
return
}
for k, v := range req.Items {
if v < 0 {
//bSell = true
trolltrain.SellCount += 1 // 交易次数+1
}
trolltrain.Items[k] += v
// 校验 是否大于买入最大限制
goods := this.configure.GetTrollGoods(k)
if goods == nil {
return
}
if goods.Max < trolltrain.Items[k] { // 判断是否有效交易
// TODO 买入上限 直接返回
//code = pb.ErrorCode_
return
} else if trolltrain.Items[k] < 0 {
// TODO 卖出数量不足 直接返回
return
}
// 第一次购买商品
if trolltrain.TarinPos == 0 {
trolltrain.Price[k] = goods.Goodsprice * goods.StarMoney / 1000
trolltrain.RefreshTime = time.Now().Unix()
//消耗的金币
gold = trolltrain.Price[k] * trolltrain.Items[k]
} else {
p := this.configure.GetTrollCoefficient(trolltrain.TarinPos)
if p == nil {
return
}
if v < 0 { // 卖出
// 卖出价格
var sellPrice int32
if trolltrain.TarinPos == 0 {
sellPrice = goods.Goodsprice * goods.StarMoney / 1000
} else {
sellPrice = int32(p.Coefficient) * goods.Goodsprice / 1000
}
if sellPrice > trolltrain.Price[k] { // 赚了
earn += (sellPrice - trolltrain.Price[k]) * trolltrain.Items[k]
}
gold += (sellPrice - trolltrain.Price[k]) * trolltrain.Items[k]
} else { // 买入 计算平均价格
totalGold := trolltrain.Items[k] * trolltrain.Price[k]
sellPrice := int32(p.Coefficient) * goods.Goodsprice / 1000
totalGold += v * goods.Goodsprice * sellPrice
trolltrain.Price[k] = totalGold / (trolltrain.Items[k] + v)
}
}
if gold < 0 {
if code = this.module.CheckRes(session, []*cfg.Gameatn{&cfg.Gameatn{
A: "attr",
T: "gold",
N: earn,
}}); code != pb.ErrorCode_Success {
return
}
}
}
trolltrain.TotalEarn += int64(earn) // 累计获得的金币
update["items"] = trolltrain.Items
update["price"] = trolltrain.Price
update["totalEarn"] = trolltrain.TotalEarn
this.module.ModifyTrollData(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), TrollBuyOrSellResp, &pb.TrollBuyOrSellResp{Data: trolltrain})
return
}

View File

@ -3,7 +3,6 @@ package troll
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"time"
"google.golang.org/protobuf/proto"
)
@ -17,19 +16,15 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.TrollGetLis
///获取美食城基本信息
func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq) (code pb.ErrorCode, data proto.Message) {
code = this.GetListCheck(session, req)
if code != pb.ErrorCode_Success {
if code = this.GetListCheck(session, req); code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
_gourmet, err := this.module.modelTroll.getTrollList(session.GetUserId())
trolltrain, err := this.module.modelTroll.getTrollList(session.GetUserId())
if err != nil {
code = pb.ErrorCode_DBError
return
}
if _gourmet.Ctime == 0 {
_gourmet.Ctime = time.Now().Unix()
}
session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: _gourmet})
session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain})
return
}

View File

@ -10,46 +10,29 @@ import (
)
const (
game_gourmet = "game_gourmet.json"
game_gourmetskill = "game_gourmetskill.json"
game_trollgoods = "game_trollgoods.json"
game_trollcoefficient = "game_trollcoefficient.json"
game_trolltrain = "game_trolltrain.json"
game_trollrule = "game_trollrule.json"
)
///配置管理基础组件
type configureComp struct {
hlock sync.RWMutex
modules.MCompConfigure
_gourmetMap map[int64]*cfg.GameGourmetData
}
//组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options)
this._gourmetMap = make(map[int64]*cfg.GameGourmetData, 0)
configure.RegisterConfigure(game_gourmet, cfg.NewGameGourmet, func() {
if v, err := this.GetConfigure(game_gourmet); err == nil {
if configure, ok := v.(*cfg.GameGourmet); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
for _, value := range configure.GetDataList() {
this._gourmetMap[int64(value.Type<<16)+int64(value.Level)] = value
}
return
}
}
log.Errorf("get game_pagoda conf err:%v", err)
return
})
this.LoadConfigure(game_trollgoods, cfg.NewGameTrollGoods)
this.LoadConfigure(game_trollcoefficient, cfg.NewGameTrollCoefficient)
this.LoadConfigure(game_trolltrain, cfg.NewGameTrollTrain)
this.LoadConfigure(game_trollrule, cfg.NewGameTrollRule)
return
}
// 获取美食馆配置数据
func (this *configureComp) GetGourmetConfigData(gourmetType int32, level int32) (data *cfg.GameGourmetData) {
return this._gourmetMap[int64(gourmetType<<16)+int64(level)]
}
//加载多个配置文件
func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
for k, v := range confs {
@ -66,19 +49,54 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
return configure.GetConfigure(name)
}
func (this *configureComp) GetGourmetSkillConfigBySkillType(skillType int32) (data []int32) {
data = make([]int32, 0)
if v, err := this.GetConfigure(game_gourmet); err == nil {
if configure, ok := v.(*cfg.GameGourmet); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
for _, value := range configure.GetDataList() {
if value.SkillType == skillType && value.Initial == 1 {
data = append(data, value.Type)
}
}
// 获取列车货物信息
func (this *configureComp) GetTrollGoods(itemId int32) (data *cfg.GameTrollGoodsData) {
if v, err := this.GetConfigure(game_trollgoods); err == nil {
if configure, ok := v.(*cfg.GameTrollGoods); ok {
data = configure.Get(itemId)
return
}
} else {
log.Errorf("get GameTrollGoodsData conf err:%v", err)
}
return
}
// 获取商人位置信息
func (this *configureComp) GetTrollTrain(id int32) (data *cfg.GameTrollTrainData) {
if v, err := this.GetConfigure(game_trolltrain); err == nil {
if configure, ok := v.(*cfg.GameTrollTrain); ok {
data = configure.Get(id)
return
}
} else {
log.Errorf("get GameTrollTrainData conf err:%v", err)
}
return
}
// 获取基本规则
func (this *configureComp) GetTrollRule(id int32) (data *cfg.GameTrollRuleData) {
if v, err := this.GetConfigure(game_trollrule); err == nil {
if configure, ok := v.(*cfg.GameTrollRule); ok {
data = configure.Get(id)
return
}
} else {
log.Errorf("get GameTrollRuleData conf err:%v", err)
}
return
}
func (this *configureComp) GetTrollCoefficient(id int32) (data *cfg.GameTrollCoefficientData) {
if v, err := this.GetConfigure(game_trollcoefficient); err == nil {
if configure, ok := v.(*cfg.GameTrollCoefficient); ok {
data = configure.Get(id)
return
}
} else {
log.Errorf("get GameTrollCoefficientData conf err:%v", err)
}
return
}

View File

@ -3,9 +3,12 @@ package troll
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
@ -27,9 +30,26 @@ func (this *modelTroll) Init(service core.IService, module core.IModule, comp co
}
func (this *modelTroll) getTrollList(uid string) (result *pb.DBTrollTrain, err error) {
result = &pb.DBTrollTrain{}
if err = this.Get(uid, result); err != nil {
result = &pb.DBTrollTrain{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
Items: map[int32]int32{},
Price: map[int32]int32{},
GridNum: 0,
TarinPos: 1,
RangeId: 0,
Buy: 0,
Sell: 0,
NpcLv: 0,
NpcReward: map[int32]int32{},
TotalEarn: 0,
SellCount: 0,
RefreshTime: time.Now().Unix(),
Ctime: time.Now().Unix(),
}
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
// 创建一条数据
err = this.Add(uid, result)
return
}
err = nil

View File

@ -10,6 +10,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
)
type Troll struct {
@ -48,3 +49,40 @@ func (this *Troll) ModifyTrollData(uid string, data map[string]interface{}) (cod
}
return
}
// AI 玩法
func (this *Troll) TrollAI(uid string, troll *pb.DBTrollTrain) (code pb.ErrorCode) {
if troll.Buy != 0 && troll.Sell != 0 {
return
}
var fTime [3]int32
for i := 0; i < 3; i++ {
if conf := this.configure.GetTrollTrain(int32(i) + 1); conf != nil {
fTime[i] = conf.Time
}
}
var (
index int32
crossTime int32 // 经过的时间
)
// 计算时间差
crossTime = int32(time.Now().Unix() - troll.RefreshTime)
for i := 0; ; i++ {
index = int32(i) % 3
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
}
}
}
return
}

View File

@ -49,7 +49,7 @@ func (this *modelViking) getVikingList(uid string) (result *pb.DBViking, err err
result.BossTime[str] = 0
}
}
this.module.modelViking.Add(uid, result)
this.Add(uid, result)
}
err = nil
return result, err

View File

@ -26,18 +26,21 @@ type DBTrollTrain struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
Items map[int32]int32 `protobuf:"bytes,3,rep,name=items,proto3" json:"items" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 货物
GridNum int32 `protobuf:"varint,4,opt,name=gridNum,proto3" json:"gridNum" bson:"gridNum"` //当前使用格子数量
TarinPos int32 `protobuf:"varint,5,opt,name=tarinPos,proto3" json:"tarinPos" bson:"tarinPos"` //火车位置
RangeId int32 `protobuf:"varint,6,opt,name=rangeId,proto3" json:"rangeId" bson:"rangeId"` //增长幅度
Buy int32 `protobuf:"varint,7,opt,name=buy,proto3" json:"buy"` // 挂机进货标准/千分比
Sell int32 `protobuf:"varint,8,opt,name=sell,proto3" json:"sell"` //挂机卖出标准/千分比
NpcLv int32 `protobuf:"varint,9,opt,name=npcLv,proto3" json:"npcLv" bson:"npcLv"` //npc 等级
NpcReward map[int32]int32 `protobuf:"bytes,10,rep,name=npcReward,proto3" json:"npcReward" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"npcReward"` //npc奖励
TotalEarn int64 `protobuf:"varint,11,opt,name=totalEarn,proto3" json:"totalEarn" bson:"totalEarn"` //累计赚的钱
Ctime int64 `protobuf:"varint,12,opt,name=ctime,proto3" json:"ctime"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
Items map[int32]int32 `protobuf:"bytes,3,rep,name=items,proto3" json:"items" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 货物 key 货物ID
Price map[int32]int32 `protobuf:"bytes,4,rep,name=price,proto3" json:"price" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 货物买入价格 key 货物ID
GridNum int32 `protobuf:"varint,5,opt,name=gridNum,proto3" json:"gridNum" bson:"gridNum"` //当前使用格子数量
TarinPos int32 `protobuf:"varint,6,opt,name=tarinPos,proto3" json:"tarinPos" bson:"tarinPos"` //火车位置 (商人位置)
RangeId int32 `protobuf:"varint,7,opt,name=rangeId,proto3" json:"rangeId" bson:"rangeId"` //增长幅度
Buy int32 `protobuf:"varint,8,opt,name=buy,proto3" json:"buy"` // 挂机进货标准/千分比
Sell int32 `protobuf:"varint,9,opt,name=sell,proto3" json:"sell"` //挂机卖出标准/千分比
NpcLv int32 `protobuf:"varint,10,opt,name=npcLv,proto3" json:"npcLv" bson:"npcLv"` //npc 等级
NpcReward map[int32]int32 `protobuf:"bytes,11,rep,name=npcReward,proto3" json:"npcReward" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"npcReward"` //npc奖励
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"`
}
func (x *DBTrollTrain) Reset() {
@ -93,6 +96,13 @@ func (x *DBTrollTrain) GetItems() map[int32]int32 {
return nil
}
func (x *DBTrollTrain) GetPrice() map[int32]int32 {
if x != nil {
return x.Price
}
return nil
}
func (x *DBTrollTrain) GetGridNum() int32 {
if x != nil {
return x.GridNum
@ -149,6 +159,20 @@ func (x *DBTrollTrain) GetTotalEarn() int64 {
return 0
}
func (x *DBTrollTrain) GetSellCount() int32 {
if x != nil {
return x.SellCount
}
return 0
}
func (x *DBTrollTrain) GetRefreshTime() int64 {
if x != nil {
return x.RefreshTime
}
return 0
}
func (x *DBTrollTrain) GetCtime() int64 {
if x != nil {
return x.Ctime
@ -160,37 +184,48 @@ 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, 0xd4, 0x03, 0x0a, 0x0c, 0x44, 0x42, 0x54, 0x72, 0x6f,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfe, 0x04, 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,
0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f,
0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x69,
0x64, 0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x67, 0x72, 0x69, 0x64,
0x72, 0x79, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x2e, 0x0a, 0x05, 0x70, 0x72, 0x69,
0x63, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f,
0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x2e, 0x50, 0x72, 0x69, 0x63, 0x65, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x69,
0x64, 0x4e, 0x75, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x67, 0x72, 0x69, 0x64,
0x4e, 0x75, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x72, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x18,
0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x72, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x12,
0x18, 0x0a, 0x07, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05,
0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x72, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x12,
0x18, 0x0a, 0x07, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05,
0x52, 0x07, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x75, 0x79,
0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x62, 0x75, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x73,
0x65, 0x6c, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x65, 0x6c, 0x6c, 0x12,
0x14, 0x0a, 0x05, 0x6e, 0x70, 0x63, 0x4c, 0x76, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x62, 0x75, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x73,
0x65, 0x6c, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x65, 0x6c, 0x6c, 0x12,
0x14, 0x0a, 0x05, 0x6e, 0x70, 0x63, 0x4c, 0x76, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
0x6e, 0x70, 0x63, 0x4c, 0x76, 0x12, 0x3a, 0x0a, 0x09, 0x6e, 0x70, 0x63, 0x52, 0x65, 0x77, 0x61,
0x72, 0x64, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f,
0x72, 0x64, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x44, 0x42, 0x54, 0x72, 0x6f,
0x6c, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x2e, 0x4e, 0x70, 0x63, 0x52, 0x65, 0x77, 0x61, 0x72,
0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6e, 0x70, 0x63, 0x52, 0x65, 0x77, 0x61, 0x72,
0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x61, 0x72, 0x6e, 0x18, 0x0b,
0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x61, 0x72, 0x6e, 0x18, 0x0c,
0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x61, 0x72, 0x6e, 0x12,
0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05,
0x1c, 0x0a, 0x09, 0x73, 0x65, 0x6c, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0d, 0x20, 0x01,
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,
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, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -205,20 +240,22 @@ 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, 3)
var file_troll_troll_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_troll_troll_db_proto_goTypes = []interface{}{
(*DBTrollTrain)(nil), // 0: DBTrollTrain
nil, // 1: DBTrollTrain.ItemsEntry
nil, // 2: DBTrollTrain.NpcRewardEntry
nil, // 2: DBTrollTrain.PriceEntry
nil, // 3: DBTrollTrain.NpcRewardEntry
}
var file_troll_troll_db_proto_depIdxs = []int32{
1, // 0: DBTrollTrain.items:type_name -> DBTrollTrain.ItemsEntry
2, // 1: DBTrollTrain.npcReward:type_name -> DBTrollTrain.NpcRewardEntry
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
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
}
func init() { file_troll_troll_db_proto_init() }
@ -246,7 +283,7 @@ func file_troll_troll_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_troll_troll_db_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -28,6 +28,7 @@ import (
"go_dreamfactory/modules/smithy"
"go_dreamfactory/modules/sys"
"go_dreamfactory/modules/task"
"go_dreamfactory/modules/troll"
"go_dreamfactory/modules/user"
"go_dreamfactory/modules/viking"
"go_dreamfactory/pb"
@ -90,6 +91,7 @@ func main() {
linestory.NewModule(),
library.NewModule(),
arena.NewModule(),
troll.NewModule(),
)
}

View File

@ -12,7 +12,7 @@ import "errors"
type GameTrollCoefficientData struct {
Id int32
Coefficient string
Coefficient int32
}
const TypeId_GameTrollCoefficientData = -856241206
@ -23,7 +23,7 @@ func (*GameTrollCoefficientData) GetTypeId() int32 {
func (_v *GameTrollCoefficientData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
{ var _ok_ bool; if _v.Coefficient, _ok_ = _buf["coefficient"].(string); !_ok_ { err = errors.New("coefficient error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["coefficient"].(float64); !_ok_ { err = errors.New("coefficient error"); return }; _v.Coefficient = int32(_tempNum_) }
return
}

View File

@ -12,7 +12,7 @@ import "errors"
type GameTrollRuleData struct {
Id int32
Quantity string
Quantity int32
}
const TypeId_GameTrollRuleData = 902547931
@ -23,7 +23,7 @@ func (*GameTrollRuleData) GetTypeId() int32 {
func (_v *GameTrollRuleData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
{ var _ok_ bool; if _v.Quantity, _ok_ = _buf["quantity"].(string); !_ok_ { err = errors.New("quantity error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["quantity"].(float64); !_ok_ { err = errors.New("quantity error"); return }; _v.Quantity = int32(_tempNum_) }
return
}