task_manager.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. package model
  2. import (
  3. "rocommon/util"
  4. "roserver/serverproto"
  5. )
  6. // 参数说明,在common.proto协议文件中
  7. // [枚举类型:枚举参数...] 枚举参数根据枚举类型不同会有不同个数
  8. func TaskMagCheck(role *Role, taskType serverproto.TaskType, count int32) {
  9. //todo...
  10. // 对当前已经接受的任务做枚举判断
  11. // 主界面任务单独做处理
  12. if !role.isLoad {
  13. util.ErrorF("uid=%v TaskMagCheck taskType=%v", role.GetUUid(), taskType)
  14. return
  15. }
  16. role.roleTask.TaskCheck(taskType, count)
  17. //头像设置处理
  18. role.roleTask.headConditionCheck(taskType, count)
  19. //转职条件处理
  20. role.roleTask.jobConditionCheck(taskType, count)
  21. //精彩活动任务处理
  22. role.roleActivity.TaskCheck(taskType, count)
  23. // 称号任务系统
  24. role.roleHead.TaskCheck(taskType, count)
  25. }
  26. func TaskConditionCheck(role *Role, taskData *serverproto.TaskData, taskType serverproto.TaskType,
  27. conditionList map[int32][]int32, count int32, bForce bool) bool {
  28. if taskData.State == TASK_REWARD_STATE_COMPLETED ||
  29. taskData.State == TASK_REWARD_STATE_REWARD {
  30. return false
  31. }
  32. bChange := false
  33. //完成单条任务条件
  34. if count > 0 {
  35. for key := range conditionList {
  36. //判断当前任务中的子条件是否已经完成
  37. if checkSubConditionState(key, taskData) {
  38. break
  39. }
  40. if key == int32(taskType) {
  41. ret := conditionCheck(role, taskData, taskType, conditionList[key], count, bForce)
  42. if ret == TASK_CONDITION_OK {
  43. bChange = true
  44. } else if ret == TASK_CONDITION_CHANGE {
  45. bChange = true
  46. }
  47. break
  48. }
  49. }
  50. } else {
  51. //直接检查任务所有条件,适用于接取新任务时的操作
  52. for key, _ := range conditionList {
  53. if checkSubConditionState(key, taskData) {
  54. continue
  55. }
  56. //默认为0,如果是特定的任务枚举。则做初始化
  57. initCount := GetNextTaskInitCount(role, key)
  58. ret := conditionCheck(role, taskData, serverproto.TaskType(key), conditionList[key], initCount, bForce)
  59. if ret == TASK_CONDITION_OK {
  60. bChange = true
  61. } else if ret == TASK_CONDITION_CHANGE {
  62. bChange = true
  63. }
  64. }
  65. }
  66. //统计子条件完成数量
  67. finishNum := 0
  68. for _, data := range taskData.Progress {
  69. if data.State == 1 {
  70. finishNum++
  71. }
  72. }
  73. if finishNum >= len(conditionList) {
  74. taskData.State = TASK_REWARD_STATE_COMPLETED
  75. }
  76. if finishNum > 0 || bChange {
  77. return true
  78. }
  79. return false
  80. }
  81. // true->finish bool->not finish
  82. func checkSubConditionState(key int32, taskData *serverproto.TaskData) bool {
  83. for idx := 0; idx < len(taskData.Progress); idx++ {
  84. item := taskData.Progress[idx]
  85. if item.Key == key {
  86. if item.State == 1 {
  87. return true
  88. }
  89. break
  90. }
  91. }
  92. return false
  93. }
  94. func conditionCheck(role *Role, taskData *serverproto.TaskData, taskType serverproto.TaskType,
  95. conditionList []int32, count int32, bForce bool) int32 {
  96. switch taskType {
  97. case serverproto.TaskType_BT_ZhenJiaRecharge: // 真/假每日累计充值活动
  98. targetNum := conditionList[1]
  99. if count <= 0 && !bForce {
  100. return TASK_CONDITION_NONE
  101. }
  102. return changeTaskProgressAdd2(&taskData.Progress, count, int32(taskType), targetNum)
  103. //主角Base等级
  104. case serverproto.TaskType_Base_Level:
  105. targetNum := conditionList[1]
  106. baseLevel := role.GetRoleBase().GetRoleLevel()
  107. return changeTaskProgressSet(&taskData.Progress, baseLevel, int32(taskType), targetNum)
  108. //job等级
  109. case serverproto.TaskType_Job_Level:
  110. targetNum := conditionList[1]
  111. jobLevel := role.GetRoleBase().GetRoleJobLevel()
  112. return changeTaskProgressSet(&taskData.Progress, jobLevel, int32(taskType), targetNum)
  113. //todo...
  114. // 完成转职,对应转职阶段
  115. case serverproto.TaskType_Job_Stage:
  116. //任意N个伙伴等级达到X级
  117. case serverproto.TaskType_Hero_Level_Num:
  118. if len(conditionList) >= 3 {
  119. heroLevel := conditionList[1]
  120. targetNum := conditionList[2]
  121. heroNum := role.GetRoleHero().GetHeroLevelNum(heroLevel)
  122. return changeTaskProgressSet(&taskData.Progress, heroNum, int32(taskType), targetNum)
  123. }
  124. //N个伙伴战力达到指定数值
  125. case serverproto.TaskType_Hero_Power_Num:
  126. if len(conditionList) >= 3 {
  127. heroPower := conditionList[1]
  128. targetNum := conditionList[2]
  129. heroNum := role.GetRoleHero().GetHeroPowerNum(heroPower)
  130. return changeTaskProgressSet(&taskData.Progress, heroNum, int32(taskType), targetNum)
  131. }
  132. //任意N件装备精炼等级达到X级
  133. case serverproto.TaskType_Equip_Level_Num:
  134. if len(conditionList) >= 3 {
  135. equipLevel := conditionList[1]
  136. targetNum := conditionList[2]
  137. equipNum := role.GetRoleBase().GetEquipSlotLevelNum(equipLevel)
  138. return changeTaskProgressSet(&taskData.Progress, equipNum, int32(taskType), targetNum)
  139. }
  140. case serverproto.TaskType_Eve_Equip_Level_Role:
  141. if len(conditionList) >= 3 {
  142. equipLevel := conditionList[1]
  143. targetNum := conditionList[2]
  144. equipNum := role.GetRoleBase().GetEquipSlotLevelRoleCnt(equipLevel)
  145. return changeTaskProgressSet(&taskData.Progress, equipNum, int32(taskType), targetNum)
  146. }
  147. //通关指定关卡
  148. case serverproto.TaskType_Level_Battle_Count:
  149. passBattleId := conditionList[1]
  150. var targetNum int32 = 1
  151. if len(conditionList) >= 3 {
  152. targetNum = conditionList[2]
  153. }
  154. //todo...关卡通关次数会在battle结构中做记录
  155. passNum := role.GetRoleBattle().GetPassBattleIdNum(passBattleId)
  156. return changeTaskProgressSet(&taskData.Progress, passNum, int32(taskType), targetNum)
  157. case serverproto.TaskType_Level_Hard_Battle_Count:
  158. passBattleId := conditionList[1]
  159. var targetNum int32 = 1
  160. if len(conditionList) >= 3 {
  161. targetNum = conditionList[2]
  162. }
  163. //todo...关卡通关次数会在battle结构中做记录
  164. passNum := role.GetRoleBattle().GetPassHardBattleIdNum(passBattleId)
  165. return changeTaskProgressSet(&taskData.Progress, passNum, int32(taskType), targetNum)
  166. // 总战力达到指定数值
  167. case serverproto.TaskType_Total_Power:
  168. targetNum := conditionList[1]
  169. //var totalPower = int32(role.GetRoleFightPower().TotalFightPower)
  170. var totalPower = int32(role.roleBattleAttr.curTotalFightPower)
  171. return changeTaskProgressSet(&taskData.Progress, totalPower, int32(taskType), targetNum)
  172. //主角全身装备精炼等级达到N
  173. case serverproto.TaskType_Role_Equip_Forge_Count:
  174. if len(conditionList) >= 3 {
  175. refineLevel := conditionList[1]
  176. targetNum := conditionList[2]
  177. levelNum := role.GetRoleBase().GetMainEquipSlotLevelNum(refineLevel)
  178. return changeTaskProgressSet(&taskData.Progress, levelNum, int32(taskType), targetNum)
  179. }
  180. //N个伙伴装备精炼等级达到X
  181. case serverproto.TaskType_Part_Equip_Forge_Count:
  182. if len(conditionList) >= 3 {
  183. refineLevel := conditionList[1]
  184. targetNum := conditionList[2]
  185. levelNum := role.GetRoleBase().GetPartnerEquipSlotLevelNum(refineLevel)
  186. return changeTaskProgressSet(&taskData.Progress, levelNum, int32(taskType), targetNum)
  187. }
  188. //获得N个数量的任意伙伴
  189. case serverproto.TaskType_Hero_Total_Num:
  190. targetNum := conditionList[1]
  191. totalHeroNum := role.GetRoleHero().GetHeroNum()
  192. return changeTaskProgressSet(&taskData.Progress, totalHeroNum, int32(taskType), targetNum)
  193. //指定伙伴达到指定等级 [23:伙伴ID:伙伴等级]
  194. case serverproto.TaskType_Hero_Id_Level:
  195. if len(conditionList) >= 3 {
  196. targetNum := conditionList[2]
  197. heroLevel := role.GetRoleHero().GetHeroByConfigId(conditionList[1]).BaseLevel
  198. return changeTaskProgressSet(&taskData.Progress, heroLevel, int32(taskType), targetNum)
  199. }
  200. case serverproto.TaskType_Climbing_Tower_Level:
  201. if len(conditionList) >= 2 {
  202. targetNum := conditionList[1]
  203. towerLevel := role.GetRoleTower().GetCurTower()
  204. return changeTaskProgressSet(&taskData.Progress, towerLevel, int32(taskType), targetNum)
  205. }
  206. //累计获得银币数量(累计)
  207. case serverproto.TaskType_Get_Silver_Count:
  208. if len(conditionList) >= 2 {
  209. targetNum := conditionList[1]
  210. curNum := role.GetRoleTask().totalAddZeny
  211. return changeTaskProgressSet(&taskData.Progress, int32(curNum), int32(taskType), targetNum)
  212. }
  213. //英灵殿胜利次数(累计,主线任务)
  214. case serverproto.TaskType_Arena_Battle_Win_Count_Accu:
  215. if len(conditionList) >= 2 {
  216. targetNum := conditionList[1]
  217. curNum := role.GetRoleArena().arenaInfo.RecordWinCount
  218. return changeTaskProgressSet(&taskData.Progress, int32(curNum), int32(taskType), targetNum)
  219. }
  220. //当前拥有的该品质的装备数量
  221. case serverproto.TaskType_Equip_Quality_Num:
  222. if len(conditionList) >= 3 {
  223. equipQuality := conditionList[1]
  224. targetNum := conditionList[2]
  225. curNum := role.GetRoleEquip().GetQualityEquipNum(equipQuality)
  226. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  227. }
  228. //当前拥有该品质的卡片数量
  229. case serverproto.TaskType_Card_Quality_Num:
  230. if len(conditionList) >= 3 {
  231. cardQuality := conditionList[1] //normal mini mvp
  232. targetNum := conditionList[2]
  233. curNum := role.GetRoleCard().GetQualityCardNum(cardQuality)
  234. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  235. }
  236. //当前拥有对应品质的宠物
  237. case serverproto.TaskType_Pet_Quality_Num:
  238. if len(conditionList) >= 3 {
  239. petQuality := conditionList[1] //normal mini mvp
  240. targetNum := conditionList[2]
  241. curNum := role.GetRolePet().GetQualityPetNum(petQuality)
  242. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  243. }
  244. //任务开启时能达到的最大排名,pvp排名
  245. case serverproto.TaskType_Arena_Rank_Level:
  246. if len(conditionList) >= 2 {
  247. targetNum := conditionList[1]
  248. //count表示排名
  249. curNum := count
  250. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  251. }
  252. //互相关注的好友数量
  253. case serverproto.TaskType_Friend_SubFan_Num:
  254. if len(conditionList) >= 2 {
  255. targetNum := conditionList[1]
  256. curNum := int32(len(role.GetRoleSocial().GetFriendList()))
  257. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  258. }
  259. //对应恶魔品质完成挑战次数
  260. case serverproto.TaskType_Evil_Battle_Count_Accu:
  261. if len(conditionList) >= 3 {
  262. evilQuality := conditionList[1] //normal mini mvp
  263. targetNum := conditionList[2]
  264. curNum := role.GetRoleBattle().GetQualityBossChallengeCount(evilQuality)
  265. //count表示品质
  266. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  267. }
  268. //英灵殿战斗次数累计
  269. case serverproto.TaskType_Arena_Battle_Start_Count_Accu:
  270. if len(conditionList) >= 2 {
  271. targetNum := conditionList[1]
  272. curNum := role.GetRoleArena().GetTotalChallengeCount()
  273. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  274. }
  275. //历史抽卡次数
  276. case serverproto.TaskType_Draw_Card_Num:
  277. if len(conditionList) >= 2 {
  278. targetNum := conditionList[1]
  279. curNum := role.GetRoleDraw().GetDrawCardNum()
  280. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  281. }
  282. //历史抽宠物次数
  283. case serverproto.TaskType_Draw_Pet_Num:
  284. if len(conditionList) >= 2 {
  285. targetNum := conditionList[1]
  286. curNum := role.GetRoleDraw().GetDrawPetNum()
  287. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  288. }
  289. //历史商店购买次数
  290. case serverproto.TaskType_Shop_Buy_Count:
  291. if len(conditionList) >= 2 {
  292. targetNum := conditionList[1]
  293. curNum := role.GetRoleShop().GetShopTotalBuyNum()
  294. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  295. }
  296. //历史拥有时装数量
  297. case serverproto.TaskType_Get_Suit_Count:
  298. if len(conditionList) >= 2 {
  299. targetNum := conditionList[1]
  300. curNum := role.GetRoleFashion().GetFashionCount()
  301. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  302. }
  303. //历史上在远征之门中通关任意副本
  304. case serverproto.TaskType_Expedition_Battle_Count:
  305. if len(conditionList) >= 2 {
  306. targetNum := conditionList[1]
  307. curNum := role.GetRoleBattle().GetExpeditionTotalFinishNum()
  308. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  309. }
  310. case serverproto.TaskType_Eve_Expedition_Battle_Type:
  311. if len(conditionList) >= 2 {
  312. targetNum := conditionList[1]
  313. curNum := role.GetRoleBattle().GetExpeditionCur()
  314. return changeTaskProgressSet(&taskData.Progress, curNum, int32(taskType), targetNum)
  315. }
  316. case serverproto.TaskType_Eve_Pet_Id_Cnt:
  317. if len(conditionList) >= 3 {
  318. cfgId := conditionList[1]
  319. cnt := role.GetRolePet().GetPetNumByCfgId(cfgId)
  320. cnt += role.GetRolePet().GetBondPetCntByCfgId(cfgId)
  321. return changeTaskProgressSet(&taskData.Progress, cnt, int32(taskType), conditionList[2])
  322. }
  323. case serverproto.TaskType_Eve_Arean_Dan:
  324. if len(conditionList) >= 2 {
  325. lvl := conditionList[1]
  326. curLvl := role.roleArena.scoreLevel
  327. //// 客户端要求 服务器来处理
  328. if curLvl >= 10000 {
  329. curLvl -= 10000
  330. }
  331. lvl -= 10000
  332. return changeTaskProgressSet(&taskData.Progress, curLvl, int32(taskType), lvl)
  333. }
  334. case serverproto.TaskType_Eve_Pet_Battle_Quality_cnt:
  335. if len(conditionList) >= 3 {
  336. petCnt := conditionList[1]
  337. quality := conditionList[2]
  338. curPetCnt := role.GetRolePet().GetPetBattleCntByQuality(quality)
  339. return changeTaskProgressSet(&taskData.Progress, curPetCnt, int32(taskType), petCnt)
  340. }
  341. case serverproto.TaskType_Eve_Fight_value:
  342. roleBase := role.GetRoleBase()
  343. if count > 0 && roleBase != nil && roleBase.RoleData() != nil {
  344. startFight := uint64(0)
  345. for _, progress := range taskData.Progress {
  346. if progress.Key != int32(serverproto.TaskType_Eve_Fight_value) {
  347. continue
  348. }
  349. startFight = uint64(progress.Total)
  350. }
  351. var totalPower = roleBase.RoleData().FightPower - startFight
  352. if totalPower < 0 {
  353. totalPower = 0
  354. }
  355. return changeTaskProgressSet(&taskData.Progress, int32(totalPower), int32(taskType), conditionList[1])
  356. }
  357. case serverproto.TaskType_Eve_Item_Count:
  358. if len(conditionList) >= 3 {
  359. id := conditionList[1]
  360. cnt := conditionList[2]
  361. if count <= 0 || count == id {
  362. num := role.GetRoleBag().getItemNum(id)
  363. return changeTaskProgressSet(&taskData.Progress, int32(num), int32(taskType), cnt)
  364. }
  365. }
  366. case serverproto.TaskType_Eve_Head_Icon_Cont:
  367. if len(conditionList) >= 2 {
  368. count := conditionList[1]
  369. curCont := role.GetRoleBase().GetHeadFrameCount()
  370. return changeTaskProgressSet(&taskData.Progress, curCont, int32(taskType), count)
  371. }
  372. case serverproto.TaskType_Eve_Skill_Advance_Num:
  373. if len(conditionList) >= 2 {
  374. Lvl := conditionList[1]
  375. curLvl := role.GetRoleSkill().GetAllHeroSkillAdvanceNum()
  376. return changeTaskProgressSet(&taskData.Progress, curLvl, int32(taskType), Lvl)
  377. }
  378. case serverproto.TaskType_Eve_Five_Artifact_Activate:
  379. if len(conditionList) >= 3 {
  380. star := conditionList[1]
  381. cnt := conditionList[2]
  382. curCnt := role.roleSkillEquip.GetSkillEquipCntByStar(star)
  383. return changeTaskProgressSet(&taskData.Progress, curCnt, int32(taskType), cnt)
  384. }
  385. case serverproto.TaskType_Eve_Evil_Fight_Lvl:
  386. if len(conditionList) >= 2 {
  387. Lvl := conditionList[1]
  388. curLvl := role.GetRoleBattle().GetEvilLvl()
  389. return changeTaskProgressSet(&taskData.Progress, curLvl, int32(taskType), Lvl)
  390. }
  391. case serverproto.TaskType_Eve_Login_Day:
  392. fallthrough
  393. case serverproto.TaskType_Eve_Use_Quick_Battle:
  394. fallthrough
  395. case serverproto.TaskType_Eve_DaoChange_Win:
  396. fallthrough
  397. case serverproto.TaskType_Eve_Month_Card_High:
  398. fallthrough
  399. case serverproto.TaskType_Eve_Month_Card:
  400. fallthrough
  401. case serverproto.TaskType_Eve_Arean_First: // 赛季冠军
  402. if len(conditionList) >= 2 {
  403. cnt := role.roleTask.GetTypeCnt(int32(taskType))
  404. return changeTaskProgressEqual(&taskData.Progress, cnt, int32(taskType), conditionList[1])
  405. }
  406. case serverproto.TaskType_Eve_Battle_Role_Quality:
  407. if len(conditionList) >= 3 {
  408. equipQuality := conditionList[1]
  409. cnt := conditionList[2]
  410. curcnt := role.GetRoleHero().GetQualityEquipNumByBattle(equipQuality)
  411. return changeTaskProgressSet(&taskData.Progress, curcnt, int32(taskType), cnt)
  412. }
  413. case serverproto.TaskType_Eve_Keepsake_lvl_All:
  414. lvl := conditionList[1]
  415. meet := role.roleKeepSake.IsAllMeetLvl(lvl)
  416. ty := int32(taskType)
  417. if len(taskData.Progress) <= 0 {
  418. addProgress := &serverproto.TaskProgressType{
  419. Key: ty,
  420. }
  421. if meet {
  422. addProgress.State = TASK_REWARD_STATE_COMPLETED
  423. }
  424. taskData.Progress = append(taskData.Progress, addProgress)
  425. }
  426. for _, data := range taskData.Progress {
  427. if data.Key != ty {
  428. continue
  429. }
  430. //已经完成
  431. if data.State == TASK_REWARD_STATE_COMPLETED {
  432. return TASK_CONDITION_OK
  433. }
  434. if !meet {
  435. continue
  436. }
  437. data.State = TASK_REWARD_STATE_COMPLETED
  438. return TASK_CONDITION_OK
  439. }
  440. case serverproto.TaskType_Eve_Merge_Card: // 合成指定卡片
  441. fallthrough
  442. case serverproto.TaskType_Eve_Merge_Equip: // 合成指定装备ID
  443. targetNum := conditionList[1]
  444. ty := int32(taskType)
  445. if len(taskData.Progress) <= 0 {
  446. addProgress := &serverproto.TaskProgressType{
  447. Key: ty,
  448. }
  449. taskData.Progress = append(taskData.Progress, addProgress)
  450. }
  451. for _, data := range taskData.Progress {
  452. if data.Key != ty {
  453. continue
  454. }
  455. //已经完成
  456. if data.State == TASK_REWARD_STATE_COMPLETED {
  457. return TASK_CONDITION_OK
  458. }
  459. if count != targetNum {
  460. continue
  461. }
  462. data.Value++
  463. data.State = TASK_REWARD_STATE_COMPLETED
  464. return TASK_CONDITION_OK
  465. }
  466. return TASK_CONDITION_NONE
  467. /////////////////////////记录次数操作
  468. case serverproto.TaskType_Get_Card_Count: //获得卡片数量
  469. fallthrough
  470. case serverproto.TaskType_Silver_Consumption_Count: //银币消耗
  471. fallthrough
  472. case serverproto.TaskType_Climbing_Tower_Count: //爬塔次数
  473. fallthrough
  474. case serverproto.TaskType_Gold_Consumption_Count: //金币消耗
  475. fallthrough
  476. case serverproto.TaskType_Arena_Battle_Win_Count: //英灵殿胜利次数
  477. fallthrough
  478. case serverproto.TaskType_Arena_Battle_Start_Count: //英灵殿战斗次数
  479. fallthrough
  480. case serverproto.TaskType_Card_Composed_Count: //卡片合成
  481. fallthrough
  482. case serverproto.TaskType_Card_Reset_Count: //卡片重置
  483. fallthrough
  484. case serverproto.TaskType_Evil_Fight_Count: //恶魔协会战斗次数
  485. fallthrough
  486. case serverproto.TaskType_Get_Online_Box_Count: //开宝箱次数
  487. fallthrough
  488. case serverproto.TaskType_Hero_LevelUp_Count: //升级任意伙伴N次
  489. fallthrough
  490. case serverproto.TaskType_Equip_Level_Count: //精炼任意装备N次
  491. fallthrough
  492. case serverproto.TaskType_Equip_Forge_Count: //合成任意装备N次
  493. fallthrough
  494. case serverproto.TaskType_Battle_Boss_Count: //boss战次数
  495. fallthrough
  496. case serverproto.TaskType_Role_Quick_Battle_Count: //快速战斗次数
  497. fallthrough
  498. case serverproto.TaskType_Battle_Boss_Reward_Count: //挑战boss成功次数
  499. fallthrough
  500. case serverproto.TaskType_Skill_Slot_Level_Up_Count: //升级任意技能槽N次
  501. fallthrough
  502. case serverproto.TaskType_Expedition_CallHelp_Count: //远征之门发起救助操作次数
  503. fallthrough
  504. case serverproto.TaskType_Friend_Invite_Count: //完成发起好友邀请次数
  505. fallthrough
  506. case serverproto.TaskType_Guild_Join_Count: //加入公会次数
  507. fallthrough
  508. case serverproto.TaskType_Chat_Message_Count: //主线任务中新增在聊天频道中发一句话的任务需求
  509. fallthrough
  510. case serverproto.TaskType_Expedition_Challenge_Count: //远征之门使用消耗挑战次数(任务开启时记录)
  511. fallthrough
  512. case serverproto.TaskType_Guild_Boss_Normal_Count: //公会普通boss挑战次数(任务开启)
  513. fallthrough
  514. case serverproto.TaskType_Eve_Card_Num:
  515. fallthrough
  516. case serverproto.TaskType_Eve_Pet_Num:
  517. fallthrough
  518. case serverproto.TaskType_Recharge_Num:
  519. fallthrough
  520. case serverproto.TaskType_Eve_Arean_Buy:
  521. fallthrough
  522. case serverproto.TaskType_Eve_Arean_First_Cnt:
  523. fallthrough
  524. case serverproto.TaskType_Eve_Recharge_Value:
  525. fallthrough
  526. case serverproto.TaskType_Eve_DaoChange_Win_Add:
  527. fallthrough
  528. case serverproto.TaskType_World_Boss_Challenge_Count: //公会普通boss挑战次数(任务开启)
  529. fallthrough
  530. case serverproto.TaskType_BT_ROCoinRecharge: // bt RO币累计活动
  531. targetNum := conditionList[1]
  532. if count <= 0 && !bForce {
  533. return TASK_CONDITION_NONE
  534. }
  535. return changeTaskProgressAdd(&taskData.Progress, count, int32(taskType), targetNum)
  536. case serverproto.TaskType_Eve_Accu_count:
  537. evilQuality := conditionList[1] //normal mini mvp
  538. targetNum := conditionList[2]
  539. if evilQuality == count {
  540. return changeTaskProgressAdd(&taskData.Progress, 1, int32(taskType), targetNum)
  541. }
  542. }
  543. return TASK_CONDITION_NONE
  544. }
  545. // 累计方式
  546. func changeTaskProgressAdd(progress *[]*serverproto.TaskProgressType, addCount, taskType, targetNum int32) int32 {
  547. bEdit := false
  548. for index, data := range *progress {
  549. if data.Key == taskType {
  550. //已经完成
  551. if data.State == TASK_REWARD_STATE_COMPLETED {
  552. return TASK_CONDITION_OK
  553. }
  554. (*progress)[index].Value += addCount
  555. if (*progress)[index].Value >= targetNum {
  556. (*progress)[index].Value = targetNum
  557. (*progress)[index].State = TASK_REWARD_STATE_COMPLETED
  558. return TASK_CONDITION_OK
  559. }
  560. bEdit = true
  561. break
  562. }
  563. }
  564. if !bEdit {
  565. addProgress := &serverproto.TaskProgressType{
  566. Key: taskType,
  567. Value: addCount,
  568. }
  569. *progress = append(*progress, addProgress)
  570. if addCount >= targetNum {
  571. addProgress.Value = targetNum
  572. addProgress.State = TASK_REWARD_STATE_COMPLETED
  573. return TASK_CONDITION_OK
  574. }
  575. }
  576. return TASK_CONDITION_CHANGE
  577. }
  578. func changeTaskProgressAdd2(progress *[]*serverproto.TaskProgressType, addCount, taskType, targetNum int32) int32 {
  579. bEdit := false
  580. for index, data := range *progress {
  581. if data.Key == taskType {
  582. //数值一直加
  583. (*progress)[index].Value = addCount
  584. //已经完成
  585. if data.State == TASK_REWARD_STATE_COMPLETED {
  586. return TASK_CONDITION_OK
  587. }
  588. if (*progress)[index].Value >= targetNum {
  589. (*progress)[index].Value = targetNum
  590. (*progress)[index].State = TASK_REWARD_STATE_COMPLETED
  591. return TASK_CONDITION_OK
  592. }
  593. bEdit = true
  594. break
  595. }
  596. }
  597. if !bEdit {
  598. addProgress := &serverproto.TaskProgressType{
  599. Key: taskType,
  600. Value: addCount,
  601. }
  602. *progress = append(*progress, addProgress)
  603. if addCount >= targetNum {
  604. addProgress.Value = targetNum
  605. addProgress.State = TASK_REWARD_STATE_COMPLETED
  606. return TASK_CONDITION_OK
  607. }
  608. }
  609. return TASK_CONDITION_CHANGE
  610. }
  611. // 数值方式(目标个数)
  612. func changeTaskProgressSet(progress *[]*serverproto.TaskProgressType, setCount, taskType, targetNum int32) int32 {
  613. bEdit := false
  614. for index, data := range *progress {
  615. if data.Key == taskType {
  616. //已经完成
  617. if data.State == TASK_REWARD_STATE_COMPLETED {
  618. return TASK_CONDITION_OK
  619. }
  620. if setCount >= (*progress)[index].Value {
  621. (*progress)[index].Value = setCount
  622. if (*progress)[index].Value >= targetNum {
  623. (*progress)[index].Value = targetNum
  624. (*progress)[index].State = TASK_REWARD_STATE_COMPLETED
  625. return TASK_CONDITION_OK
  626. }
  627. bEdit = true
  628. } else {
  629. return TASK_CONDITION_NONE
  630. }
  631. //if (*progress)[index].Value >= setCount {
  632. // (*progress)[index].State = TASK_REWARD_STATE_COMPLETED
  633. // return TASK_CONDITION_OK
  634. //} else {
  635. // if setCount > (*progress)[index].Value {
  636. // (*progress)[index].Value = setCount
  637. // if (*progress)[index].Value >= targetNum {
  638. // (*progress)[index].Value = targetNum
  639. // (*progress)[index].State = TASK_REWARD_STATE_COMPLETED
  640. // return TASK_CONDITION_OK
  641. // }
  642. // bEdit = true
  643. // } else {
  644. // return TASK_CONDITION_NONE
  645. // }
  646. //}
  647. break
  648. }
  649. }
  650. if !bEdit {
  651. addProgress := &serverproto.TaskProgressType{
  652. Key: taskType,
  653. Value: setCount,
  654. }
  655. *progress = append(*progress, addProgress)
  656. if setCount >= targetNum {
  657. addProgress.Value = targetNum
  658. addProgress.State = TASK_REWARD_STATE_COMPLETED
  659. return TASK_CONDITION_OK
  660. }
  661. }
  662. return TASK_CONDITION_CHANGE
  663. }
  664. // 直接赋值 注意该函数的区别
  665. func changeTaskProgressEqual(progress *[]*serverproto.TaskProgressType, addCount, taskType, targetNum int32) int32 {
  666. bEdit := false
  667. for index, data := range *progress {
  668. if data.Key == taskType {
  669. //已经完成
  670. if data.State == TASK_REWARD_STATE_COMPLETED {
  671. return TASK_CONDITION_OK
  672. }
  673. (*progress)[index].Value = addCount
  674. if (*progress)[index].Value >= targetNum {
  675. (*progress)[index].Value = targetNum
  676. (*progress)[index].State = TASK_REWARD_STATE_COMPLETED
  677. return TASK_CONDITION_OK
  678. }
  679. bEdit = true
  680. break
  681. }
  682. }
  683. if !bEdit {
  684. addProgress := &serverproto.TaskProgressType{
  685. Key: taskType,
  686. Value: addCount,
  687. }
  688. *progress = append(*progress, addProgress)
  689. if addCount >= targetNum {
  690. addProgress.Value = targetNum
  691. addProgress.State = TASK_REWARD_STATE_COMPLETED
  692. return TASK_CONDITION_OK
  693. }
  694. }
  695. return TASK_CONDITION_CHANGE
  696. }
  697. func GetNextTaskInitCount(role *Role, taskEnum int32) int32 {
  698. if role == nil {
  699. return 0
  700. }
  701. switch serverproto.TaskType(taskEnum) {
  702. case serverproto.TaskType_Get_Card_Count:
  703. return role.GetRoleCard().GetCardCount()
  704. case serverproto.TaskType_Guild_Join_Count:
  705. if role.GetRoleGuildId() > 0 {
  706. return 1
  707. }
  708. }
  709. return 0
  710. }