TaskStepVo.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 任务步骤
  5. */
  6. class TaskStepVo extends Object_ext {
  7. /**
  8. * @var type 查询用的id
  9. */
  10. public $typeId = 0;
  11. /**
  12. * @var float 任务进度(浮点值好了>=1代表完成)
  13. */
  14. public $progress = 0;
  15. /**
  16. * 用于将进度更新的数据待会给客户端,比如当前PVP积分之类的,在客户端是无法即时拿到数据的
  17. * @var object
  18. */
  19. public $tag1;
  20. public $tag2;
  21. /**
  22. * @var int 计数器
  23. */
  24. public $counter = 0;
  25. /**
  26. * @return \sm_task_step mo
  27. */
  28. public function mo() {
  29. $mo = GameConfig::task_step_getItem($this->typeId);
  30. my_Assert(null != $mo, ErrCode::err_const_no);
  31. return $mo;
  32. }
  33. public function __construct($args) {
  34. if (isInt($args)) {
  35. $this->typeId = $args;
  36. } else {
  37. parent::__construct($args);
  38. }
  39. }
  40. /**
  41. * @param TaskParams $taskParam
  42. * @return bool
  43. */
  44. public function check($taskParam) {
  45. if ($this->progress >= 1) {
  46. return true;
  47. }
  48. if ($taskParam->taskType == $this->mo()->tasktype) {
  49. if (null == $this->mo()->canshu1) {
  50. $this->progress = 1;
  51. return true;
  52. }
  53. if ($this->mo()->canshu1 == $taskParam->canshu1) {
  54. $this->tag1 = $taskParam->canshu1;
  55. if (null == $this->mo()->canshu2 || 0 == $this->mo()->canshu2) {
  56. $this->progress = 1;
  57. $this->tag2 = $taskParam->canshu2;
  58. return true;
  59. } else {
  60. if (is_numeric($this->mo()->canshu2)) {
  61. $this->tag2 = max($this->tag2, $taskParam->canshu2);
  62. if ($this->mo()->canshu2 <= $taskParam->canshu2) {
  63. $this->progress = 1;
  64. return true;
  65. }
  66. } else {
  67. $this->tag2 = $taskParam->canshu2;
  68. if ($this->mo()->canshu2 == $taskParam->canshu2) {
  69. $this->progress = 1;
  70. return true;
  71. }
  72. }
  73. }
  74. }
  75. }
  76. return false;
  77. }
  78. }