TaskInfo.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace loyalsoft;
  8. /**
  9. * 任务信息
  10. */
  11. class TaskInfo extends Object_ext {
  12. /**
  13. *
  14. * @var 任务ID
  15. */
  16. public $taskId;
  17. /**
  18. * @var float 任务进度(浮点值好了>=1代表完成)
  19. */
  20. public $progress = 0;
  21. /**
  22. * 用于将进度更新的数据待会给客户端,比如当前PVP积分之类的,在客户端是无法即时拿到数据的
  23. * @var object
  24. */
  25. public $tag1;
  26. public $tag2;
  27. /**
  28. * @var int 计数器
  29. */
  30. public $counter = 0;
  31. /**
  32. * @var int 奖励是否已领取 0/1
  33. */
  34. public $rewardGeted = 0;
  35. public function bCheckProgress($param) {
  36. $taskCfg = GameConfig::task_getItem($this->taskId);
  37. my_Assert($taskCfg != null, ErrCode::err_const_no); # 获取任务配置数据
  38. if ($taskCfg->tasktype != $param->taskType) { # 任务类型必须匹配
  39. return false;
  40. }
  41. if (is_null($taskCfg->canshu1)) {
  42. $this->progress = 1;
  43. return true;
  44. }
  45. $this->tag1 = max($this->tag1, $param->canshu1);
  46. if ($taskCfg->canshu1 <= $param->canshu1) {
  47. if (null == $taskCfg->canshu2 || 0 == $taskCfg->canshu2) {
  48. $this->progress = 1;
  49. return true;
  50. }
  51. if (is_numeric($taskCfg->canshu2)) {
  52. $this->tag2 = max($this->tag2, $param->canshu2);
  53. if ($taskCfg->canshu2 <= $param->canshu2) {
  54. $this->progress = 1;
  55. return true;
  56. }
  57. } else {
  58. $this->tag2 = $param->canshu2;
  59. if ($taskCfg->canshu2 == $param->canshu2) {
  60. $this->progress = 1;
  61. return true;
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67. }