Ins_TaskCard.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. *
  31. * @return type
  32. */
  33. public function mo() {
  34. $mo = GameConfig::taskcard_getItem($this->typeId);
  35. my_Assert(null != $mo, ErrCode::err_const_no);
  36. return $mo;
  37. }
  38. public function __construct($args = 0) {
  39. if (isInt($args)) {
  40. $this->typeId = $args;
  41. $arr = array();
  42. $cfg = GameConfig::item_taskcard_getItem($this->typeId);
  43. my_Assert(null != $cfg, ErrCode::err_const_no);
  44. foreach (explode(',', $cfg->tasksteps) as $taskStepTypeId) {
  45. $arr [] = new Ins_TaskStep($taskStepTypeId);
  46. }
  47. $this->curSteps = $arr;
  48. } else {
  49. parent::__construct($args);
  50. }
  51. }
  52. /**
  53. * @return boolean 分析任务卡是否已经完成所有步骤
  54. */
  55. public function IsFinish() {
  56. if ($this->state >= Enum_TaskCardStateType::finish) { # 已经完成
  57. return true;
  58. }
  59. $isFinish = true;
  60. foreach ($this->curSteps as &$tsp) { # 初期里面只有一个任务
  61. $tsp = new Ins_TaskStep($tsp);
  62. if (!$tsp->isFinish()) {
  63. $isFinish = false;
  64. break;
  65. }
  66. }
  67. return $isFinish;
  68. }
  69. public function AddStep($stpid) {
  70. $exists = false;
  71. foreach ($this->curSteps as $stp) {
  72. // $stp = new Ins_TaskStep($stp);
  73. if ($stp->typeId == $stpid) {
  74. $exists = true;
  75. }
  76. }
  77. if (!$exists) {
  78. $newstp = new Ins_TaskStep($stpid);
  79. $this->curSteps[] = $newstp;
  80. // $newstp->doStartAct();
  81. }
  82. }
  83. }