Revamped Challenge Buttons completely, Added primal abilities, items and primals themselves
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
BIN
public/Sprites/back/384-mega.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
273
public/js/app.js
@@ -225,7 +225,10 @@
|
||||
FIRE_ROCK_START: "Molten rocks float in the air around $ts!",
|
||||
FIRE_ROCK_HURT: "$p is hurt by molten rocks!",
|
||||
FIRE_ROCK_END: "The molten rocks disappeared from around $ts!",
|
||||
ILLUSION_BROKE: "The foes $p broke it's illusion!"
|
||||
ILLUSION_BROKE: "The foes $p broke it's illusion!",
|
||||
WEATHER_FAIL: "But the weather was suppressed!",
|
||||
HARSHSUN_MOVEFAIL: "But the Harsh Sun caused the move to fail!",
|
||||
HEAVYRAIN_MOVEFAIL: "But the Harsh Sun caused the move to fail!"
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1120,7 +1123,8 @@
|
||||
NONE: 'None',
|
||||
MOON: 'Moon',
|
||||
DELTASTREAM: 'DeltaStream',
|
||||
HARSHSUN: 'HarshSun'
|
||||
HARSHSUN: 'HarshSun',
|
||||
HEAVYRAIN: 'HeavyRain'
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
@@ -1810,6 +1814,9 @@
|
||||
|
||||
Pokemon.prototype.canMegaEvolve = function() {
|
||||
var forme, item, species, _ref;
|
||||
if (this.get('species') === "Rayquaza" && __indexOf.call(this.get('moves'), "Dragon Ascent") >= 0) {
|
||||
return true;
|
||||
}
|
||||
item = this.getItem();
|
||||
if (item.type !== 'megastone') {
|
||||
return false;
|
||||
@@ -3080,7 +3087,7 @@
|
||||
};
|
||||
|
||||
BattleView.prototype.renderActions = function(validActions) {
|
||||
var $actions, $button, locals, pokemon, _ref;
|
||||
var $actions, $button, locals, pokemon;
|
||||
if (validActions == null) {
|
||||
validActions = [];
|
||||
}
|
||||
@@ -3092,20 +3099,19 @@
|
||||
$actions = this.$('.battle_actions');
|
||||
$actions.html(this.action_template(locals));
|
||||
pokemon = this.model.getPokemon(this.model.get('index'), 0);
|
||||
if (((_ref = pokemon.getItem()) != null ? _ref.type : void 0) === 'megastone') {
|
||||
$button = $actions.find('.mega-evolve');
|
||||
$button = $actions.find('.mega-evolve');
|
||||
if (pokemon.canMegaEvolve()) {
|
||||
$button.removeClass("hidden");
|
||||
if (!pokemon.canMegaEvolve()) {
|
||||
$button.addClass('disabled');
|
||||
}
|
||||
} else {
|
||||
$button.addClass('disabled');
|
||||
}
|
||||
$actions.find('.move.button').each((function(_this) {
|
||||
return function(i, el) {
|
||||
var $this, gen, moveData, moveName, _ref1;
|
||||
var $this, gen, moveData, moveName, _ref;
|
||||
$this = $(el);
|
||||
moveName = $this.data('move-id');
|
||||
gen = _this.model.get('generation').toUpperCase();
|
||||
moveData = (_ref1 = window.Generations[gen]) != null ? _ref1.MoveData[moveName] : void 0;
|
||||
moveData = (_ref = window.Generations[gen]) != null ? _ref.MoveData[moveName] : void 0;
|
||||
return _this.movePopover($this, moveName, moveData);
|
||||
};
|
||||
})(this));
|
||||
@@ -7492,8 +7498,184 @@
|
||||
|
||||
})();
|
||||
|
||||
this.SelectedTeamID = null;
|
||||
|
||||
this.SelectedFormat = null;
|
||||
|
||||
this.ChallengePaneOpts = {
|
||||
SelectedTeamID: null,
|
||||
SelectedFormat: null,
|
||||
SelectedAlt: null
|
||||
};
|
||||
|
||||
this.createChallengeButton = function(opts) {
|
||||
var $button, $clauses, $eventName, acceptEventName, cancelChallenge, cancelEventName, capitalizedEventName, defaultformat, disableButtons, getChallengeOpts, getSelectedTeam, rejectEventName;
|
||||
$button = opts.button;
|
||||
$eventName = opts.eventName;
|
||||
$clauses = opts.clauses;
|
||||
capitalizedEventName = "" + ($eventName[0].toUpperCase()) + ($eventName.substr(1));
|
||||
acceptEventName = "accept" + capitalizedEventName;
|
||||
rejectEventName = "reject" + capitalizedEventName;
|
||||
cancelEventName = "cancel" + capitalizedEventName;
|
||||
getSelectedTeam = function() {
|
||||
return PokeBattle.TeamStore.get(this.ChallengePaneOpts.SelectedTeamID) || PokeBattle.TeamStore.at(0);
|
||||
};
|
||||
cancelChallenge = function() {
|
||||
var format;
|
||||
format = getChallengeOpts().SelectedFormat;
|
||||
PokeBattle.primus.send(cancelEventName, format);
|
||||
return $button.trigger('cancelChallenge');
|
||||
};
|
||||
getChallengeOpts = function() {
|
||||
return this.ChallengePaneOpts;
|
||||
};
|
||||
disableButtons = function() {
|
||||
return $('.select').addClass('disabled');
|
||||
};
|
||||
defaultformat = function() {
|
||||
return this.DEFAULT_FORMAT;
|
||||
};
|
||||
return $button.on('click.challenge', function() {
|
||||
var format, options, team, teamJSON;
|
||||
PokeBattle.requestNotifyPermission();
|
||||
options = getChallengeOpts();
|
||||
if (options.SelectedFormat !== null) {
|
||||
format = options.SelectedFormat;
|
||||
} else {
|
||||
format = defaultformat();
|
||||
}
|
||||
if (!$button.hasClass('disabled')) {
|
||||
team = getSelectedTeam();
|
||||
if (!team) {
|
||||
alert("You need to create a team using the Teambuilder before you can battle.");
|
||||
PokeBattle.navigation.showTeambuilder();
|
||||
return;
|
||||
}
|
||||
disableButtons();
|
||||
teamJSON = team.toNonNullJSON().pokemon;
|
||||
PokeBattle.primus.send($eventName, format, teamJSON, options.selectedAlt);
|
||||
return $button.addClass('disabled').trigger('challenge');
|
||||
} else {
|
||||
return cancelChallenge();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.createChallengePaneNew = function(opts) {
|
||||
var $accept, $format, $reject, $selectFormat, $wrapper, disableButtons, generation, getSelectedTeam, isAttachedToDom, renderCurrentTeam, setAlt, setFormat, setTeam, teamUpdated;
|
||||
$wrapper = opts.populate;
|
||||
$accept = opts.acceptButton || $();
|
||||
$reject = opts.rejectButton || $();
|
||||
generation = opts.generation;
|
||||
getSelectedTeam = function() {
|
||||
return PokeBattle.TeamStore.get(this.ChallengePaneOpts.SelectedTeamID) || PokeBattle.TeamStore.at(0);
|
||||
};
|
||||
renderCurrentTeam = function($context) {
|
||||
var $selectTeam, currentTeam, html;
|
||||
$selectTeam = $context.find('.select-team');
|
||||
if (PokeBattle.TeamStore.length > 0) {
|
||||
currentTeam = getSelectedTeam();
|
||||
html = JST['team_dropdown']({
|
||||
window: window,
|
||||
team: currentTeam
|
||||
});
|
||||
return $selectTeam.html(html);
|
||||
} else {
|
||||
return $selectTeam.html("You have no teams!");
|
||||
}
|
||||
};
|
||||
disableButtons = function() {
|
||||
return $('.select').addClass('disabled');
|
||||
};
|
||||
$wrapper.html(JST['new_battle']({
|
||||
window: window
|
||||
}));
|
||||
$selectFormat = $wrapper.find(".select-format");
|
||||
$wrapper.find('.select-alt').click(function(e) {
|
||||
var html;
|
||||
html = JST['alt_dropdown']({
|
||||
alts: PokeBattle.alts.list,
|
||||
username: PokeBattle.username
|
||||
});
|
||||
return $wrapper.find('.alt-dropdown').html(html);
|
||||
});
|
||||
setAlt = function(altname) {
|
||||
return this.ChallengePaneOpts.SelectedAlt = altname;
|
||||
};
|
||||
$wrapper.find('.alt-dropdown').on('click', '.select-alt-dropdown-item', function(e) {
|
||||
setAlt($(this).data('alt-name'));
|
||||
return $wrapper.find('.select-alt').html($(this).html());
|
||||
});
|
||||
$wrapper.find('.alt-dropdown').on('click', '.add-alt-dropdown-item', function(e) {
|
||||
return toggleAltInput(true);
|
||||
});
|
||||
$wrapper.find('.alt-input .add-button').click(function(e) {
|
||||
var altName;
|
||||
altName = $wrapper.find('.alt-input input').val().trim();
|
||||
return PokeBattle.alts.createAlt(altName);
|
||||
});
|
||||
$wrapper.find('.alt-input .cancel-button').click(function(e) {
|
||||
return toggleAltInput(false);
|
||||
});
|
||||
$wrapper.find('.select-team').click(function(e) {
|
||||
var allTeams, html;
|
||||
allTeams = PokeBattle.TeamStore.models || [];
|
||||
html = JST['team_dropdown']({
|
||||
window: window,
|
||||
teams: allTeams
|
||||
});
|
||||
return $wrapper.find('.team-dropdown').html(html);
|
||||
});
|
||||
setTeam = function(slot) {
|
||||
return this.ChallengePaneOpts.SelectedTeamID = PokeBattle.TeamStore.at(slot).id;
|
||||
};
|
||||
$wrapper.find('.team-dropdown').on('click', '.select-team-dropdown-item', function(e) {
|
||||
var slot;
|
||||
slot = $(e.currentTarget).data('slot');
|
||||
setTeam(slot);
|
||||
return renderCurrentTeam($wrapper);
|
||||
});
|
||||
$wrapper.find('.team-dropdown').on('click', '.build-team-option', function(e) {
|
||||
return PokeBattle.navigation.showTeambuilder();
|
||||
});
|
||||
setFormat = function(format) {
|
||||
return this.ChallengePaneOpts.SelectedFormat = format;
|
||||
};
|
||||
$wrapper.find('.format-dropdown').on('click', '.select-format-dropdown-item', function(e) {
|
||||
var $target, format;
|
||||
$target = $(e.currentTarget);
|
||||
format = $target.data('format');
|
||||
$selectFormat.text($target.text());
|
||||
setFormat(format);
|
||||
return $selectFormat.data('format', format);
|
||||
});
|
||||
$wrapper.find('.select-alt').html(JST['alt_dropdown']({
|
||||
alt: null,
|
||||
username: PokeBattle.username
|
||||
}));
|
||||
if (generation) {
|
||||
$format = $wrapper.find(".format-dropdown a[data-format='" + generation + "']");
|
||||
$format.first().click();
|
||||
$wrapper.find('.select-format').addClass('disabled');
|
||||
} else {
|
||||
$wrapper.find('.format-dropdown a').first().click();
|
||||
}
|
||||
isAttachedToDom = function() {
|
||||
return $.contains(document, $wrapper.get(0));
|
||||
};
|
||||
renderCurrentTeam($wrapper);
|
||||
teamUpdated = function() {
|
||||
if (!isAttachedToDom()) {
|
||||
PokeBattle.TeamStore.off('add remove reset saved', teamUpdated);
|
||||
return;
|
||||
}
|
||||
return renderCurrentTeam($wrapper);
|
||||
};
|
||||
return PokeBattle.TeamStore.on('add remove reset saved', teamUpdated);
|
||||
};
|
||||
|
||||
this.createChallengePane = function(opts) {
|
||||
var $PaneArray, $accept, $button, $buttons, $checkboxes, $format, $reject, $selectFormat, $wrapper, acceptEventName, altCreatedEvent, blockedClauses, cancelChallenge, cancelEventName, capitalizedEventName, defaultClauses, disableButtons, enableButtons, eventName, generation, getSelectedTeam, isAttachedToDom, personId, rejectEventName, renderCurrentTeam, selectedAlt, selectedTeamId, teamUpdated, toggleAltInput, _ref;
|
||||
var $accept, $button, $buttons, $checkboxes, $format, $reject, $selectFormat, $wrapper, acceptEventName, altCreatedEvent, blockedClauses, cancelChallenge, cancelEventName, capitalizedEventName, defaultClauses, disableButtons, enableButtons, eventName, generation, getSelectedTeam, isAttachedToDom, personId, rejectEventName, renderCurrentTeam, selectedAlt, selectedTeamId, teamUpdated, toggleAltInput, _ref;
|
||||
$wrapper = opts.populate;
|
||||
$button = opts.button;
|
||||
$accept = opts.acceptButton || $();
|
||||
@@ -7510,7 +7692,6 @@
|
||||
blockedClauses = (_ref = opts.blockedClauses) != null ? _ref : false;
|
||||
selectedTeamId = null;
|
||||
selectedAlt = null;
|
||||
$PaneArray = this.challengePaneArray;
|
||||
getSelectedTeam = function() {
|
||||
return PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0);
|
||||
};
|
||||
@@ -7571,20 +7752,13 @@
|
||||
}));
|
||||
$selectFormat = $wrapper.find(".select-format");
|
||||
$button.on('click.challenge', function() {
|
||||
var $clauses, clauses, format, team, teamJSON, thisChallenge;
|
||||
thisChallenge = _.find($PaneArray, function(butt) {
|
||||
return butt.button.selector === $button.selector;
|
||||
});
|
||||
var $clauses, clauses, format, team, teamJSON;
|
||||
PokeBattle.requestNotifyPermission();
|
||||
format = $selectFormat.data('format');
|
||||
if (typeof format === "undefined" && typeof personId === "undefined") {
|
||||
format = $('.select-format').data('format');
|
||||
}
|
||||
if (!$button.hasClass('disabled')) {
|
||||
team = getSelectedTeam();
|
||||
if (!team) {
|
||||
alert("You need to create a team using the Teambuilder before you can battle.");
|
||||
PokeBattle.navigation.showTeambuilder();
|
||||
return;
|
||||
}
|
||||
disableButtons();
|
||||
@@ -7595,7 +7769,7 @@
|
||||
$clauses.each(function() {
|
||||
return clauses.push(parseInt($(this).val(), 10));
|
||||
});
|
||||
PokeBattle.primus.send(eventName, personId, format, teamJSON, thisChallenge.clauses, selectedAlt);
|
||||
PokeBattle.primus.send(eventName, personId, format, teamJSON, clauses, selectedAlt);
|
||||
} else {
|
||||
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt);
|
||||
}
|
||||
@@ -7612,7 +7786,6 @@
|
||||
team = getSelectedTeam();
|
||||
if (!team) {
|
||||
alert("You need to create a team using the Teambuilder before you can battle.");
|
||||
PokeBattle.navigation.showTeambuilder();
|
||||
return;
|
||||
}
|
||||
disableButtons();
|
||||
@@ -7651,12 +7824,14 @@
|
||||
});
|
||||
$wrapper.find('.select-team').click(function(e) {
|
||||
var allTeams, html;
|
||||
allTeams = PokeBattle.TeamStore.models || [];
|
||||
html = JST['team_dropdown']({
|
||||
window: window,
|
||||
teams: allTeams
|
||||
});
|
||||
return $wrapper.find('.team-dropdown').html(html);
|
||||
allTeams = PokeBattle.TeamStore.models;
|
||||
if (allTeams && allTeams.length > 0) {
|
||||
html = JST['team_dropdown']({
|
||||
window: window,
|
||||
teams: allTeams
|
||||
});
|
||||
return $wrapper.find('.team-dropdown').html(html);
|
||||
}
|
||||
});
|
||||
$wrapper.find('.team-dropdown').on('click', '.select-team-dropdown-item', function(e) {
|
||||
var slot;
|
||||
@@ -7664,9 +7839,6 @@
|
||||
selectedTeamId = PokeBattle.TeamStore.at(slot).id;
|
||||
return renderCurrentTeam($wrapper);
|
||||
});
|
||||
$wrapper.find('.team-dropdown').on('click', '.build-team-option', function(e) {
|
||||
return PokeBattle.navigation.showTeambuilder();
|
||||
});
|
||||
$wrapper.find('.format-dropdown').on('click', '.select-format-dropdown-item', function(e) {
|
||||
var $target, format;
|
||||
$target = $(e.currentTarget);
|
||||
@@ -11088,42 +11260,23 @@
|
||||
var depressFindBattle, depressFindBattleUnranked;
|
||||
|
||||
$(function() {
|
||||
var $mainButtons, challengeobj, challengeobjunranked, challengepaneobj, challengepaneobjunranked;
|
||||
var $mainButtons;
|
||||
$mainButtons = $('.main_buttons');
|
||||
$mainButtons.on('click', '.teambuilder_button', function(e) {
|
||||
return PokeBattle.navigation.showTeambuilder();
|
||||
});
|
||||
challengeobjunranked = {
|
||||
eventName: "findBattleunranked",
|
||||
populate: $mainButtons.find('.find_battle_select_team'),
|
||||
button: $mainButtons.find('.find_battle_non_ranked'),
|
||||
defaultClauses: [Conditions.SLEEP_CLAUSE, Conditions.EVASION_CLAUSE, Conditions.SPECIES_CLAUSE, Conditions.OHKO_CLAUSE, Conditions.PRANKSTER_SWAGGER_CLAUSE, Conditions.UNRELEASED_BAN, Conditions.TIMED_BATTLE],
|
||||
blockedClauses: true
|
||||
};
|
||||
challengeobj = {
|
||||
createChallengeButton({
|
||||
eventName: "findBattle",
|
||||
populate: $mainButtons.find('.find_battle_select_team'),
|
||||
button: $mainButtons.find('.find_battle'),
|
||||
defaultClauses: [Conditions.SLEEP_CLAUSE, Conditions.EVASION_CLAUSE, Conditions.SPECIES_CLAUSE, Conditions.OHKO_CLAUSE, Conditions.PRANKSTER_SWAGGER_CLAUSE, Conditions.UNRELEASED_BAN, Conditions.RATED_BATTLE, Conditions.TIMED_BATTLE],
|
||||
blockedClauses: true
|
||||
};
|
||||
challengepaneobjunranked = new challengePaneObject(challengeobjunranked);
|
||||
challengePaneArray.push(challengepaneobjunranked);
|
||||
challengepaneobj = new challengePaneObject(challengeobj);
|
||||
challengePaneArray.push(challengepaneobj);
|
||||
createChallengePane({
|
||||
eventName: "findBattleunranked",
|
||||
populate: $mainButtons.find('.find_battle_select_team'),
|
||||
button: $mainButtons.find('.find_battle_non_ranked'),
|
||||
defaultClauses: [Conditions.SLEEP_CLAUSE, Conditions.EVASION_CLAUSE, Conditions.SPECIES_CLAUSE, Conditions.OHKO_CLAUSE, Conditions.PRANKSTER_SWAGGER_CLAUSE, Conditions.UNRELEASED_BAN, Conditions.TIMED_BATTLE],
|
||||
blockedClauses: true
|
||||
clauses: [Conditions.SLEEP_CLAUSE, Conditions.EVASION_CLAUSE, Conditions.SPECIES_CLAUSE, Conditions.OHKO_CLAUSE, Conditions.PRANKSTER_SWAGGER_CLAUSE, Conditions.UNRELEASED_BAN, Conditions.RATED_BATTLE, Conditions.TIMED_BATTLE]
|
||||
});
|
||||
createChallengePane({
|
||||
eventName: "findBattle",
|
||||
populate: $mainButtons.find('.find_battle_select_team'),
|
||||
button: $mainButtons.find('.find_battle'),
|
||||
defaultClauses: [Conditions.SLEEP_CLAUSE, Conditions.EVASION_CLAUSE, Conditions.SPECIES_CLAUSE, Conditions.OHKO_CLAUSE, Conditions.PRANKSTER_SWAGGER_CLAUSE, Conditions.UNRELEASED_BAN, Conditions.RATED_BATTLE, Conditions.TIMED_BATTLE],
|
||||
blockedClauses: true
|
||||
createChallengeButton({
|
||||
eventName: "findBattleunranked",
|
||||
button: $mainButtons.find('.find_battle_non_ranked'),
|
||||
clauses: [Conditions.SLEEP_CLAUSE, Conditions.EVASION_CLAUSE, Conditions.SPECIES_CLAUSE, Conditions.OHKO_CLAUSE, Conditions.PRANKSTER_SWAGGER_CLAUSE, Conditions.UNRELEASED_BAN, Conditions.TIMED_BATTLE]
|
||||
});
|
||||
createChallengePaneNew({
|
||||
populate: $mainButtons.find('.find_battle_select_team')
|
||||
});
|
||||
$mainButtons.find('.find_battle').on('challenge', function() {
|
||||
var $this;
|
||||
|
||||
@@ -225,7 +225,10 @@
|
||||
FIRE_ROCK_START: "Molten rocks float in the air around $ts!",
|
||||
FIRE_ROCK_HURT: "$p is hurt by molten rocks!",
|
||||
FIRE_ROCK_END: "The molten rocks disappeared from around $ts!",
|
||||
ILLUSION_BROKE: "The foes $p broke it's illusion!"
|
||||
ILLUSION_BROKE: "The foes $p broke it's illusion!",
|
||||
WEATHER_FAIL: "But the weather was suppressed!",
|
||||
HARSHSUN_MOVEFAIL: "But the Harsh Sun caused the move to fail!",
|
||||
HEAVYRAIN_MOVEFAIL: "But the Harsh Sun caused the move to fail!"
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1120,7 +1123,8 @@
|
||||
NONE: 'None',
|
||||
MOON: 'Moon',
|
||||
DELTASTREAM: 'DeltaStream',
|
||||
HARSHSUN: 'HarshSun'
|
||||
HARSHSUN: 'HarshSun',
|
||||
HEAVYRAIN: 'HeavyRain'
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
@@ -1810,6 +1814,9 @@
|
||||
|
||||
Pokemon.prototype.canMegaEvolve = function() {
|
||||
var forme, item, species, _ref;
|
||||
if (this.get('species') === "Rayquaza" && __indexOf.call(this.get('moves'), "Dragon Ascent") >= 0) {
|
||||
return true;
|
||||
}
|
||||
item = this.getItem();
|
||||
if (item.type !== 'megastone') {
|
||||
return false;
|
||||
@@ -2806,7 +2813,7 @@
|
||||
};
|
||||
|
||||
BattleView.prototype.renderActions = function(validActions) {
|
||||
var $actions, $button, locals, pokemon, _ref;
|
||||
var $actions, $button, locals, pokemon;
|
||||
if (validActions == null) {
|
||||
validActions = [];
|
||||
}
|
||||
@@ -2818,20 +2825,19 @@
|
||||
$actions = this.$('.battle_actions');
|
||||
$actions.html(this.action_template(locals));
|
||||
pokemon = this.model.getPokemon(this.model.get('index'), 0);
|
||||
if (((_ref = pokemon.getItem()) != null ? _ref.type : void 0) === 'megastone') {
|
||||
$button = $actions.find('.mega-evolve');
|
||||
$button = $actions.find('.mega-evolve');
|
||||
if (pokemon.canMegaEvolve()) {
|
||||
$button.removeClass("hidden");
|
||||
if (!pokemon.canMegaEvolve()) {
|
||||
$button.addClass('disabled');
|
||||
}
|
||||
} else {
|
||||
$button.addClass('disabled');
|
||||
}
|
||||
$actions.find('.move.button').each((function(_this) {
|
||||
return function(i, el) {
|
||||
var $this, gen, moveData, moveName, _ref1;
|
||||
var $this, gen, moveData, moveName, _ref;
|
||||
$this = $(el);
|
||||
moveName = $this.data('move-id');
|
||||
gen = _this.model.get('generation').toUpperCase();
|
||||
moveData = (_ref1 = window.Generations[gen]) != null ? _ref1.MoveData[moveName] : void 0;
|
||||
moveData = (_ref = window.Generations[gen]) != null ? _ref.MoveData[moveName] : void 0;
|
||||
return _this.movePopover($this, moveName, moveData);
|
||||
};
|
||||
})(this));
|
||||
@@ -5224,8 +5230,184 @@
|
||||
|
||||
})();
|
||||
|
||||
this.SelectedTeamID = null;
|
||||
|
||||
this.SelectedFormat = null;
|
||||
|
||||
this.ChallengePaneOpts = {
|
||||
SelectedTeamID: null,
|
||||
SelectedFormat: null,
|
||||
SelectedAlt: null
|
||||
};
|
||||
|
||||
this.createChallengeButton = function(opts) {
|
||||
var $button, $clauses, $eventName, acceptEventName, cancelChallenge, cancelEventName, capitalizedEventName, defaultformat, disableButtons, getChallengeOpts, getSelectedTeam, rejectEventName;
|
||||
$button = opts.button;
|
||||
$eventName = opts.eventName;
|
||||
$clauses = opts.clauses;
|
||||
capitalizedEventName = "" + ($eventName[0].toUpperCase()) + ($eventName.substr(1));
|
||||
acceptEventName = "accept" + capitalizedEventName;
|
||||
rejectEventName = "reject" + capitalizedEventName;
|
||||
cancelEventName = "cancel" + capitalizedEventName;
|
||||
getSelectedTeam = function() {
|
||||
return PokeBattle.TeamStore.get(this.ChallengePaneOpts.SelectedTeamID) || PokeBattle.TeamStore.at(0);
|
||||
};
|
||||
cancelChallenge = function() {
|
||||
var format;
|
||||
format = getChallengeOpts().SelectedFormat;
|
||||
PokeBattle.primus.send(cancelEventName, format);
|
||||
return $button.trigger('cancelChallenge');
|
||||
};
|
||||
getChallengeOpts = function() {
|
||||
return this.ChallengePaneOpts;
|
||||
};
|
||||
disableButtons = function() {
|
||||
return $('.select').addClass('disabled');
|
||||
};
|
||||
defaultformat = function() {
|
||||
return this.DEFAULT_FORMAT;
|
||||
};
|
||||
return $button.on('click.challenge', function() {
|
||||
var format, options, team, teamJSON;
|
||||
PokeBattle.requestNotifyPermission();
|
||||
options = getChallengeOpts();
|
||||
if (options.SelectedFormat !== null) {
|
||||
format = options.SelectedFormat;
|
||||
} else {
|
||||
format = defaultformat();
|
||||
}
|
||||
if (!$button.hasClass('disabled')) {
|
||||
team = getSelectedTeam();
|
||||
if (!team) {
|
||||
alert("You need to create a team using the Teambuilder before you can battle.");
|
||||
PokeBattle.navigation.showTeambuilder();
|
||||
return;
|
||||
}
|
||||
disableButtons();
|
||||
teamJSON = team.toNonNullJSON().pokemon;
|
||||
PokeBattle.primus.send($eventName, format, teamJSON, options.selectedAlt);
|
||||
return $button.addClass('disabled').trigger('challenge');
|
||||
} else {
|
||||
return cancelChallenge();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.createChallengePaneNew = function(opts) {
|
||||
var $accept, $format, $reject, $selectFormat, $wrapper, disableButtons, generation, getSelectedTeam, isAttachedToDom, renderCurrentTeam, setAlt, setFormat, setTeam, teamUpdated;
|
||||
$wrapper = opts.populate;
|
||||
$accept = opts.acceptButton || $();
|
||||
$reject = opts.rejectButton || $();
|
||||
generation = opts.generation;
|
||||
getSelectedTeam = function() {
|
||||
return PokeBattle.TeamStore.get(this.ChallengePaneOpts.SelectedTeamID) || PokeBattle.TeamStore.at(0);
|
||||
};
|
||||
renderCurrentTeam = function($context) {
|
||||
var $selectTeam, currentTeam, html;
|
||||
$selectTeam = $context.find('.select-team');
|
||||
if (PokeBattle.TeamStore.length > 0) {
|
||||
currentTeam = getSelectedTeam();
|
||||
html = JST['team_dropdown']({
|
||||
window: window,
|
||||
team: currentTeam
|
||||
});
|
||||
return $selectTeam.html(html);
|
||||
} else {
|
||||
return $selectTeam.html("You have no teams!");
|
||||
}
|
||||
};
|
||||
disableButtons = function() {
|
||||
return $('.select').addClass('disabled');
|
||||
};
|
||||
$wrapper.html(JST['new_battle']({
|
||||
window: window
|
||||
}));
|
||||
$selectFormat = $wrapper.find(".select-format");
|
||||
$wrapper.find('.select-alt').click(function(e) {
|
||||
var html;
|
||||
html = JST['alt_dropdown']({
|
||||
alts: PokeBattle.alts.list,
|
||||
username: PokeBattle.username
|
||||
});
|
||||
return $wrapper.find('.alt-dropdown').html(html);
|
||||
});
|
||||
setAlt = function(altname) {
|
||||
return this.ChallengePaneOpts.SelectedAlt = altname;
|
||||
};
|
||||
$wrapper.find('.alt-dropdown').on('click', '.select-alt-dropdown-item', function(e) {
|
||||
setAlt($(this).data('alt-name'));
|
||||
return $wrapper.find('.select-alt').html($(this).html());
|
||||
});
|
||||
$wrapper.find('.alt-dropdown').on('click', '.add-alt-dropdown-item', function(e) {
|
||||
return toggleAltInput(true);
|
||||
});
|
||||
$wrapper.find('.alt-input .add-button').click(function(e) {
|
||||
var altName;
|
||||
altName = $wrapper.find('.alt-input input').val().trim();
|
||||
return PokeBattle.alts.createAlt(altName);
|
||||
});
|
||||
$wrapper.find('.alt-input .cancel-button').click(function(e) {
|
||||
return toggleAltInput(false);
|
||||
});
|
||||
$wrapper.find('.select-team').click(function(e) {
|
||||
var allTeams, html;
|
||||
allTeams = PokeBattle.TeamStore.models || [];
|
||||
html = JST['team_dropdown']({
|
||||
window: window,
|
||||
teams: allTeams
|
||||
});
|
||||
return $wrapper.find('.team-dropdown').html(html);
|
||||
});
|
||||
setTeam = function(slot) {
|
||||
return this.ChallengePaneOpts.SelectedTeamID = PokeBattle.TeamStore.at(slot).id;
|
||||
};
|
||||
$wrapper.find('.team-dropdown').on('click', '.select-team-dropdown-item', function(e) {
|
||||
var slot;
|
||||
slot = $(e.currentTarget).data('slot');
|
||||
setTeam(slot);
|
||||
return renderCurrentTeam($wrapper);
|
||||
});
|
||||
$wrapper.find('.team-dropdown').on('click', '.build-team-option', function(e) {
|
||||
return PokeBattle.navigation.showTeambuilder();
|
||||
});
|
||||
setFormat = function(format) {
|
||||
return this.ChallengePaneOpts.SelectedFormat = format;
|
||||
};
|
||||
$wrapper.find('.format-dropdown').on('click', '.select-format-dropdown-item', function(e) {
|
||||
var $target, format;
|
||||
$target = $(e.currentTarget);
|
||||
format = $target.data('format');
|
||||
$selectFormat.text($target.text());
|
||||
setFormat(format);
|
||||
return $selectFormat.data('format', format);
|
||||
});
|
||||
$wrapper.find('.select-alt').html(JST['alt_dropdown']({
|
||||
alt: null,
|
||||
username: PokeBattle.username
|
||||
}));
|
||||
if (generation) {
|
||||
$format = $wrapper.find(".format-dropdown a[data-format='" + generation + "']");
|
||||
$format.first().click();
|
||||
$wrapper.find('.select-format').addClass('disabled');
|
||||
} else {
|
||||
$wrapper.find('.format-dropdown a').first().click();
|
||||
}
|
||||
isAttachedToDom = function() {
|
||||
return $.contains(document, $wrapper.get(0));
|
||||
};
|
||||
renderCurrentTeam($wrapper);
|
||||
teamUpdated = function() {
|
||||
if (!isAttachedToDom()) {
|
||||
PokeBattle.TeamStore.off('add remove reset saved', teamUpdated);
|
||||
return;
|
||||
}
|
||||
return renderCurrentTeam($wrapper);
|
||||
};
|
||||
return PokeBattle.TeamStore.on('add remove reset saved', teamUpdated);
|
||||
};
|
||||
|
||||
this.createChallengePane = function(opts) {
|
||||
var $PaneArray, $accept, $button, $buttons, $checkboxes, $format, $reject, $selectFormat, $wrapper, acceptEventName, altCreatedEvent, blockedClauses, cancelChallenge, cancelEventName, capitalizedEventName, defaultClauses, disableButtons, enableButtons, eventName, generation, getSelectedTeam, isAttachedToDom, personId, rejectEventName, renderCurrentTeam, selectedAlt, selectedTeamId, teamUpdated, toggleAltInput, _ref;
|
||||
var $accept, $button, $buttons, $checkboxes, $format, $reject, $selectFormat, $wrapper, acceptEventName, altCreatedEvent, blockedClauses, cancelChallenge, cancelEventName, capitalizedEventName, defaultClauses, disableButtons, enableButtons, eventName, generation, getSelectedTeam, isAttachedToDom, personId, rejectEventName, renderCurrentTeam, selectedAlt, selectedTeamId, teamUpdated, toggleAltInput, _ref;
|
||||
$wrapper = opts.populate;
|
||||
$button = opts.button;
|
||||
$accept = opts.acceptButton || $();
|
||||
@@ -5242,7 +5424,6 @@
|
||||
blockedClauses = (_ref = opts.blockedClauses) != null ? _ref : false;
|
||||
selectedTeamId = null;
|
||||
selectedAlt = null;
|
||||
$PaneArray = this.challengePaneArray;
|
||||
getSelectedTeam = function() {
|
||||
return PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0);
|
||||
};
|
||||
@@ -5303,20 +5484,13 @@
|
||||
}));
|
||||
$selectFormat = $wrapper.find(".select-format");
|
||||
$button.on('click.challenge', function() {
|
||||
var $clauses, clauses, format, team, teamJSON, thisChallenge;
|
||||
thisChallenge = _.find($PaneArray, function(butt) {
|
||||
return butt.button.selector === $button.selector;
|
||||
});
|
||||
var $clauses, clauses, format, team, teamJSON;
|
||||
PokeBattle.requestNotifyPermission();
|
||||
format = $selectFormat.data('format');
|
||||
if (typeof format === "undefined" && typeof personId === "undefined") {
|
||||
format = $('.select-format').data('format');
|
||||
}
|
||||
if (!$button.hasClass('disabled')) {
|
||||
team = getSelectedTeam();
|
||||
if (!team) {
|
||||
alert("You need to create a team using the Teambuilder before you can battle.");
|
||||
PokeBattle.navigation.showTeambuilder();
|
||||
return;
|
||||
}
|
||||
disableButtons();
|
||||
@@ -5327,7 +5501,7 @@
|
||||
$clauses.each(function() {
|
||||
return clauses.push(parseInt($(this).val(), 10));
|
||||
});
|
||||
PokeBattle.primus.send(eventName, personId, format, teamJSON, thisChallenge.clauses, selectedAlt);
|
||||
PokeBattle.primus.send(eventName, personId, format, teamJSON, clauses, selectedAlt);
|
||||
} else {
|
||||
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt);
|
||||
}
|
||||
@@ -5344,7 +5518,6 @@
|
||||
team = getSelectedTeam();
|
||||
if (!team) {
|
||||
alert("You need to create a team using the Teambuilder before you can battle.");
|
||||
PokeBattle.navigation.showTeambuilder();
|
||||
return;
|
||||
}
|
||||
disableButtons();
|
||||
@@ -5383,12 +5556,14 @@
|
||||
});
|
||||
$wrapper.find('.select-team').click(function(e) {
|
||||
var allTeams, html;
|
||||
allTeams = PokeBattle.TeamStore.models || [];
|
||||
html = JST['team_dropdown']({
|
||||
window: window,
|
||||
teams: allTeams
|
||||
});
|
||||
return $wrapper.find('.team-dropdown').html(html);
|
||||
allTeams = PokeBattle.TeamStore.models;
|
||||
if (allTeams && allTeams.length > 0) {
|
||||
html = JST['team_dropdown']({
|
||||
window: window,
|
||||
teams: allTeams
|
||||
});
|
||||
return $wrapper.find('.team-dropdown').html(html);
|
||||
}
|
||||
});
|
||||
$wrapper.find('.team-dropdown').on('click', '.select-team-dropdown-item', function(e) {
|
||||
var slot;
|
||||
@@ -5396,9 +5571,6 @@
|
||||
selectedTeamId = PokeBattle.TeamStore.at(slot).id;
|
||||
return renderCurrentTeam($wrapper);
|
||||
});
|
||||
$wrapper.find('.team-dropdown').on('click', '.build-team-option', function(e) {
|
||||
return PokeBattle.navigation.showTeambuilder();
|
||||
});
|
||||
$wrapper.find('.format-dropdown').on('click', '.select-format-dropdown-item', function(e) {
|
||||
var $target, format;
|
||||
$target = $(e.currentTarget);
|
||||
|
||||
@@ -654,7 +654,10 @@ buf.push("<li><a" + (jade.attrs({ 'data-format':("" + (format.name) + ""), "clas
|
||||
}
|
||||
}).call(this);
|
||||
|
||||
buf.push("</ul></div><p><strong>Select a team:</strong></p><div class=\"dropdown\"><div data-toggle=\"dropdown\" class=\"select select-team rounded\"><strong>Your team</strong></div><ul role=\"menu\" class=\"dropdown-menu team-dropdown\"></ul></div><p><strong>Clauses:</strong></p><ul class=\"challenge_clauses well\">");
|
||||
buf.push("</ul></div><p><strong>Select a team:</strong></p><div class=\"dropdown\"><div data-toggle=\"dropdown\" class=\"select select-team rounded\"><strong>Your team</strong></div><ul role=\"menu\" class=\"dropdown-menu team-dropdown\"></ul></div>");
|
||||
if ( defaultClauses)
|
||||
{
|
||||
buf.push("<p><strong>Clauses:</strong></p><ul class=\"challenge_clauses well\">");
|
||||
// iterate window.SelectableConditions
|
||||
;(function(){
|
||||
var $$obj = window.SelectableConditions;
|
||||
@@ -681,7 +684,8 @@ buf.push("<li><label><input" + (jade.attrs({ 'type':("checkbox"), 'value':(value
|
||||
}
|
||||
}).call(this);
|
||||
|
||||
buf.push("</ul>");;return buf.join("");
|
||||
buf.push("</ul>");
|
||||
};return buf.join("");
|
||||
};
|
||||
|
||||
this["JST"]["private_message"] = function anonymous(locals
|
||||
|
||||