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