| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758 |
- 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 {
- case serverproto.TaskType_BT_ZhenJiaRecharge: // 真/假每日累计充值活动
- targetNum := conditionList[1]
- if count <= 0 && !bForce {
- return TASK_CONDITION_NONE
- }
- return changeTaskProgressAdd2(&taskData.Progress, count, int32(taskType), targetNum)
- //主角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_Level_Hard_Battle_Count:
- passBattleId := conditionList[1]
- var targetNum int32 = 1
- if len(conditionList) >= 3 {
- targetNum = conditionList[2]
- }
- //todo...关卡通关次数会在battle结构中做记录
- passNum := role.GetRoleBattle().GetPassHardBattleIdNum(passBattleId)
- return changeTaskProgressSet(&taskData.Progress, passNum, int32(taskType), targetNum)
- case serverproto.TaskType_Level_Hard_Battle2_Count:
- passBattleId := conditionList[1]
- var targetNum int32 = 1
- if len(conditionList) >= 3 {
- targetNum = conditionList[2]
- }
- //todo...关卡通关次数会在battle结构中做记录
- passNum := role.GetRoleBattle().GetPassHardBattle2IdNum(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_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_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_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_World_Boss_Challenge_Count: //公会普通boss挑战次数(任务开启)
- fallthrough
- case serverproto.TaskType_BT_ROCoinRecharge: // bt RO币累计活动
- 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 changeTaskProgressAdd2(progress *[]*serverproto.TaskProgressType, addCount, taskType, targetNum int32) int32 {
- bEdit := false
- for index, data := range *progress {
- if data.Key == taskType {
- //数值一直加
- (*progress)[index].Value = addCount
- //已经完成
- if data.State == TASK_REWARD_STATE_COMPLETED {
- return TASK_CONDITION_OK
- }
- 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
- }
|