ClubRecordPrefab.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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, 'ClubRecordUserItem', 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, bSelfShow) {
  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. // if(this.m_LabGameKind) this.m_LabGameKind.string = window.GameList[this.m_Info[3]];
  51. var strLabGame = "";
  52. if(this.m_LabGameKind)strLabGame = window.GameList[this.m_Info[3]];
  53. if(this.m_Info[4]&gamedef.GAME_RULE_SP_15)strLabGame = '台灣北部麻將';
  54. if(this.m_Info[4]&gamedef.GAME_RULE_SP_16)strLabGame = '台灣南部麻將';
  55. this.m_LabGameKind.string = strLabGame ;
  56. // if(this.m_LabGameKind) this.m_LabGameKind.string = gamedef.GetGameMode(this.m_Info[5], this.m_Info[9]);
  57. if(this.m_LabGameRules) this.m_LabGameRules.string = gamedef.GetRulesStr(this.m_Info[5], this.m_Info[9]);
  58. //var UserIndex = 0;
  59. var sortIDArr = this.SortUserIndexByScore(this.m_Info);
  60. var iIndex = 0;
  61. for(var i in this.m_Info[8]){ // 8 UserScore
  62. this.m_ListCtrl.InsertListInfo(0, [sortIDArr[iIndex], this.m_Info, gamedef, this.m_RecordID]); //this.m_Info[8][i]
  63. iIndex++;
  64. }
  65. },
  66. SortUserIndexByScore:function(info){
  67. var indexArr = new Array();
  68. var scoreArr = new Array();
  69. var totalCnt = 0;
  70. for(var i in info[8]){
  71. indexArr[totalCnt] = i;
  72. scoreArr[totalCnt] = info[8][i];
  73. totalCnt++;
  74. }
  75. for (var i = 0 ; i < totalCnt - 1 ; i++)
  76. {
  77. for (var j = i + 1 ; j < totalCnt ; j++)
  78. {
  79. if (scoreArr[i] < scoreArr[j])
  80. {
  81. var score = scoreArr[i];
  82. scoreArr[i] = scoreArr[j];
  83. scoreArr[j] = score;
  84. var index = indexArr[i];
  85. indexArr[i] = indexArr[j];
  86. indexArr[j] = index;
  87. }
  88. }
  89. }
  90. return indexArr;
  91. },
  92. OnBtReplay:function() {
  93. this.m_Hook.OnRePlayGame( this.m_RecordID, this.m_Info[3]);
  94. },
  95. OnBtShowGameInfoAll:function() {
  96. this.m_Hook.OnShowGameInfoAll(this.m_RecordID, this.m_Info[3], this.m_Info[8]);
  97. },
  98. OnBtGetShareText:function() {
  99. var gamedef = new window['CMD_GAME_'+this.m_Info[3]]();//3 KindID
  100. var NextLine = '\r\n';
  101. var str = '【'+window.GameList[this.m_Info[3]]+'】';
  102. str += NextLine+'房間號:'+this.m_Info[2];
  103. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  104. var ReplayCode = 0;
  105. for(var i in this.m_Info[8]){ // 8 UserScore
  106. if(i == pGlobalUserData.dwUserID){
  107. ReplayCode = this.m_Info[8][i][1];
  108. break;
  109. }
  110. }
  111. str += NextLine+'重播碼:'+ReplayCode;
  112. //str += NextLine+gamedef.GetGameMode(this.m_Info[5], this.m_Info[9]);
  113. // var tempstr = gamedef.GetProgress(this.m_Info[7], this.m_Info[5], this.m_Info[9]);
  114. // if(tempstr!='') tempstr = tempstr.substring(1, tempstr.length-1)
  115. // str += NextLine+'局数:'+tempstr;
  116. // str += NextLine+this.m_LabTime.string;
  117. str += NextLine+'====戰績====';
  118. var TempNd = this.$('BGRecord/Layout');
  119. for(var i=0; i<TempNd.childrenCount; i++){
  120. if(TempNd.children[i].active == false) continue
  121. str += NextLine;
  122. str +=NextLine+ '【'+this.$('Nick@Label',TempNd.children[i]).string+'】';
  123. // str +=NextLine+'ID:'+ this.$('ID/id@Label',TempNd.children[i]).string;
  124. // str +=NextLine+'抢庄次数:'+ this.$('qiang/qiang@Label',TempNd.children[i]).string;
  125. // str +=NextLine+'坐庄次数:'+ this.$('zhuang/zhuang@Label',TempNd.children[i]).string;
  126. // str +=NextLine+'推注次数:'+ this.$('tui/tui@Label',TempNd.children[i]).string;
  127. str +=NextLine+'戰績:'+ this.$('Score@Label',TempNd.children[i]).string;
  128. }
  129. ThirdPartyCopyClipper(str);
  130. this.m_Hook.ShowTips('重播資訊已複製到剪貼簿')
  131. return str;
  132. },
  133. });