限时事件优化
This commit is contained in:
parent
1145fd63ba
commit
bc1e788bd9
@ -2802,7 +2802,8 @@ func ReqSelectLimitEvent(player *Player, buf []byte) error {
|
||||
req := &msg.ReqSelectLimitEvent{}
|
||||
proto.Unmarshal(buf, req)
|
||||
LimitedTimeEventMod := player.PlayMod.getLimitedTimeEventMod()
|
||||
Items, slot_reward, slot_order_number, err := LimitedTimeEventMod.SelectProgressReward(int(req.Id))
|
||||
BaseMod := player.PlayMod.getBaseMod()
|
||||
Items, slot_reward, slot_order_number, err := LimitedTimeEventMod.SelectProgressReward(int(req.Id), BaseMod.Level)
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResSelectLimitEvent{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
|
||||
@ -92,6 +92,14 @@ func (l *LimitedTimeEventMod) InitData(Lv int) {
|
||||
l.Lv = Lv
|
||||
l.ProgressMax = limitedTimeEventCfg.GetProgressMax(Lv, l.BonusNum)
|
||||
}
|
||||
if !l.First {
|
||||
l.First = true
|
||||
EventId := limitedTimeEventCfg.GetFirstEvent()
|
||||
l.ProgressReward = map[int]int{
|
||||
1: EventId,
|
||||
}
|
||||
l.LastOption = []int{EventId}
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LimitedTimeEventMod) ZeroUpdate(Lv int) {
|
||||
@ -300,41 +308,10 @@ func (l *LimitedTimeEventMod) AddProgress(Lv int) {
|
||||
return
|
||||
}
|
||||
l.Progress++
|
||||
if l.Progress == l.ProgressMax {
|
||||
if !l.First {
|
||||
l.First = true
|
||||
EventId := limitedTimeEventCfg.GetFirstEvent()
|
||||
l.ProgressReward = map[int]int{
|
||||
1: EventId,
|
||||
}
|
||||
l.LastOption = []int{EventId}
|
||||
return
|
||||
}
|
||||
SelectNum := limitedTimeEventCfg.GetProgressSelectNum(Lv)
|
||||
BonusLv := limitedTimeEventCfg.GetBonusLv(Lv)
|
||||
RandMap := limitedTimeEventCfg.GetProgressRewardRand(BonusLv)
|
||||
n := 0
|
||||
r := make([]int, 0)
|
||||
LastOption := l.LastOption
|
||||
for n < 10 {
|
||||
n++
|
||||
r = GoUtil.RandMapNum(RandMap, SelectNum)
|
||||
Id := 1
|
||||
for _, v := range r {
|
||||
l.ProgressReward[Id] = v
|
||||
Id++
|
||||
}
|
||||
|
||||
if !GoUtil.SliceEqual(LastOption, r) {
|
||||
break
|
||||
}
|
||||
}
|
||||
l.LastOption = r
|
||||
}
|
||||
}
|
||||
|
||||
// 选择进度奖励
|
||||
func (l *LimitedTimeEventMod) SelectProgressReward(Id int) ([]*item.Item, map[int]int, int, error) {
|
||||
func (l *LimitedTimeEventMod) SelectProgressReward(Id, Lv int) ([]*item.Item, map[int]int, int, error) {
|
||||
RewardId, ok := l.ProgressReward[Id]
|
||||
if !ok {
|
||||
return nil, nil, 0, fmt.Errorf("RewardId not exist")
|
||||
@ -347,6 +324,26 @@ func (l *LimitedTimeEventMod) SelectProgressReward(Id int) ([]*item.Item, map[in
|
||||
l.Progress = 0
|
||||
l.BonusNum++
|
||||
l.ProgressMax = limitedTimeEventCfg.GetProgressMax(l.Lv, l.BonusNum)
|
||||
SelectNum := limitedTimeEventCfg.GetProgressSelectNum(Lv)
|
||||
BonusLv := limitedTimeEventCfg.GetBonusLv(Lv)
|
||||
RandMap := limitedTimeEventCfg.GetProgressRewardRand(BonusLv)
|
||||
n := 0
|
||||
r := make([]int, 0)
|
||||
LastOption := l.LastOption
|
||||
for n < 10 {
|
||||
n++
|
||||
r = GoUtil.RandMapNum(RandMap, SelectNum)
|
||||
Id := 1
|
||||
for _, v := range r {
|
||||
l.ProgressReward[Id] = v
|
||||
Id++
|
||||
}
|
||||
|
||||
if !GoUtil.SliceEqual(LastOption, r) {
|
||||
break
|
||||
}
|
||||
}
|
||||
l.LastOption = r
|
||||
return Item, r1, r2, nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user