Removed alt button, set level to max level for generation on team creation as to prevent confusion. Feature Complete for 1.0 beta.
This commit is contained in:
parent
1114909caf
commit
ed924b9957
|
@ -1,189 +1,189 @@
|
||||||
# eventName should be one of "challenge" or "find battle"
|
# eventName should be one of "challenge" or "find battle"
|
||||||
# opts may include whether to enable clauses, for example
|
# opts may include whether to enable clauses, for example
|
||||||
@challengePaneArray = []
|
@challengePaneArray = []
|
||||||
|
|
||||||
class @challengePaneObject
|
class @challengePaneObject
|
||||||
constructor: (@object) ->
|
constructor: (@object) ->
|
||||||
@event = @object.eventName
|
@event = @object.eventName
|
||||||
@button = @object.button
|
@button = @object.button
|
||||||
@populate = @object.populate
|
@populate = @object.populate
|
||||||
@clauses = @object.defaultClauses
|
@clauses = @object.defaultClauses
|
||||||
@blockedClauses = @object.blockedClauses
|
@blockedClauses = @object.blockedClauses
|
||||||
|
|
||||||
@SelectedTeamID = null
|
@SelectedTeamID = null
|
||||||
@SelectedFormat = null
|
@SelectedFormat = null
|
||||||
|
|
||||||
@ChallengePaneOpts =
|
@ChallengePaneOpts =
|
||||||
SelectedTeamID : null
|
SelectedTeamID : null
|
||||||
SelectedFormat : null
|
SelectedFormat : null
|
||||||
SelectedAlt : null
|
SelectedAlt : null
|
||||||
|
|
||||||
@createChallengeButton = (opts) ->
|
@createChallengeButton = (opts) ->
|
||||||
$button = opts.button
|
$button = opts.button
|
||||||
$eventName = opts.eventName
|
$eventName = opts.eventName
|
||||||
$clauses = opts.clauses
|
$clauses = opts.clauses
|
||||||
capitalizedEventName = "#{$eventName[0].toUpperCase()}#{$eventName.substr(1)}"
|
capitalizedEventName = "#{$eventName[0].toUpperCase()}#{$eventName.substr(1)}"
|
||||||
acceptEventName = "accept#{capitalizedEventName}"
|
acceptEventName = "accept#{capitalizedEventName}"
|
||||||
rejectEventName = "reject#{capitalizedEventName}"
|
rejectEventName = "reject#{capitalizedEventName}"
|
||||||
cancelEventName = "cancel#{capitalizedEventName}"
|
cancelEventName = "cancel#{capitalizedEventName}"
|
||||||
|
|
||||||
|
|
||||||
getSelectedTeam = ->
|
getSelectedTeam = ->
|
||||||
PokeBattle.TeamStore.get(@ChallengePaneOpts.SelectedTeamID) || PokeBattle.TeamStore.at(0)
|
PokeBattle.TeamStore.get(@ChallengePaneOpts.SelectedTeamID) || PokeBattle.TeamStore.at(0)
|
||||||
|
|
||||||
cancelChallenge = ->
|
cancelChallenge = ->
|
||||||
#enableButtons()
|
#enableButtons()
|
||||||
format = getChallengeOpts().SelectedFormat
|
format = getChallengeOpts().SelectedFormat
|
||||||
PokeBattle.primus.send(cancelEventName, format)
|
PokeBattle.primus.send(cancelEventName, format)
|
||||||
$button.trigger('cancelChallenge')
|
$button.trigger('cancelChallenge')
|
||||||
|
|
||||||
getChallengeOpts = ->
|
getChallengeOpts = ->
|
||||||
return @ChallengePaneOpts
|
return @ChallengePaneOpts
|
||||||
|
|
||||||
|
|
||||||
disableButtons = ->
|
disableButtons = ->
|
||||||
$('.select').addClass('disabled')
|
$('.select').addClass('disabled')
|
||||||
#$buttons.addClass('disabled')
|
#$buttons.addClass('disabled')
|
||||||
|
|
||||||
defaultformat = ->
|
defaultformat = ->
|
||||||
return @DEFAULT_FORMAT
|
return @DEFAULT_FORMAT
|
||||||
|
|
||||||
$button.on 'click.challenge', ->
|
$button.on 'click.challenge', ->
|
||||||
# Start requesting for notify permission here
|
# Start requesting for notify permission here
|
||||||
PokeBattle.requestNotifyPermission()
|
PokeBattle.requestNotifyPermission()
|
||||||
options = getChallengeOpts()
|
options = getChallengeOpts()
|
||||||
if options.SelectedFormat != null
|
if options.SelectedFormat != null
|
||||||
format = options.SelectedFormat
|
format = options.SelectedFormat
|
||||||
else
|
else
|
||||||
format = defaultformat()
|
format = defaultformat()
|
||||||
# Toggle state when you press the button.
|
# Toggle state when you press the button.
|
||||||
if !$button.hasClass('disabled')
|
if !$button.hasClass('disabled')
|
||||||
team = getSelectedTeam()
|
team = getSelectedTeam()
|
||||||
unless team
|
unless team
|
||||||
alert("You need to create a team using the Teambuilder before you can battle.")
|
alert("You need to create a team using the Teambuilder before you can battle.")
|
||||||
PokeBattle.navigation.showTeambuilder()
|
PokeBattle.navigation.showTeambuilder()
|
||||||
return
|
return
|
||||||
disableButtons()
|
disableButtons()
|
||||||
teamJSON = team.toNonNullJSON().pokemon
|
teamJSON = team.toNonNullJSON().pokemon
|
||||||
# Send the event
|
# Send the event
|
||||||
PokeBattle.primus.send($eventName, format, teamJSON, options.selectedAlt)
|
PokeBattle.primus.send($eventName, format, teamJSON, options.selectedAlt)
|
||||||
$button.addClass('disabled').trigger('challenge')
|
$button.addClass('disabled').trigger('challenge')
|
||||||
else
|
else
|
||||||
cancelChallenge()
|
cancelChallenge()
|
||||||
|
|
||||||
|
|
||||||
@createChallengePaneNew = (opts) ->
|
@createChallengePaneNew = (opts) ->
|
||||||
$wrapper = opts.populate
|
$wrapper = opts.populate
|
||||||
$accept = opts.acceptButton || $()
|
$accept = opts.acceptButton || $()
|
||||||
$reject = opts.rejectButton || $()
|
$reject = opts.rejectButton || $()
|
||||||
generation = opts.generation
|
generation = opts.generation
|
||||||
getSelectedTeam = ->
|
getSelectedTeam = ->
|
||||||
PokeBattle.TeamStore.get(@ChallengePaneOpts.SelectedTeamID) || PokeBattle.TeamStore.at(0)
|
PokeBattle.TeamStore.get(@ChallengePaneOpts.SelectedTeamID) || PokeBattle.TeamStore.at(0)
|
||||||
|
|
||||||
renderCurrentTeam = ($context) ->
|
renderCurrentTeam = ($context) ->
|
||||||
$selectTeam = $context.find('.select-team')
|
$selectTeam = $context.find('.select-team')
|
||||||
if PokeBattle.TeamStore.length > 0
|
if PokeBattle.TeamStore.length > 0
|
||||||
currentTeam = getSelectedTeam()
|
currentTeam = getSelectedTeam()
|
||||||
html = JST['team_dropdown'](window: window, team: currentTeam)
|
html = JST['team_dropdown'](window: window, team: currentTeam)
|
||||||
$selectTeam.html(html)
|
$selectTeam.html(html)
|
||||||
else
|
else
|
||||||
$selectTeam.html("You have no teams!")
|
$selectTeam.html("You have no teams!")
|
||||||
|
|
||||||
disableButtons = ->
|
disableButtons = ->
|
||||||
$('.select').addClass('disabled')
|
$('.select').addClass('disabled')
|
||||||
|
|
||||||
$wrapper.html(JST['new_battle']({window}))
|
$wrapper.html(JST['new_battle']({window}))
|
||||||
$selectFormat = $wrapper.find(".select-format")
|
$selectFormat = $wrapper.find(".select-format")
|
||||||
|
|
||||||
# Clicking the alts dropdown brings down an alt selection dropdown menu
|
# Clicking the alts dropdown brings down an alt selection dropdown menu
|
||||||
$wrapper.find('.select-alt').click (e) ->
|
$wrapper.find('.select-alt').click (e) ->
|
||||||
html = JST['alt_dropdown'](alts: PokeBattle.alts.list, username: PokeBattle.username)
|
html = JST['alt_dropdown'](alts: PokeBattle.alts.list, username: PokeBattle.username)
|
||||||
$wrapper.find('.alt-dropdown').html(html)
|
$wrapper.find('.alt-dropdown').html(html)
|
||||||
|
|
||||||
setAlt = (altname) ->
|
setAlt = (altname) ->
|
||||||
@ChallengePaneOpts.SelectedAlt = altname
|
@ChallengePaneOpts.SelectedAlt = altname
|
||||||
|
|
||||||
# Selecting an alt from the dropdown
|
# Selecting an alt from the dropdown
|
||||||
$wrapper.find('.alt-dropdown').on 'click', '.select-alt-dropdown-item', (e) ->
|
$wrapper.find('.alt-dropdown').on 'click', '.select-alt-dropdown-item', (e) ->
|
||||||
setAlt($(this).data('alt-name'))
|
setAlt($(this).data('alt-name'))
|
||||||
$wrapper.find('.select-alt').html($(this).html())
|
$wrapper.find('.select-alt').html($(this).html())
|
||||||
|
|
||||||
# When add alt is clicked, show the alt input form
|
# When add alt is clicked, show the alt input form
|
||||||
$wrapper.find('.alt-dropdown').on 'click', '.add-alt-dropdown-item', (e) ->
|
$wrapper.find('.alt-dropdown').on 'click', '.add-alt-dropdown-item', (e) ->
|
||||||
toggleAltInput(true)
|
toggleAltInput(true)
|
||||||
|
|
||||||
# Clicking the Add Alt Button
|
# Clicking the Add Alt Button
|
||||||
$wrapper.find('.alt-input .add-button').click (e) ->
|
$wrapper.find('.alt-input .add-button').click (e) ->
|
||||||
altName = $wrapper.find('.alt-input input').val().trim()
|
altName = $wrapper.find('.alt-input input').val().trim()
|
||||||
PokeBattle.alts.createAlt(altName)
|
PokeBattle.alts.createAlt(altName)
|
||||||
|
|
||||||
# Clicking the Cancel Add Alt Button
|
# Clicking the Cancel Add Alt Button
|
||||||
$wrapper.find('.alt-input .cancel-button').click (e) ->
|
$wrapper.find('.alt-input .cancel-button').click (e) ->
|
||||||
toggleAltInput(false)
|
toggleAltInput(false)
|
||||||
|
|
||||||
# Clicking the team dropdown brings down a team selection menu.
|
# Clicking the team dropdown brings down a team selection menu.
|
||||||
# Also updates the allTeams collection
|
# Also updates the allTeams collection
|
||||||
$wrapper.find('.select-team').click (e) ->
|
$wrapper.find('.select-team').click (e) ->
|
||||||
allTeams = PokeBattle.TeamStore.models || []
|
allTeams = PokeBattle.TeamStore.models || []
|
||||||
html = JST['team_dropdown'](window: window, teams: allTeams)
|
html = JST['team_dropdown'](window: window, teams: allTeams)
|
||||||
$wrapper.find('.team-dropdown').html(html)
|
$wrapper.find('.team-dropdown').html(html)
|
||||||
|
|
||||||
setTeam = (slot) ->
|
setTeam = (slot) ->
|
||||||
@ChallengePaneOpts.SelectedTeamID = PokeBattle.TeamStore.at(slot).id
|
@ChallengePaneOpts.SelectedTeamID = PokeBattle.TeamStore.at(slot).id
|
||||||
|
|
||||||
# Selecting a team from the menu
|
# Selecting a team from the menu
|
||||||
$wrapper.find('.team-dropdown').on 'click', '.select-team-dropdown-item', (e) ->
|
$wrapper.find('.team-dropdown').on 'click', '.select-team-dropdown-item', (e) ->
|
||||||
slot = $(e.currentTarget).data('slot')
|
slot = $(e.currentTarget).data('slot')
|
||||||
setTeam(slot)
|
setTeam(slot)
|
||||||
renderCurrentTeam($wrapper)
|
renderCurrentTeam($wrapper)
|
||||||
|
|
||||||
# Selecting build team from the menu
|
# Selecting build team from the menu
|
||||||
$wrapper.find('.team-dropdown').on 'click', '.build-team-option', (e) ->
|
$wrapper.find('.team-dropdown').on 'click', '.build-team-option', (e) ->
|
||||||
PokeBattle.navigation.showTeambuilder()
|
PokeBattle.navigation.showTeambuilder()
|
||||||
|
|
||||||
setFormat = (format) ->
|
setFormat = (format) ->
|
||||||
@ChallengePaneOpts.SelectedFormat = format
|
@ChallengePaneOpts.SelectedFormat = format
|
||||||
|
|
||||||
# Selecting the format changes the dropdown.
|
# Selecting the format changes the dropdown.
|
||||||
$wrapper.find('.format-dropdown').on 'click', '.select-format-dropdown-item', (e) ->
|
$wrapper.find('.format-dropdown').on 'click', '.select-format-dropdown-item', (e) ->
|
||||||
$target = $(e.currentTarget)
|
$target = $(e.currentTarget)
|
||||||
format = $target.data('format')
|
format = $target.data('format')
|
||||||
$selectFormat.text($target.text())
|
$selectFormat.text($target.text())
|
||||||
setFormat(format)
|
setFormat(format)
|
||||||
$selectFormat.data('format', format)
|
$selectFormat.data('format', format)
|
||||||
|
|
||||||
# Select non-alt option
|
# Select non-alt option
|
||||||
$wrapper.find('.select-alt').html(JST['alt_dropdown'](alt: null, username: PokeBattle.username))
|
$wrapper.find('.select-alt').html(JST['alt_dropdown'](alt: null, username: PokeBattle.username))
|
||||||
|
|
||||||
# Auto-select format.
|
# Auto-select format.
|
||||||
if generation
|
if generation
|
||||||
# If a generation is passed, auto-select it.
|
# If a generation is passed, auto-select it.
|
||||||
$format = $wrapper.find(".format-dropdown a[data-format='#{generation}']")
|
$format = $wrapper.find(".format-dropdown a[data-format='#{generation}']")
|
||||||
$format.first().click()
|
$format.first().click()
|
||||||
$wrapper.find('.select-format').addClass('disabled')
|
$wrapper.find('.select-format').addClass('disabled')
|
||||||
else
|
else
|
||||||
# Auto-select first available format.
|
# Auto-select first available format.
|
||||||
$wrapper.find('.format-dropdown a').first().click()
|
$wrapper.find('.format-dropdown a').first().click()
|
||||||
|
|
||||||
isAttachedToDom = ->
|
isAttachedToDom = ->
|
||||||
$.contains(document, $wrapper.get(0))
|
$.contains(document, $wrapper.get(0))
|
||||||
|
|
||||||
|
|
||||||
renderCurrentTeam($wrapper)
|
renderCurrentTeam($wrapper)
|
||||||
|
|
||||||
# Called when a team has been updated
|
# Called when a team has been updated
|
||||||
teamUpdated = ->
|
teamUpdated = ->
|
||||||
# If this challenge panel no longer exists, remove the callback
|
# If this challenge panel no longer exists, remove the callback
|
||||||
if not isAttachedToDom()
|
if not isAttachedToDom()
|
||||||
PokeBattle.TeamStore.off 'add remove reset saved', teamUpdated
|
PokeBattle.TeamStore.off 'add remove reset saved', teamUpdated
|
||||||
return
|
return
|
||||||
|
|
||||||
# Rerender the current team
|
# Rerender the current team
|
||||||
renderCurrentTeam($wrapper)
|
renderCurrentTeam($wrapper)
|
||||||
|
|
||||||
# Start listening for team updated events
|
# Start listening for team updated events
|
||||||
PokeBattle.TeamStore.on 'add remove reset saved', teamUpdated
|
PokeBattle.TeamStore.on 'add remove reset saved', teamUpdated
|
||||||
|
|
||||||
@createChallengePane = (opts) ->
|
@createChallengePane = (opts) ->
|
||||||
$wrapper = opts.populate
|
$wrapper = opts.populate
|
||||||
$button = opts.button
|
$button = opts.button
|
||||||
|
@ -373,4 +373,4 @@ class @challengePaneObject
|
||||||
renderCurrentTeam($wrapper)
|
renderCurrentTeam($wrapper)
|
||||||
|
|
||||||
# Start listening for team updated events
|
# Start listening for team updated events
|
||||||
PokeBattle.TeamStore.on 'add remove reset saved', teamUpdated
|
PokeBattle.TeamStore.on 'add remove reset saved', teamUpdated
|
|
@ -183,8 +183,12 @@ class @PokemonEditView extends Backbone.View
|
||||||
value = parseInt($input.val(), 10)
|
value = parseInt($input.val(), 10)
|
||||||
value = @generation.maxLevel if isNaN(value) || value > @generation.maxLevel
|
value = @generation.maxLevel if isNaN(value) || value > @generation.maxLevel
|
||||||
value = 1 if value < 1
|
value = 1 if value < 1
|
||||||
$input.val(value)
|
@changeLevel2(value)
|
||||||
@pokemon.set("level", value)
|
|
||||||
|
changeLevel2: (level) =>
|
||||||
|
$levelBox = $(".selected_level")
|
||||||
|
$levelBox.val(level)
|
||||||
|
@pokemon.set("level", level)
|
||||||
|
|
||||||
changeIv: (e) =>
|
changeIv: (e) =>
|
||||||
# todo: make changeIv and changeEv DRY
|
# todo: make changeIv and changeEv DRY
|
||||||
|
@ -391,6 +395,7 @@ class @PokemonEditView extends Backbone.View
|
||||||
@renderStats()
|
@renderStats()
|
||||||
@renderMoves()
|
@renderMoves()
|
||||||
@renderFormat()
|
@renderFormat()
|
||||||
|
@changeLevel2(@generation.maxLevel) if typeof @pokemon.get("level") == "undefined"
|
||||||
|
|
||||||
# Disable entering values if this is a NullPokemon
|
# Disable entering values if this is a NullPokemon
|
||||||
$elements = @$el.find("input, select").not(".species input, .species select")
|
$elements = @$el.find("input, select").not(".species input, .species select")
|
||||||
|
|
|
@ -1,15 +1,3 @@
|
||||||
p
|
|
||||||
strong In-battle display name:
|
|
||||||
.alt-input.clearfix.hidden
|
|
||||||
.input-wrapper
|
|
||||||
input(type="text")
|
|
||||||
.buttons-wrapper
|
|
||||||
button.button.add-button Add
|
|
||||||
button.button.cancel-button Cancel
|
|
||||||
.alt-dropdown-section.dropdown
|
|
||||||
.select.select-alt(data-toggle="dropdown")
|
|
||||||
ul.dropdown-menu.alt-dropdown(role = "menu")
|
|
||||||
|
|
||||||
p
|
p
|
||||||
strong Format:
|
strong Format:
|
||||||
.dropdown
|
.dropdown
|
||||||
|
|
|
@ -5496,6 +5496,7 @@
|
||||||
this.changeEv = __bind(this.changeEv, this);
|
this.changeEv = __bind(this.changeEv, this);
|
||||||
this.focusEv = __bind(this.focusEv, this);
|
this.focusEv = __bind(this.focusEv, this);
|
||||||
this.changeIv = __bind(this.changeIv, this);
|
this.changeIv = __bind(this.changeIv, this);
|
||||||
|
this.changeLevel2 = __bind(this.changeLevel2, this);
|
||||||
this.changeLevel = __bind(this.changeLevel, this);
|
this.changeLevel = __bind(this.changeLevel, this);
|
||||||
this.changeGender = __bind(this.changeGender, this);
|
this.changeGender = __bind(this.changeGender, this);
|
||||||
this.changeItem = __bind(this.changeItem, this);
|
this.changeItem = __bind(this.changeItem, this);
|
||||||
|
@ -5750,8 +5751,14 @@
|
||||||
if (value < 1) {
|
if (value < 1) {
|
||||||
value = 1;
|
value = 1;
|
||||||
}
|
}
|
||||||
$input.val(value);
|
return this.changeLevel2(value);
|
||||||
return this.pokemon.set("level", value);
|
};
|
||||||
|
|
||||||
|
PokemonEditView.prototype.changeLevel2 = function(level) {
|
||||||
|
var $levelBox;
|
||||||
|
$levelBox = $(".selected_level");
|
||||||
|
$levelBox.val(level);
|
||||||
|
return this.pokemon.set("level", level);
|
||||||
};
|
};
|
||||||
|
|
||||||
PokemonEditView.prototype.changeIv = function(e) {
|
PokemonEditView.prototype.changeIv = function(e) {
|
||||||
|
@ -6031,6 +6038,9 @@
|
||||||
this.renderStats();
|
this.renderStats();
|
||||||
this.renderMoves();
|
this.renderMoves();
|
||||||
this.renderFormat();
|
this.renderFormat();
|
||||||
|
if (typeof this.pokemon.get("level") === "undefined") {
|
||||||
|
this.changeLevel2(this.generation.maxLevel);
|
||||||
|
}
|
||||||
$elements = this.$el.find("input, select").not(".species input, .species select");
|
$elements = this.$el.find("input, select").not(".species input, .species select");
|
||||||
$elements.prop("disabled", this.pokemon.isNull);
|
$elements.prop("disabled", this.pokemon.isNull);
|
||||||
setSelectizeDisabled($elements, this.pokemon.isNull);
|
setSelectizeDisabled($elements, this.pokemon.isNull);
|
||||||
|
|
|
@ -626,7 +626,7 @@ buf.push("<p class=\"logo\"></p><h2>Chat</h2><ul class=\"nav nav_rooms\"><li cla
|
||||||
this["JST"]["new_battle"] = function anonymous(locals
|
this["JST"]["new_battle"] = function anonymous(locals
|
||||||
/**/) {
|
/**/) {
|
||||||
var buf = [];
|
var buf = [];
|
||||||
var locals_ = (locals || {}),window = locals_.window,defaultClauses = locals_.defaultClauses;buf.push("<p><strong>In-battle display name:</strong></p><div class=\"alt-input clearfix hidden\"><div class=\"input-wrapper\"><input type=\"text\"/></div><div class=\"buttons-wrapper\"><button class=\"button add-button\">Add</button><button class=\"button cancel-button\">Cancel</button></div></div><div class=\"alt-dropdown-section dropdown\"><div data-toggle=\"dropdown\" class=\"select select-alt\"></div><ul role=\"menu\" class=\"dropdown-menu alt-dropdown\"></ul></div><p><strong>Format:</strong></p><div class=\"dropdown\"><div data-toggle=\"dropdown\" class=\"select select-format\"></div><ul role=\"menu\" class=\"dropdown-menu format-dropdown\">");
|
var locals_ = (locals || {}),window = locals_.window,defaultClauses = locals_.defaultClauses;buf.push("<p><strong>Format:</strong></p><div class=\"dropdown\"><div data-toggle=\"dropdown\" class=\"select select-format\"></div><ul role=\"menu\" class=\"dropdown-menu format-dropdown\">");
|
||||||
var allformats = window.PokeBattle.conditions.Formats()
|
var allformats = window.PokeBattle.conditions.Formats()
|
||||||
// iterate allformats
|
// iterate allformats
|
||||||
;(function(){
|
;(function(){
|
||||||
|
|
Loading…
Reference in New Issue