TaskStepVo.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. static function isInt($var) {
  34. $int = intval($var);
  35. if ((string) $int === (string) $var) {
  36. return true;
  37. } else {
  38. return false;
  39. }
  40. }
  41. public function __construct($args) {
  42. if (self::isInt($args)) {
  43. $this->typeId = $args;
  44. } else {
  45. parent::__construct($args);
  46. }
  47. }
  48. /**
  49. * @param TaskParams $taskParam
  50. * @return bool
  51. */
  52. public function check($taskParam) {
  53. if ($this->progress >= 1) {
  54. return true;
  55. }
  56. if ($taskParam->taskType == $this->mo()->tasktype) {
  57. if (null == $this->mo()->canshu1) {
  58. $this->progress = 1;
  59. return true;
  60. }
  61. if ($this->mo()->canshu1 == $taskParam->canshu1) {
  62. $this->tag1 = $taskParam->canshu1;
  63. if (null == $this->mo()->canshu2 || 0 == $this->mo()->canshu2) {
  64. $this->progress = 1;
  65. $this->tag2 = $taskParam->canshu2;
  66. return true;
  67. } else {
  68. if (is_numeric($this->mo()->canshu2)) {
  69. $this->tag2 = max($this->tag2, $taskParam->canshu2);
  70. if ($this->mo()->canshu2 <= $taskParam->canshu2) {
  71. $this->progress = 1;
  72. return true;
  73. }
  74. } else {
  75. $this->tag2 = $taskParam->canshu2;
  76. if ($this->mo()->canshu2 == $taskParam->canshu2) {
  77. $this->progress = 1;
  78. return true;
  79. }
  80. }
  81. }
  82. }
  83. }
  84. return false;
  85. }
  86. }