Info_College.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. * @var type
  51. */
  52. public $ingTaskCardDic = null;
  53. /**
  54. * 圣哲学院功能结算时间
  55. * @var type
  56. */
  57. public $funUnluckTs = 0;
  58. /**
  59. * 累计积分
  60. * @var type
  61. */
  62. public $score = 0;
  63. /**
  64. *
  65. * @var type
  66. */
  67. public $scoreRewardList = array();
  68. /**
  69. * 构造函数
  70. * @param type $args
  71. */
  72. public function __construct($args = null) {
  73. if ($args == null) {
  74. $this->compMissCardDic = new \stdClass();
  75. $this->ingTaskCardDic = new \stdClass();
  76. } else {
  77. parent::__construct($args);
  78. }
  79. }
  80. /**
  81. * 废弃了
  82. */
  83. //public function initialize() {
  84. // $this->compMissCardDic = new \stdClass();
  85. // $dic = GameConfig::course_getItem($this->courseId);
  86. // $misslist = explode(',',$dic->misslist);
  87. // foreach ($misslist as $id) {
  88. // $item = new ins_missCourseItem();
  89. // $item->initialize($id);
  90. // $this->compMissCardDic->$id = $item;
  91. // }
  92. //$this->initCompMissCardDic();
  93. //}
  94. public function initCompMissCardDic() {
  95. $this->compMissCardDic = new \stdClass();
  96. $dic = GameConfig::course_getItem($this->courseId);
  97. $misslist = explode(',', $dic->misslist);
  98. foreach ($misslist as $id) {
  99. $item = new ins_missCourseItem();
  100. $item->initialize($id);
  101. $this->compMissCardDic->$id = $item;
  102. }
  103. }
  104. /**
  105. * 修改任务卡状态
  106. * @param type $id
  107. * @param type $state
  108. */
  109. public function modifyTaskCardState($id, $state) {
  110. $ingTaskCardDic = $this->ingTaskCardDic;
  111. foreach ($ingTaskCardDic as $collegeId => $courseDic) {
  112. foreach ($courseDic as $courseId => $cardDic) {
  113. foreach ($cardDic as $cardId => $val) {
  114. if ($cardId == $id) {
  115. TaskProc::OnFinishSchoolTask();
  116. $this->ingTaskCardDic->$collegeId->$courseId->$cardId->type = $state;
  117. break 3;
  118. }
  119. }
  120. }
  121. }
  122. // if(!StlUtil::dictHasProperty($this->compMissCardDic, $id)){
  123. // return;
  124. // }
  125. // $this->compMissCardDic->$id->type = $state;
  126. // $this->progress += 1;
  127. }
  128. /**
  129. * 废弃
  130. */
  131. public function updataCourseNew() {
  132. //检测是否到下一年级
  133. // $collegeDic = GameConfig::college_getItem($this->collegeId);
  134. // if(in_array($this->courseId +1,explode(',', $collegeDic->cList))){
  135. // $this->courseId += 1;
  136. // $this->initCompMissCardDic();
  137. // $this->progress = 0;
  138. // } else {
  139. $this->collegeRewardList[] = $this->collegeId;
  140. //TaskProc::OnFinishAllSchoolTaskOfGrade($this->collegeId);
  141. $this->collegeId += 1;
  142. $newCollegeDic = GameConfig::college_getItem($this->collegeId);
  143. if ($newCollegeDic == null) {
  144. $this->maskCollege = Enum_College::finish;
  145. $this->collegeId -= 1;
  146. } elseif ($newCollegeDic != null && $newCollegeDic->cList == null) {
  147. $this->maskCollege = Enum_College::update;
  148. } else {
  149. $cList = explode(',', $newCollegeDic->cList);
  150. $this->courseId = $cList[0];
  151. $this->initCompMissCardDic();
  152. }
  153. // }
  154. }
  155. /**
  156. * 废弃
  157. */
  158. public function updataCourse() {
  159. $this->comCourseList[] = $this->courseId;
  160. //检测是否到下一年级
  161. $collegeDic = GameConfig::college_getItem($this->collegeId);
  162. if (in_array($this->courseId + 1, explode(',', $collegeDic->cList))) {
  163. $this->courseId += 1;
  164. $this->initCompMissCardDic();
  165. $this->progress = 0;
  166. }
  167. // else {
  168. // $this->collegeId += 1;
  169. // $newCollegeDic = GameConfig::college_getItem($this->collegeId);
  170. // $cList = explode(',', $newCollegeDic->cList);
  171. // $this->courseId = $cList[0];
  172. // $this->initCompMissCardDic();
  173. // $this->progress = 0;
  174. // }
  175. }
  176. //废弃
  177. public function checkCollege() {
  178. if ($this->maskCollege == Enum_College::update) {
  179. $dic = GameConfig::college_getItem($this->collegeId);
  180. if ($dic != null && $dic->cList != null) {
  181. $this->maskCollege = 0;
  182. $cList = explode(',', $dic->cList);
  183. $this->courseId = $cList[0];
  184. $this->initCompMissCardDic();
  185. }
  186. }
  187. }
  188. //------------------new---------------------
  189. /**
  190. * 根据天 初始化
  191. * @return type
  192. */
  193. public function initTaskCard() {
  194. if ($this->funUnluckTs == 0) {
  195. return;
  196. }
  197. $day = TimeUtil::totalDays($this->funUnluckTs);
  198. $curDay = TimeUtil::totalDays(time());
  199. $num = $curDay - $day;
  200. $collegeMo = GameConfig::college();
  201. $college = (array) $collegeMo;
  202. ksort($college);
  203. $index = 0;
  204. foreach ($college as $collegeId => $collegeMo) {
  205. $courseArr = explode(',', $collegeMo->cList);
  206. if (!StlUtil::dictHasProperty($this->ingTaskCardDic, $collegeId)) {
  207. $this->ingTaskCardDic->$collegeId = new \stdClass();
  208. }
  209. $collegeDic = $this->ingTaskCardDic->$collegeId;
  210. foreach ($courseArr as $courseId) {
  211. if (!StlUtil::dictHasProperty($collegeDic, $courseId)) {
  212. $mo = GameConfig::course_getItem($courseId);
  213. $arr = explode(',', $mo->misslist);
  214. $dic = new \stdClass();
  215. foreach ($arr as $cardId) {
  216. $item = new ins_missCourseItem();
  217. $item->initialize($cardId);
  218. $cid = StoreProc::PutTaskCardInStore($cardId); // 存入背包
  219. NormalEventProc::OnTaskCard_Actived($cid, null); # 带入事件
  220. $item->indexId = $cid;
  221. $taskCard = new Ins_TaskCard(ctx()->store->taskcards->$cid); # 任务卡对象
  222. $taskCard->state = Enum_TaskCardStateType::ing;
  223. TaskProc::OnGetSchoolTask();
  224. foreach ($taskCard->curSteps as &$tsp) { # 初期里面只有一个任务
  225. $tsp = new Ins_TaskStep($tsp);
  226. if ($tsp->isStatusType()) { # 如果是道具收集类的, 扣除所收集道具
  227. $tsp->autoCalcStatusCur();
  228. }
  229. }
  230. if ($taskCard->IsFinish()) { # 检查是否任务卡的所有步骤都已完成
  231. $taskCard->state = Enum_TaskCardStateType::finish;
  232. $item->type = Enum_TaskCardStateType::finish;
  233. TaskProc::OnFinishSchoolTask();
  234. NormalEventProc::OnTaskCard_Finish($taskCard->uid, null); # 广播卡完成事件
  235. }
  236. $dic->$cardId = $item;
  237. //统计
  238. StatisticsProc::TargetStatistics(Enum_TargetStatistics::collegeCouseId_UnlockUserNum, $cardId);
  239. ctx()->store->taskcards->$cid = $taskCard;
  240. }
  241. //$this->ingTaskCardDic->$courseId = $dic;
  242. $collegeDic->$courseId = $dic;
  243. }
  244. $this->ingTaskCardDic->$collegeId = $collegeDic;
  245. if ($index >= $num) {
  246. break 2;
  247. }
  248. $index += 1;
  249. }
  250. }
  251. ctx()->college->ingTaskCardDic = $this->ingTaskCardDic;
  252. //--------------------
  253. //$courseDic = GameConfig::course();
  254. // $index = 0;
  255. // foreach ($courseDic as $courseId => $mo) {
  256. // if(!StlUtil::dictHasProperty($this->ingTaskCardDic, $courseId)){
  257. // $arr = explode(',',$mo->misslist);
  258. // $dic = new \stdClass();
  259. // foreach ($arr as $cardId) {
  260. // $item = new ins_missCourseItem();
  261. // $item->initialize($cardId);
  262. //
  263. // $cid = StoreProc::PutTaskCardInStore($cardId); // 存入背包
  264. // NormalEventProc::OnTaskCard_Actived($cid, null); # 带入事件
  265. //
  266. // $item->indexId = $cid;
  267. // $taskCard = new Ins_TaskCard(ctx()->store->taskcards->$cid);# 任务卡对象
  268. // $taskCard->state = Enum_TaskCardStateType::ing;
  269. //
  270. // TaskProc::OnGetSchoolTask();
  271. // foreach ($taskCard->curSteps as &$tsp) { # 初期里面只有一个任务
  272. // $tsp = new Ins_TaskStep($tsp);
  273. // if ($tsp->isStatusType()) { # 如果是道具收集类的, 扣除所收集道具
  274. // $tsp->autoCalcStatusCur();
  275. // }
  276. // }
  277. //
  278. // if ($taskCard->IsFinish()) { # 检查是否任务卡的所有步骤都已完成
  279. // $taskCard->state = Enum_TaskCardStateType::finish;
  280. // $item->type = Enum_TaskCardStateType::finish;
  281. // TaskProc::OnFinishSchoolTask();
  282. // NormalEventProc::OnTaskCard_Finish($taskCard->uid, null); # 广播卡完成事件
  283. // }
  284. // $dic->$cardId = $item;
  285. // ctx()->store->taskcards->$cid = $taskCard;
  286. // }
  287. // $this->ingTaskCardDic->$courseId = $dic;
  288. // }
  289. //
  290. // if($index >= $num){
  291. // break;
  292. // }
  293. // $index += 1;
  294. // }
  295. }
  296. /**
  297. * 圣哲学院功能结算时间
  298. */
  299. public function setFunUnluckTs() {
  300. if ($this->funUnluckTs != 0) {
  301. return;
  302. }
  303. $this->funUnluckTs = time();
  304. $this->initTaskCard();
  305. }
  306. /**
  307. * 记录已经领取奖励的课程
  308. * @param type $id
  309. */
  310. // public function addReceiveCourseList($id) {
  311. // $this->comCourseList[] = $id;
  312. // }
  313. /**
  314. * 累计积分
  315. * @param type $val
  316. */
  317. public function addScore($val) {
  318. $this->score += $val;
  319. }
  320. }