Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!Rooms.RoomBattle.prototype.___onEnd) Rooms.RoomBattle.prototype.___onEnd = Rooms.RoomBattle.prototype.onEnd;
- Rooms.RoomBattle.prototype.onEnd = function (winner) {
- //tour
- if (OG.wars) {
- let matchup = findTourFromMatchup(this.p1.name, this.p2.name, this.format, this.room);
- if (matchup) {
- let losser = false;
- if (toID(this.p1.name) === toID(winner)) losser = this.p2.name;
- if (toID(this.p2.name) === toID(winner)) losser = this.p1.name;
- let wid = toID(winner);
- if (!losser) {
- //tie
- 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.');
- invalidate(matchup.tourId, matchup.matchupId);
- } else if (wars[matchup.tourId].bo3) {
- const userMatch = OG.findMatchup(matchup.tourId, winner);
- let match = wars[matchup.tourId].matchups[toID(this.p1.name)].score;
- if (toID(this.p1.name) === wid) {
- match[0] += 1;
- } else {
- match[1] += 1;
- }
- if (match[0] === 2) {
- 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>.');
- } else {
- 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>.');
- }
- let amount = Math.round(Math.random() * (6 - 5) + 5);
- OG.writeMoney(wid, amount, () => {
- OG.readMoney(wid, () => {
- if (Users.get(wid) && Users.get(wid).connected) {
- Users.get(wid).popup(`|html|Has recibido ${amount} PokeDólar${OG.pluralFormat(amount, 'es')} por ganar tu batalla de guerra.`);
- }
- OG.logTransaction(`${Chat.escapeHTML(wid)} ganó ${amount} PokeDólar${OG.pluralFormat(amount, 'es')} en una war.`);
- });
- });
- 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.`);
- dqTeamTour(matchup.tourId, losser);
- Rooms.get(matchup.tourId).addRaw(viewTourStatus(matchup.tourId));
- Rooms.get(matchup.tourId).update();
- } else {
- let warType = OG.getTourData(matchup.tourId).format;
- let formatid = toID(this.format);
- if (warType === 'Multi-Tier') {
- if (!wars[matchup.tourId].custom) {
- if (formatid.includes('random') || formatid.includes('challengecup') || formatid.includes('cup') || formatid.includes('staff') || formatid.includes('factory')) return false;
- }
- }
- 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>.');
- let amount = Math.round(Math.random() * (6 - 5) + 5);
- OG.writeMoney(wid, amount, () => {
- OG.readMoney(wid, () => {
- if (Users.get(wid) && Users.get(wid).connected) {
- Users.get(wid).popup(`|html|Has recibido ${amount} PokeDólar${OG.pluralFormat(amount, 'es')} por ganar tu batalla de guerra.`);
- }
- OG.logTransaction(`${Chat.escapeHTML(wid)} ganó ${amount} PokeDólar${OG.pluralFormat(amount, 'es')} en una war.`);
- });
- });
- 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.`);
- dqTeamTour(matchup.tourId, losser);
- Rooms.get(matchup.tourId).addRaw(viewTourStatus(matchup.tourId));
- Rooms.get(matchup.tourId).update();
- }
- }
- }
- //end tour
- this.___onEnd(winner);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement