每日任务数值优化
This commit is contained in:
parent
b1b22e06d8
commit
9dec8fa266
@ -2,8 +2,8 @@ package dailyTask
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
dailyTaskCfg "server/conf/daily_task"
|
||||
orderCfg "server/conf/order"
|
||||
"server/game/mod/item"
|
||||
"server/game/mod/quest"
|
||||
GoUtil "server/game_util"
|
||||
@ -49,46 +49,45 @@ func (dt *DailyTaskMod) Unlock() {
|
||||
dt.Lock = true
|
||||
}
|
||||
|
||||
func (dt *DailyTaskMod) LevUpTrigger(Lv, AreaId, dailyAcitivityId int) bool {
|
||||
func (dt *DailyTaskMod) LevUpTrigger(lv, factor, dailyAcitivityId int) bool {
|
||||
if len(dt.DayTask) != 0 {
|
||||
return false
|
||||
}
|
||||
dt.ZeroUpdate(Lv, AreaId, dailyAcitivityId)
|
||||
dt.ZeroUpdate(lv, factor, dailyAcitivityId)
|
||||
return true
|
||||
}
|
||||
|
||||
func (dt *DailyTaskMod) ZeroUpdate(Lv, AreaId, activityId int) {
|
||||
TaskList := dailyTaskCfg.GetTaskList(Lv)
|
||||
if len(TaskList) <= 0 {
|
||||
func (dt *DailyTaskMod) ZeroUpdate(lv, factor, activityId int) {
|
||||
taskList := dailyTaskCfg.GetTaskList(lv)
|
||||
if len(taskList) <= 0 {
|
||||
return
|
||||
}
|
||||
TaskListId := GoUtil.GetMapKey(TaskList)
|
||||
LastTaskId := GoUtil.GetMapKey(dt.lastTask)
|
||||
TaskList1 := GoUtil.SubSlices(TaskListId, LastTaskId)
|
||||
TaskId := GoUtil.RandSliceNum(TaskList1, 3)
|
||||
OrderFactor := orderCfg.GetOrderFactor(AreaId)
|
||||
for i := 0; i < len(TaskId); i++ {
|
||||
Id := i + 1
|
||||
questStr := TaskList[TaskId[i]]
|
||||
QuestProgress, err := quest.ParseQuest(questStr)
|
||||
taskListId := GoUtil.GetMapKey(taskList)
|
||||
lastTaskId := GoUtil.GetMapKey(dt.lastTask)
|
||||
taskList1 := GoUtil.SubSlices(taskListId, lastTaskId)
|
||||
taskId := GoUtil.RandSliceNum(taskList1, 3)
|
||||
for i := range taskId {
|
||||
id := i + 1
|
||||
questStr := taskList[taskId[i]]
|
||||
questProgress, err := quest.ParseQuest(questStr)
|
||||
if err != nil {
|
||||
log.Debug("parse quest err str : %s", questStr)
|
||||
}
|
||||
Items := dailyTaskCfg.GetDailyTaskReward(Id, OrderFactor, activityId)
|
||||
dt.DayTask[Id] = DailyTask{
|
||||
Items: Items,
|
||||
UnLock: Id == 1,
|
||||
Quest: QuestProgress,
|
||||
items := dailyTaskCfg.GetDailyTaskReward(id, factor, activityId)
|
||||
dt.DayTask[id] = DailyTask{
|
||||
Items: items,
|
||||
UnLock: id == 1,
|
||||
Quest: questProgress,
|
||||
}
|
||||
}
|
||||
// 更新 lastTask,下次不重复当前任务
|
||||
dt.lastTask = make(map[int]struct{}, len(TaskId))
|
||||
for _, id := range TaskId {
|
||||
dt.lastTask = make(map[int]struct{}, len(taskId))
|
||||
for _, id := range taskId {
|
||||
dt.lastTask[id] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func (dt *DailyTaskMod) WeekUpdate() {
|
||||
func (dt *DailyTaskMod) WeekUpdate(factor int) {
|
||||
jackpot := dailyTaskCfg.GetTaskWeekJackpot()
|
||||
jackpotRand := randJackpot(jackpot, 5)
|
||||
jackpotId := GoUtil.GetMapKey(jackpotRand)
|
||||
@ -105,7 +104,20 @@ func (dt *DailyTaskMod) WeekUpdate() {
|
||||
Items: []*item.Item{{Id: item.ITEM_FIVE_STAR_CARD_PACK, Num: 1}},
|
||||
}
|
||||
dt.Active = 0
|
||||
dt.WeekReward = weekReward
|
||||
dt.WeekReward = formatWeekReward(weekReward, factor)
|
||||
}
|
||||
|
||||
func formatWeekReward(reward map[int]WeekReward, factor int) map[int]WeekReward {
|
||||
for k, v := range reward {
|
||||
for _, v := range v.Items {
|
||||
if v.Id == item.ITEM_STAR_ID {
|
||||
Num := math.Round(float64(v.Num) * float64(factor) / 100)
|
||||
v.Num = int(Num) / 5 * 5
|
||||
}
|
||||
}
|
||||
reward[k] = v
|
||||
}
|
||||
return reward
|
||||
}
|
||||
|
||||
func (dt *DailyTaskMod) Trigger(Tr *quest.Trigger) bool {
|
||||
@ -138,32 +150,32 @@ func (dt *DailyTaskMod) Trigger(Tr *quest.Trigger) bool {
|
||||
}
|
||||
|
||||
func (dt *DailyTaskMod) BackData() *msg.ResDailyTask {
|
||||
WeekReward := make(map[int32]*msg.DailyWeek)
|
||||
DailyTask := make(map[int32]*msg.DailyTask)
|
||||
weekReward := make(map[int32]*msg.DailyWeek)
|
||||
dailyTask := make(map[int32]*msg.DailyTask)
|
||||
for k, v := range dt.WeekReward {
|
||||
NeedActive := dailyTaskCfg.GetTaskActiveById(k)
|
||||
WeekReward[int32(k)] = &msg.DailyWeek{
|
||||
needActive := dailyTaskCfg.GetTaskActiveById(k)
|
||||
weekReward[int32(k)] = &msg.DailyWeek{
|
||||
Status: v.Status,
|
||||
NeedActive: int32(NeedActive),
|
||||
NeedActive: int32(needActive),
|
||||
Items: item.ItemToMsg(v.Items),
|
||||
}
|
||||
}
|
||||
for k, v := range dt.DayTask {
|
||||
DailyTask[int32(k)] = &msg.DailyTask{
|
||||
dailyTask[int32(k)] = &msg.DailyTask{
|
||||
Status: int32(v.Status),
|
||||
UnLock: v.UnLock,
|
||||
Progress: quest.QuestProgressToMsg(&v.Quest),
|
||||
Items: item.ItemToMsg(v.Items),
|
||||
}
|
||||
}
|
||||
DayEnd := GoUtil.NextZeroTimestampDuration()
|
||||
WeekEnd := GoUtil.NextWeekTimestampDuration()
|
||||
dayEnd := GoUtil.NextZeroTimestampDuration()
|
||||
weekEnd := GoUtil.NextWeekTimestampDuration()
|
||||
return &msg.ResDailyTask{
|
||||
WeekReward: WeekReward,
|
||||
DailyTask: DailyTask,
|
||||
WeekReward: weekReward,
|
||||
DailyTask: dailyTask,
|
||||
Active: int32(dt.Active),
|
||||
DayEnd: int32(DayEnd),
|
||||
WeekEnd: int32(WeekEnd),
|
||||
DayEnd: int32(dayEnd),
|
||||
WeekEnd: int32(weekEnd),
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,8 +193,8 @@ func (dt *DailyTaskMod) GetDailyReward(id, activityId int) ([]*item.Item, error)
|
||||
|
||||
func (dt *DailyTaskMod) GetWeekReward(id int) ([]*item.Item, error) {
|
||||
if v, ok := dt.WeekReward[id]; ok {
|
||||
NeedActive := dailyTaskCfg.GetTaskActiveById(id)
|
||||
if dt.Active < NeedActive {
|
||||
needActive := dailyTaskCfg.GetTaskActiveById(id)
|
||||
if dt.Active < needActive {
|
||||
return nil, fmt.Errorf("active not enough")
|
||||
}
|
||||
if !v.Status {
|
||||
@ -202,8 +214,8 @@ func (dt *DailyTaskMod) GetWeekReward2() []*item.Item {
|
||||
}
|
||||
}
|
||||
if v, ok := dt.WeekReward[maxId]; ok {
|
||||
NeedActive := dailyTaskCfg.GetTaskActiveById(maxId)
|
||||
if dt.Active < NeedActive {
|
||||
needActive := dailyTaskCfg.GetTaskActiveById(maxId)
|
||||
if dt.Active < needActive {
|
||||
return nil
|
||||
}
|
||||
if !v.Status {
|
||||
|
||||
@ -536,9 +536,8 @@ func (p *PlayerBaseData) AddExp(player *Player, exp int, pexp int) (int, error)
|
||||
upExp, upPExp = userCfg.GetLevUpExp(BaseMod.Level)
|
||||
// 日常任务解锁
|
||||
DailyTaskMod := player.PlayMod.getDailyTaskMod()
|
||||
DecorateMod := player.PlayMod.getDecorateMod()
|
||||
dailyAcitivityId := player.GetDailyTaskActivityId()
|
||||
if DailyTaskMod.LevUpTrigger(BaseMod.Level, DecorateMod.GetAreaId(), dailyAcitivityId) {
|
||||
if DailyTaskMod.LevUpTrigger(BaseMod.Level, player.GetOrderFactor(), dailyAcitivityId) {
|
||||
player.PushClientRes(DailyTaskMod.BackData())
|
||||
}
|
||||
upLv = BaseMod.Level
|
||||
|
||||
@ -413,7 +413,7 @@ func (p *Player) ZeroUpdate(a []interface{}) {
|
||||
if VarMod.WeeklyResetTime < weekZeroTimestamp {
|
||||
VarMod.WeeklyResetTime = weekZeroTimestamp
|
||||
VarMod.WeeklyVar = make(map[int]interface{})
|
||||
p.PlayMod.getDailyTaskMod().WeekUpdate()
|
||||
p.PlayMod.getDailyTaskMod().WeekUpdate(p.GetOrderFactor())
|
||||
p.PushClientRes(p.PlayMod.getDailyTaskMod().BackData())
|
||||
|
||||
p.PlayMod.getLimitedTimeEventMod().WeekUpdate()
|
||||
|
||||
@ -26,6 +26,17 @@ func TestDailyZeroUpdate(t *testing.T) {
|
||||
DailyTaskMod.BackData()
|
||||
}
|
||||
|
||||
func TestDailyWeekUpdate(t *testing.T) {
|
||||
player := new(game.Player)
|
||||
player.InitPlayerByUid(100001)
|
||||
DailyTaskMod := player.GetDailyTaskMod()
|
||||
DailyTaskMod.WeekUpdate(200)
|
||||
for _, v := range DailyTaskMod.WeekReward {
|
||||
fmt.Printf("week reward id: %d, items: %v\n", v.Id, v.Items)
|
||||
}
|
||||
DailyTaskMod.BackData()
|
||||
}
|
||||
|
||||
func TestDailyTaskRewardScore(t *testing.T) {
|
||||
score1 := dailyTaskCfg.GetDailyTaskScore(1, 1)
|
||||
if score1 == 0 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user