Info_College.php 12 KB

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