Ins_TaskStep.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 任务步骤
  5. */
  6. class Ins_TaskStep 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. // var_dump($this->typeId);
  30. $mo = GameConfig::task_step_getItem($this->typeId);
  31. my_Assert(null != $mo, ErrCode::err_const_no);
  32. return $mo;
  33. }
  34. public function __construct($args) {
  35. if (isInt($args)) {
  36. $this->typeId = $args;
  37. } else {
  38. parent::__construct($args);
  39. }
  40. }
  41. /**
  42. * @param Ins_TaskParams $taskParam
  43. * @return bool
  44. */
  45. public function check($taskParam) {
  46. if ($this->progress >= 1) {
  47. return true;
  48. }
  49. if ($taskParam->taskType == $this->mo()->tasktype) {
  50. if (null == $this->mo()->canshu1) {
  51. $this->progress = 1;
  52. return true;
  53. }
  54. if ($this->mo()->canshu1 == $taskParam->canshu1) {
  55. $this->tag1 = $taskParam->canshu1;
  56. if (null == $this->mo()->canshu2 || 0 == $this->mo()->canshu2) {
  57. $this->progress = 1;
  58. $this->tag2 = $taskParam->canshu2;
  59. return true;
  60. } else {
  61. if (is_numeric($this->mo()->canshu2)) {
  62. $this->tag2 = max($this->tag2, $taskParam->canshu2);
  63. if ($this->mo()->canshu2 <= $taskParam->canshu2) {
  64. $this->progress = 1;
  65. return true;
  66. }
  67. } else {
  68. $this->tag2 = $taskParam->canshu2;
  69. if ($this->mo()->canshu2 == $taskParam->canshu2) {
  70. $this->progress = 1;
  71. return true;
  72. }
  73. }
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79. }