1
0
mirror of https://gitlab.com/Deukhoofd/BattleSim.git synced 2025-10-28 18:20:04 +00:00

Added Smogon tiering system, made team invisible clause, sorted all pokemon

This commit is contained in:
Deukhoofd
2016-02-04 23:30:39 +01:00
parent d7316d5799
commit 398d23a0d6
23 changed files with 6735 additions and 5135 deletions

View File

@@ -185,6 +185,9 @@ class @BattleView extends Backbone.View
$this.popover(options)
pokemonPopover: ($this, pokemon) =>
if @isIllusioned(pokemon)
pokemon = pokemon.getTeam().attributes.pokemon.at(pokemon.getTeam().attributes.pokemon.length - 1)
displayName = pokemon.get('species')
displayName += " @ #{pokemon.get('item')}" if pokemon.has('item')
displayName += "<br>"

View File

@@ -56,13 +56,13 @@ class @PokemonEditView extends Backbone.View
@onPokemonChange = attributes.onPokemonChange
setFormat: (format) =>
format = Formats[format] || Formats[DEFAULT_FORMAT]
allformats = window.PokeBattle.conditions.Formats()
format = allformats[format] || allformats[DEFAULT_FORMAT]
@setGeneration(format.generation)
# TODO: Set PBV limit based on conditions
changeSort:(e) =>
sort = $(e.currentTarget).val()
console.log(sort)
if sort =="Default Sort"
@sortSpecieslist("Default")
else if sort == "Sort by Dexnumber"
@@ -74,10 +74,11 @@ class @PokemonEditView extends Backbone.View
else if sort == "Invert Alphabetically"
@sortSpecieslist("pokename", true)
sortSpecieslist: (option, reverse) =>
{MoveData, SpeciesData, ItemData} = @generation
if option == "Default"
sortedlist = @getSpecies
sortedlist = @getSpecies()
else
sortedlist = @sortObject(SpeciesData, option, reverse)
@speciesList = (species for species, data of sortedlist)
@@ -123,6 +124,9 @@ class @PokemonEditView extends Backbone.View
setTeamPBV: (pbv) =>
@teamPBV = pbv
setTeamTier: (tier) =>
@teamTier = tier
changeSpecies: (e) =>
return if not @onPokemonChange
species = $(e.currentTarget).val()
@@ -363,8 +367,13 @@ class @PokemonEditView extends Backbone.View
attachSelectize(@$el.find(".species_list"),
render:
option: (item, escape) =>
pbv = PokeBattle.PBV.determinePBV(@generation, species: item.value)
return "<div class='clearfix'>#{item.text}<div class='pbv'>#{pbv}</div></div>"
team = @pokemon.getTeam()
if team.hasPBV()
pbv = PokeBattle.PBV.determinePBV(@generation, species: item.value)
return "<div class='clearfix'>#{item.text}<div class='pbv'>#{pbv}</div></div>"
else if team.hasTier()
tier = PokeBattle.Tier.determineTier(@generation, species: item.value)
return "<div class='clearfix'>#{item.text}<div class='tier'>#{tier.humanName}</div></div>"
)
attachSelectize(@$el.find(".selected_item"))
return this
@@ -374,7 +383,7 @@ class @PokemonEditView extends Backbone.View
@renderNonStats()
@renderStats()
@renderMoves()
@renderPBV()
@renderFormat()
# Disable entering values if this is a NullPokemon
$elements = @$el.find("input, select").not(".species input, .species select")
@@ -385,14 +394,33 @@ class @PokemonEditView extends Backbone.View
renderPBV: =>
individualPBV = @pokemon.getPBV()
@$(".individual-pbv").text(individualPBV)
@$(".individual-format").text(individualPBV)
team = @pokemon.getTeam()
if team && team.hasPBV()
pbv = team.getPBV()
maxPBV = team.getMaxPBV()
@$(".total-pbv").text(pbv).toggleClass("red", pbv > maxPBV)
@$(".max-pbv").text(maxPBV)
pbv = team.getPBV()
maxPBV = team.getMaxPBV()
@$(".total-format").text(pbv).toggleClass("red", pbv > maxPBV)
@$(".max-format").text(maxPBV)
renderTier: =>
individualTier = @pokemon.getTier()
@$('.individual-format').text(individualTier.humanName)
team = @pokemon.getTeam()
if team
teamtier = team.getTier()
tier = team.getTier()
maxTier = team.getMaxTier()
@$(".total-format").text(teamtier.humanName).toggleClass("red", teamtier.tierRank > maxTier.tierRank)
@$(".max-format").text(maxTier.humanName)
renderFormat: =>
team = @pokemon.getTeam()
if team and team.hasPBV()
@renderPBV()
else if team and team.hasTier()
@renderTier()
renderSpecies: =>
@disableEventsAndExecute =>
@@ -402,6 +430,11 @@ class @PokemonEditView extends Backbone.View
@$(".selected_shininess").toggleClass("selected", @pokemon.get('shiny') == true)
@$(".selected_happiness").toggleClass("selected", @pokemon.get("happiness") == 0)
getTeam: =>
@pokemon.getTeam()
renderNonStats: =>
$nonStats = @$el.find(".non-stats")

