From 956f2473d6d8f4d856df1de2e02636cc9a9ff210 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Mon, 20 May 2013 18:48:18 -0500 Subject: [PATCH] Show error message for having no teams --- js/client-mainmenu.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index be147f8ad..2eadae5d0 100644 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -342,9 +342,14 @@ var $pmWindow = $(target).closest('.pm-window'); var userid = $pmWindow.data('userid'); + var format = $pmWindow.find('button[name=format]').val(); var teamIndex = $pmWindow.find('button[name=team]').val(); var team = null; if (app.user.teams[teamIndex]) team = app.user.teams[teamIndex].team; + if (!window.BattleFormats[format].team && !team) { + app.addPopupMessage("You need to go into the Teambuilder and build a team for this format."); + return; + } $(target).closest('.challenge').remove(); app.send('/utm '+(team?$.toJSON(team):'null')); @@ -360,11 +365,15 @@ var $pmWindow = $(target).closest('.pm-window'); var userid = $pmWindow.data('userid'); var name = $pmWindow.data('name'); - var format = $pmWindow.find('button[name=format]').val(); + var format = $pmWindow.find('button[name=format]').val(); var teamIndex = $pmWindow.find('button[name=team]').val(); var team = null; if (app.user.teams[teamIndex]) team = app.user.teams[teamIndex].team; + if (!window.BattleFormats[format].team && !team) { + app.addPopupMessage("You need to go into the Teambuilder and build a team for this format."); + return; + } var buf = '

Challenging '+Tools.escapeHTML(name)+'...

'; buf += '

'+this.renderFormats(format, true)+'

'; @@ -470,6 +479,10 @@ var teamIndex = $teamButton.val(); var team = null; if (app.user.teams[teamIndex]) team = app.user.teams[teamIndex].team; + if (!window.BattleFormats[format].team && !team) { + app.addPopupMessage("You need to go into the Teambuilder and build a team for this format."); + return; + } $formatButton.addClass('preselected')[0].disabled = true; $teamButton.addClass('preselected')[0].disabled = true;