Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into meixiongfeng
This commit is contained in:
commit
da9fbe2622
@ -4,5 +4,5 @@ Website = "http://legu.cc"
|
||||
Icon = "app.png"
|
||||
Name = "RobotGUI"
|
||||
ID = "cc.legu.app"
|
||||
Version = "1.2.3"
|
||||
Build = 31
|
||||
Version = "1.2.4"
|
||||
Build = 32
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
equip_suit = "game_equipsuit.json" //装备套装表
|
||||
new_hero = "game_hero.json" //英雄
|
||||
hero_stargrow = "game_herostargrow.json" //英雄品质系数
|
||||
hero_levelgrow = "game_herolevelgrow.json" //英雄成长系数
|
||||
@ -51,6 +52,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
this.module = module.(*Hero)
|
||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||
equip_suit: cfg.NewGameEquipSuit,
|
||||
new_hero: cfg.NewGameHero,
|
||||
hero_stargrow: cfg.NewGameHeroStargrow,
|
||||
hero_levelgrow: cfg.NewGameHeroLevelgrow,
|
||||
@ -498,3 +500,19 @@ func (this *configureComp) GetHeroStargrowConfigByStar(star int32) int32 {
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
// 获取英雄升级属性变化相关配置数据
|
||||
func (this *configureComp) GetEquipsuit(id int32) (configure *cfg.GameEquipSuitData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(equip_suit); err == nil {
|
||||
if configure, ok = v.(*cfg.GameEquipSuit).GetDataMap()[id]; !ok {
|
||||
err = fmt.Errorf("%T no is *cfg.GameEquipSuit", v)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -310,22 +310,6 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
|
||||
for _, v := range v.AdverbEntry {
|
||||
addProperty[v.AttrName] += v.Value + v.EnchValue //附加属性
|
||||
}
|
||||
for k, v := range addProperty {
|
||||
switch k {
|
||||
case comm.AtkPro:
|
||||
addProperty[comm.Atk] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Atk])))
|
||||
addProperty[comm.AtkPro] = 0
|
||||
case comm.DefPro:
|
||||
addProperty[comm.Def] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Def])))
|
||||
addProperty[comm.DefPro] = 0
|
||||
case comm.HpPro:
|
||||
addProperty[comm.Hp] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Hp])))
|
||||
addProperty[comm.HpPro] = 0
|
||||
case comm.SpeedPro:
|
||||
addProperty[comm.Speed] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Speed])))
|
||||
addProperty[comm.SpeedPro] = 0
|
||||
}
|
||||
}
|
||||
if v.Adverbskill != nil {
|
||||
for _, v := range v.Adverbskill {
|
||||
equipSkill = append(equipSkill, &pb.SkillData{
|
||||
@ -335,6 +319,37 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if hero.SuiteId != 0 { //套装
|
||||
if configure, err := this.moduleHero.configure.GetEquipsuit(hero.SuiteId); err != nil {
|
||||
this.moduleHero.Errorln(err)
|
||||
} else {
|
||||
for k, v := range configure.SetBonuses {
|
||||
addProperty[k] += v
|
||||
}
|
||||
}
|
||||
}
|
||||
if hero.SuiteExtId != 0 { //套装
|
||||
if configure, err := this.moduleHero.configure.GetEquipsuit(hero.SuiteExtId); err != nil {
|
||||
this.moduleHero.Errorln(err)
|
||||
} else {
|
||||
for k, v := range configure.SetBonuses {
|
||||
addProperty[k] += v
|
||||
}
|
||||
}
|
||||
}
|
||||
for k, v := range addProperty {
|
||||
switch k {
|
||||
case comm.AtkPro:
|
||||
addProperty[comm.Atk] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Atk])))
|
||||
case comm.DefPro:
|
||||
addProperty[comm.Def] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Def])))
|
||||
case comm.HpPro:
|
||||
addProperty[comm.Hp] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Hp])))
|
||||
case comm.SpeedPro:
|
||||
addProperty[comm.Speed] += int32(math.Floor((float64(v) / 1000) * float64(hero.Property[comm.Speed])))
|
||||
}
|
||||
}
|
||||
this.mergeAddProperty(hero.Uid, hero, addProperty, equipSkill)
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
|
||||
|
||||
if req.Amount+uint32(user.Physicalbuynum) > uint32(len(needs)) {
|
||||
code = pb.ErrorCode_ItemsBuyPsUpperLimit
|
||||
return
|
||||
}
|
||||
|
||||
haveneeds = make([]*cfg.Gameatn, 0)
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) SellItemCheck(session comm.IUserSession, req *pb.ItemsSellItemReq) (code pb.ErrorCode) {
|
||||
func (this *apiComp) DecomposeCheck(session comm.IUserSession, req *pb.ItemsDecomposeReq) (code pb.ErrorCode) {
|
||||
if req.GridId == "" || req.Amount <= 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
@ -17,14 +17,14 @@ func (this *apiComp) SellItemCheck(session comm.IUserSession, req *pb.ItemsSellI
|
||||
}
|
||||
|
||||
//出售道具
|
||||
func (this *apiComp) SellItem(session comm.IUserSession, req *pb.ItemsSellItemReq) (code pb.ErrorCode, data proto.Message) {
|
||||
func (this *apiComp) Decompose(session comm.IUserSession, req *pb.ItemsDecomposeReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
err error
|
||||
item *pb.DB_UserItemData
|
||||
itemcf *cfg.GameItemData
|
||||
sale []*cfg.Gameatn
|
||||
)
|
||||
if code = this.SellItemCheck(session, req); code != pb.ErrorCode_Success {
|
||||
if code = this.DecomposeCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if item, err = this.module.modelItems.QueryUserPackByGridId(session.GetUserId(), req.GridId); err != nil {
|
||||
@ -73,6 +73,6 @@ func (this *apiComp) SellItem(session comm.IUserSession, req *pb.ItemsSellItemRe
|
||||
if code = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "sellitem", &pb.ItemsSellItemResp{GridId: req.GridId, Amount: req.Amount, Issucc: true})
|
||||
session.SendMsg(string(this.module.GetType()), "decompose", &pb.ItemsDecomposeResp{GridId: req.GridId, Amount: req.Amount, Issucc: true})
|
||||
return
|
||||
}
|
||||
|
@ -9,22 +9,22 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) DecomposeCheck(session comm.IUserSession, req *pb.ItemsDecomposeReq) (code pb.ErrorCode) {
|
||||
func (this *apiComp) SellItemCheck(session comm.IUserSession, req *pb.ItemsSellItemReq) (code pb.ErrorCode) {
|
||||
if req.GridId == "" || req.Amount <= 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//出售道具
|
||||
func (this *apiComp) Decompose(session comm.IUserSession, req *pb.ItemsDecomposeReq) (code pb.ErrorCode, data proto.Message) {
|
||||
//分解道具
|
||||
func (this *apiComp) SellItem(session comm.IUserSession, req *pb.ItemsSellItemReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
err error
|
||||
item *pb.DB_UserItemData
|
||||
itemcf *cfg.GameItemData
|
||||
sale []*cfg.Gameatn
|
||||
)
|
||||
if code = this.DecomposeCheck(session, req); code != pb.ErrorCode_Success {
|
||||
if code = this.SellItemCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if item, err = this.module.modelItems.QueryUserPackByGridId(session.GetUserId(), req.GridId); err != nil {
|
||||
@ -44,7 +44,7 @@ func (this *apiComp) Decompose(session comm.IUserSession, req *pb.ItemsDecompose
|
||||
this.module.Errorf("SellItemCheck over all amount:[%d:%d]", req.Amount, item.Amount)
|
||||
return
|
||||
}
|
||||
sale = make([]*cfg.Gameatn, len(itemcf.Sale))
|
||||
sale = make([]*cfg.Gameatn, len(itemcf.DecomposeDeplete))
|
||||
for i, v := range itemcf.Sale {
|
||||
temp := *v
|
||||
sale[i] = &temp
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"go_dreamfactory/sys/db"
|
||||
"go_dreamfactory/utils"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go_dreamfactory/lego/base"
|
||||
@ -55,6 +56,8 @@ type User struct {
|
||||
configure *configureComp
|
||||
globalConf *cfg.GameGlobalData
|
||||
modelSign *ModelSign // 签到
|
||||
timerLock sync.Mutex
|
||||
timerMap map[string]*time.Ticker
|
||||
}
|
||||
|
||||
func (this *User) GetType() core.M_Modules {
|
||||
@ -64,6 +67,7 @@ func (this *User) GetType() core.M_Modules {
|
||||
func (this *User) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
this.service = service.(base.IRPCXService)
|
||||
this.timerMap = make(map[string]*time.Ticker)
|
||||
return
|
||||
}
|
||||
|
||||
@ -78,6 +82,7 @@ func (this *User) Start() (err error) {
|
||||
if this.globalConf == nil {
|
||||
err = errors.New("global config not found")
|
||||
}
|
||||
this.ResetSession()
|
||||
return
|
||||
}
|
||||
|
||||
@ -132,8 +137,20 @@ func (this *User) GetUserSession(uid string) *pb.CacheUser {
|
||||
return this.modelSession.getUserSession(uid)
|
||||
}
|
||||
|
||||
func (this *User) ResetSession() {
|
||||
us, err := this.UserOnlineList()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range us {
|
||||
this.modelSession.DelListlds(comm.RDS_EMPTY, v.Uid)
|
||||
}
|
||||
}
|
||||
|
||||
// 清除session
|
||||
func (this *User) CleanSession(session comm.IUserSession) {
|
||||
this.stopTicker(session.GetUserId())
|
||||
if !this.IsCross() {
|
||||
this.modelUser.updateOfflineTime(session.GetUserId())
|
||||
}
|
||||
@ -615,9 +632,29 @@ func (this *User) BingoSetUserLv(session comm.IUserSession, lv int32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *User) Update() {
|
||||
if this.IsCross() {
|
||||
return
|
||||
}
|
||||
cu, err := this.UserOnlineList()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range cu {
|
||||
if isession, ok := this.ModuleBase.GetUserSession(v.Uid); ok {
|
||||
//del session
|
||||
log.Debug("del session", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "isLogin", Value: isession.IsLogin()})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *User) RecoverUserVitStart(uid string) {
|
||||
go func(uid string) {
|
||||
timeSec := time.NewTicker(time.Second * 30)
|
||||
this.timerLock.Lock()
|
||||
this.timerMap[uid] = timeSec
|
||||
this.timerLock.Unlock()
|
||||
for {
|
||||
select {
|
||||
case <-timeSec.C:
|
||||
@ -627,6 +664,15 @@ func (this *User) RecoverUserVitStart(uid string) {
|
||||
}(uid)
|
||||
}
|
||||
|
||||
func (this *User) stopTicker(uid string) {
|
||||
if t, ok := this.timerMap[uid]; ok {
|
||||
if t != nil {
|
||||
t.Stop()
|
||||
delete(this.timerMap, uid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 玩家体力恢复
|
||||
func (this *User) recoverUserVit(uid string) {
|
||||
if this.IsCross() {
|
||||
@ -642,7 +688,11 @@ func (this *User) recoverUserVit(uid string) {
|
||||
return
|
||||
}
|
||||
|
||||
var yu int32
|
||||
var (
|
||||
yu int32
|
||||
add int32
|
||||
changed int32
|
||||
)
|
||||
cur := time.Now().Unix()
|
||||
if u.LastRecoverVitSec == 0 {
|
||||
update := map[string]interface{}{
|
||||
@ -660,19 +710,31 @@ func (this *User) recoverUserVit(uid string) {
|
||||
if pconf == nil {
|
||||
return
|
||||
}
|
||||
total := u.Ps + yu
|
||||
if total <= pconf.PsCeiling {
|
||||
if isession, ok := this.ModuleBase.GetUserSession(u.Uid); ok {
|
||||
if code := this.AddAttributeValue(isession, comm.ResPs, yu, false); code == pb.ErrorCode_Success {
|
||||
update := map[string]interface{}{
|
||||
"lastRecoverVitSec": cur,
|
||||
}
|
||||
if err := this.modelUser.Change(u.Uid, update); err == nil {
|
||||
if u.Ps < pconf.PsCeiling {
|
||||
total := u.Ps + yu
|
||||
if total > pconf.PsCeiling {
|
||||
add = pconf.PsCeiling - u.Ps
|
||||
changed = pconf.PsCeiling
|
||||
} else {
|
||||
add = yu
|
||||
changed = total
|
||||
}
|
||||
} else {
|
||||
add = 0
|
||||
}
|
||||
|
||||
if isession, ok := this.ModuleBase.GetUserSession(u.Uid); ok {
|
||||
if code := this.AddAttributeValue(isession, comm.ResPs, add, false); code == pb.ErrorCode_Success {
|
||||
update := map[string]interface{}{
|
||||
"lastRecoverVitSec": cur,
|
||||
}
|
||||
if err := this.modelUser.Change(u.Uid, update); err == nil {
|
||||
if changed > 0 {
|
||||
if err := this.SendMsgToUser(string(this.GetType()), "vitchanged",
|
||||
&pb.UserVitChangedPush{Ps: total}, u.Uid); err != nil {
|
||||
&pb.UserVitChangedPush{Ps: changed}, u.Uid); err != nil {
|
||||
this.Error("玩家体力变化 UserVitChangedPush推送失败",
|
||||
log.Field{Key: "uid", Value: u.Uid},
|
||||
log.Field{Key: comm.ResPs, Value: total},
|
||||
log.Field{Key: comm.ResPs, Value: changed},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ type GameEquipSuitData struct {
|
||||
Skill int32
|
||||
Skillname string
|
||||
Skillintr string
|
||||
SetBonuses map[string]float32
|
||||
SetBonuses map[string]int32
|
||||
}
|
||||
|
||||
const TypeId_GameEquipSuitData = -1986764885
|
||||
@ -36,15 +36,15 @@ func (_v *GameEquipSuitData)Deserialize(_buf map[string]interface{}) (err error)
|
||||
var _ok_ bool
|
||||
if _arr_, _ok_ = _buf["SetBonuses"].([]interface{}); !_ok_ { err = errors.New("SetBonuses error"); return }
|
||||
|
||||
_v.SetBonuses = make(map[string]float32)
|
||||
_v.SetBonuses = make(map[string]int32)
|
||||
|
||||
for _, _e_ := range _arr_ {
|
||||
var _kv_ []interface{}
|
||||
if _kv_, _ok_ = _e_.([]interface{}); !_ok_ || len(_kv_) != 2 { err = errors.New("SetBonuses error"); return }
|
||||
var _key_ string
|
||||
{ if _key_, _ok_ = _kv_[0].(string); !_ok_ { err = errors.New("_key_ error"); return } }
|
||||
var _value_ float32
|
||||
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _kv_[1].(float64); !_ok_ { err = errors.New("_value_ error"); return }; _value_ = float32(_x_) }
|
||||
var _value_ int32
|
||||
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _kv_[1].(float64); !_ok_ { err = errors.New("_value_ error"); return }; _value_ = int32(_x_) }
|
||||
_v.SetBonuses[_key_] = _value_
|
||||
}
|
||||
}
|
||||
|
@ -77,18 +77,18 @@ func TestMatrxing(t *testing.T) {
|
||||
utils.MatrixingHour("2022-10-11 00:00:00")
|
||||
}
|
||||
|
||||
func TestCompre(t *testing.T){
|
||||
a:=[]int32{1,2,4,5}
|
||||
b:=[]int32{1,2,4}
|
||||
fmt.Println(utils.ForContainer(a,b))
|
||||
func TestCompre(t *testing.T) {
|
||||
a := []int32{1, 2, 4, 5}
|
||||
b := []int32{1, 2, 4}
|
||||
fmt.Println(utils.ForContainer(a, b))
|
||||
}
|
||||
|
||||
func TestDeletex(t *testing.T){
|
||||
a:=[]int32{1,2,3,4}
|
||||
c:=utils.Deletex(a, 2)
|
||||
func TestDeletex(t *testing.T) {
|
||||
a := []int32{1, 2, 3, 4}
|
||||
c := utils.Deletex(a, 2)
|
||||
fmt.Println(c)
|
||||
}
|
||||
|
||||
func TestDiffDays(t *testing.T){
|
||||
func TestDiffDays(t *testing.T) {
|
||||
fmt.Println(utils.DiffDays(1614527999, 1614614400))
|
||||
}
|
Loading…
Reference in New Issue
Block a user