View File

@@ -45,7 +45,8 @@ class @TeambuilderView extends Backbone.View
onPokemonChange: (newPokemon) =>
team = @getSelectedTeam()
team.replace(@selectedPokemon, newPokemon)
@renderPBV()
@renderTier()
)
clickTeam: (e) =>
@@ -72,7 +73,7 @@ class @TeambuilderView extends Backbone.View
@listenTo(team, 'add:pokemon remove:pokemon', @renderPokemonList)
@listenTo(team, 'reset:pokemon', (=> @changeTeam(team)))
@listenTo(team, 'change nested-change reset:pokemon add:pokemon remove:pokemon', @dirty)
@listenTo(team, 'change:pokemon[*] reset:pokemon add:pokemon remove:pokemon', @renderPBV)
@listenTo(team, 'change:pokemon[*] reset:pokemon add:pokemon remove:pokemon', @renderTier, @renderPBV)
# A temporary flag to attach until the teambuilder view is refactored
team.attachedTeambuildEvents = true
@@ -152,6 +153,13 @@ class @TeambuilderView extends Backbone.View
$link = $(e.currentTarget)
format = $link.data('format')
team = @getSelectedTeam()
realformat = window.PokeBattle.conditions.Formats_[format]
console.log(team.hasPBV())
console.log(team.hasTier())
if realformat.tierBased and team.hasPBV()
console.log('this')
else if !realformat.tierBased and team.hasTier()
console.log('that')
if format != team.get('generation')
team.set('generation', format)
@renderTeam()
@@ -210,7 +218,7 @@ class @TeambuilderView extends Backbone.View
@$('.save_team').addClass('disabled')
render: =>
@$el.html @template(pokemon: @getSelectedTeam(), selected: @selectedPokemon)
@$el.html @template(pokemon: @getSelectedTeam(), selected: @selectedPokemon, window: window)
@renderTeams()
renderTeams: =>
@@ -257,9 +265,17 @@ class @TeambuilderView extends Backbone.View
@pokemonEditView.setTeamPBV(totalPBV)
@pokemonEditView.renderPBV()
renderTier: (pokemon) =>
if pokemon
individualTier = pokemon.getTier()
totalTier = @getSelectedTeam().getTier()
@pokemonEditView.setTeamTier(totalTier)
@pokemonEditView.renderTier()
renderFormat: =>
allformats = window.PokeBattle.conditions.Formats()
format = @getSelectedTeam().get("generation")
format = DEFAULT_FORMAT if format not of Formats
format = DEFAULT_FORMAT if format not of allformats
text = @$(".change-format-dropdown a[data-format='#{format}']").text()
@$(".current-format").text(text)