Info_College.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace loyalsoft;
  3. /*
  4. * To change this license header, choose License Headers in Project Properties.
  5. * To change this template file, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8. namespace loyalsoft;
  9. /**
  10. * Description of CollegeInfo
  11. *
  12. * @author cyzhao
  13. */
  14. class Info_College extends Object_ext{
  15. /**
  16. * 当前所在的级别
  17. */
  18. public $collegeId = 1;
  19. /// <summary>
  20. /// 所处的课程id
  21. /// </summary>
  22. public $courseId = 1001;
  23. /**
  24. * 将领取课程奖励的保存在这
  25. * @var type
  26. */
  27. public $comCourseList = array();
  28. /// <summary>
  29. /// 任务卡信息
  30. /// </summary>
  31. //public List<missCourseItem> compMissCardList = new List<missCourseItem>();
  32. public $compMissCardDic=null;
  33. /**
  34. * 当前课程进度,进入下一个课程清0
  35. * @var type
  36. */
  37. public $progress = 0;
  38. /**
  39. * 年级奖励领取记录
  40. * @var type
  41. */
  42. public $collegeRewardList = array();
  43. /**
  44. *
  45. * @var type
  46. */
  47. public $maskCollege = 0;
  48. /**
  49. * 构造函数
  50. * @param type $args
  51. */
  52. public function __construct($args = null) {
  53. if($args == null){
  54. $this->compMissCardDic = new \stdClass();
  55. } else {
  56. parent::__construct($args);
  57. }
  58. }
  59. public function initialize() {
  60. // $this->compMissCardDic = new \stdClass();
  61. // $dic = GameConfig::course_getItem($this->courseId);
  62. // $misslist = explode(',',$dic->misslist);
  63. // foreach ($misslist as $id) {
  64. // $item = new ins_missCourseItem();
  65. // $item->initialize($id);
  66. // $this->compMissCardDic->$id = $item;
  67. // }
  68. $this->initCompMissCardDic();
  69. }
  70. public function initCompMissCardDic() {
  71. $this->compMissCardDic = new \stdClass();
  72. $dic = GameConfig::course_getItem($this->courseId);
  73. $misslist = explode(',',$dic->misslist);
  74. foreach ($misslist as $id) {
  75. $item = new ins_missCourseItem();
  76. $item->initialize($id);
  77. $this->compMissCardDic->$id = $item;
  78. }
  79. }
  80. /**
  81. * 修改任务卡状态
  82. * @param type $id
  83. * @param type $state
  84. */
  85. public function modifyTaskCardState($id,$state) {
  86. if(!StlUtil::dictHasProperty($this->compMissCardDic, $id)){
  87. return;
  88. }
  89. $this->compMissCardDic->$id->type = $state;
  90. $this->progress += 1;
  91. }
  92. public function updataCourseNew() {
  93. //检测是否到下一年级
  94. // $collegeDic = GameConfig::college_getItem($this->collegeId);
  95. // if(in_array($this->courseId +1,explode(',', $collegeDic->cList))){
  96. // $this->courseId += 1;
  97. // $this->initCompMissCardDic();
  98. // $this->progress = 0;
  99. // } else {
  100. $this->collegeRewardList[] = $this->collegeId;
  101. $this->collegeId += 1;
  102. $newCollegeDic = GameConfig::college_getItem($this->collegeId);
  103. if($newCollegeDic == null){
  104. $this->maskCollege = Enum_College::finish;
  105. $this->collegeId -= 1;
  106. } elseif ($newCollegeDic != null && $newCollegeDic->cList == null) {
  107. $this->maskCollege = Enum_College::update;
  108. } else {
  109. $cList = explode(',', $newCollegeDic->cList);
  110. $this->courseId = $cList[0];
  111. $this->initCompMissCardDic();
  112. }
  113. // }
  114. }
  115. /**
  116. *
  117. */
  118. public function updataCourse() {
  119. $this->comCourseList[] = $this->courseId;
  120. //检测是否到下一年级
  121. $collegeDic = GameConfig::college_getItem($this->collegeId);
  122. if(in_array($this->courseId +1,explode(',', $collegeDic->cList))){
  123. $this->courseId += 1;
  124. $this->initCompMissCardDic();
  125. $this->progress = 0;
  126. }
  127. // else {
  128. // $this->collegeId += 1;
  129. // $newCollegeDic = GameConfig::college_getItem($this->collegeId);
  130. // $cList = explode(',', $newCollegeDic->cList);
  131. // $this->courseId = $cList[0];
  132. // $this->initCompMissCardDic();
  133. // $this->progress = 0;
  134. // }
  135. }
  136. public function checkCollege() {
  137. if($this->maskCollege == Enum_College::update){
  138. $dic = GameConfig::college_getItem($this->collegeId);
  139. if($dic != null && $dic->cList != null){
  140. $this->maskCollege = 0;
  141. $cList = explode(',', $dic->cList);
  142. $this->courseId = $cList[0];
  143. $this->initCompMissCardDic();
  144. }
  145. }
  146. }
  147. }