Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More work on the teambuilder #234

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions client/app/css/teambuilder.styl
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ $pokemon-list-height = 50px
.hidden-power
float right

.ev-lock
float left
margin-right 5px
cursor pointer
.icon-lock
color #444
.icon-unlocked
color #888

.remaining-evs-amount.over-limit
color $negative-color
font-weight bold
Expand Down Expand Up @@ -313,9 +322,8 @@ $pokemon-list-height = 50px
opacity .8
font-weight bold

.teambuilder .table-moves
.table-moves
border-collapse separate
margin-top 8px
border solid 1px #DDD
thead th
background whitesmoke
Expand All @@ -328,8 +336,17 @@ $pokemon-list-height = 50px
background #f0f0f9
&:first-child
text-decoration underline
&.selected td
background #f0f0f9
&:first-child
font-weight bold
img
margin-bottom 3px
.name
white-space nowrap

.teambuilder .table-moves
margin-top 8px

.teambuilder .display_teams
position absolute
Expand Down
15 changes: 11 additions & 4 deletions client/app/js/helpers/challenge_pane.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@

$wrapper.html(JST['new_battle']({window, defaultClauses}))
$selectFormat = $wrapper.find(".select-format")

# Implement finding battle/challenging
$button.on 'click.challenge', ->
# Start requesting for notify permission here
PokeBattle.requestNotifyPermission()

format = $selectFormat.data('format')

# Toggle state when you press the button.
if !$button.hasClass('disabled')
team = getSelectedTeam()
unless team
alert("You need to create a team using the Teambuilder before you can battle.")
PokeBattle.navigation.showTeambuilder()
return

disableButtons()
Expand All @@ -100,6 +103,7 @@
team = getSelectedTeam()
unless team
alert("You need to create a team using the Teambuilder before you can battle.")
PokeBattle.navigation.showTeambuilder()
return
disableButtons()
teamJSON = team.toNonNullJSON().pokemon
Expand Down Expand Up @@ -136,17 +140,20 @@
# Clicking the team dropdown brings down a team selection menu.
# Also updates the allTeams collection
$wrapper.find('.select-team').click (e) ->
allTeams = PokeBattle.TeamStore.models
if allTeams && allTeams.length > 0
html = JST['team_dropdown'](window: window, teams: allTeams)
$wrapper.find('.team-dropdown').html(html)
allTeams = PokeBattle.TeamStore.models || []
html = JST['team_dropdown'](window: window, teams: allTeams)
$wrapper.find('.team-dropdown').html(html)

# Selecting a team from the menu
$wrapper.find('.team-dropdown').on 'click', '.select-team-dropdown-item', (e) ->
slot = $(e.currentTarget).data('slot')
selectedTeamId = PokeBattle.TeamStore.at(slot).id
renderCurrentTeam($wrapper)

# Selecting build team from the menu
$wrapper.find('.team-dropdown').on 'click', '.build-team-option', (e) ->
PokeBattle.navigation.showTeambuilder()

# Selecting the format changes the dropdown.
$wrapper.find('.format-dropdown').on 'click', '.select-format-dropdown-item', (e) ->
$target = $(e.currentTarget)
Expand Down
16 changes: 16 additions & 0 deletions client/app/js/models/battles/pokemon.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class @Pokemon extends Backbone.Model
getSelectableFormes: ->
_(@getFormes()).reject((forme) => @getForme(forme).isBattleOnly)

# Returns all mega formes
getMegaFormes: ->
_(@getFormes()).reject((forme) => forme.indexOf('mega') != 0)

getAbilities: ->
forme = @getForme()
abilities = _.clone(forme.abilities)
Expand All @@ -120,6 +124,9 @@ class @Pokemon extends Backbone.Model
genders.push("M", "F")
genders

hasSelectedMove: (moveName) ->
moveName && moveName in @moves

getMovepool: ->
{SpeciesData, MoveData} = @getGeneration()
generation = GENERATION_TO_INT[@collection?.generation || DEFAULT_GENERATION]
Expand Down Expand Up @@ -230,12 +237,21 @@ class @Pokemon extends Backbone.Model
"Healthy"

canMegaEvolve: ->
# TODO: Refactor this to use getPossibleMegaForme()
# I didn't feel like making the change and testing it while implementing getPossibleMegaForme()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically I didn't want to have to test the battle system to make a change for the teambuilder.

item = @getItem()
return false if item.type != 'megastone'
[ species, forme ] = item.mega
return false if @get('species') != species || @get('forme') != 'default'
return true

getPossibleMegaForme: ->
item = @getItem()
return null if item?.type != 'megastone'
[ species, forme ] = item.mega
return forme if @get('species') == species && @get('forme') == 'default'
return null

# Returns the complete web address to the pokedex link for this pokemon.
# For this project, this leads to our website at http://www.pokebattle.com,
# but if you want it to lead somewhere else, edit this function.
Expand Down
Loading