mirror of
https://gitlab.com/Deukhoofd/BattleSim.git
synced 2025-10-27 18:00:03 +00:00
Added Smogon tiering system, made team invisible clause, sorted all pokemon
This commit is contained in:
@@ -119,6 +119,9 @@ a, .fake_link
|
||||
.team-pbv
|
||||
font-size 0.75em
|
||||
|
||||
.team-tier
|
||||
font-size 0.75em
|
||||
|
||||
// Typography
|
||||
|
||||
.monospace
|
||||
|
||||
@@ -33,7 +33,7 @@ $pokemon-list-height = 50px
|
||||
top $header
|
||||
bottom 0
|
||||
background-color $body-color
|
||||
width: 150px
|
||||
width: 160px
|
||||
|
||||
ul
|
||||
list-style-type none
|
||||
@@ -365,6 +365,9 @@ $pokemon-list-height = 50px
|
||||
.team-pbv
|
||||
margin-top -5px
|
||||
|
||||
.team-tier
|
||||
margin-top -5px
|
||||
|
||||
textarea.textarea_modal
|
||||
box-sizing border-box
|
||||
width 100%
|
||||
|
||||
@@ -19,7 +19,8 @@ class @Battle extends Backbone.AssociatedModel
|
||||
@updateQueue = []
|
||||
{@numActive, spectators} = attributes
|
||||
@spectators = new UserList(spectators) unless !spectators
|
||||
@set('generation', Formats[@get('format')].generation)
|
||||
allformats = window.PokeBattle.conditions.Formats()
|
||||
@set('generation', allformats[@get('format')].generation)
|
||||
@set('notifications', 0)
|
||||
@set('turn', 0)
|
||||
@set('teams', [{hidden: true}, {hidden: true}])
|
||||
|
||||
@@ -135,7 +135,6 @@ class @Pokemon extends Backbone.Model
|
||||
|
||||
# Map each move name to a move object
|
||||
return _(learnset).map (moveName) ->
|
||||
console.log(moveName)
|
||||
move = _(MoveData[moveName]).clone()
|
||||
move['name'] = moveName
|
||||
move
|
||||
@@ -213,6 +212,10 @@ class @Pokemon extends Backbone.Model
|
||||
gen = @getGeneration()
|
||||
PokeBattle.PBV.determinePBV(gen, @attributes)
|
||||
|
||||
getTier: ->
|
||||
gen = @getGeneration()
|
||||
PokeBattle.Tier.determineTier(gen, @attributes)
|
||||
|
||||
setPP: (moveIndex, newPP) ->
|
||||
array = _.clone(@get('pp'))
|
||||
array[moveIndex] = newPP
|
||||
|
||||
@@ -66,8 +66,9 @@ class @Team extends Backbone.AssociatedModel
|
||||
|
||||
getFormat: =>
|
||||
format = @get('generation') # TODO: Migrate to format
|
||||
format = DEFAULT_FORMAT if format not of Formats
|
||||
Formats[format]
|
||||
allformats = window.PokeBattle.conditions.Formats()
|
||||
format = DEFAULT_FORMAT if format not of allformats
|
||||
allformats[format]
|
||||
|
||||
getGeneration: (generation) ->
|
||||
gen = generation || @getFormat().generation
|
||||
@@ -79,6 +80,11 @@ class @Team extends Backbone.AssociatedModel
|
||||
pokemon = @get('pokemon').toJSON()
|
||||
PokeBattle.PBV.determinePBV(gen, pokemon)
|
||||
|
||||
getTier: =>
|
||||
gen = @getGeneration()
|
||||
pokemon = @get('pokemon').toJSON()
|
||||
PokeBattle.Tier.determineTier(gen, pokemon)
|
||||
|
||||
getMaxPBV: =>
|
||||
{conditions} = @getFormat()
|
||||
if Conditions.PBV_1000 in conditions
|
||||
@@ -91,6 +97,23 @@ class @Team extends Backbone.AssociatedModel
|
||||
hasPBV: =>
|
||||
@getMaxPBV() > 0
|
||||
|
||||
hasTier: =>
|
||||
typeof @getMaxTier() != 'undefined'
|
||||
|
||||
getMaxTierName: =>
|
||||
{conditions} = @getFormat()
|
||||
for condition in conditions
|
||||
tiername = _.invert(Conditions)[condition]
|
||||
if (tiername.search /TIER_/) == 0
|
||||
tier = tiername.replace /TIER_/, ""
|
||||
tier
|
||||
|
||||
getMaxTier: =>
|
||||
tiername = @getMaxTierName()
|
||||
if tiername
|
||||
tier = PokeBattle.Tier.Tiers[tiername]
|
||||
tier
|
||||
|
||||
getNonNullPokemon: =>
|
||||
@get('pokemon').where(isNull: false)
|
||||
|
||||
|
||||
@@ -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>"
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -15,12 +15,10 @@ p
|
||||
.dropdown
|
||||
.select.select-format(data-toggle = "dropdown")
|
||||
ul.dropdown-menu.format-dropdown(role = "menu")
|
||||
li
|
||||
a.select-format-dropdown-item(data-format="insur1000") 1000 PBV Insurgence
|
||||
li
|
||||
a.select-format-dropdown-item(data-format="xy1000") 1000 PBV XY
|
||||
li
|
||||
a.select-format-dropdown-item(data-format="xy500") 500 PBV XY
|
||||
- var allformats = window.PokeBattle.conditions.Formats()
|
||||
each format in allformats
|
||||
li
|
||||
a.select-format-dropdown-item(data-format="#{format.name}") #{format.humanName}
|
||||
|
||||
p
|
||||
strong Select a team:
|
||||
|
||||
@@ -5,6 +5,14 @@ if team.hasPBV()
|
||||
else
|
||||
span.red= team.getPBV()
|
||||
| /#{team.getMaxPBV()}
|
||||
else if team.hasTier()
|
||||
.team-tier Tier:
|
||||
if team.getTier().tierRank <= team.getMaxTier().tierRank
|
||||
= team.getTier().humanName
|
||||
else
|
||||
span.red= team.getTier().humanName
|
||||
| /#{team.getMaxTier().humanName}
|
||||
|
||||
.team_icons.clearfix
|
||||
each pokemon, i in team.get('pokemon').models
|
||||
- var style = window.PokemonIconBackground(pokemon)
|
||||
|
||||
@@ -5,13 +5,11 @@
|
||||
.team_meta_buttons
|
||||
.dropdown.change-format-dropdown.left
|
||||
.current-format.button.dropdown-toggle(data-toggle="dropdown")
|
||||
- var allformats = window.PokeBattle.conditions.Formats()
|
||||
ul.dropdown-menu(role="menu")
|
||||
li
|
||||
a(href="#", data-format="insur1000") 1000 PBV Insurgence
|
||||
li
|
||||
a(href="#", data-format="xy1000") 1000 PBV XY
|
||||
li
|
||||
a(href="#", data-format="xy500") 500 PBV XY
|
||||
for format in allformats
|
||||
li
|
||||
a(href="#", data-format="#{format.name}") #{format.humanName}
|
||||
.button.button_blue.save_team.disabled Save
|
||||
.button.go_back Back
|
||||
.navigation
|
||||
|
||||
@@ -25,16 +25,15 @@ mixin printStat(statName, keyName)
|
||||
each species in speciesList
|
||||
option(value=species)= species
|
||||
.species-info
|
||||
|
||||
.non-stats
|
||||
.teambuilder_row.pbv-row
|
||||
.teambuilder_col.non-stat-label PBV:
|
||||
.teambuilder_row.format_row
|
||||
.teambuilder_col.non-stat.label.formatname
|
||||
.teambuilder_col
|
||||
span.individual-pbv
|
||||
span.individual-format
|
||||
.right
|
||||
span.total-pbv
|
||||
span.total-format
|
||||
/
|
||||
span.max-pbv
|
||||
span.max-format
|
||||
.teambuilder_row
|
||||
.teambuilder_col.non-stat-label Nickname:
|
||||
.teambuilder_col
|
||||
|
||||
@@ -7,6 +7,11 @@ each pokemon, i in pokemonList
|
||||
em.name Empty
|
||||
else
|
||||
.name= pokemon.get("species")
|
||||
.pokemon-pbv
|
||||
| PBV:
|
||||
span.pbv-value= pokemon.getPBV()
|
||||
if pokemon.getTeam().hasPBV()
|
||||
.pokemon-pbv
|
||||
| PBV:
|
||||
span.pbv-value= pokemon.getPBV()
|
||||
else if pokemon.getTeam().hasTier()
|
||||
.pokemon-pbv
|
||||
| Tier:
|
||||
span.pbv-value= pokemon.getTier().humanName
|
||||
Reference in New Issue
Block a user