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

Added Find Battle Unranked

This commit is contained in:
Deukhoofd
2016-02-10 03:10:17 +01:00
parent 398d23a0d6
commit 16ac69171d
23 changed files with 778 additions and 419 deletions

View File

@@ -4,6 +4,57 @@ $ ->
$mainButtons.on 'click', '.teambuilder_button', (e) ->
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 =
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
createChallengePane
eventName: "findBattle"
populate: $mainButtons.find('.find_battle_select_team')
@@ -26,6 +77,12 @@ $ ->
.addClass('icon-spinner spinner-anim')
.removeClass("icon-earth")
$mainButtons.find('.find_battle_non_ranked').on 'challenge', ->
$this = $(this)
$this.find('.find-icon')
.addClass('icon-spinner spinner-anim')
.removeClass("icon-earth")
$mainButtons.find('.display_credits').click ->
$modal = PokeBattle.modal('modals/credits')
$modal.find('.modal-footer button').first().focus()
@@ -40,11 +97,24 @@ depressFindBattle = ->
.addClass("icon-earth")
$mainButtons.find('.find_battle_select_team .select').removeClass('disabled')
depressFindBattleUnranked = ->
$mainButtons = $('.main_buttons')
$button = $mainButtons.find('.find_battle_non_ranked')
$button.removeClass("disabled")
$button.find('.find-icon')
.removeClass("icon-spinner spinner-anim")
.addClass("icon-earth")
$mainButtons.find('.find_battle_select_team .select').removeClass('disabled')
$(window).load ->
$mainButtons = $('.main_buttons')
PokeBattle.battles.on 'add', (battle) ->
if !battle.get('spectating')
depressFindBattle()
depressFindBattleUnranked()
PokeBattle.primus.on 'findBattleCanceled', depressFindBattle
PokeBattle.events.on 'findBattleCanceled', depressFindBattle
PokeBattle.primus.on 'findBattleCanceledUnranked', depressFindBattleUnranked
PokeBattle.events.on 'findBattleCanceledUnranked', depressFindBattleUnranked

View File

@@ -1,5 +1,16 @@
# eventName should be one of "challenge" or "find battle"
# opts may include whether to enable clauses, for example
@challengePaneArray = []
class @challengePaneObject
constructor: (@object) ->
@event = @object.eventName
@button = @object.button
@populate = @object.populate
@clauses = @object.defaultClauses
@blockedClauses = @object.blockedClauses
@createChallengePane = (opts) ->
$wrapper = opts.populate
$button = opts.button
@@ -18,7 +29,7 @@
selectedTeamId = null
selectedAlt = null
$PaneArray = @challengePaneArray
getSelectedTeam = ->
PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0)
@@ -70,11 +81,13 @@
# Implement finding battle/challenging
$button.on 'click.challenge', ->
thisChallenge = _.find($PaneArray, (butt) -> butt.button.selector is $button.selector)
console.log(thisChallenge)
# Start requesting for notify permission here
PokeBattle.requestNotifyPermission()
format = $selectFormat.data('format')
if typeof format == "undefined" and typeof personId == "undefined"
format = $('.select-format').data('format')
# Toggle state when you press the button.
if !$button.hasClass('disabled')
team = getSelectedTeam()
@@ -90,7 +103,7 @@
$clauses = $wrapper.find('input:checked[type="checkbox"]')
clauses = []
$clauses.each(-> clauses.push(parseInt($(this).val(), 10)))
PokeBattle.primus.send(eventName, personId, format, teamJSON, clauses, selectedAlt)
PokeBattle.primus.send(eventName, personId, format, teamJSON, thisChallenge.clauses, selectedAlt)
else
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt)
$button.addClass('disabled').trigger('challenge')

View File

@@ -161,7 +161,7 @@ class @BattleView extends Backbone.View
team = $this.data('team')
slot = $this.data('slot')
pokemon = @model.getPokemon(team, slot)
@pokemonPopover($this, pokemon)
#@pokemonPopover($this, pokemon)
@renderTimers()
this
@@ -278,6 +278,8 @@ class @BattleView extends Backbone.View
$newPokemon.attr('data-slot', slot)
$newPokemon.removeClass('hidden')
@pokemonPopover($newSprite, pokemon)
pokemon.set('beeninbattle', true)
@cannedText('SENT_OUT', player, player, slot)