上传挑战卷恢复代码

This commit is contained in:
liwei1dao 2022-10-27 10:38:11 +08:00
parent 14194c5fca
commit 5a91b06f3d
9 changed files with 143 additions and 77 deletions

View File

@ -20,7 +20,7 @@
"n": 5 "n": 5
} }
], ],
"png": "", "png": "wp_icon_bydw02",
"k_value": 32 "k_value": 32
}, },
{ {
@ -44,7 +44,7 @@
"n": 7 "n": 7
} }
], ],
"png": "", "png": "wp_icon_bydw02",
"k_value": 64 "k_value": 64
}, },
{ {
@ -68,7 +68,7 @@
"n": 9 "n": 9
} }
], ],
"png": "", "png": "wp_icon_bydw02",
"k_value": 32 "k_value": 32
}, },
{ {
@ -92,7 +92,7 @@
"n": 11 "n": 11
} }
], ],
"png": "", "png": "wp_icon_bydw02",
"k_value": 16 "k_value": 16
}, },
{ {
@ -116,7 +116,7 @@
"n": 13 "n": 13
} }
], ],
"png": "", "png": "wp_icon_bydw02",
"k_value": 8 "k_value": 8
}, },
{ {
@ -140,7 +140,7 @@
"n": 15 "n": 15
} }
], ],
"png": "", "png": "wp_icon_bydw02",
"k_value": 8 "k_value": 8
}, },
{ {
@ -164,7 +164,7 @@
"n": 17 "n": 17
} }
], ],
"png": "", "png": "wp_icon_bydw02",
"k_value": 8 "k_value": 8
}, },
{ {
@ -188,7 +188,7 @@
"n": 19 "n": 19
} }
], ],
"png": "", "png": "wp_icon_bydw02",
"k_value": 8 "k_value": 8
} }
] ]

View File

@ -4,7 +4,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 20 "n": 20
} }
] ]
@ -14,7 +14,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 30 "n": 30
} }
] ]
@ -24,7 +24,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 30 "n": 30
} }
] ]
@ -34,7 +34,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 50 "n": 50
} }
] ]
@ -44,7 +44,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 50 "n": 50
} }
] ]
@ -54,7 +54,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 50 "n": 50
} }
] ]
@ -64,7 +64,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 100 "n": 100
} }
] ]
@ -74,7 +74,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 150 "n": 150
} }
] ]
@ -84,7 +84,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 200 "n": 200
} }
] ]
@ -94,7 +94,7 @@
"need": [ "need": [
{ {
"a": "attr", "a": "attr",
"t": "rmbmoney", "t": "diamond",
"n": 250 "n": 250
} }
] ]

View File

