英雄优化
This commit is contained in:
parent
5ae9fa6037
commit
6b33d3704b
@ -61,6 +61,7 @@ func (this *ModelHero) InitHero(uid string, heroCfgId string) *pb.DBHero {
|
|||||||
EnergyProperty: make(map[string]int32),
|
EnergyProperty: make(map[string]int32),
|
||||||
JuexProperty: make(map[string]int32),
|
JuexProperty: make(map[string]int32),
|
||||||
TalentProperty: make(map[string]int32),
|
TalentProperty: make(map[string]int32),
|
||||||
|
HoroscopeProperty: make(map[string]int32),
|
||||||
}
|
}
|
||||||
this.PropertyCompute(newHero)
|
this.PropertyCompute(newHero)
|
||||||
this.initHeroSkill(newHero)
|
this.initHeroSkill(newHero)
|
||||||
@ -470,6 +471,7 @@ func (this *ModelHero) ChangeHeroProperty(session comm.IUserSession, hero *pb.DB
|
|||||||
this.PropertyCompute(hero) //重新计算 property 的值
|
this.PropertyCompute(hero) //重新计算 property 的值
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"property": hero.Property,
|
"property": hero.Property,
|
||||||
|
"talentProperty": hero.TalentProperty,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = this.ChangeList(session.GetUserId(), hero.Id, update); err != nil {
|
if err = this.ChangeList(session.GetUserId(), hero.Id, update); err != nil {
|
||||||
@ -676,6 +678,8 @@ func (this *ModelHero) InitTempHero(heroCfgId string, star, lv int32) *pb.DBHero
|
|||||||
Property: make(map[string]int32),
|
Property: make(map[string]int32),
|
||||||
EnergyProperty: make(map[string]int32),
|
EnergyProperty: make(map[string]int32),
|
||||||
JuexProperty: make(map[string]int32),
|
JuexProperty: make(map[string]int32),
|
||||||
|
TalentProperty: make(map[string]int32),
|
||||||
|
HoroscopeProperty: make(map[string]int32),
|
||||||
}
|
}
|
||||||
this.PropertyCompute(newHero)
|
this.PropertyCompute(newHero)
|
||||||
this.initHeroSkill(newHero)
|
this.initHeroSkill(newHero)
|
||||||
|
@ -91,10 +91,6 @@ func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string,
|
|||||||
if _, ok := result.GetTujian()[heroCfgId]; !ok {
|
if _, ok := result.GetTujian()[heroCfgId]; !ok {
|
||||||
sz[heroCfgId] = 0
|
sz[heroCfgId] = 0
|
||||||
initUpdate["tujian"] = sz
|
initUpdate["tujian"] = sz
|
||||||
}
|
|
||||||
|
|
||||||
if len(initUpdate) != 0 {
|
|
||||||
|
|
||||||
this.ModuleUser.ChangeUserExpand(uid, initUpdate)
|
this.ModuleUser.ChangeUserExpand(uid, initUpdate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -663,6 +659,7 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
|
|||||||
hero.JuexingLv = int32(maxJux)
|
hero.JuexingLv = int32(maxJux)
|
||||||
hero.ResonateNum = maxGongm
|
hero.ResonateNum = maxGongm
|
||||||
hero.SameCount = 1
|
hero.SameCount = 1
|
||||||
|
this.modelHero.PropertyCompute(hero) // 重新计算属性
|
||||||
_heroMap := map[string]interface{}{
|
_heroMap := map[string]interface{}{
|
||||||
"lv": hero.Lv,
|
"lv": hero.Lv,
|
||||||
"star": hero.Star,
|
"star": hero.Star,
|
||||||
@ -671,8 +668,9 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
|
|||||||
"isOverlying": false,
|
"isOverlying": false,
|
||||||
"sameCount": 1,
|
"sameCount": 1,
|
||||||
"normalSkill": hero.NormalSkill,
|
"normalSkill": hero.NormalSkill,
|
||||||
|
"talentProperty": hero.TalentProperty,
|
||||||
}
|
}
|
||||||
this.modelHero.PropertyCompute(hero) // 重新计算属性
|
|
||||||
// 保存数据
|
// 保存数据
|
||||||
err = this.modelHero.ChangeList(session.GetUserId(), hero.Id, _heroMap)
|
err = this.modelHero.ChangeList(session.GetUserId(), hero.Id, _heroMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -7,10 +7,8 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -300,15 +298,13 @@ func (r Robot) GetRandUser() bool {
|
|||||||
}
|
}
|
||||||
//return true
|
//return true
|
||||||
}
|
}
|
||||||
func (r *Robot) Create() int64 {
|
func (r *Robot) Create(i uint64) int64 {
|
||||||
var byteLen int64
|
var byteLen int64
|
||||||
mainType := "user"
|
mainType := "user"
|
||||||
subType := "create"
|
subType := "create"
|
||||||
msg := &pb.UserMessage{MainType: mainType, SubType: subType}
|
msg := &pb.UserMessage{MainType: mainType, SubType: subType}
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
n2 := rand.Int63n(9000000)
|
|
||||||
|
|
||||||
name := strconv.Itoa(int(n2) + 100000)
|
name := "a100000" + strconv.Itoa(int(i))
|
||||||
rsp := &pb.UserCreateReq{
|
rsp := &pb.UserCreateReq{
|
||||||
NickName: name,
|
NickName: name,
|
||||||
Figure: 100,
|
Figure: 100,
|
||||||
@ -457,3 +453,55 @@ func (r Robot) GourmetOrder() int64 {
|
|||||||
}
|
}
|
||||||
return byteLen
|
return byteLen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 抽卡压测 参数 0~4 0 普通抽
|
||||||
|
|
||||||
|
func (r *Robot) DrawCard(drawType int32) int64 {
|
||||||
|
var byteLen int64
|
||||||
|
mainType := "hero"
|
||||||
|
subType := "drawcard"
|
||||||
|
msg := &pb.UserMessage{MainType: mainType, SubType: subType}
|
||||||
|
|
||||||
|
rsp := &pb.HeroDrawCardReq{
|
||||||
|
DrawType: drawType,
|
||||||
|
DrawCount: 10,
|
||||||
|
}
|
||||||
|
msg.Sec = r.BuildSecStr()
|
||||||
|
if comm.ProtoMarshal(rsp, msg) {
|
||||||
|
data, _ := proto.Marshal(msg)
|
||||||
|
err := r.ws.WriteMessage(websocket.BinaryMessage, data)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("WriteMessage err:%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
var msg *pb.UserMessage = &pb.UserMessage{}
|
||||||
|
_, data, err := r.ws.ReadMessage()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("readMessage err:%v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = proto.Unmarshal(data, msg); err != nil {
|
||||||
|
fmt.Printf("unmarshal err:%v", err)
|
||||||
|
}
|
||||||
|
if msg.MainType == mainType && msg.SubType == subType {
|
||||||
|
byteLen += int64(len(data))
|
||||||
|
resp := &pb.UserCreateResp{}
|
||||||
|
if !comm.ProtoUnmarshal(msg, resp) { //反序列化失败
|
||||||
|
byteLen = 0
|
||||||
|
}
|
||||||
|
break
|
||||||
|
} else if msg.MainType == "notify" && msg.SubType == "errornotify" {
|
||||||
|
|
||||||
|
rsp := &pb.NotifyErrorNotifyPush{}
|
||||||
|
if !comm.ProtoUnmarshal(msg, rsp) { // 记录错误码
|
||||||
|
fmt.Printf("NotifyErrorNotifyPush ProtoUnmarshal err")
|
||||||
|
}
|
||||||
|
byteLen = 0
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return byteLen
|
||||||
|
}
|
||||||
|
@ -63,7 +63,7 @@ func Dispose(ctx context.Context, concurrency, totalNumber uint64, request *mode
|
|||||||
// 并发建立长链接
|
// 并发建立长链接
|
||||||
go func(i uint64) {
|
go func(i uint64) {
|
||||||
r := robot.NewRobot(request.URL)
|
r := robot.NewRobot(request.URL)
|
||||||
r.SetAccount("61112" + strconv.Itoa(int(i)))
|
r.SetAccount("71112" + strconv.Itoa(int(i)))
|
||||||
//head := &pb.UserMessage{MainType: "user", SubType: "login"}
|
//head := &pb.UserMessage{MainType: "user", SubType: "login"}
|
||||||
|
|
||||||
// 先登录
|
// 先登录
|
||||||
|
@ -83,7 +83,7 @@ func webSocketRequest(chanID uint64, ch chan<- *model.RequestResults, i uint64,
|
|||||||
if byteLen == 0 {
|
if byteLen == 0 {
|
||||||
isSucceed = false
|
isSucceed = false
|
||||||
} else {
|
} else {
|
||||||
byteLen += r.Create()
|
byteLen += r.Create(i)
|
||||||
}
|
}
|
||||||
if byteLen == 0 {
|
if byteLen == 0 {
|
||||||
isSucceed = false
|
isSucceed = false
|
||||||
|
Loading…
Reference in New Issue
Block a user