RecordInfoItem.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. ctor:function(){
  6. },
  7. InitPre:function(){
  8. if(this.m_ListCtrl == null) this.m_ListCtrl = this.$('@CustomListCtrl');
  9. this.m_ListCtrl.InitList(0, 'RecordUserItem2', this);
  10. this.node.active = false;
  11. },
  12. SetPreInfo:function(ParaArr){//0 Kind 1 RecordID 2 index 3 info
  13. this.node.active = true;
  14. this.m_KindID = ParaArr[0];
  15. this.m_RecordID = ParaArr[1];
  16. this.m_GameIndex = ParaArr[2];
  17. this.m_ScoreInfo = ParaArr[3];
  18. this.$('Info/LabTime@Label').string = this.m_ScoreInfo['Time'];
  19. this.$('Info/LbIndex@Label').string = pad(this.m_GameIndex, 2) ;
  20. var sortIDArr = this.SortUserIndexByScore(this.m_ScoreInfo);
  21. for (var i in sortIDArr)
  22. {
  23. this.m_ListCtrl.InsertListInfo(0, [sortIDArr[i], this.m_ScoreInfo[sortIDArr[i]]]);
  24. }
  25. // for(var i in this.m_ScoreInfo){
  26. // if(i == 'Time') continue;
  27. // this.m_ListCtrl.InsertListInfo(0, [i, this.m_ScoreInfo[i]]);
  28. // }
  29. },
  30. SortUserIndexByScore:function(ScoreInfo){
  31. var indexArr = new Array();
  32. var scoreArr = new Array();
  33. var totalCnt = 0;
  34. for(var i in ScoreInfo){
  35. if(i == 'Time') continue;
  36. indexArr[totalCnt] = i;
  37. scoreArr[totalCnt] = ScoreInfo[i];
  38. totalCnt++;
  39. }
  40. for (var i = 0 ; i < totalCnt - 1 ; i++)
  41. {
  42. for (var j = i + 1 ; j < totalCnt ; j++)
  43. {
  44. if (scoreArr[i] < scoreArr[j])
  45. {
  46. var score = scoreArr[i];
  47. scoreArr[i] = scoreArr[j];
  48. scoreArr[j] = score;
  49. var index = indexArr[i];
  50. indexArr[i] = indexArr[j];
  51. indexArr[j] = index;
  52. }
  53. }
  54. }
  55. return indexArr;
  56. },
  57. OnClick_RePlayGame:function(){
  58. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  59. g_Lobby.OnRePlayGame(this.m_RecordID, this.m_KindID, pGlobalUserData, this.m_GameIndex - 1);
  60. },
  61. OnAnalysisReplay:function(){
  62. return
  63. GameDef = new window['CMD_GAME_'+this.m_KindID]();
  64. //显示手牌(回放 处理逻辑 )
  65. try {
  66. this.m_ReplayEngine = this.node.getComponent('ReplayEngine_'+this.m_KindID);
  67. if(this.m_ReplayEngine == null) this.m_ReplayEngine = this.node.addComponent('ReplayEngine_'+this.m_KindID);
  68. } catch (error) {
  69. if(window.LOG_NET_DATA)console.log(error)
  70. return false;
  71. }
  72. var webUrl = window.PHP_HOME+'/GameRecord.php?&GetMark=1&ID='+this.m_RecordID+'&GameIndex='+(this.m_GameIndex-1);
  73. WebCenter.GetData(webUrl, 999999, function (data) {
  74. if(data.length < 50){
  75. console.log('err 11111 ',webUrl)
  76. return
  77. }
  78. var RecordInfo = JSON.parse(data);
  79. if(RecordInfo[0] == 0) {
  80. console.log('err 22222 ',webUrl)
  81. return
  82. }
  83. if(this.m_ReplayEngine){
  84. this.m_ReplayEngine.SetData(RecordInfo[3], 0, true);
  85. for(var i in this.m_ReplayEngine.GameData[0].user){
  86. var TempUserID = this.m_ReplayEngine.GameData[0].user[i].dwUserID;
  87. var TempChairID = this.m_ReplayEngine.GameData[0].user[i].wChairID;
  88. var Score,CardData,CardType,Banker,Player,bBanker;
  89. Score = this.m_ReplayEngine.GameData.GameEnd.llGameScore[TempChairID];
  90. if(this.m_ReplayEngine.GameData.CardData) CardData = this.m_ReplayEngine.GameData.CardData[TempChairID];
  91. //牌型
  92. if(this.m_ReplayEngine.GameData.OxType) CardType = this.m_ReplayEngine.GameData.OxType[TempChairID];
  93. //庄显示
  94. if(this.m_ReplayEngine.GameData.lBankerCall) Banker = this.m_ReplayEngine.GameData.lBankerCall[TempChairID];
  95. if(Banker == 0xff) Banker='';
  96. if(Banker == 0) Banker='不搶';
  97. if(Banker > 0 && Banker < 0xff) Banker+='倍';
  98. //闲显示
  99. if(this.m_ReplayEngine.GameData.lPlayerCall) Player = this.m_ReplayEngine.GameData.lPlayerCall[TempChairID];
  100. if(Player == 0) Player='';
  101. if(Player > 0 ) Player='X'+Player;
  102. bBanker = this.m_ReplayEngine.GameData.wBankerUser == TempChairID;
  103. this.m_ListCtrl.InsertListInfo(0, [TempUserID, Score, CardData, this.m_ReplayEngine.GameData.CardCnt, CardType, Banker, Player, bBanker]);//0 UserID 1 Score 2 Card 3 CardCnt 4 Type 5Banker 6Player 7bBanker
  104. }
  105. }
  106. }.bind(this));
  107. },
  108. });