@ -2,7 +2,7 @@
{ {
"id": 1, "id": 1,
"rank_low": 1, "rank_low": 1,
"rank_up": 1, "rank_up": 2,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -19,7 +19,7 @@
{ {
"id": 2, "id": 2,
"rank_low": 2, "rank_low": 2,
"rank_up": 2, "rank_up": 3,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -36,7 +36,7 @@
{ {
"id": 3, "id": 3,
"rank_low": 3, "rank_low": 3,
"rank_up": 3, "rank_up": 4,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -53,7 +53,7 @@
{ {
"id": 4, "id": 4,
"rank_low": 4, "rank_low": 4,
"rank_up": 10, "rank_up": 11,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -70,7 +70,7 @@
{ {
"id": 5, "id": 5,
"rank_low": 11, "rank_low": 11,
"rank_up": 20, "rank_up": 21,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -87,7 +87,7 @@
{ {
"id": 6, "id": 6,
"rank_low": 21, "rank_low": 21,
"rank_up": 50, "rank_up": 51,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -104,7 +104,7 @@
{ {
"id": 7, "id": 7,
"rank_low": 51, "rank_low": 51,
"rank_up": 100, "rank_up": 101,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -121,7 +121,7 @@
{ {
"id": 8, "id": 8,
"rank_low": 101, "rank_low": 101,
"rank_up": 200, "rank_up": 201,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -138,7 +138,7 @@
{ {
"id": 9, "id": 9,
"rank_low": 201, "rank_low": 201,
"rank_up": 500, "rank_up": 501,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -155,7 +155,7 @@
{ {
"id": 10, "id": 10,
"rank_low": 501, "rank_low": 501,
"rank_up": 1000, "rank_up": 1001,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",
@ -172,7 +172,7 @@
{ {
"id": 11, "id": 11,
"rank_low": 1001, "rank_low": 1001,
"rank_up": 99999999, "rank_up": 100000000,
"rank_reward": [ "rank_reward": [
{ {
"a": "attr", "a": "attr",

View File

@ -210,6 +210,17 @@
"ArenaTicket_RecoveryTime": 144, "ArenaTicket_RecoveryTime": 144,
"ArenaTicket_PurchaseRrestrictions": 10, "ArenaTicket_PurchaseRrestrictions": 10,
"arena_InitiaIntegral": 1000, "arena_InitiaIntegral": 1000,
"arena_RecordMax": 10 "arena_RecordMax": 10,
"arena_RefreshCd": 10,
"show_male": [
100001,
100002,
100003
],
"show_female": [
200001,
200002,
200003
]
} }
] ]

View File

@ -33,6 +33,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p
code = pb.ErrorCode_CacheReadError code = pb.ErrorCode_CacheReadError
return return
} }
this.module.modelArena.recoverTicket(info)
global = this.module.configure.GetGlobalConf() global = this.module.configure.GetGlobalConf()
if info.Ticket+req.BuyNum > global.ArenaTicketMax { if info.Ticket+req.BuyNum > global.ArenaTicketMax {
code = pb.ErrorCode_ArenaTicketBuyUp code = pb.ErrorCode_ArenaTicketBuyUp
@ -56,10 +57,10 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p
} }
info.Buynum += req.BuyNum info.Buynum += req.BuyNum
info.Ticket += req.BuyNum info.Ticket += req.BuyNum
this.module.modelArena.Change(session.GetUserId(), map[string]interface{}{ if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
"ticket": info.Ticket, code = pb.ErrorCode_DBError
"buynum": info.Buynum, return
}) }
session.SendMsg(string(this.module.GetType()), "buy", &pb.MoonfantasyBuyResp{Issucc: true, BattleNum: info.Ticket}) session.SendMsg(string(this.module.GetType()), "buy", &pb.MoonfantasyBuyResp{Issucc: true, BattleNum: info.Ticket})
return return
} }

View File

@ -3,6 +3,7 @@ package arena
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"time"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -52,6 +53,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge
if red.Ticket > 0 { if red.Ticket > 0 {
red.Ticket-- red.Ticket--
if red.Lastrtickettime == 0 {
red.Lastrtickettime = time.Now().Unix()
}
} else { } else {
code = pb.ErrorCode_ArenaTicketNotEnough code = pb.ErrorCode_ArenaTicketNotEnough
return return

View File

@ -6,6 +6,7 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"math"
"time" "time"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
@ -24,6 +25,8 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code
info *pb.DBArenaUser info *pb.DBArenaUser
user *pb.DBUser user *pb.DBUser
model *db.DBModel model *db.DBModel
duration time.Duration
ticketNum int32
err error err error
) )
if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success { if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success {
@ -52,6 +55,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code
Integral: global.ArenaInitiaIntegral, Integral: global.ArenaInitiaIntegral,
Ticket: 10, Ticket: 10,
Record: make([]*pb.DBArenaBattleRecord, 0), Record: make([]*pb.DBArenaBattleRecord, 0),
Lastrtickettime: 0,
} }
if info.Dan, err = this.module.modelArena.computedan(info.Integral); err != nil { if info.Dan, err = this.module.modelArena.computedan(info.Integral); err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
@ -60,8 +64,19 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code
if err = this.module.modelArena.Add(session.GetUserId(), info); err != nil { if err = this.module.modelArena.Add(session.GetUserId(), info); err != nil {
this.module.Errorln(err) this.module.Errorln(err)
} }
} else if info.Ticket < global.ArenaTicketMax && info.Lastrtickettime > 0 {
duration = time.Now().Sub(time.Unix(info.Lastrtickettime, 0))
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
if ticketNum > 0 {
info.Ticket += ticketNum
if info.Ticket > global.ArenaTicketMax {
info.Ticket = global.ArenaTicketMax
info.Lastrtickettime = 0
} else {
info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
}
}
} }
session.SendMsg(string(this.module.GetType()), "info", &pb.ArenaInfoResp{Info: info}) session.SendMsg(string(this.module.GetType()), "info", &pb.ArenaInfoResp{Info: info})
return return
} }

View File

@ -11,6 +11,7 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"math"
"math/rand" "math/rand"
"time" "time"
@ -108,6 +109,8 @@ func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) {
"dan": dan, "dan": dan,
"rank": info.Rank, "rank": info.Rank,
"ticket": info.Ticket, "ticket": info.Ticket,
"buynum": info.Buynum,
"lastrtickettime": info.Lastrtickettime,
"attack": info.Attack, "attack": info.Attack,
"defend": info.Defend, "defend": info.Defend,
"streak": info.Streak, "streak": info.Streak,
@ -333,3 +336,24 @@ func (this *modelArena) integralCompute(red, bule *pb.ArenaPlayer, iswin bool) {
bule.Integral = bule.Integral + bule.Changeintegral bule.Integral = bule.Integral + bule.Changeintegral
} }
} }
func (this *modelArena) recoverTicket(info *pb.DBArenaUser) {
var (
duration time.Duration
ticketNum int32
)
global := this.module.configure.GetGlobalConf()
if info.Ticket < global.ArenaTicketMax && info.Lastrtickettime > 0 {
duration = time.Now().Sub(time.Unix(info.Lastrtickettime, 0))
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
if ticketNum > 0 {
info.Ticket += ticketNum
if info.Ticket > global.ArenaTicketMax {
info.Ticket = global.ArenaTicketMax
info.Lastrtickettime = 0
} else {
info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
}
}
}
}

View File

@ -387,6 +387,7 @@ type DBArenaUser struct {
Rank int32 `protobuf:"varint,13,opt,name=rank,proto3" json:"rank"` //排名 Rank int32 `protobuf:"varint,13,opt,name=rank,proto3" json:"rank"` //排名
Buynum int32 `protobuf:"varint,14,opt,name=buynum,proto3" json:"buynum"` //购买次数 Buynum int32 `protobuf:"varint,14,opt,name=buynum,proto3" json:"buynum"` //购买次数
Record []*DBArenaBattleRecord `protobuf:"bytes,15,rep,name=record,proto3" json:"record"` //战斗记录 Record []*DBArenaBattleRecord `protobuf:"bytes,15,rep,name=record,proto3" json:"record"` //战斗记录
Lastrtickettime int64 `protobuf:"varint,16,opt,name=lastrtickettime,proto3" json:"lastrtickettime"` //最后领劵时间
} }
func (x *DBArenaUser) Reset() { func (x *DBArenaUser) Reset() {
@ -526,6 +527,13 @@ func (x *DBArenaUser) GetRecord() []*DBArenaBattleRecord {
return nil return nil
} }
func (x *DBArenaUser) GetLastrtickettime() int64 {
if x != nil {
return x.Lastrtickettime
}
return 0
}
var File_arena_arena_db_proto protoreflect.FileDescriptor var File_arena_arena_db_proto protoreflect.FileDescriptor
var file_arena_arena_db_proto_rawDesc = []byte{ var file_arena_arena_db_proto_rawDesc = []byte{
@ -570,7 +578,7 @@ var file_arena_arena_db_proto_rawDesc = []byte{
0x0b, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x12, 0x28, 0x0a, 0x05, 0x0b, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x12, 0x28, 0x0a, 0x05,
0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x42, 0x61, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x42, 0x61,
0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52,
0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0xaf, 0x03, 0x0a, 0x0b, 0x44, 0x42, 0x41, 0x72, 0x65, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0xd9, 0x03, 0x0a, 0x0b, 0x44, 0x42, 0x41, 0x72, 0x65,
0x6e, 0x61, 0x55, 0x73, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x6e, 0x61, 0x55, 0x73, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06,
@ -597,15 +605,18 @@ var file_arena_arena_db_proto_rawDesc = []byte{
0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x79, 0x6e, 0x75, 0x6d, 0x12, 0x2c, 0x0a, 0x06, 0x72, 0x65, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x79, 0x6e, 0x75, 0x6d, 0x12, 0x2c, 0x0a, 0x06, 0x72, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x41, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x41,
0x72, 0x65, 0x6e, 0x61, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x72, 0x65, 0x6e, 0x61, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2a, 0x73, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x61, 0x73, 0x74,
0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x07, 0x0a, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28,
0x03, 0x57, 0x69, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x6f, 0x73, 0x74, 0x10, 0x01, 0x03, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69,
0x12, 0x12, 0x0a, 0x0e, 0x57, 0x61, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x6d, 0x65, 0x2a, 0x73, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f,
0x67, 0x65, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x57, 0x69, 0x6e, 0x10, 0x00,
0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x6f, 0x73, 0x74, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x61,
0x67, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x65, 0x64, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x10, 0x02, 0x12, 0x11,
0x0a, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x45, 0x6e, 0x64, 0x10, 0x05, 0x42, 0x06, 0x5a, 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x03, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x53, 0x75, 0x63, 0x63,
0x65, 0x65, 0x64, 0x65, 0x64, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x6e,
0x67, 0x65, 0x45, 0x6e, 0x64, 0x10, 0x05, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (