上传红点数据优化
This commit is contained in:
parent
3eea25c1e2
commit
2b478ce282
@ -387,11 +387,35 @@ func (this *modelArena) recoverTicket(info *pb.DBArenaUser) {
|
||||
func (this *modelArena) reddot(session comm.IUserSession) bool {
|
||||
var (
|
||||
info *pb.DBArenaUser
|
||||
user *pb.DBUser
|
||||
err error
|
||||
)
|
||||
if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil {
|
||||
return false
|
||||
}
|
||||
if err == mgo.MongodbNil {
|
||||
global := this.module.configure.GetGlobalConf()
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
return false
|
||||
}
|
||||
info = &pb.DBArenaUser{
|
||||
Uid: session.GetUserId(),
|
||||
Name: user.Name,
|
||||
Integral: global.ArenaInitiaIntegral,
|
||||
Ticket: 10,
|
||||
Streak: 0,
|
||||
Record: make([]*pb.DBArenaBattleRecord, 0),
|
||||
Lastrtickettime: 0,
|
||||
Isdef: false,
|
||||
Npc: make(map[int32]*pb.DBNpc),
|
||||
}
|
||||
if info.Dan, err = this.module.modelArena.computedan(info.Integral); err != nil {
|
||||
return false
|
||||
}
|
||||
if err = this.module.modelArena.Add(session.GetUserId(), info); err != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if info.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos {
|
||||
return true
|
||||
}
|
||||
|
@ -78,9 +78,7 @@ func (this *Arena) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (re
|
||||
for _, v := range rid {
|
||||
switch v {
|
||||
case comm.Reddot19:
|
||||
if isredot := this.modelArena.reddot(session); isredot {
|
||||
result[comm.Reddot19] = true
|
||||
}
|
||||
result[comm.Reddot19] = this.modelArena.reddot(session)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ package battle
|
||||
|
||||
import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -38,3 +40,22 @@ func (this *clientComp) Start() (err error) {
|
||||
func (this *clientComp) CheckBattle() {
|
||||
|
||||
}
|
||||
|
||||
func (this *clientComp) run() {
|
||||
var (
|
||||
data []byte
|
||||
msg *pb.BattleRpcMessage = &pb.BattleRpcMessage{}
|
||||
err error
|
||||
)
|
||||
locp:
|
||||
for {
|
||||
if _, data, err = this.conn.ReadMessage(); err != nil {
|
||||
this.module.Errorf("client err:%v", err)
|
||||
break locp
|
||||
}
|
||||
if err = proto.Unmarshal(data, msg); err != nil {
|
||||
this.module.Errorf("client Unmarshal err:%v", err)
|
||||
break locp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"go_dreamfactory/modules/hero"
|
||||
"go_dreamfactory/modules/items"
|
||||
"go_dreamfactory/modules/user"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/services"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/sys/db"
|
||||
@ -20,6 +21,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
)
|
||||
|
||||
func newService(ops ...rpcx.Option) core.IService {
|
||||
@ -95,6 +98,12 @@ func Test_Comment(t *testing.T) {
|
||||
return
|
||||
} else {
|
||||
defer connect.Close()
|
||||
connect.WriteMessage(websocket.TextMessage, []byte("from client to server"))
|
||||
msg := &pb.BattleRpcMessage{
|
||||
Rid: 1,
|
||||
Method: "test",
|
||||
}
|
||||
msg.Data, _ = anypb.New(&pb.BattleTestMessage{})
|
||||
data, _ := proto.Marshal(msg)
|
||||
connect.WriteMessage(websocket.BinaryMessage, data)
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,7 @@ func (this *Horoscope) Reddot(session comm.IUserSession, rid ...comm.ReddotType)
|
||||
for _, v := range rid {
|
||||
switch v {
|
||||
case comm.Reddot17:
|
||||
if isredot := this.modelHoroscope.reddot(session); isredot {
|
||||
result[comm.Reddot17] = true
|
||||
}
|
||||
result[comm.Reddot17] = this.modelHoroscope.reddot(session)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -56,19 +56,13 @@ func (this *Martialhall) Reddot(session comm.IUserSession, rid ...comm.ReddotTyp
|
||||
for _, v := range rid {
|
||||
switch v {
|
||||
case comm.Reddot23:
|
||||
if isredot := this.modelMartialhall.checkReddot23(session); isredot {
|
||||
reddot[comm.Reddot23] = true
|
||||
}
|
||||
reddot[comm.Reddot23] = this.modelMartialhall.checkReddot23(session)
|
||||
break
|
||||
case comm.Reddot24:
|
||||
if isredot := this.modelMartialhall.checkReddot24(session); isredot {
|
||||
reddot[comm.Reddot24] = true
|
||||
}
|
||||
reddot[comm.Reddot24] = this.modelMartialhall.checkReddot24(session)
|
||||
break
|
||||
case comm.Reddot25:
|
||||
if isredot := this.modelMartialhall.checkReddot25(session); isredot {
|
||||
reddot[comm.Reddot25] = true
|
||||
}
|
||||
reddot[comm.Reddot25] = this.modelMartialhall.checkReddot25(session)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user