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

This commit is contained in:
meixiongfeng 2022-11-08 18:10:21 +08:00
commit 8640273534
13 changed files with 157 additions and 36 deletions

View File

@ -230,6 +230,8 @@ const ( //Rpc
// 充值发货
Rpc_ModulePayDelivery core.Rpc_Key = "Rpc_ModuleArenaRaceSettlement" //充值发货
// 羁绊信息
Rpc_ModuleFetter core.Rpc_Key = "Rpc_ModuleFetter"
)
//事件类型定义处

View File

@ -206,8 +206,8 @@ type (
IHeroFetter interface {
ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息
QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息
//QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息
AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息
AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息
SendRpcAddHero(session IUserSession, heroConfId string) (err error)
}
//月子秘境
IMoonFantasy interface {

View File

@ -70,8 +70,6 @@ func GetMonthStartEnd() (int64, int64) {
return _d1, _d2
}
func Test_Main(t *testing.T) {
GetMonthStartEnd()
fmt.Printf("%d", 9/10)
ids := utils.RandomNumbers(0, 10, 5)
for _, v := range ids {
fmt.Printf("%d", v)

View File

@ -278,11 +278,11 @@ func (this *ModelHero) setEnergyProperty(hero *pb.DBHero, star int32) {
EnergyProperty := make(map[string]int32) //副属性
for k, v := range hero.Energy {
if k == comm.ResonanceHpPro {
EnergyProperty[comm.Hp] += int32(math.Floor((1.0 + float64(resonConfig.Hppro*v)/1000) * float64(hero.Property[comm.Hp])))
EnergyProperty[comm.Hp] += int32(math.Floor(float64(resonConfig.Hppro*v) / 1000 * float64(hero.Property[comm.Hp])))
} else if k == comm.ResonanceAtkPro {
EnergyProperty[comm.Atk] += int32(math.Floor((1.0 + float64(resonConfig.Atkpro*v)/1000) * float64(hero.Property[comm.Atk])))
EnergyProperty[comm.Atk] += int32(math.Floor(float64(resonConfig.Atkpro*v) / 1000 * float64(hero.Property[comm.Atk])))
} else if k == comm.ResonanceDefPro {
EnergyProperty[comm.Def] += int32(math.Floor((1.0 + float64(resonConfig.Defpro*v)/1000) * float64(hero.Property[comm.Def])))
EnergyProperty[comm.Def] += int32(math.Floor(float64(resonConfig.Defpro*v) / 1000 * float64(hero.Property[comm.Def])))
}
}
_heroMap := make(map[string]interface{}, 0)

View File

@ -67,7 +67,11 @@ func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string,
if err == nil {
go func(uid string, heroCfgId string) { // 携程处理 图鉴数据
this.moduleFetter.AddHeroFetterData(uid, heroCfgId)
if db.IsCross() {
this.moduleFetter.SendRpcAddHero(session, heroCfgId)
} else {
this.moduleFetter.AddHeroFetterData(uid, heroCfgId)
}
if result, err1 := this.ModuleUser.GetUserExpand(uid); err1 == nil {
initUpdate := map[string]interface{}{}
sz := result.GetTujian()

View File

@ -1,8 +1,13 @@
package library
import (
"context"
"errors"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
@ -11,6 +16,7 @@ import (
type Library struct {
modules.ModuleBase
service base.IRPCXService
modelLibrary *modelLibrary
modelFetter *modelFetter
api *apiComp
@ -27,7 +33,7 @@ func (this *Library) GetType() core.M_Modules {
func (this *Library) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service.(base.IRPCXService)
return
}
@ -40,6 +46,12 @@ func (this *Library) OnInstallComp() {
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
}
func (this *Library) Start() (err error) {
err = this.ModuleBase.Start()
this.service.RegisterFunctionName(string(comm.Rpc_ModuleFetter), this.Rpc_ModuleFetter)
return
}
// 接口信息 更新藏书馆数据
func (this *Library) ModifyLibraryData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) {
err := this.modelLibrary.modifyLibraryDataByObjId(uid, obj, data)
@ -135,8 +147,26 @@ func (this *Library) QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter
return nil
}
// 发送prc消息到区服处理
func (this *Library) SendRpcAddHero(session comm.IUserSession, heroConfId string) (err error) {
if this.IsCross() {
if _, err = this.service.AcrossClusterRpcGo( // 给区服发送rpc消息
context.Background(),
session.GetServiecTag(),
comm.Service_Worker,
string(comm.Rpc_ModuleFetter),
pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: heroConfId},
nil); err != nil {
this.Errorln(err)
}
return
}
return
}
// 创建一条羁绊信息
func (this *Library) AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) {
func (this *Library) AddHeroFetterData(uid, heroConfId string) (code pb.ErrorCode) {
_conf := this.configure.GetLibraryHero(heroConfId) // 配置表中没有这个英雄数据 直接返回
if _conf == nil {
return
@ -195,3 +225,18 @@ func (this *Library) AddHeroFetterData(uid string, heroConfId string) (code pb.E
func (this *Library) getLibraryByObjID(uid, oid string) *pb.DBLibrary {
return this.modelLibrary.getOneLibrary(uid, oid)
}
func (this *Library) Rpc_ModuleFetter(ctx context.Context, args *pb.RPCGeneralReqA2, reply *pb.EmptyResp) (err error) {
this.Debug("Rpc_ModuleFetter", log.Field{Key: "args", Value: args.String()})
if args.Param1 == "" || args.Param2 == "" {
err = errors.New("请求参数错误")
}
if session, ok := this.GetUserSession(args.Param1); !ok {
err = fmt.Errorf("目标用户:%s 不在线", args.Param1)
return
} else {
this.AddHeroFetterData(session.GetUserId(), args.Param2)
session.Push()
}
return
}

View File

@ -46,7 +46,7 @@ func (this *configureComp) GetMainline() {
return
}
} else {
log.Errorf("get game_pagoda conf err:%v", err)
log.Errorf("get game_mainline conf err:%v", err)
}
return
}

View File

@ -32,11 +32,10 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
code = pb.ErrorCode_DBError
return
}
//dayMaxCount := this.configure.GetTrollRule(comm.TrollBuyCount) // 8
aiCount := this.configure.GetTrollRule(comm.TrollAIBuyCount) // 10
if trolltrain.AiCount+trolltrain.SellCount < aiCount {
this.module.TrollAI(session, trolltrain)
}
// 自动交易
//if trolltrain.AiCount+trolltrain.SellCount < this.configure.GetTrollRule(comm.TrollAIBuyCount) {
this.module.TrollAI(session, trolltrain)
//}
maxCoefficient = this.configure.GetTrollMaxCoefficientNux() // 增长幅度的最大值
if maxCoefficient == 0 {

View File

@ -3,6 +3,8 @@ package user
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto"
)
@ -16,6 +18,61 @@ func (this *apiComp) SignCheck(session comm.IUserSession, req *pb.UserSignReq) (
//登录
func (this *apiComp) Sign(session comm.IUserSession, req *pb.UserSignReq) (code pb.ErrorCode, data proto.Message) {
code = this.module.modelSign.checkResetSignData(session)
var (
update map[string]interface{}
bReward bool
)
update = make(map[string]interface{}, 0)
if sign, err := this.module.modelSign.GetUserSign(session.GetUserId()); err == nil {
start, _ := utils.GetMonthStartEnd()
if sign.RTime < start { // 重置
sign.RTime = time.Now().Unix()
sign.SignTime = sign.RTime
sign.SignCount = 1
if newGroup := this.module.configure.GetSignResetConf(sign.Cid + 1); newGroup != -1 { // 获取当前的组id
sign.Cid += 1
sign.Group = newGroup
update["cid"] = sign.Cid
update["group"] = sign.Group
}
update["rTime"] = sign.RTime
update["signTime"] = sign.SignTime
update["signCount"] = sign.SignCount
this.module.modelSign.Change(session.GetUserId(), update)
bReward = true
} else {
if !utils.IsToday(sign.SignTime) {
sign.SignCount += 1
update["signCount"] = sign.SignCount
sign.SignTime = time.Now().Unix()
update["signTime"] = sign.SignTime
sign.RTime = sign.SignTime
update["rTime"] = sign.RTime
this.module.modelSign.Change(session.GetUserId(), update)
bReward = true
}
}
_data := this.module.configure.GetSignConf(sign.Cid, sign.Group)
if _data != nil { // 发奖
if bReward {
this.module.DispenseRes(session, _data.Loopgift, true)
}
} else {
globalCnf := this.module.configure.GetGlobalAtnConf("unified_reward") // 获取重置消耗
if globalCnf == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
if bReward {
this.module.DispenseRes(session, globalCnf.Var, true) // 发放通用奖励
}
}
session.SendMsg(string(this.module.GetType()), "sign", &pb.UserSignResp{
Data: sign,
Reward: bReward,
})
}
return
}

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"go_dreamfactory/utils"
"go.mongodb.org/mongo-driver/mongo"
@ -26,8 +27,18 @@ func (this *ModelExpand) Init(service core.IService, module core.IModule, comp c
//获取用户通过扩展表
func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
result = &pb.DBUserExpand{}
if err = this.module.modelExpand.Get(uid, result); err != nil && mongo.ErrNoDocuments != err {
return
if this.module.IsCross() {
if model, err := this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil {
this.module.Errorln(err)
} else {
if err = model.Get(uid, &result); err != nil && mongo.ErrNoDocuments != err {
this.module.Errorf("err:%v", err)
}
}
} else {
if err = this.Get(uid, result); err != nil && mongo.ErrNoDocuments != err {
this.module.Errorf("err:%v", err)
}
}
err = nil
return result, err
@ -38,7 +49,19 @@ func (this *ModelExpand) ChangeUserExpand(uid string, value map[string]interface
if len(value) == 0 {
return nil
}
return this.module.modelExpand.Change(uid, value)
var (
model *db.DBModel
)
if this.module.IsCross() {
if model, err = this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err == nil {
return model.Change(uid, value)
} else {
this.module.Errorln(err)
return err
}
}
return this.Change(uid, value)
}

View File

@ -48,7 +48,7 @@ func (this *ModelSetting) InitSetting(uid string) {
// 用户设置获取
func (this *ModelSetting) GetSetting(uid string) *pb.DBUserSetting {
setting := &pb.DBUserSetting{}
if err := this.module.modelSetting.Get(uid, setting); err != nil {
if err := this.Get(uid, setting); err != nil {
return nil
}
return setting
@ -59,7 +59,7 @@ func (this *ModelSetting) UpdateSetting(uid string, data map[string]interface{})
if len(data) == 0 {
return nil
}
return this.module.modelSetting.Change(uid, data)
return this.Change(uid, data)
}
//校验时间和初始次数
@ -91,7 +91,7 @@ func (this *ModelSetting) checkInitCount(uid string) bool {
func (this *ModelSetting) checkVeriCode(uid string) (int32, bool) {
key := fmt.Sprintf("code:%s", uid)
var code int32
err := this.module.modelSetting.Redis.Get(key, &code)
err := this.Redis.Get(key, &code)
if err != nil {
if err == redis.RedisNil {
return 0, false
@ -112,7 +112,7 @@ func (this *ModelSetting) refresh(uid string) (code int32) {
return
} else {
code = cast.ToInt32(utils.GenValidateCode(6))
if err := this.module.modelSetting.Redis.Set(key, code, time.Second*60); err != nil {
if err := this.Redis.Set(key, code, time.Second*60); err != nil {
this.module.Errorf("%v", err)
return 0
}
@ -122,7 +122,7 @@ func (this *ModelSetting) refresh(uid string) (code int32) {
// 清空设置
func (this *ModelSetting) cleanData(uid string) {
if err := this.module.modelSetting.DelByUId(uid); err != nil {
if err := this.DelByUId(uid); err != nil {
this.module.Errorf("cleanData err:%v", err)
}
}

View File

@ -33,23 +33,16 @@ func (this *ModelSign) GetUserSign(uid string) (result *pb.DBSign, err error) {
_data := this.module.configure.GetSignConf(1, 1)
if _data != nil {
result = &pb.DBSign{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
SignTime: 0,
SignCount: 0,
Group: _data.Group,
Cid: 0,
RTime: 0,
Id: primitive.NewObjectID().Hex(),
Uid: uid,
Group: _data.Group,
}
this.Add(uid, result)
} else {
err = errors.New("conf err")
return nil, err
}
}
err = nil
return
}
err = nil
return result, err
@ -129,6 +122,5 @@ func (this *ModelSign) checkResetSignData(session comm.IUserSession) (code pb.Er
Reward: bReward,
})
}
return
}

View File

@ -425,6 +425,7 @@ func (this *User) EventUserChanged(session comm.IUserSession) {
}
func (this *User) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
return this.modelExpand.GetUserExpand(uid)
}