diff --git a/js/client-battle.js b/js/client-battle.js index 6b8ba286e..adb7cb3e6 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -73,7 +73,7 @@ if (this.battle) this.battle.destroy(); }, requestLeave: function (e) { - if (this.side && this.battle && !this.battleEnded && !this.expired && !this.battle.forfeitPending) { + if ((this.side || this.requireForfeit) && this.battle && !this.battleEnded && !this.expired && !this.battle.forfeitPending) { app.addPopup(ForfeitPopup, {room: this, sourceEl: e && e.currentTarget, gameType: 'battle'}); return false; } @@ -138,6 +138,14 @@ if (data.substr(0, 6) === '|init|') { return this.init(data); } + if (data.substr(0, 11) === '|cantleave|') { + this.requireForfeit = true; + return; + } + if (data.substr(0, 12) === '|allowleave|') { + this.requireForfeit = false; + return; + } if (data.substr(0, 9) === '|request|') { data = data.slice(9); diff --git a/js/client-chat-tournament.js b/js/client-chat-tournament.js index 4a6139840..56a0e73c6 100644 --- a/js/client-chat-tournament.js +++ b/js/client-chat-tournament.js @@ -167,19 +167,22 @@ self.room.send('/tournament leave'); }); this.$challengeChallenge.on('click', function () { - app.sendTeam(Storage.teams[self.$teamSelect.children().val()]); - self.room.send('/tournament challenge ' + self.$challengeUserMenu.children().val()); + app.sendTeam(Storage.teams[self.$teamSelect.children().val()], function () { + self.room.send('/tournament challenge ' + self.$challengeUserMenu.children().val()); + }); }); this.$challengeAccept.on('click', function () { - app.sendTeam(Storage.teams[self.$teamSelect.children().val()]); - self.room.send('/tournament acceptchallenge'); + app.sendTeam(Storage.teams[self.$teamSelect.children().val()], function () { + self.room.send('/tournament acceptchallenge'); + }); }); this.$challengeCancel.on('click', function () { self.room.send('/tournament cancelchallenge'); }); this.$validate.on('click', function () { - app.sendTeam(Storage.teams[self.$teamSelect.children().val()]); - self.room.send('/tournament vtm'); + app.sendTeam(Storage.teams[self.$teamSelect.children().val()], function () { + self.room.send('/tournament vtm'); + }); }); app.user.on('saveteams', this.updateTeams, this); @@ -477,7 +480,7 @@ break; case 'end': - var endData = JSON.parse(data[0]); + var endData = JSON.parse(data.join('|')); var $bracket = this.generateBracket(endData.bracketData); if ($bracket) { diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index 353d2918b..d83c7f88c 100644 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -896,6 +896,8 @@ buf += '

' + this.renderFormats(format) + '

'; buf += '

' + this.renderTeams(format) + '

'; buf += '

'; + buf += '