RecordPrefab.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_LabIndex:cc.Label,
  5. m_LabRoom:cc.Label,
  6. m_LabTime:cc.Label,
  7. m_LabGameCount:cc.Label,
  8. m_LabGameKind:cc.Label,
  9. m_LabGameRules:cc.Label,
  10. m_UserLayout:cc.Node,
  11. m_atlas:cc.SpriteAtlas
  12. },
  13. ctor:function(){
  14. this.m_MaxChair = 10;
  15. },
  16. InitPre:function(){
  17. if(this.m_ListCtrl == null) this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  18. this.m_ListCtrl.InitList(0, 'RecordUserItem', this);
  19. },
  20. SetPreInfo:function(ParaArr){
  21. this.node.active = false;
  22. this.SetRecord(ParaArr[1][1], ParaArr[1][0]);
  23. },
  24. SetRecord:function(wIndex, ID) {
  25. this.m_RecordID = ID;
  26. this.m_Index = parseInt(wIndex);
  27. if(this.m_LabIndex)this.m_LabIndex.string = pad(this.m_Index, 3);
  28. var webUrl = window.PHP_HOME+'/GameRecord.php?&GetMark=3&RecordID='+ID;
  29. WebCenter.GetData(webUrl, 24*60*60, function (data) {
  30. g_Lobby.StopLoading();
  31. var Json = JSON.parse(data);
  32. this.SetInfo(Json)
  33. }.bind(this));
  34. },
  35. SetInfo:function(Info, bSelfShow) {
  36. this.m_Info = Info;
  37. this.m_LabTime.string = Time2Str(this.m_Info[6]);//6 CreateTime Key
  38. try {
  39. var gamedef = new window['CMD_GAME_'+this.m_Info[3]]();//3 KindID
  40. var str = gamedef.GetProgress(this.m_Info[7], this.m_Info[5], this.m_Info[9]);// 4 Rules 7 Progress 5 ServerRules 9 RulesArr
  41. if(str!='') str = str.substring(1, str.length-1)//去掉 第 和 局
  42. this.m_LabGameCount.string = str;
  43. } catch (error) {
  44. if(window.LOG_NET_DATA)console.log(this.m_Info[3]+'遊戲未實裝 ID '+this.m_Info[0])
  45. return;
  46. }
  47. this.node.active = true;
  48. this.m_LabRoom.string = this.m_Info[2];//2 RoomID
  49. //5 ServerRules
  50. var gameKingstr = "";
  51. if(this.m_Info[4]&gamedef.GAME_RULE_SP_15)gameKingstr="台灣北部麻將";
  52. if(this.m_Info[4]&gamedef.GAME_RULE_SP_16)gameKingstr="台灣南部麻將";
  53. if(this.m_LabGameKind) this.m_LabGameKind.string = gameKingstr;
  54. // if(this.m_LabGameKind) this.m_LabGameKind.string = gamedef.GetGameMode(this.m_Info[5], this.m_Info[9]);
  55. if(this.m_LabGameRules) this.m_LabGameRules.string = gamedef.GetRulesStr(this.m_Info[5], this.m_Info[9]);
  56. //var UserIndex = 0;
  57. var sortIDArr = this.SortUserIndexByScore(this.m_Info);
  58. var iIndex = 0;
  59. for(var i in this.m_Info[8]){ // 8 UserScore
  60. this.m_ListCtrl.InsertListInfo(0, [sortIDArr[iIndex], this.m_Info, gamedef, this.m_RecordID]); //this.m_Info[8][i]
  61. iIndex++;
  62. }
  63. },
  64. SortUserIndexByScore:function(info){
  65. var indexArr = new Array();
  66. var scoreArr = new Array();
  67. var totalCnt = 0;
  68. for(var i in info[8]){
  69. indexArr[totalCnt] = i;
  70. scoreArr[totalCnt] = info[8][i];
  71. totalCnt++;
  72. }
  73. for (var i = 0 ; i < totalCnt - 1 ; i++)
  74. {
  75. for (var j = i + 1 ; j < totalCnt ; j++)
  76. {
  77. if (scoreArr[i] < scoreArr[j])
  78. {
  79. var score = scoreArr[i];
  80. scoreArr[i] = scoreArr[j];
  81. scoreArr[j] = score;
  82. var index = indexArr[i];
  83. indexArr[i] = indexArr[j];
  84. indexArr[j] = index;
  85. }
  86. }
  87. }
  88. return indexArr;
  89. },
  90. OnBtReplay:function() {
  91. this.m_Hook.OnRePlayGame( this.m_RecordID, this.m_Info[3]);
  92. },
  93. OnBtShowGameInfoAll:function() {
  94. this.m_Hook.OnShowGameInfoAll(this.m_RecordID, this.m_Info[3], this.m_Info[8]);
  95. },
  96. OnBtGetShareText:function() {
  97. var gamedef = new window['CMD_GAME_'+this.m_Info[3]]();//3 KindID
  98. var NextLine = '\r\n';
  99. var str = '【'+window.GameList[this.m_Info[3]]+'】';
  100. str += NextLine+'房間碼:'+this.m_Info[2];
  101. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  102. var ReplayCode = 0;
  103. for(var i in this.m_Info[8]){ // 8 UserScore
  104. if(i == pGlobalUserData.dwUserID){
  105. ReplayCode = this.m_Info[8][i][1];
  106. break;
  107. }
  108. }
  109. str += NextLine+'重播碼:'+ReplayCode;
  110. //str += NextLine+gamedef.GetGameMode(this.m_Info[5], this.m_Info[9]);
  111. // var tempstr = gamedef.GetProgress(this.m_Info[7], this.m_Info[5], this.m_Info[9]);
  112. // if(tempstr!='') tempstr = tempstr.substring(1, tempstr.length-1)
  113. // str += NextLine+'局数:'+tempstr;
  114. // str += NextLine+this.m_LabTime.string;
  115. str += NextLine+'====戰績====';
  116. var TempNd = this.$('BGRecord/Layout');
  117. for(var i=0; i<TempNd.childrenCount; i++){
  118. if(TempNd.children[i].active == false) continue
  119. str += NextLine;
  120. str +=NextLine+ '【'+this.$('Nick@Label',TempNd.children[i]).string+'】';
  121. // str +=NextLine+'ID:'+ this.$('ID/id@Label',TempNd.children[i]).string;
  122. // str +=NextLine+'抢庄次数:'+ this.$('qiang/qiang@Label',TempNd.children[i]).string;
  123. // str +=NextLine+'坐庄次数:'+ this.$('zhuang/zhuang@Label',TempNd.children[i]).string;
  124. // str +=NextLine+'推注次数:'+ this.$('tui/tui@Label',TempNd.children[i]).string;
  125. str +=NextLine+'戰績:'+ this.$('Score@Label',TempNd.children[i]).string;
  126. }
  127. ThirdPartyCopyClipper(str);
  128. this.m_Hook.ShowTips('重播資訊已複製到剪貼簿')
  129. return str;
  130. },
  131. });