mirror of
https://gitlab.com/Deukhoofd/BattleSim.git
synced 2025-10-29 02:30:05 +00:00
Added Find Battle Unranked
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user