Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. if (!Rooms.RoomBattle.prototype.___onEnd) Rooms.RoomBattle.prototype.___onEnd = Rooms.RoomBattle.prototype.onEnd;
  2. Rooms.RoomBattle.prototype.onEnd = function (winner) {
  3. //tour
  4. if (OG.wars) {
  5. let matchup = findTourFromMatchup(this.p1.name, this.p2.name, this.format, this.room);
  6. if (matchup) {
  7. let losser = false;
  8. if (toID(this.p1.name) === toID(winner)) losser = this.p2.name;
  9. if (toID(this.p2.name) === toID(winner)) losser = this.p1.name;
  10. let wid = toID(winner);
  11.  
  12. if (!losser) {
  13. //tie
  14. Rooms.get(matchup.tourId).addRaw('La batalla entre <b>' + this.p1.name + '</b> y <b>' + this.p2.name + '</b> ha terminado en empate. Es necesario iniciar otra batalla.');
  15. invalidate(matchup.tourId, matchup.matchupId);
  16. } else if (wars[matchup.tourId].bo3) {
  17. const userMatch = OG.findMatchup(matchup.tourId, winner);
  18. let match = wars[matchup.tourId].matchups[toID(this.p1.name)].score;
  19. if (toID(this.p1.name) === wid) {
  20. match[0] += 1;
  21. } else {
  22. match[1] += 1;
  23. }
  24.  
  25. if (match[0] === 2) {
  26. Rooms.get(matchup.tourId).addRaw('<br /><font color=green><b>' + winner + '</b></font> ha ganado su batalla contra <font color=red><b>' + losser + '</b></font>.');
  27. } else {
  28. Rooms.get(matchup.tourId).addRaw('<br /><font color=green><b>' + winner + '</b></font> ha ganado su batalla contra <font color=red><b>' + losser + '</b></font>.');
  29. }
  30.  
  31. let amount = Math.round(Math.random() * (6 - 5) + 5);
  32. OG.writeMoney(wid, amount, () => {
  33. OG.readMoney(wid, () => {
  34. if (Users.get(wid) && Users.get(wid).connected) {
  35. Users.get(wid).popup(`|html|Has recibido ${amount} PokeDólar${OG.pluralFormat(amount, 'es')} por ganar tu batalla de guerra.`);
  36. }
  37. OG.logTransaction(`${Chat.escapeHTML(wid)} ganó ${amount} PokeDólar${OG.pluralFormat(amount, 'es')} en una war.`);
  38. });
  39. });
  40. Rooms.get(matchup.tourId).addRaw(`${OG.nameColor(winner, true)} ha obtenido <b><font color="green">${amount}</font></b> PokeDólar${OG.pluralFormat(amount, 'es')} por su victoria.`);
  41.  
  42. dqTeamTour(matchup.tourId, losser);
  43. Rooms.get(matchup.tourId).addRaw(viewTourStatus(matchup.tourId));
  44. Rooms.get(matchup.tourId).update();
  45. } else {
  46. let warType = OG.getTourData(matchup.tourId).format;
  47. let formatid = toID(this.format);
  48. if (warType === 'Multi-Tier') {
  49. if (!wars[matchup.tourId].custom) {
  50. if (formatid.includes('random') || formatid.includes('challengecup') || formatid.includes('cup') || formatid.includes('staff') || formatid.includes('factory')) return false;
  51. }
  52. }
  53. Rooms.get(matchup.tourId).addRaw('<br /><font color=green><b>' + winner + '</b></font> ha ganado su batalla contra <font color=red><b>' + losser + '</b></font>.');
  54.  
  55. let amount = Math.round(Math.random() * (6 - 5) + 5);
  56. OG.writeMoney(wid, amount, () => {
  57. OG.readMoney(wid, () => {
  58. if (Users.get(wid) && Users.get(wid).connected) {
  59. Users.get(wid).popup(`|html|Has recibido ${amount} PokeDólar${OG.pluralFormat(amount, 'es')} por ganar tu batalla de guerra.`);
  60. }
  61. OG.logTransaction(`${Chat.escapeHTML(wid)} ganó ${amount} PokeDólar${OG.pluralFormat(amount, 'es')} en una war.`);
  62. });
  63. });
  64. Rooms.get(matchup.tourId).addRaw(`${OG.nameColor(winner, true)} ha obtenido <b><font color="green">${amount}</font></b> PokeDólar${OG.pluralFormat(amount, 'es')} por su victoria.`);
  65.  
  66. dqTeamTour(matchup.tourId, losser);
  67. Rooms.get(matchup.tourId).addRaw(viewTourStatus(matchup.tourId));
  68. Rooms.get(matchup.tourId).update();
  69. }
  70. }
  71. }
  72. //end tour
  73. this.___onEnd(winner);
  74. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement