721 lines
24 KiB
Go
721 lines
24 KiB
Go
package model
|
||
|
||
import (
|
||
"rocommon/util"
|
||
"roserver/serverproto"
|
||
)
|
||
|
||
//参数说明,在common.proto协议文件中
|
||
//[枚举类型:枚举参数...] 枚举参数根据枚举类型不同会有不同个数
|
||
func TaskMagCheck(role *Role, taskType serverproto.TaskType, count int32) {
|
||
//todo...
|
||
// 对当前已经接受的任务做枚举判断
|
||
// 主界面任务单独做处理
|
||
if !role.isLoad {
|
||
util.ErrorF("uid=%v TaskMagCheck taskType=%v", role.GetUUid(), taskType)
|
||
return
|
||
}
|
||
|
||
role.roleTask.TaskCheck(taskType, count)
|
||
|
||
//头像设置处理
|
||
role.roleTask.headConditionCheck(taskType, count)
|
||
|
||
//转职条件处理
|
||
role.roleTask.jobConditionCheck(taskType, count)
|
||
|
||
//精彩活动任务处理
|
||
role.roleActivity.TaskCheck(taskType, count)
|
||
|
||
// 称号任务系统
|
||
role.roleHead.TaskCheck(taskType, count)
|
||
}
|
||
|
||
func TaskConditionCheck(role *Role, taskData *serverproto.TaskData, taskType serverproto.TaskType,
|
||
conditionList map[int32][]int32, count int32, bForce bool) bool {
|
||
|
||
if taskData.State == TASK_REWARD_STATE_COMPLETED ||
|
||
taskData.State == TASK_REWARD_STATE_REWARD {
|
||
return false
|
||
}
|
||
|
||
bChange := false
|
||
//完成单条任务条件
|
||
if count > 0 {
|
||
for key := range conditionList {
|
||
//判断当前任务中的子条件是否已经完成
|
||
if checkSubConditionState(key, taskData) {
|
||
break
|
||
}
|
||
if key == int32(taskType) {
|
||
ret := conditionCheck(role, taskData, taskType, conditionList[key], count, bForce)
|
||
if ret == TASK_CONDITION_OK {
|
||
bChange = true
|
||
} else if ret == TASK_CONDITION_CHANGE {
|
||
bChange = true
|
||
}
|
||
break
|
||
}
|
||
}
|
||
} else {
|
||
//直接检查任务所有条件,适用于接取新任务时的操作
|
||
for key, _ := range conditionList {
|
||
if checkSubConditionState(key, taskData) {
|
||
continue
|
||
}
|
||
//默认为0,如果是特定的任务枚举。则做初始化
|
||
initCount := GetNextTaskInitCount(role, key)
|
||
ret := conditionCheck(role, taskData, serverproto.TaskType(key), conditionList[key], initCount, bForce)
|
||
if ret == TASK_CONDITION_OK {
|
||
bChange = true
|
||
} else if ret == TASK_CONDITION_CHANGE {
|
||
bChange = true
|
||
}
|
||
}
|
||
}
|
||
//统计子条件完成数量
|
||
finishNum := 0
|
||
for _, data := range taskData.Progress {
|
||
if data.State == 1 {
|
||
finishNum++
|
||
}
|
||
}
|
||
|
||
if finishNum >= len(conditionList) {
|
||
taskData.State = TASK_REWARD_STATE_COMPLETED
|
||
}
|
||
|
||
if finishNum > 0 || bChange {
|
||
return true
|
||
}
|
||
|
||
return false
|
||
}
|
||
|
||
//true->finish bool->not finish
|
||
func checkSubConditionState(key int32, taskData *serverproto.TaskData) bool {
|
||
for idx := 0; idx < len(taskData.Progress); idx++ {
|
||
item := taskData.Progress[idx]
|
||
if item.Key == key {
|
||
if item.State == 1 {
|
||
return true
|
||
}
|
||
break
|
||
}
|
||
}
|
||
return false
|
||
}
|
||
|
||
func conditionCheck(role *Role, taskData *serverproto.TaskData, taskType serverproto.TaskType,
|
||
conditionList []int32, count int32, bForce bool) int32 {
|
||
|
||
switch taskType {
|
||
//主角Base等级
|
||
case serverproto.TaskType_Base_Level:
|
||
targetNum := conditionList[1]
|
||
baseLevel := role.GetRoleBase().GetRoleLevel()
|
||
return changeTaskProgressSet(&taskData.Progress, baseLevel, int32(taskType), targetNum)
|
||
|
||
//job等级
|
||
case serverproto.TaskType_Job_Level:
|
||
targetNum := conditionList[1]
|
||
jobLevel := role.GetRoleBase().GetRoleJobLevel()
|
||
return changeTaskProgressSet(&taskData.Progress, jobLevel, int32(taskType), targetNum)
|
||
//todo...
|
||
// 完成转职,对应转职阶段
|
||
case serverproto.TaskType_Job_Stage:
|
||
|
||
//任意N个伙伴等级达到X级
|
||
case serverproto.TaskType_Hero_Level_Num:
|
||
if len(conditionList) >= 3 {
|
||
heroLevel := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
heroNum := role.GetRoleHero().GetHeroLevelNum(heroLevel)
|
||
return changeTaskProgressSet(&taskData.Progress, heroNum, int32(taskType), targetNum)
|
||
}
|
||
//N个伙伴战力达到指定数值
|
||
case serverproto.TaskType_Hero_Power_Num:
|
||
if len(conditionList) >= 3 {
|
||
heroPower := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
heroNum := role.GetRoleHero().GetHeroPowerNum(heroPower)
|
||
return changeTaskProgressSet(&taskData.Progress, heroNum, int32(taskType), targetNum)
|
||
}
|
||
|
||
//任意N件装备精炼等级达到X级
|
||
case serverproto.TaskType_Equip_Level_Num:
|
||
if len(conditionList) >= 3 {
|
||
equipLevel := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
equipNum := role.GetRoleBase().GetEquipSlotLevelNum(equipLevel)
|
||
return changeTaskProgressSet(&taskData.Progress, equipNum, int32(taskType), targetNum)
|
||
}
|
||
case serverproto.TaskType_Eve_Equip_Level_Role:
|
||
if len(conditionList) >= 3 {
|
||
equipLevel := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
equipNum := role.GetRoleBase().GetEquipSlotLevelRoleCnt(equipLevel)
|
||
return changeTaskProgressSet(&taskData.Progress, equipNum, int32(taskType), targetNum)
|
||
}
|
||
//通关指定关卡
|
||
case serverproto.TaskType_Level_Battle_Count:
|
||
passBattleId := conditionList[1]
|
||
var targetNum int32 = 1
|
||
if len(conditionList) >= 3 {
|
||
targetNum = conditionList[2]
|
||
}
|
||
//todo...关卡通关次数会在battle结构中做记录
|
||
passNum := role.GetRoleBattle().GetPassBattleIdNum(passBattleId)
|
||
return changeTaskProgressSet(&taskData.Progress, passNum, int32(taskType), targetNum)
|
||
|
||
// 总战力达到指定数值
|
||
case serverproto.TaskType_Total_Power:
|
||
targetNum := conditionList[1]
|
||
//var totalPower = int32(role.GetRoleFightPower().TotalFightPower)
|
||
var totalPower = int32(role.roleBattleAttr.curTotalFightPower)
|
||
return changeTaskProgressSet(&taskData.Progress, totalPower, int32(taskType), targetNum)
|
||
|
||
//主角全身装备精炼等级达到N
|
||
case serverproto.TaskType_Role_Equip_Forge_Count:
|
||
if len(conditionList) >= 3 {
|
||
refineLevel := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
levelNum := role.GetRoleBase().GetMainEquipSlotLevelNum(refineLevel)
|
||
return changeTaskProgressSet(&taskData.Progress, levelNum, int32(taskType), targetNum)
|
||
}
|
||
//N个伙伴装备精炼等级达到X
|
||
case serverproto.TaskType_Part_Equip_Forge_Count:
|
||
if len(conditionList) >= 3 {
|
||
refineLevel := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
levelNum := role.GetRoleBase().GetPartnerEquipSlotLevelNum(refineLevel)
|
||
return changeTaskProgressSet(&taskData.Progress, levelNum, int32(taskType), targetNum)
|
||
}
|
||
//获得N个数量的任意伙伴
|
||
case serverproto.TaskType_Hero_Total_Num:
|
||
targetNum := conditionList[1]
|
||
totalHeroNum := role.GetRoleHero().GetHeroNum()
|
||
return changeTaskProgressSet(&taskData.Progress, totalHeroNum, int32(taskType), targetNum)
|
||
//指定伙伴达到指定等级 [23:伙伴ID:伙伴等级]
|
||
case serverproto.TaskType_Hero_Id_Level:
|
||
if len(conditionList) >= 3 {
|
||
targetNum := conditionList[2]
|
||
heroLevel := role.GetRoleHero().GetHeroByConfigId(conditionList[1]).BaseLevel
|
||
return changeTaskProgressSet(&taskData.Progress, heroLevel, int32(taskType), targetNum)
|
||
}
|
||
case serverproto.TaskType_Climbing_Tower_Level:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
towerLevel := role.GetRoleTower().GetCurTower()
|
||
return changeTaskProgressSet(&taskData.Progress, towerLevel, int32(taskType), targetNum)
|
||
}
|
||
//累计获得银币数量(累计)
|
||
case serverproto.TaskType_Get_Silver_Count:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleTask().totalAddZeny
|
||
return changeTaskProgressSet(&taskData.Progress, int32(curNum), int32(taskType), targetNum)
|
||
}
|
||
//英灵殿胜利次数(累计,主线任务)
|
||
case serverproto.TaskType_Arena_Battle_Win_Count_Accu:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleArena().arenaInfo.RecordWinCount
|
||
return changeTaskProgressSet(&taskData.Progress, int32(curNum), int32(taskType), targetNum)
|
||
}
|
||
//当前拥有的该品质的装备数量
|
||
case serverproto.TaskType_Equip_Quality_Num:
|
||
if len(conditionList) >= 3 {
|
||
equipQuality := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
curNum := role.GetRoleEquip().GetQualityEquipNum(equipQuality)
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//当前拥有该品质的卡片数量
|
||
case serverproto.TaskType_Card_Quality_Num:
|
||
if len(conditionList) >= 3 {
|
||
cardQuality := conditionList[1] //normal mini mvp
|
||
targetNum := conditionList[2]
|
||
curNum := role.GetRoleCard().GetQualityCardNum(cardQuality)
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//当前拥有对应品质的宠物
|
||
case serverproto.TaskType_Pet_Quality_Num:
|
||
if len(conditionList) >= 3 {
|
||
petQuality := conditionList[1] //normal mini mvp
|
||
targetNum := conditionList[2]
|
||
curNum := role.GetRolePet().GetQualityPetNum(petQuality)
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//任务开启时能达到的最大排名,pvp排名
|
||
case serverproto.TaskType_Arena_Rank_Level:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
//count表示排名
|
||
curNum := count
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//互相关注的好友数量
|
||
case serverproto.TaskType_Friend_SubFan_Num:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := int32(len(role.GetRoleSocial().GetFriendList()))
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//对应恶魔品质完成挑战次数
|
||
case serverproto.TaskType_Evil_Battle_Count_Accu:
|
||
if len(conditionList) >= 3 {
|
||
evilQuality := conditionList[1] //normal mini mvp
|
||
targetNum := conditionList[2]
|
||
curNum := role.GetRoleBattle().GetQualityBossChallengeCount(evilQuality)
|
||
//count表示品质
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//英灵殿战斗次数累计
|
||
case serverproto.TaskType_Arena_Battle_Start_Count_Accu:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleArena().GetTotalChallengeCount()
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//历史抽卡次数
|
||
case serverproto.TaskType_Draw_Card_Num:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleDraw().GetDrawCardNum()
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//历史抽宠物次数
|
||
case serverproto.TaskType_Draw_Pet_Num:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleDraw().GetDrawPetNum()
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//历史商店购买次数
|
||
case serverproto.TaskType_Shop_Buy_Count:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleShop().GetShopTotalBuyNum()
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//历史拥有时装数量
|
||
case serverproto.TaskType_Get_Suit_Count:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleFashion().GetFashionCount()
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
//历史上在远征之门中通关任意副本
|
||
case serverproto.TaskType_Expedition_Battle_Count:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleBattle().GetExpeditionTotalFinishNum()
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
case serverproto.TaskType_Guild_Specific_Boss_Damage:
|
||
if len(conditionList) >= 3 {
|
||
bossId := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
curNum := role.GetRoleGuild().GetBossMaxDamage((uint32)(bossId))
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
case serverproto.TaskType_Guild_Specific_Boss_Fight_Count:
|
||
if len(conditionList) >= 3 {
|
||
bossId := conditionList[1]
|
||
targetNum := conditionList[2]
|
||
curNum := role.GetRoleGuild().GetBossFightTotalCount((uint32)(bossId))
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
case serverproto.TaskType_Eve_Expedition_Battle_Type:
|
||
if len(conditionList) >= 2 {
|
||
targetNum := conditionList[1]
|
||
curNum := role.GetRoleBattle().GetExpeditionCur()
|
||
return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
|
||
}
|
||
case serverproto.TaskType_Eve_Pet_Id_Cnt:
|
||
if len(conditionList) >= 3 {
|
||
cfgId := conditionList[1]
|
||
cnt := role.GetRolePet().GetPetNumByCfgId(cfgId)
|
||
cnt += role.GetRolePet().GetBondPetCntByCfgId(cfgId)
|
||
return changeTaskProgressSet(&taskData.Progress, cnt, int32(taskType), conditionList[2])
|
||
}
|
||
case serverproto.TaskType_Eve_Arean_Dan:
|
||
if len(conditionList) >= 2 {
|
||
lvl := conditionList[1]
|
||
curLvl := role.roleArena.scoreLevel
|
||
//// 客户端要求 服务器来处理
|
||
if curLvl >= 10000 {
|
||
curLvl -= 10000
|
||
}
|
||
lvl -= 10000
|
||
return changeTaskProgressSet(&taskData.Progress, curLvl, int32(taskType), lvl)
|
||
}
|
||
case serverproto.TaskType_Eve_Pet_Battle_Quality_cnt:
|
||
if len(conditionList) >= 3 {
|
||
petCnt := conditionList[1]
|
||
quality := conditionList[2]
|
||
curPetCnt := role.GetRolePet().GetPetBattleCntByQuality(quality)
|
||
return changeTaskProgressSet(&taskData.Progress, curPetCnt, int32(taskType), petCnt)
|
||
}
|
||
case serverproto.TaskType_Eve_Fight_value:
|
||
roleBase := role.GetRoleBase()
|
||
if count > 0 && roleBase != nil && roleBase.RoleData() != nil {
|
||
startFight := uint64(0)
|
||
for _, progress := range taskData.Progress {
|
||
if progress.Key != int32(serverproto.TaskType_Eve_Fight_value) {
|
||
continue
|
||
}
|
||
startFight = uint64(progress.Total)
|
||
}
|
||
var totalPower = roleBase.RoleData().FightPower - startFight
|
||
if totalPower < 0 {
|
||
totalPower = 0
|
||
}
|
||
return changeTaskProgressSet(&taskData.Progress, int32(totalPower), int32(taskType), conditionList[1])
|
||
}
|
||
case serverproto.TaskType_Eve_Item_Count:
|
||
if len(conditionList) >= 3 {
|
||
id := conditionList[1]
|
||
cnt := conditionList[2]
|
||
if count <= 0 || count == id {
|
||
num := role.GetRoleBag().getItemNum(id)
|
||
return changeTaskProgressSet(&taskData.Progress, int32(num), int32(taskType), cnt)
|
||
}
|
||
}
|
||
case serverproto.TaskType_Eve_Head_Icon_Cont:
|
||
if len(conditionList) >= 2 {
|
||
count := conditionList[1]
|
||
curCont := role.GetRoleBase().GetHeadFrameCount()
|
||
return changeTaskProgressSet(&taskData.Progress, curCont, int32(taskType), count)
|
||
}
|
||
case serverproto.TaskType_Eve_Skill_Advance_Num:
|
||
if len(conditionList) >= 2 {
|
||
Lvl := conditionList[1]
|
||
curLvl := role.GetRoleSkill().GetAllHeroSkillAdvanceNum()
|
||
return changeTaskProgressSet(&taskData.Progress, curLvl, int32(taskType), Lvl)
|
||
}
|
||
case serverproto.TaskType_Eve_Five_Artifact_Activate:
|
||
if len(conditionList) >= 3 {
|
||
star := conditionList[1]
|
||
cnt := conditionList[2]
|
||
curCnt := role.roleSkillEquip.GetSkillEquipCntByStar(star)
|
||
return changeTaskProgressSet(&taskData.Progress, curCnt, int32(taskType), cnt)
|
||
}
|
||
case serverproto.TaskType_Eve_Evil_Fight_Lvl:
|
||
if len(conditionList) >= 2 {
|
||
Lvl := conditionList[1]
|
||
curLvl := role.GetRoleBattle().GetEvilLvl()
|
||
return changeTaskProgressSet(&taskData.Progress, curLvl, int32(taskType), Lvl)
|
||
}
|
||
case serverproto.TaskType_Eve_Month_Card_Active:
|
||
if len(conditionList) >= 2 {
|
||
needCount := conditionList[1]
|
||
|
||
return changeTaskProgressSet(&taskData.Progress, count, int32(taskType), needCount)
|
||
}
|
||
case serverproto.TaskType_Eve_Login_Day:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Use_Quick_Battle:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_DaoChange_Win:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Month_Card_High:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Month_Card:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Login_Next:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Arean_First: // 赛季冠军
|
||
if len(conditionList) >= 2 {
|
||
cnt := role.roleTask.GetTypeCnt(int32(taskType))
|
||
return changeTaskProgressEqual(&taskData.Progress, cnt, int32(taskType), conditionList[1])
|
||
}
|
||
case serverproto.TaskType_Eve_Battle_Role_Quality:
|
||
if len(conditionList) >= 3 {
|
||
equipQuality := conditionList[1]
|
||
cnt := conditionList[2]
|
||
curcnt := role.GetRoleHero().GetQualityEquipNumByBattle(equipQuality)
|
||
return changeTaskProgressSet(&taskData.Progress, curcnt, int32(taskType), cnt)
|
||
}
|
||
case serverproto.TaskType_Eve_Keepsake_lvl_All:
|
||
lvl := conditionList[1]
|
||
meet := role.roleKeepSake.IsAllMeetLvl(lvl)
|
||
ty := int32(taskType)
|
||
if len(taskData.Progress) <= 0 {
|
||
addProgress := &serverproto.TaskProgressType{
|
||
Key: ty,
|
||
}
|
||
if meet {
|
||
addProgress.State = TASK_REWARD_STATE_COMPLETED
|
||
}
|
||
taskData.Progress = append(taskData.Progress, addProgress)
|
||
}
|
||
for _, data := range taskData.Progress {
|
||
if data.Key != ty {
|
||
continue
|
||
}
|
||
//已经完成
|
||
if data.State == TASK_REWARD_STATE_COMPLETED {
|
||
return TASK_CONDITION_OK
|
||
}
|
||
|
||
if !meet {
|
||
continue
|
||
}
|
||
data.State = TASK_REWARD_STATE_COMPLETED
|
||
return TASK_CONDITION_OK
|
||
}
|
||
case serverproto.TaskType_Eve_Merge_Card: // 合成指定卡片
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Merge_Equip: // 合成指定装备ID
|
||
targetNum := conditionList[1]
|
||
ty := int32(taskType)
|
||
if len(taskData.Progress) <= 0 {
|
||
addProgress := &serverproto.TaskProgressType{
|
||
Key: ty,
|
||
}
|
||
taskData.Progress = append(taskData.Progress, addProgress)
|
||
}
|
||
for _, data := range taskData.Progress {
|
||
if data.Key != ty {
|
||
continue
|
||
}
|
||
//已经完成
|
||
if data.State == TASK_REWARD_STATE_COMPLETED {
|
||
return TASK_CONDITION_OK
|
||
}
|
||
|
||
if count != targetNum {
|
||
continue
|
||
}
|
||
data.Value++
|
||
data.State = TASK_REWARD_STATE_COMPLETED
|
||
return TASK_CONDITION_OK
|
||
}
|
||
return TASK_CONDITION_NONE
|
||
|
||
/////////////////////////记录次数操作
|
||
case serverproto.TaskType_Get_Card_Count: //获得卡片数量
|
||
fallthrough
|
||
case serverproto.TaskType_Silver_Consumption_Count: //银币消耗
|
||
fallthrough
|
||
case serverproto.TaskType_Climbing_Tower_Count: //爬塔次数
|
||
fallthrough
|
||
case serverproto.TaskType_Gold_Consumption_Count: //金币消耗
|
||
fallthrough
|
||
case serverproto.TaskType_Arena_Battle_Win_Count: //英灵殿胜利次数
|
||
fallthrough
|
||
case serverproto.TaskType_Arena_Battle_Start_Count: //英灵殿战斗次数
|
||
fallthrough
|
||
case serverproto.TaskType_Card_Composed_Count: //卡片合成
|
||
fallthrough
|
||
case serverproto.TaskType_Card_Reset_Count: //卡片重置
|
||
fallthrough
|
||
case serverproto.TaskType_Evil_Fight_Count: //恶魔协会战斗次数
|
||
fallthrough
|
||
case serverproto.TaskType_Get_Online_Box_Count: //开宝箱次数
|
||
fallthrough
|
||
case serverproto.TaskType_Hero_LevelUp_Count: //升级任意伙伴N次
|
||
fallthrough
|
||
case serverproto.TaskType_Equip_Level_Count: //精炼任意装备N次
|
||
fallthrough
|
||
case serverproto.TaskType_Equip_Forge_Count: //合成任意装备N次
|
||
fallthrough
|
||
case serverproto.TaskType_Battle_Boss_Count: //boss战次数
|
||
fallthrough
|
||
case serverproto.TaskType_Role_Quick_Battle_Count: //快速战斗次数
|
||
fallthrough
|
||
case serverproto.TaskType_Battle_Boss_Reward_Count: //挑战boss成功次数
|
||
fallthrough
|
||
case serverproto.TaskType_Skill_Slot_Level_Up_Count: //升级任意技能槽N次
|
||
fallthrough
|
||
case serverproto.TaskType_Expedition_CallHelp_Count: //远征之门发起救助操作次数
|
||
fallthrough
|
||
case serverproto.TaskType_Friend_Invite_Count: //完成发起好友邀请次数
|
||
fallthrough
|
||
case serverproto.TaskType_Guild_Join_Count: //加入公会次数
|
||
fallthrough
|
||
case serverproto.TaskType_Chat_Message_Count: //主线任务中新增在聊天频道中发一句话的任务需求
|
||
fallthrough
|
||
case serverproto.TaskType_Expedition_Challenge_Count: //远征之门使用消耗挑战次数(任务开启时记录)
|
||
fallthrough
|
||
case serverproto.TaskType_Guild_Boss_Normal_Count: //公会普通boss挑战次数(任务开启)
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Card_Num:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Pet_Num:
|
||
fallthrough
|
||
case serverproto.TaskType_Recharge_Num:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Arean_Buy:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Arean_First_Cnt:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_Recharge_Value:
|
||
fallthrough
|
||
case serverproto.TaskType_Eve_DaoChange_Win_Add:
|
||
fallthrough
|
||
case serverproto.TaskType_Wheel:
|
||
fallthrough
|
||
case serverproto.TaskType_World_Boss_Challenge_Count: //公会普通boss挑战次数(任务开启)
|
||
targetNum := conditionList[1]
|
||
if count <= 0 && !bForce {
|
||
return TASK_CONDITION_NONE
|
||
}
|
||
return changeTaskProgressAdd(&taskData.Progress, count, int32(taskType), targetNum)
|
||
case serverproto.TaskType_Eve_Accu_count:
|
||
evilQuality := conditionList[1] //normal mini mvp
|
||
targetNum := conditionList[2]
|
||
if evilQuality == count {
|
||
return changeTaskProgressAdd(&taskData.Progress, 1, int32(taskType), targetNum)
|
||
}
|
||
}
|
||
|
||
return TASK_CONDITION_NONE
|
||
}
|
||
|
||
//累计方式
|
||
func changeTaskProgressAdd(progress *[]*serverproto.TaskProgressType, addCount, taskType, targetNum int32) int32 {
|
||
bEdit := false
|
||
for index, data := range *progress {
|
||
if data.Key == taskType {
|
||
//已经完成
|
||
if data.State == TASK_REWARD_STATE_COMPLETED {
|
||
return TASK_CONDITION_OK
|
||
}
|
||
(*progress)[index].Value += addCount
|
||
if (*progress)[index].Value >= targetNum {
|
||
(*progress)[index].Value = targetNum
|
||
(*progress)[index].State = TASK_REWARD_STATE_COMPLETED
|
||
return TASK_CONDITION_OK
|
||
}
|
||
bEdit = true
|
||
break
|
||
}
|
||
}
|
||
if !bEdit {
|
||
addProgress := &serverproto.TaskProgressType{
|
||
Key: taskType,
|
||
Value: addCount,
|
||
}
|
||
*progress = append(*progress, addProgress)
|
||
if addCount >= targetNum {
|
||
addProgress.Value = targetNum
|
||
addProgress.State = TASK_REWARD_STATE_COMPLETED
|
||
return TASK_CONDITION_OK
|
||
}
|
||
}
|
||
|
||
return TASK_CONDITION_CHANGE
|
||
}
|
||
|
||
//数值方式(目标个数)
|
||
func changeTaskProgressSet(progress *[]*serverproto.TaskProgressType, setCount, taskType, targetNum int32) int32 {
|
||
bEdit := false
|
||
for index, data := range *progress {
|
||
if data.Key == taskType {
|
||
//已经完成
|
||
if data.State == TASK_REWARD_STATE_COMPLETED {
|
||
return TASK_CONDITION_OK
|
||
}
|
||
|
||
if setCount >= (*progress)[index].Value {
|
||
(*progress)[index].Value = setCount
|
||
if (*progress)[index].Value >= targetNum {
|
||
(*progress)[index].Value = targetNum
|
||
(*progress)[index].State = TASK_REWARD_STATE_COMPLETED
|
||
return TASK_CONDITION_OK
|
||
}
|
||
bEdit = true
|
||
} else {
|
||
return TASK_CONDITION_NONE
|
||
}
|
||
|
||
//if (*progress)[index].Value >= setCount {
|
||
// (*progress)[index].State = TASK_REWARD_STATE_COMPLETED
|
||
// return TASK_CONDITION_OK
|
||
//} else {
|
||
// if setCount > (*progress)[index].Value {
|
||
// (*progress)[index].Value = setCount
|
||
// if (*progress)[index].Value >= targetNum {
|
||
// (*progress)[index].Value = targetNum
|
||
// (*progress)[index].State = TASK_REWARD_STATE_COMPLETED
|
||
// return TASK_CONDITION_OK
|
||
// }
|
||
// bEdit = true
|
||
// } else {
|
||
// return TASK_CONDITION_NONE
|
||
// }
|
||
//}
|
||
break
|
||
}
|
||
}
|
||
if !bEdit {
|
||
addProgress := &serverproto.TaskProgressType{
|
||
Key: taskType,
|
||
Value: setCount,
|
||
}
|
||
*progress = append(*progress, addProgress)
|
||
if setCount >= targetNum {
|
||
addProgress.Value = targetNum
|
||
addProgress.State = TASK_REWARD_STATE_COMPLETED
|
||
return TASK_CONDITION_OK
|
||
}
|
||
}
|
||
|
||
return TASK_CONDITION_CHANGE
|
||
}
|
||
|
||
//直接赋值 注意该函数的区别
|
||
func changeTaskProgressEqual(progress *[]*serverproto.TaskProgressType, addCount, taskType, targetNum int32) int32 {
|
||
bEdit := false
|
||
for index, data := range *progress {
|
||
if data.Key == taskType {
|
||
//已经完成
|
||
if data.State == TASK_REWARD_STATE_COMPLETED {
|
||
return TASK_CONDITION_OK
|
||
}
|
||
(*progress)[index].Value = addCount
|
||
if (*progress)[index].Value >= targetNum {
|
||
(*progress)[index].Value = targetNum
|
||
(*progress)[index].State = TASK_REWARD_STATE_COMPLETED
|
||
return TASK_CONDITION_OK
|
||
}
|
||
bEdit = true
|
||
break
|
||
}
|
||
}
|
||
if !bEdit {
|
||
addProgress := &serverproto.TaskProgressType{
|
||
Key: taskType,
|
||
Value: addCount,
|
||
}
|
||
*progress = append(*progress, addProgress)
|
||
if addCount >= targetNum {
|
||
addProgress.Value = targetNum
|
||
addProgress.State = TASK_REWARD_STATE_COMPLETED
|
||
return TASK_CONDITION_OK
|
||
}
|
||
}
|
||
|
||
return TASK_CONDITION_CHANGE
|
||
}
|
||
|
||
func GetNextTaskInitCount(role *Role, taskEnum int32) int32 {
|
||
if role == nil {
|
||
return 0
|
||
}
|
||
|
||
switch serverproto.TaskType(taskEnum) {
|
||
case serverproto.TaskType_Get_Card_Count:
|
||
return role.GetRoleCard().GetCardCount()
|
||
case serverproto.TaskType_Guild_Join_Count:
|
||
if role.GetRoleGuildId() > 0 {
|
||
return 1
|
||
}
|
||
}
|
||
|
||
return 0
|
||
}
|