Ins_TaskCard.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * Description of TaskCardVo
  5. * 任务卡
  6. * @author gwang
  7. */
  8. class Ins_TaskCard extends Object_ext {
  9. /**
  10. * @var type 这个物品在玩家身上唯一的id
  11. */
  12. public $uid = 0;
  13. /**
  14. * @var type 当前已完成步骤数量
  15. */
  16. public $count = 0;
  17. /**
  18. * @var type 查询用的id
  19. */
  20. public $typeId = 0;
  21. /**
  22. * @var int 任务状态未完成/已完成:0/1
  23. */
  24. public $state = 0;
  25. /**
  26. * @var array[]当前任务步骤数据
  27. */
  28. public $curSteps;
  29. /**
  30. * @var type 当前任务步骤索引
  31. * @deprecated since version 2020年12月25日13:44:43
  32. */
  33. public $curStepIndex = 0;
  34. /**
  35. *
  36. * @return type
  37. */
  38. public function mo() {
  39. $mo = GameConfig::item_taskcard_getItem($this->typeId);
  40. my_Assert(null != $mo, ErrCode::err_const_no);
  41. return $mo;
  42. }
  43. public function __construct($args = 0) {
  44. if (isInt($args)) {
  45. $this->typeId = $args;
  46. $arr = array();
  47. $cfg = GameConfig::item_taskcard_getItem($this->typeId);
  48. my_Assert(null != $cfg, ErrCode::err_const_no);
  49. foreach (explode(',', $cfg->tasksteps) as $taskStepTypeId) {
  50. $arr [] = new Ins_TaskStep($taskStepTypeId);
  51. }
  52. $this->curSteps = $arr;
  53. } else {
  54. parent::__construct($args);
  55. }
  56. }
  57. /**
  58. * @return boolean 分析任务卡是否已经完成所有步骤
  59. */
  60. public function IsFinish() {
  61. if ($this->state >= Enum_TaskCardStateType::finish) { # 已经完成
  62. return true;
  63. }
  64. $isFinish = true;
  65. foreach ($this->curSteps as &$tsp) { # 初期里面只有一个任务
  66. $tsp = new Ins_TaskStep($tsp);
  67. if (!$tsp->isFinish()) {
  68. $isFinish = false;
  69. break;
  70. }
  71. }
  72. return $isFinish;
  73. }
  74. public function AddStep($stpid) {
  75. $exists = false;
  76. foreach ($this->curSteps as $stp) {
  77. // $stp = new Ins_TaskStep($stp);
  78. if ($stp->typeId == $stpid) {
  79. $exists = true;
  80. }
  81. }
  82. if (!$exists) {
  83. $newstp = new Ins_TaskStep($stpid);
  84. $this->curSteps[] = $newstp;
  85. // $newstp->doStartAct();
  86. }
  87. }
  88. }