diff --git a/bin/json/game_arenaactivereward.json b/bin/json/game_arenaactivereward.json index 9904341c6..a52aaaa9d 100644 --- a/bin/json/game_arenaactivereward.json +++ b/bin/json/game_arenaactivereward.json @@ -20,7 +20,7 @@ "n": 5 } ], - "png": "", + "png": "wp_icon_bydw02", "k_value": 32 }, { @@ -44,7 +44,7 @@ "n": 7 } ], - "png": "", + "png": "wp_icon_bydw02", "k_value": 64 }, { @@ -68,7 +68,7 @@ "n": 9 } ], - "png": "", + "png": "wp_icon_bydw02", "k_value": 32 }, { @@ -92,7 +92,7 @@ "n": 11 } ], - "png": "", + "png": "wp_icon_bydw02", "k_value": 16 }, { @@ -116,7 +116,7 @@ "n": 13 } ], - "png": "", + "png": "wp_icon_bydw02", "k_value": 8 }, { @@ -140,7 +140,7 @@ "n": 15 } ], - "png": "", + "png": "wp_icon_bydw02", "k_value": 8 }, { @@ -164,7 +164,7 @@ "n": 17 } ], - "png": "", + "png": "wp_icon_bydw02", "k_value": 8 }, { @@ -188,7 +188,7 @@ "n": 19 } ], - "png": "", + "png": "wp_icon_bydw02", "k_value": 8 } ] \ No newline at end of file diff --git a/bin/json/game_arenabuychallenge.json b/bin/json/game_arenabuychallenge.json index 09d0c8064..cff9c2657 100644 --- a/bin/json/game_arenabuychallenge.json +++ b/bin/json/game_arenabuychallenge.json @@ -4,7 +4,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 20 } ] @@ -14,7 +14,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 30 } ] @@ -24,7 +24,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 30 } ] @@ -34,7 +34,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 50 } ] @@ -44,7 +44,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 50 } ] @@ -54,7 +54,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 50 } ] @@ -64,7 +64,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 100 } ] @@ -74,7 +74,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 150 } ] @@ -84,7 +84,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 200 } ] @@ -94,7 +94,7 @@ "need": [ { "a": "attr", - "t": "rmbmoney", + "t": "diamond", "n": 250 } ] diff --git a/bin/json/game_arenarankreward.json b/bin/json/game_arenarankreward.json index 07798a90c..d3e78c208 100644 --- a/bin/json/game_arenarankreward.json +++ b/bin/json/game_arenarankreward.json @@ -2,7 +2,7 @@ { "id": 1, "rank_low": 1, - "rank_up": 1, + "rank_up": 2, "rank_reward": [ { "a": "attr", @@ -19,7 +19,7 @@ { "id": 2, "rank_low": 2, - "rank_up": 2, + "rank_up": 3, "rank_reward": [ { "a": "attr", @@ -36,7 +36,7 @@ { "id": 3, "rank_low": 3, - "rank_up": 3, + "rank_up": 4, "rank_reward": [ { "a": "attr", @@ -53,7 +53,7 @@ { "id": 4, "rank_low": 4, - "rank_up": 10, + "rank_up": 11, "rank_reward": [ { "a": "attr", @@ -70,7 +70,7 @@ { "id": 5, "rank_low": 11, - "rank_up": 20, + "rank_up": 21, "rank_reward": [ { "a": "attr", @@ -87,7 +87,7 @@ { "id": 6, "rank_low": 21, - "rank_up": 50, + "rank_up": 51, "rank_reward": [ { "a": "attr", @@ -104,7 +104,7 @@ { "id": 7, "rank_low": 51, - "rank_up": 100, + "rank_up": 101, "rank_reward": [ { "a": "attr", @@ -121,7 +121,7 @@ { "id": 8, "rank_low": 101, - "rank_up": 200, + "rank_up": 201, "rank_reward": [ { "a": "attr", @@ -138,7 +138,7 @@ { "id": 9, "rank_low": 201, - "rank_up": 500, + "rank_up": 501, "rank_reward": [ { "a": "attr", @@ -155,7 +155,7 @@ { "id": 10, "rank_low": 501, - "rank_up": 1000, + "rank_up": 1001, "rank_reward": [ { "a": "attr", @@ -172,7 +172,7 @@ { "id": 11, "rank_low": 1001, - "rank_up": 99999999, + "rank_up": 100000000, "rank_reward": [ { "a": "attr", diff --git a/bin/json/game_global.json b/bin/json/game_global.json index 7fe2dbe96..4aea8e432 100644 --- a/bin/json/game_global.json +++ b/bin/json/game_global.json @@ -210,6 +210,17 @@ "ArenaTicket_RecoveryTime": 144, "ArenaTicket_PurchaseRrestrictions": 10, "arena_InitiaIntegral": 1000, - "arena_RecordMax": 10 + "arena_RecordMax": 10, + "arena_RefreshCd": 10, + "show_male": [ + 100001, + 100002, + 100003 + ], + "show_female": [ + 200001, + 200002, + 200003 + ] } ] \ No newline at end of file diff --git a/modules/arena/api_buy.go b/modules/arena/api_buy.go index 0452616c8..319a666ed 100644 --- a/modules/arena/api_buy.go +++ b/modules/arena/api_buy.go @@ -33,6 +33,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p code = pb.ErrorCode_CacheReadError return } + this.module.modelArena.recoverTicket(info) global = this.module.configure.GetGlobalConf() if info.Ticket+req.BuyNum > global.ArenaTicketMax { 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.Ticket += req.BuyNum - this.module.modelArena.Change(session.GetUserId(), map[string]interface{}{ - "ticket": info.Ticket, - "buynum": info.Buynum, - }) + if err = this.module.modelArena.updateArenaUserInfo(info); err != nil { + code = pb.ErrorCode_DBError + return + } session.SendMsg(string(this.module.GetType()), "buy", &pb.MoonfantasyBuyResp{Issucc: true, BattleNum: info.Ticket}) return } diff --git a/modules/arena/api_challenge.go b/modules/arena/api_challenge.go index 72d172ea6..f6a770d85 100644 --- a/modules/arena/api_challenge.go +++ b/modules/arena/api_challenge.go @@ -3,6 +3,7 @@ package arena import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + "time" "google.golang.org/protobuf/proto" ) @@ -52,6 +53,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge if red.Ticket > 0 { red.Ticket-- + if red.Lastrtickettime == 0 { + red.Lastrtickettime = time.Now().Unix() + } } else { code = pb.ErrorCode_ArenaTicketNotEnough return diff --git a/modules/arena/api_info.go b/modules/arena/api_info.go index eb9d73da5..fd536d70a 100644 --- a/modules/arena/api_info.go +++ b/modules/arena/api_info.go @@ -6,6 +6,7 @@ import ( "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" + "math" "time" "google.golang.org/protobuf/proto" @@ -20,11 +21,13 @@ func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.ArenaInfoReq) ///获取自己的排行榜信息 func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code pb.ErrorCode, data proto.Message) { var ( - global *cfg.GameGlobalData - info *pb.DBArenaUser - user *pb.DBUser - model *db.DBModel - err error + global *cfg.GameGlobalData + info *pb.DBArenaUser + user *pb.DBUser + model *db.DBModel + duration time.Duration + ticketNum int32 + err error ) if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success { return @@ -47,11 +50,12 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code return } info = &pb.DBArenaUser{ - Uid: session.GetUserId(), - Name: user.Name, - Integral: global.ArenaInitiaIntegral, - Ticket: 10, - Record: make([]*pb.DBArenaBattleRecord, 0), + Uid: session.GetUserId(), + Name: user.Name, + Integral: global.ArenaInitiaIntegral, + Ticket: 10, + Record: make([]*pb.DBArenaBattleRecord, 0), + Lastrtickettime: 0, } if info.Dan, err = this.module.modelArena.computedan(info.Integral); err != nil { 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 { 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}) return } diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index 61a90b875..870b996fc 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -11,6 +11,7 @@ import ( "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" + "math" "math/rand" "time" @@ -104,13 +105,15 @@ func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) { return } this.Change(info.Uid, map[string]interface{}{ - "integral": info.Integral, - "dan": dan, - "rank": info.Rank, - "ticket": info.Ticket, - "attack": info.Attack, - "defend": info.Defend, - "streak": info.Streak, + "integral": info.Integral, + "dan": dan, + "rank": info.Rank, + "ticket": info.Ticket, + "buynum": info.Buynum, + "lastrtickettime": info.Lastrtickettime, + "attack": info.Attack, + "defend": info.Defend, + "streak": info.Streak, }) return } @@ -333,3 +336,24 @@ func (this *modelArena) integralCompute(red, bule *pb.ArenaPlayer, iswin bool) { 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() + } + } + } +} diff --git a/pb/arena_db.pb.go b/pb/arena_db.pb.go index e5dee17e7..7142cecb8 100644 --- a/pb/arena_db.pb.go +++ b/pb/arena_db.pb.go @@ -372,21 +372,22 @@ type DBArenaUser struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //用户id - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name"` //玩家名称 - Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar" bson:"avatar"` //头像 - Lv int32 `protobuf:"varint,4,opt,name=lv,proto3" json:"lv" bson:"lv"` //等级 - Integral int32 `protobuf:"varint,5,opt,name=integral,proto3" json:"integral"` //积分 - Ticket int32 `protobuf:"varint,6,opt,name=ticket,proto3" json:"ticket"` //挑战券 - Dan int32 `protobuf:"varint,7,opt,name=dan,proto3" json:"dan"` //段位 - Attack *DBPlayerBattleFormt `protobuf:"bytes,8,opt,name=attack,proto3" json:"attack"` //进攻阵型 - Defend *DBPlayerBattleFormt `protobuf:"bytes,9,opt,name=defend,proto3" json:"defend"` //防守阵型 - Streak int32 `protobuf:"varint,10,opt,name=streak,proto3" json:"streak"` //连胜 - Attackrate int32 `protobuf:"varint,11,opt,name=attackrate,proto3" json:"attackrate"` //进攻胜率 - Defendrate int32 `protobuf:"varint,12,opt,name=defendrate,proto3" json:"defendrate"` //防守胜率 - Rank int32 `protobuf:"varint,13,opt,name=rank,proto3" json:"rank"` //排名 - Buynum int32 `protobuf:"varint,14,opt,name=buynum,proto3" json:"buynum"` //购买次数 - Record []*DBArenaBattleRecord `protobuf:"bytes,15,rep,name=record,proto3" json:"record"` //战斗记录 + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //用户id + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name"` //玩家名称 + Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar" bson:"avatar"` //头像 + Lv int32 `protobuf:"varint,4,opt,name=lv,proto3" json:"lv" bson:"lv"` //等级 + Integral int32 `protobuf:"varint,5,opt,name=integral,proto3" json:"integral"` //积分 + Ticket int32 `protobuf:"varint,6,opt,name=ticket,proto3" json:"ticket"` //挑战券 + Dan int32 `protobuf:"varint,7,opt,name=dan,proto3" json:"dan"` //段位 + Attack *DBPlayerBattleFormt `protobuf:"bytes,8,opt,name=attack,proto3" json:"attack"` //进攻阵型 + Defend *DBPlayerBattleFormt `protobuf:"bytes,9,opt,name=defend,proto3" json:"defend"` //防守阵型 + Streak int32 `protobuf:"varint,10,opt,name=streak,proto3" json:"streak"` //连胜 + Attackrate int32 `protobuf:"varint,11,opt,name=attackrate,proto3" json:"attackrate"` //进攻胜率 + Defendrate int32 `protobuf:"varint,12,opt,name=defendrate,proto3" json:"defendrate"` //防守胜率 + Rank int32 `protobuf:"varint,13,opt,name=rank,proto3" json:"rank"` //排名 + Buynum int32 `protobuf:"varint,14,opt,name=buynum,proto3" json:"buynum"` //购买次数 + 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() { @@ -526,6 +527,13 @@ func (x *DBArenaUser) GetRecord() []*DBArenaBattleRecord { 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_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, 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, - 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, 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, @@ -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, 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, - 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2a, 0x73, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, - 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x07, 0x0a, - 0x03, 0x57, 0x69, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x6f, 0x73, 0x74, 0x10, 0x01, - 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x61, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x76, 0x65, 0x6e, - 0x67, 0x65, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x46, - 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 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, + 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x61, 0x73, 0x74, + 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, + 0x6d, 0x65, 0x2a, 0x73, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x57, 0x69, 0x6e, 0x10, 0x00, + 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x6f, 0x73, 0x74, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x61, + 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x10, 0x02, 0x12, 0x11, + 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, + 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 (