Added Find Battle Unranked
This commit is contained in:
parent
398d23a0d6
commit
16ac69171d
|
@ -14,7 +14,7 @@ html, body
|
||||||
margin 0
|
margin 0
|
||||||
font-size 100%
|
font-size 100%
|
||||||
normal-font()
|
normal-font()
|
||||||
background $background-color url("//media.pokebattle.com/img/bg.png")
|
background $background-color blue
|
||||||
line-height normal
|
line-height normal
|
||||||
|
|
||||||
ul, ol
|
ul, ol
|
||||||
|
|
|
@ -4,6 +4,57 @@ $ ->
|
||||||
$mainButtons.on 'click', '.teambuilder_button', (e) ->
|
$mainButtons.on 'click', '.teambuilder_button', (e) ->
|
||||||
PokeBattle.navigation.showTeambuilder()
|
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
|
createChallengePane
|
||||||
eventName: "findBattle"
|
eventName: "findBattle"
|
||||||
populate: $mainButtons.find('.find_battle_select_team')
|
populate: $mainButtons.find('.find_battle_select_team')
|
||||||
|
@ -26,6 +77,12 @@ $ ->
|
||||||
.addClass('icon-spinner spinner-anim')
|
.addClass('icon-spinner spinner-anim')
|
||||||
.removeClass("icon-earth")
|
.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 ->
|
$mainButtons.find('.display_credits').click ->
|
||||||
$modal = PokeBattle.modal('modals/credits')
|
$modal = PokeBattle.modal('modals/credits')
|
||||||
$modal.find('.modal-footer button').first().focus()
|
$modal.find('.modal-footer button').first().focus()
|
||||||
|
@ -40,11 +97,24 @@ depressFindBattle = ->
|
||||||
.addClass("icon-earth")
|
.addClass("icon-earth")
|
||||||
$mainButtons.find('.find_battle_select_team .select').removeClass('disabled')
|
$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 ->
|
$(window).load ->
|
||||||
$mainButtons = $('.main_buttons')
|
$mainButtons = $('.main_buttons')
|
||||||
PokeBattle.battles.on 'add', (battle) ->
|
PokeBattle.battles.on 'add', (battle) ->
|
||||||
if !battle.get('spectating')
|
if !battle.get('spectating')
|
||||||
depressFindBattle()
|
depressFindBattle()
|
||||||
|
depressFindBattleUnranked()
|
||||||
|
|
||||||
PokeBattle.primus.on 'findBattleCanceled', depressFindBattle
|
PokeBattle.primus.on 'findBattleCanceled', depressFindBattle
|
||||||
PokeBattle.events.on 'findBattleCanceled', depressFindBattle
|
PokeBattle.events.on 'findBattleCanceled', depressFindBattle
|
||||||
|
|
||||||
|
PokeBattle.primus.on 'findBattleCanceledUnranked', depressFindBattleUnranked
|
||||||
|
PokeBattle.events.on 'findBattleCanceledUnranked', depressFindBattleUnranked
|
|
@ -1,5 +1,16 @@
|
||||||
# eventName should be one of "challenge" or "find battle"
|
# eventName should be one of "challenge" or "find battle"
|
||||||
# opts may include whether to enable clauses, for example
|
# 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) ->
|
@createChallengePane = (opts) ->
|
||||||
$wrapper = opts.populate
|
$wrapper = opts.populate
|
||||||
$button = opts.button
|
$button = opts.button
|
||||||
|
@ -18,7 +29,7 @@
|
||||||
|
|
||||||
selectedTeamId = null
|
selectedTeamId = null
|
||||||
selectedAlt = null
|
selectedAlt = null
|
||||||
|
$PaneArray = @challengePaneArray
|
||||||
getSelectedTeam = ->
|
getSelectedTeam = ->
|
||||||
PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0)
|
PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0)
|
||||||
|
|
||||||
|
@ -70,11 +81,13 @@
|
||||||
|
|
||||||
# Implement finding battle/challenging
|
# Implement finding battle/challenging
|
||||||
$button.on 'click.challenge', ->
|
$button.on 'click.challenge', ->
|
||||||
|
thisChallenge = _.find($PaneArray, (butt) -> butt.button.selector is $button.selector)
|
||||||
|
console.log(thisChallenge)
|
||||||
# Start requesting for notify permission here
|
# Start requesting for notify permission here
|
||||||
PokeBattle.requestNotifyPermission()
|
PokeBattle.requestNotifyPermission()
|
||||||
|
|
||||||
format = $selectFormat.data('format')
|
format = $selectFormat.data('format')
|
||||||
|
if typeof format == "undefined" and typeof personId == "undefined"
|
||||||
|
format = $('.select-format').data('format')
|
||||||
# Toggle state when you press the button.
|
# Toggle state when you press the button.
|
||||||
if !$button.hasClass('disabled')
|
if !$button.hasClass('disabled')
|
||||||
team = getSelectedTeam()
|
team = getSelectedTeam()
|
||||||
|
@ -90,7 +103,7 @@
|
||||||
$clauses = $wrapper.find('input:checked[type="checkbox"]')
|
$clauses = $wrapper.find('input:checked[type="checkbox"]')
|
||||||
clauses = []
|
clauses = []
|
||||||
$clauses.each(-> clauses.push(parseInt($(this).val(), 10)))
|
$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
|
else
|
||||||
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt)
|
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt)
|
||||||
$button.addClass('disabled').trigger('challenge')
|
$button.addClass('disabled').trigger('challenge')
|
||||||
|
|
|
@ -161,7 +161,7 @@ class @BattleView extends Backbone.View
|
||||||
team = $this.data('team')
|
team = $this.data('team')
|
||||||
slot = $this.data('slot')
|
slot = $this.data('slot')
|
||||||
pokemon = @model.getPokemon(team, slot)
|
pokemon = @model.getPokemon(team, slot)
|
||||||
@pokemonPopover($this, pokemon)
|
#@pokemonPopover($this, pokemon)
|
||||||
@renderTimers()
|
@renderTimers()
|
||||||
this
|
this
|
||||||
|
|
||||||
|
@ -278,6 +278,8 @@ class @BattleView extends Backbone.View
|
||||||
$newPokemon.attr('data-slot', slot)
|
$newPokemon.attr('data-slot', slot)
|
||||||
$newPokemon.removeClass('hidden')
|
$newPokemon.removeClass('hidden')
|
||||||
@pokemonPopover($newSprite, pokemon)
|
@pokemonPopover($newSprite, pokemon)
|
||||||
|
|
||||||
|
pokemon.set('beeninbattle', true)
|
||||||
|
|
||||||
@cannedText('SENT_OUT', player, player, slot)
|
@cannedText('SENT_OUT', player, player, slot)
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,13 @@ block content
|
||||||
.chat
|
.chat
|
||||||
.main_buttons
|
.main_buttons
|
||||||
.section
|
.section
|
||||||
.button.big.find_battle
|
.button.big.find_battle_non_ranked
|
||||||
span.find-icon.icon-earth
|
span.find-icon.icon-earth
|
||||||
| Find battle
|
| Find battle
|
||||||
|
p
|
||||||
|
.button.big.find_battle
|
||||||
|
span.find-icon.icon-earth
|
||||||
|
| Ranked battle
|
||||||
.find_battle_select_team
|
.find_battle_select_team
|
||||||
.section
|
.section
|
||||||
.button.teambuilder_button
|
.button.teambuilder_button
|
||||||
|
|
|
@ -4,7 +4,7 @@ html
|
||||||
meta(http-equiv="X-UA-Compatible", content="IE=Edge")
|
meta(http-equiv="X-UA-Compatible", content="IE=Edge")
|
||||||
meta(name="viewport", content="width=device-width, initial-scale=1.0, user-scalable=0")
|
meta(name="viewport", content="width=device-width, initial-scale=1.0, user-scalable=0")
|
||||||
title PokeBattle
|
title PokeBattle
|
||||||
link(rel="icon", type="image/png", href="//media.pokebattle.com/img/favicon.png")
|
link(rel="icon", type="image/png", href="../Sprites/favicon.png")
|
||||||
link(rel="stylesheet", href=asset_path("css/vendor.css"))
|
link(rel="stylesheet", href=asset_path("css/vendor.css"))
|
||||||
link(rel="stylesheet", href=asset_path("css/main.css"))
|
link(rel="stylesheet", href=asset_path("css/main.css"))
|
||||||
body(class = bodyClass)
|
body(class = bodyClass)
|
||||||
|
|
|
@ -9,17 +9,32 @@ each team in [ yourTeam, opponentTeam ]
|
||||||
.pokemon_icons
|
.pokemon_icons
|
||||||
- var teamvisible = team.collection.parents[0].get('visibleteam')
|
- var teamvisible = team.collection.parents[0].get('visibleteam')
|
||||||
- var isdef = typeof teamvisible
|
- var isdef = typeof teamvisible
|
||||||
if isdef != 'undefined' && teamvisible
|
- var orig = team.get('pokemon')
|
||||||
- var orig = team.get('pokemon')
|
- var teamPokemon = team.getRandomOrder()
|
||||||
- var teamPokemon = team.getRandomOrder()
|
- for (var i = 0, len = teamPokemon.length; i < len; i += 1)
|
||||||
- for (var i = 0, len = teamPokemon.length; i < len; i += 1)
|
- var pokemon = teamPokemon[i]
|
||||||
- var pokemon = teamPokemon[i]
|
if pokemon
|
||||||
if pokemon
|
.icon_wrapper
|
||||||
.icon_wrapper
|
- var origpkmn = orig.findWhere({species: pokemon.species});
|
||||||
- var origpkmn = orig.findWhere({species: pokemon.species});
|
- var faintClass = (origpkmn.isFainted() ? 'fainted' : '')
|
||||||
- var faintClass = (origpkmn.isFainted() ? 'fainted' : '')
|
- var style = window.PokemonIconBackground(origpkmn)
|
||||||
- var style = window.PokemonIconBackground(origpkmn)
|
if isdef != 'undefined' && teamvisible
|
||||||
a.pokemon_icon(href=window.PokemonIconBackground(origpkmn), target="_blank", class = faintClass, style = style, data-team = teamIndex, data-slot = i)
|
a.pokemon_icon(href=window.PokemonIconBackground(origpkmn), target="_blank", class = faintClass, style = style, data-team = teamIndex, data-slot = i)
|
||||||
if !origpkmn.isFainted()
|
if !origpkmn.isFainted()
|
||||||
.pokemon_hp_background
|
.pokemon_hp_background
|
||||||
.pokemon_hp(style="height: " + (origpkmn.getSpecies().id) + "%", class=origpkmn.getHPColor())
|
.pokemon_hp(style="height: " + (origpkmn.getSpecies().id) + "%", class=origpkmn.getHPColor())
|
||||||
|
else
|
||||||
|
- var hasbeeninbattle = origpkmn.get('beeninbattle')
|
||||||
|
if hasbeeninbattle == true
|
||||||
|
- console.log('hasbeeninbattle')
|
||||||
|
a.pokemon_icon(href=window.PokemonIconBackground(origpkmn), target="_blank", class = faintClass, style = style, data-team = teamIndex, data-slot = i)
|
||||||
|
if !origpkmn.isFainted()
|
||||||
|
.pokemon_hp_background
|
||||||
|
.pokemon_hp(style="height: " + (origpkmn.getSpecies().id) + "%", class=origpkmn.getHPColor())
|
||||||
|
else
|
||||||
|
- console.log('hasnoybeeninbattle')
|
||||||
|
- var newstyle = "background:url('../Sprites/Icons/iconempty.png')!important; background-size: cover!important;"
|
||||||
|
a.pokemon_icon(href="", target="_blank", class = faintClass, style = newstyle, data-team = teamIndex, data-slot = i)
|
||||||
|
if !origpkmn.isFainted()
|
||||||
|
.pokemon_hp_background
|
||||||
|
.pokemon_hp(style="height: " + (origpkmn.getSpecies().id) + "%", class=origpkmn.getHPColor())
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 301 B |
Binary file not shown.
After Width: | Height: | Size: 597 B |
|
@ -6,7 +6,7 @@
|
||||||
.red{color:#dc4e48}
|
.red{color:#dc4e48}
|
||||||
.yellow{color:#b92}
|
.yellow{color:#b92}
|
||||||
.grey{color:#999}
|
.grey{color:#999}
|
||||||
html,body{color:#333332;padding:0;margin:0;font-size:100%;font-family:'proxima-nova','Helvetica Neue',Calibri,'Droid Sans',Helvetica,Arial,sans-serif;background:#f3f3f3 url("//media.pokebattle.com/img/bg.png");line-height:normal}
|
html,body{color:#333332;padding:0;margin:0;font-size:100%;font-family:'proxima-nova','Helvetica Neue',Calibri,'Droid Sans',Helvetica,Arial,sans-serif;background:#f3f3f3 #00f;line-height:normal}
|
||||||
ul,ol{list-style:none}
|
ul,ol{list-style:none}
|
||||||
ul,ol,p{margin:0;padding:0}
|
ul,ol,p{margin:0;padding:0}
|
||||||
#content{position:absolute;top:0;left:150px;right:0;bottom:0;-webkit-box-shadow:0 0 10px #000;box-shadow:0 0 10px #000}
|
#content{position:absolute;top:0;left:150px;right:0;bottom:0;-webkit-box-shadow:0 0 10px #000;box-shadow:0 0 10px #000}
|
||||||
|
|
|
@ -3146,8 +3146,7 @@
|
||||||
$this = $(el);
|
$this = $(el);
|
||||||
team = $this.data('team');
|
team = $this.data('team');
|
||||||
slot = $this.data('slot');
|
slot = $this.data('slot');
|
||||||
pokemon = _this.model.getPokemon(team, slot);
|
return pokemon = _this.model.getPokemon(team, slot);
|
||||||
return _this.pokemonPopover($this, pokemon);
|
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
this.renderTimers();
|
this.renderTimers();
|
||||||
|
@ -3338,6 +3337,7 @@
|
||||||
$newPokemon.attr('data-slot', slot);
|
$newPokemon.attr('data-slot', slot);
|
||||||
$newPokemon.removeClass('hidden');
|
$newPokemon.removeClass('hidden');
|
||||||
this.pokemonPopover($newSprite, pokemon);
|
this.pokemonPopover($newSprite, pokemon);
|
||||||
|
pokemon.set('beeninbattle', true);
|
||||||
this.cannedText('SENT_OUT', player, player, slot);
|
this.cannedText('SENT_OUT', player, player, slot);
|
||||||
if (this.skip != null) {
|
if (this.skip != null) {
|
||||||
$oldPokemon.css({
|
$oldPokemon.css({
|
||||||
|
@ -7476,8 +7476,24 @@
|
||||||
(function() {
|
(function() {
|
||||||
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||||
|
|
||||||
|
this.challengePaneArray = [];
|
||||||
|
|
||||||
|
this.challengePaneObject = (function() {
|
||||||
|
function challengePaneObject(object) {
|
||||||
|
this.object = object;
|
||||||
|
this.event = this.object.eventName;
|
||||||
|
this.button = this.object.button;
|
||||||
|
this.populate = this.object.populate;
|
||||||
|
this.clauses = this.object.defaultClauses;
|
||||||
|
this.blockedClauses = this.object.blockedClauses;
|
||||||
|
}
|
||||||
|
|
||||||
|
return challengePaneObject;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
this.createChallengePane = function(opts) {
|
this.createChallengePane = function(opts) {
|
||||||
var $accept, $button, $buttons, $checkboxes, $format, $reject, $selectFormat, $wrapper, acceptEventName, altCreatedEvent, blockedClauses, cancelChallenge, cancelEventName, capitalizedEventName, defaultClauses, disableButtons, enableButtons, eventName, generation, getSelectedTeam, isAttachedToDom, personId, rejectEventName, renderCurrentTeam, selectedAlt, selectedTeamId, teamUpdated, toggleAltInput, _ref;
|
var $PaneArray, $accept, $button, $buttons, $checkboxes, $format, $reject, $selectFormat, $wrapper, acceptEventName, altCreatedEvent, blockedClauses, cancelChallenge, cancelEventName, capitalizedEventName, defaultClauses, disableButtons, enableButtons, eventName, generation, getSelectedTeam, isAttachedToDom, personId, rejectEventName, renderCurrentTeam, selectedAlt, selectedTeamId, teamUpdated, toggleAltInput, _ref;
|
||||||
$wrapper = opts.populate;
|
$wrapper = opts.populate;
|
||||||
$button = opts.button;
|
$button = opts.button;
|
||||||
$accept = opts.acceptButton || $();
|
$accept = opts.acceptButton || $();
|
||||||
|
@ -7494,6 +7510,7 @@
|
||||||
blockedClauses = (_ref = opts.blockedClauses) != null ? _ref : false;
|
blockedClauses = (_ref = opts.blockedClauses) != null ? _ref : false;
|
||||||
selectedTeamId = null;
|
selectedTeamId = null;
|
||||||
selectedAlt = null;
|
selectedAlt = null;
|
||||||
|
$PaneArray = this.challengePaneArray;
|
||||||
getSelectedTeam = function() {
|
getSelectedTeam = function() {
|
||||||
return PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0);
|
return PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0);
|
||||||
};
|
};
|
||||||
|
@ -7554,9 +7571,16 @@
|
||||||
}));
|
}));
|
||||||
$selectFormat = $wrapper.find(".select-format");
|
$selectFormat = $wrapper.find(".select-format");
|
||||||
$button.on('click.challenge', function() {
|
$button.on('click.challenge', function() {
|
||||||
var $clauses, clauses, format, team, teamJSON;
|
var $clauses, clauses, format, team, teamJSON, thisChallenge;
|
||||||
|
thisChallenge = _.find($PaneArray, function(butt) {
|
||||||
|
return butt.button.selector === $button.selector;
|
||||||
|
});
|
||||||
|
console.log(thisChallenge);
|
||||||
PokeBattle.requestNotifyPermission();
|
PokeBattle.requestNotifyPermission();
|
||||||
format = $selectFormat.data('format');
|
format = $selectFormat.data('format');
|
||||||
|
if (typeof format === "undefined" && typeof personId === "undefined") {
|
||||||
|
format = $('.select-format').data('format');
|
||||||
|
}
|
||||||
if (!$button.hasClass('disabled')) {
|
if (!$button.hasClass('disabled')) {
|
||||||
team = getSelectedTeam();
|
team = getSelectedTeam();
|
||||||
if (!team) {
|
if (!team) {
|
||||||
|
@ -7572,7 +7596,7 @@
|
||||||
$clauses.each(function() {
|
$clauses.each(function() {
|
||||||
return clauses.push(parseInt($(this).val(), 10));
|
return 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 {
|
} else {
|
||||||
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt);
|
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt);
|
||||||
}
|
}
|
||||||
|
@ -11062,14 +11086,39 @@
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var depressFindBattle;
|
var depressFindBattle, depressFindBattleUnranked;
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var $mainButtons;
|
var $mainButtons, challengeobj, challengeobjunranked, challengepaneobj, challengepaneobjunranked;
|
||||||
$mainButtons = $('.main_buttons');
|
$mainButtons = $('.main_buttons');
|
||||||
$mainButtons.on('click', '.teambuilder_button', function(e) {
|
$mainButtons.on('click', '.teambuilder_button', function(e) {
|
||||||
return PokeBattle.navigation.showTeambuilder();
|
return 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({
|
createChallengePane({
|
||||||
eventName: "findBattle",
|
eventName: "findBattle",
|
||||||
populate: $mainButtons.find('.find_battle_select_team'),
|
populate: $mainButtons.find('.find_battle_select_team'),
|
||||||
|
@ -11082,6 +11131,11 @@
|
||||||
$this = $(this);
|
$this = $(this);
|
||||||
return $this.find('.find-icon').addClass('icon-spinner spinner-anim').removeClass("icon-earth");
|
return $this.find('.find-icon').addClass('icon-spinner spinner-anim').removeClass("icon-earth");
|
||||||
});
|
});
|
||||||
|
$mainButtons.find('.find_battle_non_ranked').on('challenge', function() {
|
||||||
|
var $this;
|
||||||
|
$this = $(this);
|
||||||
|
return $this.find('.find-icon').addClass('icon-spinner spinner-anim').removeClass("icon-earth");
|
||||||
|
});
|
||||||
return $mainButtons.find('.display_credits').click(function() {
|
return $mainButtons.find('.display_credits').click(function() {
|
||||||
var $modal;
|
var $modal;
|
||||||
$modal = PokeBattle.modal('modals/credits');
|
$modal = PokeBattle.modal('modals/credits');
|
||||||
|
@ -11098,16 +11152,28 @@
|
||||||
return $mainButtons.find('.find_battle_select_team .select').removeClass('disabled');
|
return $mainButtons.find('.find_battle_select_team .select').removeClass('disabled');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
depressFindBattleUnranked = function() {
|
||||||
|
var $button, $mainButtons;
|
||||||
|
$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");
|
||||||
|
return $mainButtons.find('.find_battle_select_team .select').removeClass('disabled');
|
||||||
|
};
|
||||||
|
|
||||||
$(window).load(function() {
|
$(window).load(function() {
|
||||||
var $mainButtons;
|
var $mainButtons;
|
||||||
$mainButtons = $('.main_buttons');
|
$mainButtons = $('.main_buttons');
|
||||||
PokeBattle.battles.on('add', function(battle) {
|
PokeBattle.battles.on('add', function(battle) {
|
||||||
if (!battle.get('spectating')) {
|
if (!battle.get('spectating')) {
|
||||||
return depressFindBattle();
|
depressFindBattle();
|
||||||
|
return depressFindBattleUnranked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PokeBattle.primus.on('findBattleCanceled', depressFindBattle);
|
PokeBattle.primus.on('findBattleCanceled', depressFindBattle);
|
||||||
return PokeBattle.events.on('findBattleCanceled', depressFindBattle);
|
PokeBattle.events.on('findBattleCanceled', depressFindBattle);
|
||||||
|
PokeBattle.primus.on('findBattleCanceledUnranked', depressFindBattleUnranked);
|
||||||
|
return PokeBattle.events.on('findBattleCanceledUnranked', depressFindBattleUnranked);
|
||||||
});
|
});
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2872,8 +2872,7 @@
|
||||||
$this = $(el);
|
$this = $(el);
|
||||||
team = $this.data('team');
|
team = $this.data('team');
|
||||||
slot = $this.data('slot');
|
slot = $this.data('slot');
|
||||||
pokemon = _this.model.getPokemon(team, slot);
|
return pokemon = _this.model.getPokemon(team, slot);
|
||||||
return _this.pokemonPopover($this, pokemon);
|
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
this.renderTimers();
|
this.renderTimers();
|
||||||
|
@ -3064,6 +3063,7 @@
|
||||||
$newPokemon.attr('data-slot', slot);
|
$newPokemon.attr('data-slot', slot);
|
||||||
$newPokemon.removeClass('hidden');
|
$newPokemon.removeClass('hidden');
|
||||||
this.pokemonPopover($newSprite, pokemon);
|
this.pokemonPopover($newSprite, pokemon);
|
||||||
|
pokemon.set('beeninbattle', true);
|
||||||
this.cannedText('SENT_OUT', player, player, slot);
|
this.cannedText('SENT_OUT', player, player, slot);
|
||||||
if (this.skip != null) {
|
if (this.skip != null) {
|
||||||
$oldPokemon.css({
|
$oldPokemon.css({
|
||||||
|
@ -5208,8 +5208,24 @@
|
||||||
(function() {
|
(function() {
|
||||||
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||||
|
|
||||||
|
this.challengePaneArray = [];
|
||||||
|
|
||||||
|
this.challengePaneObject = (function() {
|
||||||
|
function challengePaneObject(object) {
|
||||||
|
this.object = object;
|
||||||
|
this.event = this.object.eventName;
|
||||||
|
this.button = this.object.button;
|
||||||
|
this.populate = this.object.populate;
|
||||||
|
this.clauses = this.object.defaultClauses;
|
||||||
|
this.blockedClauses = this.object.blockedClauses;
|
||||||
|
}
|
||||||
|
|
||||||
|
return challengePaneObject;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
this.createChallengePane = function(opts) {
|
this.createChallengePane = function(opts) {
|
||||||
var $accept, $button, $buttons, $checkboxes, $format, $reject, $selectFormat, $wrapper, acceptEventName, altCreatedEvent, blockedClauses, cancelChallenge, cancelEventName, capitalizedEventName, defaultClauses, disableButtons, enableButtons, eventName, generation, getSelectedTeam, isAttachedToDom, personId, rejectEventName, renderCurrentTeam, selectedAlt, selectedTeamId, teamUpdated, toggleAltInput, _ref;
|
var $PaneArray, $accept, $button, $buttons, $checkboxes, $format, $reject, $selectFormat, $wrapper, acceptEventName, altCreatedEvent, blockedClauses, cancelChallenge, cancelEventName, capitalizedEventName, defaultClauses, disableButtons, enableButtons, eventName, generation, getSelectedTeam, isAttachedToDom, personId, rejectEventName, renderCurrentTeam, selectedAlt, selectedTeamId, teamUpdated, toggleAltInput, _ref;
|
||||||
$wrapper = opts.populate;
|
$wrapper = opts.populate;
|
||||||
$button = opts.button;
|
$button = opts.button;
|
||||||
$accept = opts.acceptButton || $();
|
$accept = opts.acceptButton || $();
|
||||||
|
@ -5226,6 +5242,7 @@
|
||||||
blockedClauses = (_ref = opts.blockedClauses) != null ? _ref : false;
|
blockedClauses = (_ref = opts.blockedClauses) != null ? _ref : false;
|
||||||
selectedTeamId = null;
|
selectedTeamId = null;
|
||||||
selectedAlt = null;
|
selectedAlt = null;
|
||||||
|
$PaneArray = this.challengePaneArray;
|
||||||
getSelectedTeam = function() {
|
getSelectedTeam = function() {
|
||||||
return PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0);
|
return PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0);
|
||||||
};
|
};
|
||||||
|
@ -5286,9 +5303,16 @@
|
||||||
}));
|
}));
|
||||||
$selectFormat = $wrapper.find(".select-format");
|
$selectFormat = $wrapper.find(".select-format");
|
||||||
$button.on('click.challenge', function() {
|
$button.on('click.challenge', function() {
|
||||||
var $clauses, clauses, format, team, teamJSON;
|
var $clauses, clauses, format, team, teamJSON, thisChallenge;
|
||||||
|
thisChallenge = _.find($PaneArray, function(butt) {
|
||||||
|
return butt.button.selector === $button.selector;
|
||||||
|
});
|
||||||
|
console.log(thisChallenge);
|
||||||
PokeBattle.requestNotifyPermission();
|
PokeBattle.requestNotifyPermission();
|
||||||
format = $selectFormat.data('format');
|
format = $selectFormat.data('format');
|
||||||
|
if (typeof format === "undefined" && typeof personId === "undefined") {
|
||||||
|
format = $('.select-format').data('format');
|
||||||
|
}
|
||||||
if (!$button.hasClass('disabled')) {
|
if (!$button.hasClass('disabled')) {
|
||||||
team = getSelectedTeam();
|
team = getSelectedTeam();
|
||||||
if (!team) {
|
if (!team) {
|
||||||
|
@ -5304,7 +5328,7 @@
|
||||||
$clauses.each(function() {
|
$clauses.each(function() {
|
||||||
return clauses.push(parseInt($(this).val(), 10));
|
return 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 {
|
} else {
|
||||||
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt);
|
PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,8 +383,6 @@ var teamIndex = (team === yourTeam ? yourIndex : 1 - yourIndex)
|
||||||
buf.push("<div" + (jade.attrs({ "class": [('bg-faded-blue'),('fill-' + leftOrRight)] }, {"class":true})) + "><div" + (jade.attrs({ "class": [(leftOrRight)] }, {"class":true})) + "><div class=\"owner_name\">" + (jade.escape(null == (jade.interp = team.get('owner')) ? "" : jade.interp)) + "</div><div class=\"battle-timer frozen-timer hidden\"></div><div class=\"battle-timer remaining-timer\"></div><div class=\"pokemon_icons\">");
|
buf.push("<div" + (jade.attrs({ "class": [('bg-faded-blue'),('fill-' + leftOrRight)] }, {"class":true})) + "><div" + (jade.attrs({ "class": [(leftOrRight)] }, {"class":true})) + "><div class=\"owner_name\">" + (jade.escape(null == (jade.interp = team.get('owner')) ? "" : jade.interp)) + "</div><div class=\"battle-timer frozen-timer hidden\"></div><div class=\"battle-timer remaining-timer\"></div><div class=\"pokemon_icons\">");
|
||||||
var teamvisible = team.collection.parents[0].get('visibleteam')
|
var teamvisible = team.collection.parents[0].get('visibleteam')
|
||||||
var isdef = typeof teamvisible
|
var isdef = typeof teamvisible
|
||||||
if ( isdef != 'undefined' && teamvisible)
|
|
||||||
{
|
|
||||||
var orig = team.get('pokemon')
|
var orig = team.get('pokemon')
|
||||||
var teamPokemon = team.getRandomOrder()
|
var teamPokemon = team.getRandomOrder()
|
||||||
for (var i = 0, len = teamPokemon.length; i < len; i += 1)
|
for (var i = 0, len = teamPokemon.length; i < len; i += 1)
|
||||||
|
@ -396,13 +394,38 @@ buf.push("<div class=\"icon_wrapper\">");
|
||||||
var origpkmn = orig.findWhere({species: pokemon.species});
|
var origpkmn = orig.findWhere({species: pokemon.species});
|
||||||
var faintClass = (origpkmn.isFainted() ? 'fainted' : '')
|
var faintClass = (origpkmn.isFainted() ? 'fainted' : '')
|
||||||
var style = window.PokemonIconBackground(origpkmn)
|
var style = window.PokemonIconBackground(origpkmn)
|
||||||
|
if ( isdef != 'undefined' && teamvisible)
|
||||||
|
{
|
||||||
buf.push("<a" + (jade.attrs({ 'href':(window.PokemonIconBackground(origpkmn)), 'target':("_blank"), 'style':(style), 'data-team':(teamIndex), 'data-slot':(i), "class": [('pokemon_icon'),(faintClass)] }, {"class":true,"href":true,"target":true,"style":true,"data-team":true,"data-slot":true})) + "></a>");
|
buf.push("<a" + (jade.attrs({ 'href':(window.PokemonIconBackground(origpkmn)), 'target':("_blank"), 'style':(style), 'data-team':(teamIndex), 'data-slot':(i), "class": [('pokemon_icon'),(faintClass)] }, {"class":true,"href":true,"target":true,"style":true,"data-team":true,"data-slot":true})) + "></a>");
|
||||||
if ( !origpkmn.isFainted())
|
if ( !origpkmn.isFainted())
|
||||||
{
|
{
|
||||||
buf.push("<div class=\"pokemon_hp_background\"><div" + (jade.attrs({ 'style':("height: " + (origpkmn.getSpecies().id) + "%"), "class": [('pokemon_hp'),(origpkmn.getHPColor())] }, {"class":true,"style":true})) + "></div></div>");
|
buf.push("<div class=\"pokemon_hp_background\"><div" + (jade.attrs({ 'style':("height: " + (origpkmn.getSpecies().id) + "%"), "class": [('pokemon_hp'),(origpkmn.getHPColor())] }, {"class":true,"style":true})) + "></div></div>");
|
||||||
}
|
}
|
||||||
buf.push("</div>");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var hasbeeninbattle = origpkmn.get('beeninbattle')
|
||||||
|
if ( hasbeeninbattle == true)
|
||||||
|
{
|
||||||
|
console.log('hasbeeninbattle')
|
||||||
|
buf.push("<a" + (jade.attrs({ 'href':(window.PokemonIconBackground(origpkmn)), 'target':("_blank"), 'style':(style), 'data-team':(teamIndex), 'data-slot':(i), "class": [('pokemon_icon'),(faintClass)] }, {"class":true,"href":true,"target":true,"style":true,"data-team":true,"data-slot":true})) + "></a>");
|
||||||
|
if ( !origpkmn.isFainted())
|
||||||
|
{
|
||||||
|
buf.push("<div class=\"pokemon_hp_background\"><div" + (jade.attrs({ 'style':("height: " + (origpkmn.getSpecies().id) + "%"), "class": [('pokemon_hp'),(origpkmn.getHPColor())] }, {"class":true,"style":true})) + "></div></div>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log('hasnoybeeninbattle')
|
||||||
|
var newstyle = "background:url('../Sprites/Icons/iconempty.png')!important; background-size: cover!important;"
|
||||||
|
buf.push("<a" + (jade.attrs({ 'href':(""), 'target':("_blank"), 'style':(newstyle), 'data-team':(teamIndex), 'data-slot':(i), "class": [('pokemon_icon'),(faintClass)] }, {"class":true,"href":true,"target":true,"style":true,"data-team":true,"data-slot":true})) + "></a>");
|
||||||
|
if ( !origpkmn.isFainted())
|
||||||
|
{
|
||||||
|
buf.push("<div class=\"pokemon_hp_background\"><div" + (jade.attrs({ 'style':("height: " + (origpkmn.getSpecies().id) + "%"), "class": [('pokemon_hp'),(origpkmn.getHPColor())] }, {"class":true,"style":true})) + "></div></div>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf.push("</div>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf.push("</div></div></div>");
|
buf.push("</div></div></div>");
|
||||||
|
@ -418,8 +441,6 @@ var teamIndex = (team === yourTeam ? yourIndex : 1 - yourIndex)
|
||||||
buf.push("<div" + (jade.attrs({ "class": [('bg-faded-blue'),('fill-' + leftOrRight)] }, {"class":true})) + "><div" + (jade.attrs({ "class": [(leftOrRight)] }, {"class":true})) + "><div class=\"owner_name\">" + (jade.escape(null == (jade.interp = team.get('owner')) ? "" : jade.interp)) + "</div><div class=\"battle-timer frozen-timer hidden\"></div><div class=\"battle-timer remaining-timer\"></div><div class=\"pokemon_icons\">");
|
buf.push("<div" + (jade.attrs({ "class": [('bg-faded-blue'),('fill-' + leftOrRight)] }, {"class":true})) + "><div" + (jade.attrs({ "class": [(leftOrRight)] }, {"class":true})) + "><div class=\"owner_name\">" + (jade.escape(null == (jade.interp = team.get('owner')) ? "" : jade.interp)) + "</div><div class=\"battle-timer frozen-timer hidden\"></div><div class=\"battle-timer remaining-timer\"></div><div class=\"pokemon_icons\">");
|
||||||
var teamvisible = team.collection.parents[0].get('visibleteam')
|
var teamvisible = team.collection.parents[0].get('visibleteam')
|
||||||
var isdef = typeof teamvisible
|
var isdef = typeof teamvisible
|
||||||
if ( isdef != 'undefined' && teamvisible)
|
|
||||||
{
|
|
||||||
var orig = team.get('pokemon')
|
var orig = team.get('pokemon')
|
||||||
var teamPokemon = team.getRandomOrder()
|
var teamPokemon = team.getRandomOrder()
|
||||||
for (var i = 0, len = teamPokemon.length; i < len; i += 1)
|
for (var i = 0, len = teamPokemon.length; i < len; i += 1)
|
||||||
|
@ -431,13 +452,38 @@ buf.push("<div class=\"icon_wrapper\">");
|
||||||
var origpkmn = orig.findWhere({species: pokemon.species});
|
var origpkmn = orig.findWhere({species: pokemon.species});
|
||||||
var faintClass = (origpkmn.isFainted() ? 'fainted' : '')
|
var faintClass = (origpkmn.isFainted() ? 'fainted' : '')
|
||||||
var style = window.PokemonIconBackground(origpkmn)
|
var style = window.PokemonIconBackground(origpkmn)
|
||||||
|
if ( isdef != 'undefined' && teamvisible)
|
||||||
|
{
|
||||||
buf.push("<a" + (jade.attrs({ 'href':(window.PokemonIconBackground(origpkmn)), 'target':("_blank"), 'style':(style), 'data-team':(teamIndex), 'data-slot':(i), "class": [('pokemon_icon'),(faintClass)] }, {"class":true,"href":true,"target":true,"style":true,"data-team":true,"data-slot":true})) + "></a>");
|
buf.push("<a" + (jade.attrs({ 'href':(window.PokemonIconBackground(origpkmn)), 'target':("_blank"), 'style':(style), 'data-team':(teamIndex), 'data-slot':(i), "class": [('pokemon_icon'),(faintClass)] }, {"class":true,"href":true,"target":true,"style":true,"data-team":true,"data-slot":true})) + "></a>");
|
||||||
if ( !origpkmn.isFainted())
|
if ( !origpkmn.isFainted())
|
||||||
{
|
{
|
||||||
buf.push("<div class=\"pokemon_hp_background\"><div" + (jade.attrs({ 'style':("height: " + (origpkmn.getSpecies().id) + "%"), "class": [('pokemon_hp'),(origpkmn.getHPColor())] }, {"class":true,"style":true})) + "></div></div>");
|
buf.push("<div class=\"pokemon_hp_background\"><div" + (jade.attrs({ 'style':("height: " + (origpkmn.getSpecies().id) + "%"), "class": [('pokemon_hp'),(origpkmn.getHPColor())] }, {"class":true,"style":true})) + "></div></div>");
|
||||||
}
|
}
|
||||||
buf.push("</div>");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var hasbeeninbattle = origpkmn.get('beeninbattle')
|
||||||
|
if ( hasbeeninbattle == true)
|
||||||
|
{
|
||||||
|
console.log('hasbeeninbattle')
|
||||||
|
buf.push("<a" + (jade.attrs({ 'href':(window.PokemonIconBackground(origpkmn)), 'target':("_blank"), 'style':(style), 'data-team':(teamIndex), 'data-slot':(i), "class": [('pokemon_icon'),(faintClass)] }, {"class":true,"href":true,"target":true,"style":true,"data-team":true,"data-slot":true})) + "></a>");
|
||||||
|
if ( !origpkmn.isFainted())
|
||||||
|
{
|
||||||
|
buf.push("<div class=\"pokemon_hp_background\"><div" + (jade.attrs({ 'style':("height: " + (origpkmn.getSpecies().id) + "%"), "class": [('pokemon_hp'),(origpkmn.getHPColor())] }, {"class":true,"style":true})) + "></div></div>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log('hasnoybeeninbattle')
|
||||||
|
var newstyle = "background:url('../Sprites/Icons/iconempty.png')!important; background-size: cover!important;"
|
||||||
|
buf.push("<a" + (jade.attrs({ 'href':(""), 'target':("_blank"), 'style':(newstyle), 'data-team':(teamIndex), 'data-slot':(i), "class": [('pokemon_icon'),(faintClass)] }, {"class":true,"href":true,"target":true,"style":true,"data-team":true,"data-slot":true})) + "></a>");
|
||||||
|
if ( !origpkmn.isFainted())
|
||||||
|
{
|
||||||
|
buf.push("<div class=\"pokemon_hp_background\"><div" + (jade.attrs({ 'style':("height: " + (origpkmn.getSpecies().id) + "%"), "class": [('pokemon_hp'),(origpkmn.getHPColor())] }, {"class":true,"style":true})) + "></div></div>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf.push("</div>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf.push("</div></div></div>");
|
buf.push("</div></div></div>");
|
||||||
|
|
|
@ -269,7 +269,6 @@ class @Move
|
||||||
weatherModifier: (battle, user, target) ->
|
weatherModifier: (battle, user, target) ->
|
||||||
# TODO: This is wrong.
|
# TODO: This is wrong.
|
||||||
type = @getType(battle, user, target)
|
type = @getType(battle, user, target)
|
||||||
console.log(type)
|
|
||||||
if type == 'Fire' && battle.hasWeather(Weather.SUN)
|
if type == 'Fire' && battle.hasWeather(Weather.SUN)
|
||||||
0x1800
|
0x1800
|
||||||
else if type == 'Fire' && battle.hasWeather(Weather.RAIN)
|
else if type == 'Fire' && battle.hasWeather(Weather.RAIN)
|
||||||
|
@ -280,8 +279,6 @@ class @Move
|
||||||
0x800
|
0x800
|
||||||
else if type == 'Dark' && battle.hasWeather(Weather.MOON)
|
else if type == 'Dark' && battle.hasWeather(Weather.MOON)
|
||||||
0x159A
|
0x159A
|
||||||
else if type == 'Ghost' && battle.hasWeather(Weather.MOON)
|
|
||||||
0x159A
|
|
||||||
else if type == 'Fairy' && battle.hasWeather(Weather.MOON)
|
else if type == 'Fairy' && battle.hasWeather(Weather.MOON)
|
||||||
0xC00
|
0xC00
|
||||||
else
|
else
|
||||||
|
|
|
@ -12,322 +12,321 @@ ConditionHash = {}
|
||||||
createCondition = (condition, effects = {}) ->
|
createCondition = (condition, effects = {}) ->
|
||||||
ConditionHash[condition] = effects
|
ConditionHash[condition] = effects
|
||||||
|
|
||||||
# Attaches each condition to the Battle facade.
|
# Attaches each condition to the Battle facade.
|
||||||
@attach = (battleFacade) ->
|
@attach = (battleFacade) ->
|
||||||
battle = battleFacade.battle
|
battle = battleFacade.battle
|
||||||
for condition in battle.conditions
|
for condition in battle.conditions
|
||||||
if condition not of ConditionHash
|
if condition not of ConditionHash
|
||||||
throw new Error("Undefined condition: #{condition}")
|
throw new Error("Undefined condition: #{condition}")
|
||||||
hash = ConditionHash[condition] || {}
|
hash = ConditionHash[condition] || {}
|
||||||
# Attach each condition's event listeners
|
# Attach each condition's event listeners
|
||||||
for eventName, callback of hash.attach
|
for eventName, callback of hash.attach
|
||||||
battle.on(eventName, callback)
|
battle.on(eventName, callback)
|
||||||
|
|
||||||
# Extend battle with each function
|
# Extend battle with each function
|
||||||
# TODO: Attach to prototype, and only once.
|
# TODO: Attach to prototype, and only once.
|
||||||
for funcName, funcRef of hash.extend
|
for funcName, funcRef of hash.extend
|
||||||
battle[funcName] = funcRef
|
battle[funcName] = funcRef
|
||||||
|
|
||||||
for funcName, funcRef of hash.extendFacade
|
for funcName, funcRef of hash.extendFacade
|
||||||
battleFacade[funcName] = funcRef
|
battleFacade[funcName] = funcRef
|
||||||
|
|
||||||
# validates an entire team
|
# validates an entire team
|
||||||
@validateTeam = (conditions, team, genData) ->
|
@validateTeam = (conditions, team, genData) ->
|
||||||
errors = []
|
errors = []
|
||||||
for condition in conditions
|
for condition in conditions
|
||||||
if condition not of ConditionHash
|
if condition not of ConditionHash
|
||||||
throw new Error("Undefined condition: #{condition}")
|
throw new Error("Undefined condition: #{condition}")
|
||||||
validator = ConditionHash[condition].validateTeam
|
validator = ConditionHash[condition].validateTeam
|
||||||
continue if !validator
|
continue if !validator
|
||||||
errors.push(validator(team, genData)...)
|
errors.push(validator(team, genData)...)
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
# validates a single pokemon
|
# validates a single pokemon
|
||||||
@validatePokemon = (conditions, pokemon, genData, prefix) ->
|
@validatePokemon = (conditions, pokemon, genData, prefix) ->
|
||||||
errors = []
|
errors = []
|
||||||
for condition in conditions
|
for condition in conditions
|
||||||
if condition not of ConditionHash
|
if condition not of ConditionHash
|
||||||
throw new Error("Undefined condition: #{condition}")
|
throw new Error("Undefined condition: #{condition}")
|
||||||
validator = ConditionHash[condition].validatePokemon
|
validator = ConditionHash[condition].validatePokemon
|
||||||
continue if !validator
|
continue if !validator
|
||||||
errors.push(validator(pokemon, genData, prefix)...)
|
errors.push(validator(pokemon, genData, prefix)...)
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
createPBVCondition = (totalPBV) ->
|
createPBVCondition = (totalPBV) ->
|
||||||
createCondition Conditions["PBV_#{totalPBV}"],
|
createCondition Conditions["PBV_#{totalPBV}"],
|
||||||
validateTeam: (team, genData) ->
|
validateTeam: (team, genData) ->
|
||||||
errors = []
|
errors = []
|
||||||
if pbv.determinePBV(genData, team) > totalPBV
|
if pbv.determinePBV(genData, team) > totalPBV
|
||||||
errors.push "Total team PBV cannot surpass #{totalPBV}."
|
errors.push "Total team PBV cannot surpass #{totalPBV}."
|
||||||
if team.length != 6
|
if team.length != 6
|
||||||
errors.push "Your team must have 6 pokemon."
|
errors.push "Your team must have 6 pokemon."
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
validatePokemon: (pokemon, genData, prefix) ->
|
validatePokemon: (pokemon, genData, prefix) ->
|
||||||
errors = []
|
errors = []
|
||||||
MAX_INDIVIDUAL_PBV = Math.floor(totalPBV / 3)
|
MAX_INDIVIDUAL_PBV = Math.floor(totalPBV / 3)
|
||||||
individualPBV = pbv.determinePBV(genData, pokemon)
|
individualPBV = pbv.determinePBV(genData, pokemon)
|
||||||
|
|
||||||
if individualPBV > MAX_INDIVIDUAL_PBV
|
if individualPBV > MAX_INDIVIDUAL_PBV
|
||||||
errors.push "#{prefix}: This Pokemon's PBV is #{individualPBV}. Individual
|
errors.push "#{prefix}: This Pokemon's PBV is #{individualPBV}. Individual
|
||||||
PBVs cannot go over 1/3 the total (over #{MAX_INDIVIDUAL_PBV} PBV)."
|
PBVs cannot go over 1/3 the total (over #{MAX_INDIVIDUAL_PBV} PBV)."
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
createPBVCondition(1000)
|
createPBVCondition(1000)
|
||||||
createPBVCondition(500)
|
createPBVCondition(500)
|
||||||
|
|
||||||
createTierCondition = (conditionName, tier) ->
|
createTierCondition = (conditionName, tier) ->
|
||||||
createCondition Conditions[conditionName],
|
createCondition Conditions[conditionName],
|
||||||
validateTeam: (team, genData) ->
|
validateTeam: (team, genData) ->
|
||||||
errors = []
|
errors = []
|
||||||
tierdata = Tiers[tier]
|
tierdata = Tiers[tier]
|
||||||
teamtier = tiering.determineTier(genData, team)
|
teamtier = tiering.determineTier(genData, team)
|
||||||
if teamtier.tierRank > tierdata.tierRank
|
if teamtier.tierRank > tierdata.tierRank
|
||||||
errors.push "Your team tier may not exceed the #{tierdata.humanName} tier"
|
errors.push "Your team tier may not exceed the #{tierdata.humanName} tier"
|
||||||
if team.length != 6
|
if team.length != 6
|
||||||
errors.push "Your team must have 6 pokemon."
|
errors.push "Your team must have 6 pokemon."
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
for key, val of Tiers
|
for key, val of Tiers
|
||||||
createTierCondition("TIER_#{key}", key)
|
createTierCondition("TIER_#{key}", key)
|
||||||
|
|
||||||
createCondition Conditions.SLEEP_CLAUSE,
|
createCondition Conditions.SLEEP_CLAUSE,
|
||||||
attach:
|
attach:
|
||||||
initialize: ->
|
initialize: ->
|
||||||
for team in @getTeams()
|
for team in @getTeams()
|
||||||
for p in team.pokemon
|
for p in team.pokemon
|
||||||
p.attach(@getAttachment("SleepClause"))
|
p.attach(@getAttachment("SleepClause"))
|
||||||
|
|
||||||
createCondition Conditions.SPECIES_CLAUSE,
|
createCondition Conditions.SPECIES_CLAUSE,
|
||||||
validateTeam: (team, genData) ->
|
validateTeam: (team, genData) ->
|
||||||
errors = []
|
errors = []
|
||||||
species = team.map((p) -> p.species)
|
species = team.map((p) -> p.species)
|
||||||
species.sort()
|
species.sort()
|
||||||
for i in [1...species.length]
|
for i in [1...species.length]
|
||||||
speciesName = species[i - 1]
|
speciesName = species[i - 1]
|
||||||
if speciesName == species[i]
|
if speciesName == species[i]
|
||||||
errors.push("Cannot have the same species: #{speciesName}")
|
errors.push("Cannot have the same species: #{speciesName}")
|
||||||
while speciesName == species[i]
|
while speciesName == species[i]
|
||||||
i++
|
i++
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
createCondition Conditions.EVASION_CLAUSE,
|
createCondition Conditions.EVASION_CLAUSE,
|
||||||
validatePokemon: (pokemon, genData, prefix) ->
|
validatePokemon: (pokemon, genData, prefix) ->
|
||||||
{moves, ability} = pokemon
|
{moves, ability} = pokemon
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
# Check evasion abilities
|
# Check evasion abilities
|
||||||
if ability in [ "Moody" ]
|
if ability in [ "Moody" ]
|
||||||
errors.push("#{prefix}: #{ability} is banned under Evasion Clause.")
|
errors.push("#{prefix}: #{ability} is banned under Evasion Clause.")
|
||||||
|
|
||||||
# Check evasion moves
|
# Check evasion moves
|
||||||
for moveName in moves || []
|
for moveName in moves || []
|
||||||
move = genData.MoveData[moveName]
|
move = genData.MoveData[moveName]
|
||||||
continue if !move
|
continue if !move
|
||||||
if move.primaryBoostStats? && move.primaryBoostStats.evasion > 0 &&
|
if move.primaryBoostStats? && move.primaryBoostStats.evasion > 0 &&
|
||||||
move.primaryBoostTarget == 'self'
|
move.primaryBoostTarget == 'self'
|
||||||
errors.push("#{prefix}: #{moveName} is banned under Evasion Clause.")
|
errors.push("#{prefix}: #{moveName} is banned under Evasion Clause.")
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
createCondition Conditions.OHKO_CLAUSE,
|
createCondition Conditions.OHKO_CLAUSE,
|
||||||
validatePokemon: (pokemon, genData, prefix) ->
|
validatePokemon: (pokemon, genData, prefix) ->
|
||||||
{moves} = pokemon
|
{moves} = pokemon
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
# Check OHKO moves
|
# Check OHKO moves
|
||||||
for moveName in moves || []
|
for moveName in moves || []
|
||||||
move = genData.MoveData[moveName]
|
move = genData.MoveData[moveName]
|
||||||
continue if !move
|
continue if !move
|
||||||
if "ohko" in move.flags
|
if "ohko" in move.flags
|
||||||
errors.push("#{prefix}: #{moveName} is banned under One-Hit KO Clause.")
|
errors.push("#{prefix}: #{moveName} is banned under One-Hit KO Clause.")
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
createCondition Conditions.PRANKSTER_SWAGGER_CLAUSE,
|
createCondition Conditions.PRANKSTER_SWAGGER_CLAUSE,
|
||||||
validatePokemon: (pokemon, genData, prefix) ->
|
validatePokemon: (pokemon, genData, prefix) ->
|
||||||
errors = []
|
errors = []
|
||||||
if "Swagger" in pokemon.moves && "Prankster" == pokemon.ability
|
if "Swagger" in pokemon.moves && "Prankster" == pokemon.ability
|
||||||
errors.push("#{prefix}: A Pokemon can't have both Prankster and Swagger.")
|
errors.push("#{prefix}: A Pokemon can't have both Prankster and Swagger.")
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
createCondition Conditions.UNRELEASED_BAN,
|
createCondition Conditions.UNRELEASED_BAN,
|
||||||
validatePokemon: (pokemon, genData, prefix) ->
|
validatePokemon: (pokemon, genData, prefix) ->
|
||||||
# Check for unreleased items
|
# Check for unreleased items
|
||||||
errors = []
|
errors = []
|
||||||
if pokemon.item && genData.ItemData[pokemon.item]?.unreleased
|
if pokemon.item && genData.ItemData[pokemon.item]?.unreleased
|
||||||
errors.push("#{prefix}: The item '#{pokemon.item}' is unreleased.")
|
errors.push("#{prefix}: The item '#{pokemon.item}' is unreleased.")
|
||||||
# Check for unreleased abilities
|
# Check for unreleased abilities
|
||||||
forme = genData.FormeData[pokemon.species][pokemon.forme || "default"]
|
forme = genData.FormeData[pokemon.species][pokemon.forme || "default"]
|
||||||
if forme.unreleasedHidden && pokemon.ability == forme.hiddenAbility &&
|
if forme.unreleasedHidden && pokemon.ability == forme.hiddenAbility &&
|
||||||
forme.hiddenAbility not in forme.abilities
|
forme.hiddenAbility not in forme.abilities
|
||||||
errors.push("#{prefix}: The ability #{pokemon.ability} is unreleased.")
|
errors.push("#{prefix}: The ability #{pokemon.ability} is unreleased.")
|
||||||
# Check for unreleased Pokemon
|
# Check for unreleased Pokemon
|
||||||
if forme.unreleased
|
if forme.unreleased
|
||||||
errors.push("#{prefix}: The Pokemon #{pokemon.species} is unreleased.")
|
errors.push("#{prefix}: The Pokemon #{pokemon.species} is unreleased.")
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
createCondition Conditions.RATED_BATTLE,
|
createCondition Conditions.RATED_BATTLE,
|
||||||
attach:
|
attach:
|
||||||
end: (winnerId) ->
|
end: (winnerId) ->
|
||||||
return if !winnerId
|
return if !winnerId
|
||||||
index = @getPlayerIndex(winnerId)
|
index = @getPlayerIndex(winnerId)
|
||||||
loserId = @playerIds[1 - index]
|
loserId = @playerIds[1 - index]
|
||||||
ratings = require './ratings'
|
ratings = require './ratings'
|
||||||
|
|
||||||
winner = @getPlayer(winnerId)
|
winner = @getPlayer(winnerId)
|
||||||
loser = @getPlayer(loserId)
|
loser = @getPlayer(loserId)
|
||||||
|
|
||||||
winnerId = winner.ratingKey
|
winnerId = winner.ratingKey
|
||||||
loserId = loser.ratingKey
|
loserId = loser.ratingKey
|
||||||
|
|
||||||
ratings.getRatings [ winnerId, loserId ], (err, oldRatings) =>
|
ratings.getRatings [ winnerId, loserId ], (err, oldRatings) =>
|
||||||
ratings.updatePlayers winnerId, loserId, ratings.results.WIN, (err, result) =>
|
ratings.updatePlayers winnerId, loserId, ratings.results.WIN, (err, result) =>
|
||||||
return @message "An error occurred updating rankings :(" if err
|
return @message "An error occurred updating rankings :(" if err
|
||||||
|
|
||||||
oldRating = Math.floor(oldRatings[0])
|
oldRating = Math.floor(oldRatings[0])
|
||||||
newRating = Math.floor(result[0])
|
newRating = Math.floor(result[0])
|
||||||
@cannedText('RATING_UPDATE', index, oldRating, newRating)
|
@cannedText('RATING_UPDATE', index, oldRating, newRating)
|
||||||
|
|
||||||
oldRating = Math.floor(oldRatings[1])
|
oldRating = Math.floor(oldRatings[1])
|
||||||
newRating = Math.floor(result[1])
|
newRating = Math.floor(result[1])
|
||||||
@cannedText('RATING_UPDATE', 1 - index, oldRating, newRating)
|
@cannedText('RATING_UPDATE', 1 - index, oldRating, newRating)
|
||||||
|
|
||||||
@emit('ratingsUpdated')
|
@emit('ratingsUpdated')
|
||||||
@sendUpdates()
|
@sendUpdates()
|
||||||
|
|
||||||
createCondition Conditions.TIMED_BATTLE,
|
createCondition Conditions.TIMED_BATTLE,
|
||||||
attach:
|
attach:
|
||||||
initialize: ->
|
initialize: ->
|
||||||
@playerTimes = {}
|
@playerTimes = {}
|
||||||
@lastActionTimes = {}
|
@lastActionTimes = {}
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
|
|
||||||
# Set up initial values
|
# Set up initial values
|
||||||
for id in @playerIds
|
for id in @playerIds
|
||||||
@playerTimes[id] = now + @TEAM_PREVIEW_TIMER
|
@playerTimes[id] = now + @TEAM_PREVIEW_TIMER
|
||||||
|
|
||||||
# Set up timers and event listeners
|
# Set up timers and event listeners
|
||||||
check = () =>
|
check = () =>
|
||||||
@startBattle()
|
@startBattle()
|
||||||
@sendUpdates()
|
@sendUpdates()
|
||||||
@teamPreviewTimerId = setTimeout(check, @TEAM_PREVIEW_TIMER)
|
@teamPreviewTimerId = setTimeout(check, @TEAM_PREVIEW_TIMER)
|
||||||
@once('end', => clearTimeout(@teamPreviewTimerId))
|
@once('end', => clearTimeout(@teamPreviewTimerId))
|
||||||
@once('start', => clearTimeout(@teamPreviewTimerId))
|
@once('start', => clearTimeout(@teamPreviewTimerId))
|
||||||
|
|
||||||
start: ->
|
start: ->
|
||||||
nowTime = Date.now()
|
nowTime = Date.now()
|
||||||
for id in @playerIds
|
for id in @playerIds
|
||||||
@playerTimes[id] = nowTime + @DEFAULT_TIMER
|
@playerTimes[id] = nowTime + @DEFAULT_TIMER
|
||||||
# Remove first turn since we'll be increasing it again.
|
# Remove first turn since we'll be increasing it again.
|
||||||
@playerTimes[id] -= @TIMER_PER_TURN_INCREASE
|
@playerTimes[id] -= @TIMER_PER_TURN_INCREASE
|
||||||
@startTimer()
|
@startTimer()
|
||||||
|
|
||||||
requestActions: (playerId) ->
|
requestActions: (playerId) ->
|
||||||
# If a player has selected a move, then there's an amount of time spent
|
# If a player has selected a move, then there's an amount of time spent
|
||||||
# between move selection and requesting another action that was "lost".
|
# between move selection and requesting another action that was "lost".
|
||||||
# We grant this back here.
|
# We grant this back here.
|
||||||
if @lastActionTimes[playerId]
|
if @lastActionTimes[playerId]
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
leftoverTime = now - @lastActionTimes[playerId]
|
leftoverTime = now - @lastActionTimes[playerId]
|
||||||
delete @lastActionTimes[playerId]
|
delete @lastActionTimes[playerId]
|
||||||
@addTime(playerId, leftoverTime)
|
@addTime(playerId, leftoverTime)
|
||||||
# In either case, we tell people that this player's timer resumes.
|
# In either case, we tell people that this player's timer resumes.
|
||||||
@send('resumeTimer', @id, @getPlayerIndex(playerId))
|
@send('resumeTimer', @id, @getPlayerIndex(playerId))
|
||||||
|
|
||||||
addAction: (playerId, action) ->
|
addAction: (playerId, action) ->
|
||||||
# Record the last action for use
|
# Record the last action for use
|
||||||
@lastActionTimes[playerId] = Date.now()
|
@lastActionTimes[playerId] = Date.now()
|
||||||
@recalculateTimers()
|
@recalculateTimers()
|
||||||
|
|
||||||
undoCompletedRequest: (playerId) ->
|
undoCompletedRequest: (playerId) ->
|
||||||
delete @lastActionTimes[playerId]
|
delete @lastActionTimes[playerId]
|
||||||
@recalculateTimers()
|
@recalculateTimers()
|
||||||
|
|
||||||
# Show players updated times
|
# Show players updated times
|
||||||
beginTurn: ->
|
beginTurn: ->
|
||||||
remainingTimes = []
|
remainingTimes = []
|
||||||
for id in @playerIds
|
for id in @playerIds
|
||||||
@addTime(id, @TIMER_PER_TURN_INCREASE)
|
@addTime(id, @TIMER_PER_TURN_INCREASE)
|
||||||
remainingTimes.push(@timeRemainingFor(id))
|
remainingTimes.push(@timeRemainingFor(id))
|
||||||
@send('updateTimers', @id, remainingTimes)
|
@send('updateTimers', @id, remainingTimes)
|
||||||
|
|
||||||
continueTurn: ->
|
continueTurn: ->
|
||||||
for id in @playerIds
|
for id in @playerIds
|
||||||
@send('pauseTimer', @id, @getPlayerIndex(id))
|
@send('pauseTimer', @id, @getPlayerIndex(id))
|
||||||
|
|
||||||
spectateBattle: (user) ->
|
spectateBattle: (user) ->
|
||||||
playerId = user.name
|
playerId = user.name
|
||||||
remainingTimes = (@timeRemainingFor(id) for id in @playerIds)
|
remainingTimes = (@timeRemainingFor(id) for id in @playerIds)
|
||||||
user.send('updateTimers', @id, remainingTimes)
|
user.send('updateTimers', @id, remainingTimes)
|
||||||
|
|
||||||
# Pause timer for players who have already chosen a move.
|
# Pause timer for players who have already chosen a move.
|
||||||
if @hasCompletedRequests(playerId)
|
if @hasCompletedRequests(playerId)
|
||||||
index = @getPlayerIndex(playerId)
|
index = @getPlayerIndex(playerId)
|
||||||
timeSinceLastAction = Date.now() - @lastActionTimes[playerId]
|
timeSinceLastAction = Date.now() - @lastActionTimes[playerId]
|
||||||
user.send('pauseTimer', @id, index, timeSinceLastAction)
|
user.send('pauseTimer', @id, index, timeSinceLastAction)
|
||||||
|
|
||||||
extend:
|
extend:
|
||||||
DEFAULT_TIMER: 3 * 60 * 1000 # three minutes
|
DEFAULT_TIMER: 3 * 60 * 1000 # three minutes
|
||||||
TIMER_PER_TURN_INCREASE: 15 * 1000 # fifteen seconds
|
TIMER_PER_TURN_INCREASE: 15 * 1000 # fifteen seconds
|
||||||
TIMER_CAP: 3 * 60 * 1000 # three minutes
|
TIMER_CAP: 3 * 60 * 1000 # three minutes
|
||||||
TEAM_PREVIEW_TIMER: 1.5 * 60 * 1000 # 1 minute and 30 seconds
|
TEAM_PREVIEW_TIMER: 1.5 * 60 * 1000 # 1 minute and 30 seconds
|
||||||
|
|
||||||
startTimer: (msecs) ->
|
startTimer: (msecs) ->
|
||||||
msecs ?= @DEFAULT_TIMER
|
msecs ?= @DEFAULT_TIMER
|
||||||
@timerId = setTimeout(@declareWinner.bind(this), msecs)
|
@timerId = setTimeout(@declareWinner.bind(this), msecs)
|
||||||
@once('end', => clearTimeout(@timerId))
|
@once('end', => clearTimeout(@timerId))
|
||||||
|
|
||||||
addTime: (id, msecs) ->
|
addTime: (id, msecs) ->
|
||||||
@playerTimes[id] += msecs
|
@playerTimes[id] += msecs
|
||||||
remainingTime = @timeRemainingFor(id)
|
remainingTime = @timeRemainingFor(id)
|
||||||
if remainingTime > @TIMER_CAP
|
if remainingTime > @TIMER_CAP
|
||||||
diff = remainingTime - @TIMER_CAP
|
diff = remainingTime - @TIMER_CAP
|
||||||
@playerTimes[id] -= diff
|
@playerTimes[id] -= diff
|
||||||
@recalculateTimers()
|
@recalculateTimers()
|
||||||
@playerTimes[id]
|
@playerTimes[id]
|
||||||
|
|
||||||
recalculateTimers: ->
|
recalculateTimers: ->
|
||||||
playerTimes = for id in @playerIds
|
playerTimes = for id in @playerIds
|
||||||
if @lastActionTimes[id] then Infinity else @timeRemainingFor(id)
|
if @lastActionTimes[id] then Infinity else @timeRemainingFor(id)
|
||||||
leastTime = Math.min(playerTimes...)
|
leastTime = Math.min(playerTimes...)
|
||||||
clearTimeout(@timerId)
|
clearTimeout(@timerId)
|
||||||
if 0 < leastTime < Infinity
|
if 0 < leastTime < Infinity
|
||||||
@timerId = setTimeout(@declareWinner.bind(this), leastTime)
|
@timerId = setTimeout(@declareWinner.bind(this), leastTime)
|
||||||
else if leastTime <= 0
|
else if leastTime <= 0
|
||||||
@declareWinner()
|
@declareWinner()
|
||||||
|
|
||||||
timeRemainingFor: (playerId) ->
|
timeRemainingFor: (playerId) ->
|
||||||
endTime = @playerTimes[playerId]
|
endTime = @playerTimes[playerId]
|
||||||
nowTime = @lastActionTimes[playerId] || Date.now()
|
nowTime = @lastActionTimes[playerId] || Date.now()
|
||||||
return endTime - nowTime
|
return endTime - nowTime
|
||||||
|
|
||||||
playersWithLeastTime: ->
|
playersWithLeastTime: ->
|
||||||
losingIds = []
|
losingIds = []
|
||||||
leastTimeRemaining = Infinity
|
leastTimeRemaining = Infinity
|
||||||
for id in @playerIds
|
for id in @playerIds
|
||||||
timeRemaining = @timeRemainingFor(id)
|
timeRemaining = @timeRemainingFor(id)
|
||||||
if timeRemaining < leastTimeRemaining
|
if timeRemaining < leastTimeRemaining
|
||||||
losingIds = [ id ]
|
losingIds = [ id ]
|
||||||
leastTimeRemaining = timeRemaining
|
leastTimeRemaining = timeRemaining
|
||||||
else if timeRemaining == leastTimeRemaining
|
else if timeRemaining == leastTimeRemaining
|
||||||
losingIds.push(id)
|
losingIds.push(id)
|
||||||
return losingIds
|
return losingIds
|
||||||
|
|
||||||
declareWinner: ->
|
declareWinner: ->
|
||||||
loserIds = @playersWithLeastTime()
|
loserIds = @playersWithLeastTime()
|
||||||
loserId = @rng.choice(loserIds, "timer")
|
loserId = @rng.choice(loserIds, "timer")
|
||||||
index = @getPlayerIndex(loserId)
|
index = @getPlayerIndex(loserId)
|
||||||
winnerIndex = 1 - index
|
winnerIndex = 1 - index
|
||||||
@timerWin(winnerIndex)
|
@timerWin(winnerIndex)
|
||||||
|
|
||||||
timerWin: (winnerIndex) ->
|
timerWin: (winnerIndex) ->
|
||||||
@tell(Protocol.TIMER_WIN, winnerIndex)
|
@tell(Protocol.TIMER_WIN, winnerIndex)
|
||||||
@emit('end', @playerIds[winnerIndex])
|
@emit('end', @playerIds[winnerIndex])
|
||||||
@sendUpdates()
|
@sendUpdates()
|
||||||
|
|
||||||
|
|
||||||
createCondition Conditions.TEAM_PREVIEW,
|
createCondition Conditions.TEAM_PREVIEW,
|
||||||
attach:
|
attach:
|
||||||
initialize: ->
|
initialize: ->
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{_} = require('underscore')
|
{_} = require('underscore')
|
||||||
{Formats} = require('../shared/conditions')
|
ConditionsFunc = require('../shared/conditions')
|
||||||
config = require('../knexfile')[process.env.NODE_ENV || 'development']
|
config = require('../knexfile')[process.env.NODE_ENV || 'development']
|
||||||
|
|
||||||
knex = require('knex')(config)
|
knex = require('knex')(config)
|
||||||
|
@ -39,7 +39,8 @@ Battle = bookshelf.Model.extend
|
||||||
@get('name') || @getPlayerNames().join(' vs. ') || 'Untitled'
|
@get('name') || @getPlayerNames().join(' vs. ') || 'Untitled'
|
||||||
|
|
||||||
getFormat: ->
|
getFormat: ->
|
||||||
Formats[@get('format')].humanName
|
allformats = ConditionsFunc.Formats()
|
||||||
|
allformats[@get('format')].humanName
|
||||||
|
|
||||||
getPlayerNames: ->
|
getPlayerNames: ->
|
||||||
# players is denormalized. It's an array with a comma delimiter.
|
# players is denormalized. It's an array with a comma delimiter.
|
||||||
|
|
|
@ -88,6 +88,8 @@ class @Attachment.Livewire extends @TeamAttachment
|
||||||
|
|
||||||
#On switch in
|
#On switch in
|
||||||
switchIn: (pokemon) ->
|
switchIn: (pokemon) ->
|
||||||
|
if pokemon.isFainted()
|
||||||
|
return
|
||||||
#if pokemon is part electric and not immune to ground, remove livewire. Also if has ground and is not immune to ground
|
#if pokemon is part electric and not immune to ground, remove livewire. Also if has ground and is not immune to ground
|
||||||
if (pokemon.hasType("Electric") && !pokemon.isImmune("Ground")) || (pokemon.hasType("Ground") && !pokemon.isImmune("Ground"))
|
if (pokemon.hasType("Electric") && !pokemon.isImmune("Ground")) || (pokemon.hasType("Ground") && !pokemon.isImmune("Ground"))
|
||||||
@team.unattach(@constructor)
|
@team.unattach(@constructor)
|
||||||
|
|
|
@ -798,12 +798,12 @@
|
||||||
"Fighting"
|
"Fighting"
|
||||||
],
|
],
|
||||||
"stats": {
|
"stats": {
|
||||||
"attack": 165,
|
"attack": 155,
|
||||||
"defense": 100,
|
"defense": 100,
|
||||||
"hp": 65,
|
"hp": 65,
|
||||||
"specialAttack": 70,
|
"specialAttack": 80,
|
||||||
"specialDefense": 60,
|
"specialDefense": 70,
|
||||||
"speed": 130
|
"speed": 120
|
||||||
},
|
},
|
||||||
"abilities": [
|
"abilities": [
|
||||||
"Technician"
|
"Technician"
|
||||||
|
@ -6259,6 +6259,7 @@
|
||||||
"Psychic"
|
"Psychic"
|
||||||
],
|
],
|
||||||
"weight": 3,
|
"weight": 3,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 145,
|
"pokeBattleValue": 145,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
}
|
}
|
||||||
|
@ -8206,19 +8207,18 @@
|
||||||
"Steel"
|
"Steel"
|
||||||
],
|
],
|
||||||
"stats": {
|
"stats": {
|
||||||
"attack": 145,
|
"attack": 155,
|
||||||
"defense": 125,
|
"defense": 100,
|
||||||
"hp": 65,
|
"hp": 65,
|
||||||
"specialAttack": 60,
|
"specialAttack": 80,
|
||||||
"specialDefense": 85,
|
"specialDefense": 70,
|
||||||
"speed": 105
|
"speed": 120
|
||||||
},
|
},
|
||||||
"abilities": [
|
"abilities": [
|
||||||
"Moxie"
|
"Moxie"
|
||||||
],
|
],
|
||||||
"isBattleOnly": true,
|
"isBattleOnly": true,
|
||||||
"weight": 700,
|
"weight": 700,
|
||||||
"unreleased": true,
|
|
||||||
"pokeBattleValue": 1001,
|
"pokeBattleValue": 1001,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "Uber" ]
|
||||||
}
|
}
|
||||||
|
@ -10770,6 +10770,7 @@
|
||||||
"Grass"
|
"Grass"
|
||||||
],
|
],
|
||||||
"weight": 50,
|
"weight": 50,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 150,
|
"pokeBattleValue": 150,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
}
|
}
|
||||||
|
@ -12977,6 +12978,7 @@
|
||||||
],
|
],
|
||||||
"weight": 2500,
|
"weight": 2500,
|
||||||
"pokeBattleValue": 130,
|
"pokeBattleValue": 130,
|
||||||
|
"unreleased": true,
|
||||||
"tier": [ "UU" ]
|
"tier": [ "UU" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -13904,6 +13906,7 @@
|
||||||
"Psychic"
|
"Psychic"
|
||||||
],
|
],
|
||||||
"weight": 856,
|
"weight": 856,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 140,
|
"pokeBattleValue": 140,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
}
|
}
|
||||||
|
@ -14699,6 +14702,7 @@
|
||||||
"types": [
|
"types": [
|
||||||
"Dark"
|
"Dark"
|
||||||
],
|
],
|
||||||
|
"unreleased": true,
|
||||||
"weight": 505,
|
"weight": 505,
|
||||||
"pokeBattleValue": 1001,
|
"pokeBattleValue": 1001,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "Uber" ]
|
||||||
|
@ -15598,6 +15602,7 @@
|
||||||
"Psychic"
|
"Psychic"
|
||||||
],
|
],
|
||||||
"weight": 608,
|
"weight": 608,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 1001,
|
"pokeBattleValue": 1001,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "Uber" ]
|
||||||
},
|
},
|
||||||
|
@ -15693,6 +15698,7 @@
|
||||||
"Psychic"
|
"Psychic"
|
||||||
],
|
],
|
||||||
"weight": 608,
|
"weight": 608,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 200,
|
"pokeBattleValue": 200,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "Uber" ]
|
||||||
},
|
},
|
||||||
|
@ -15732,6 +15738,7 @@
|
||||||
],
|
],
|
||||||
"weight": 608,
|
"weight": 608,
|
||||||
"pokeBattleValue": 200,
|
"pokeBattleValue": 200,
|
||||||
|
"unreleased": true,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "Uber" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -16066,6 +16073,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pokeBattleValue": 155,
|
"pokeBattleValue": 155,
|
||||||
|
"unreleased": true,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
},
|
},
|
||||||
"mega": {
|
"mega": {
|
||||||
|
@ -31349,6 +31357,7 @@
|
||||||
"Fighting"
|
"Fighting"
|
||||||
],
|
],
|
||||||
"weight": 485,
|
"weight": 485,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 175,
|
"pokeBattleValue": 175,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
},
|
},
|
||||||
|
@ -31438,6 +31447,7 @@
|
||||||
"Fighting"
|
"Fighting"
|
||||||
],
|
],
|
||||||
"weight": 485,
|
"weight": 485,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 175,
|
"pokeBattleValue": 175,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
}
|
}
|
||||||
|
@ -32623,6 +32633,7 @@
|
||||||
"Dragon",
|
"Dragon",
|
||||||
"Ice"
|
"Ice"
|
||||||
],
|
],
|
||||||
|
"unreleased": true,
|
||||||
"weight": 3250,
|
"weight": 3250,
|
||||||
"pokeBattleValue": 180,
|
"pokeBattleValue": 180,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
|
@ -33052,6 +33063,7 @@
|
||||||
"Flying"
|
"Flying"
|
||||||
],
|
],
|
||||||
"weight": 680,
|
"weight": 680,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 180,
|
"pokeBattleValue": 180,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "Uber" ]
|
||||||
},
|
},
|
||||||
|
@ -33148,6 +33160,7 @@
|
||||||
"Flying"
|
"Flying"
|
||||||
],
|
],
|
||||||
"weight": 680,
|
"weight": 680,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 175,
|
"pokeBattleValue": 175,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
}
|
}
|
||||||
|
@ -33606,6 +33619,7 @@
|
||||||
"Psychic"
|
"Psychic"
|
||||||
],
|
],
|
||||||
"weight": 400,
|
"weight": 400,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 165,
|
"pokeBattleValue": 165,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
},
|
},
|
||||||
|
@ -33627,8 +33641,8 @@
|
||||||
],
|
],
|
||||||
"isBattleOnly": true,
|
"isBattleOnly": true,
|
||||||
"weight": 520,
|
"weight": 520,
|
||||||
"pokeBattleValue": 1001,
|
"pokeBattleValue": 190,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "OU"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Latios": {
|
"Latios": {
|
||||||
|
@ -33730,6 +33744,7 @@
|
||||||
"Dragon",
|
"Dragon",
|
||||||
"Psychic"
|
"Psychic"
|
||||||
],
|
],
|
||||||
|
"unreleased": true,
|
||||||
"weight": 600,
|
"weight": 600,
|
||||||
"pokeBattleValue": 175,
|
"pokeBattleValue": 175,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
|
@ -33752,8 +33767,8 @@
|
||||||
],
|
],
|
||||||
"isBattleOnly": true,
|
"isBattleOnly": true,
|
||||||
"weight": 700,
|
"weight": 700,
|
||||||
"pokeBattleValue": 1001,
|
"pokeBattleValue": 190,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "OU" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Leafeon": {
|
"Leafeon": {
|
||||||
|
@ -39046,6 +39061,7 @@
|
||||||
"Psychic"
|
"Psychic"
|
||||||
],
|
],
|
||||||
"weight": 3,
|
"weight": 3,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 130,
|
"pokeBattleValue": 130,
|
||||||
"tier": [ "UU" ]
|
"tier": [ "UU" ]
|
||||||
}
|
}
|
||||||
|
@ -44893,6 +44909,7 @@
|
||||||
"Water"
|
"Water"
|
||||||
],
|
],
|
||||||
"weight": 31,
|
"weight": 31,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 80,
|
"pokeBattleValue": 80,
|
||||||
"tier": [ "Unsorted" ]
|
"tier": [ "Unsorted" ]
|
||||||
}
|
}
|
||||||
|
@ -52850,8 +52867,9 @@
|
||||||
"Grass"
|
"Grass"
|
||||||
],
|
],
|
||||||
"weight": 21,
|
"weight": 21,
|
||||||
"pokeBattleValue": 140,
|
"unreleased": true,
|
||||||
"tier": [ "OU" ]
|
"pokeBattleValue": 130,
|
||||||
|
"tier": [ "UU" ]
|
||||||
},
|
},
|
||||||
"sky": {
|
"sky": {
|
||||||
"abilities": [
|
"abilities": [
|
||||||
|
@ -52915,6 +52933,7 @@
|
||||||
"Flying"
|
"Flying"
|
||||||
],
|
],
|
||||||
"weight": 52,
|
"weight": 52,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 335,
|
"pokeBattleValue": 335,
|
||||||
"tier": [ "Uber" ]
|
"tier": [ "Uber" ]
|
||||||
}
|
}
|
||||||
|
@ -60197,6 +60216,7 @@
|
||||||
"Fighting"
|
"Fighting"
|
||||||
],
|
],
|
||||||
"weight": 2600,
|
"weight": 2600,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 160,
|
"pokeBattleValue": 160,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
}
|
}
|
||||||
|
@ -61197,6 +61217,7 @@
|
||||||
"Flying"
|
"Flying"
|
||||||
],
|
],
|
||||||
"weight": 630,
|
"weight": 630,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 160,
|
"pokeBattleValue": 160,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
},
|
},
|
||||||
|
@ -61291,6 +61312,7 @@
|
||||||
"Flying"
|
"Flying"
|
||||||
],
|
],
|
||||||
"weight": 630,
|
"weight": 630,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 170,
|
"pokeBattleValue": 170,
|
||||||
"tier": [ "OU" ]
|
"tier": [ "OU" ]
|
||||||
}
|
}
|
||||||
|
@ -62387,12 +62409,12 @@
|
||||||
"Fire"
|
"Fire"
|
||||||
],
|
],
|
||||||
"stats": {
|
"stats": {
|
||||||
"attack": 85,
|
"attack": 90,
|
||||||
"defense": 78,
|
"defense": 88,
|
||||||
"hp": 78,
|
"hp": 78,
|
||||||
"specialAttack": 160,
|
"specialAttack": 160,
|
||||||
"specialDefense": 109,
|
"specialDefense": 110,
|
||||||
"speed": 125
|
"speed": 109
|
||||||
},
|
},
|
||||||
"abilities": [
|
"abilities": [
|
||||||
"Hubris"
|
"Hubris"
|
||||||
|
@ -63118,6 +63140,7 @@
|
||||||
"types": [
|
"types": [
|
||||||
"Psychic"
|
"Psychic"
|
||||||
],
|
],
|
||||||
|
"unreleased": true,
|
||||||
"weight": 3,
|
"weight": 3,
|
||||||
"pokeBattleValue": 130,
|
"pokeBattleValue": 130,
|
||||||
"tier": [ "UU" ]
|
"tier": [ "UU" ]
|
||||||
|
@ -64309,6 +64332,7 @@
|
||||||
"Fighting"
|
"Fighting"
|
||||||
],
|
],
|
||||||
"weight": 2000,
|
"weight": 2000,
|
||||||
|
"unreleased": true,
|
||||||
"pokeBattleValue": 130,
|
"pokeBattleValue": 130,
|
||||||
"tier": [ "UU" ]
|
"tier": [ "UU" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 407,
|
"spriteId": 407,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Absorb Bulb": {
|
"Absorb Bulb": {
|
||||||
|
@ -55,6 +56,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 397,
|
"spriteId": 397,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Aguav Berry": {
|
"Aguav Berry": {
|
||||||
|
@ -81,6 +83,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 409,
|
"spriteId": 409,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Amaze Mulch": {
|
"Amaze Mulch": {
|
||||||
|
@ -193,6 +196,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 398,
|
"spriteId": 398,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -204,7 +208,8 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 404,
|
"spriteId": 404,
|
||||||
"type": "megastone"
|
"type": "megastone",
|
||||||
|
"unreleased": true
|
||||||
}, "Belue Berry": {
|
}, "Belue Berry": {
|
||||||
"description": "No competitive use.",
|
"description": "No competitive use.",
|
||||||
"flingPower": 10,
|
"flingPower": 10,
|
||||||
|
@ -213,6 +218,7 @@
|
||||||
"type": "Electric"
|
"type": "Electric"
|
||||||
},
|
},
|
||||||
"spriteId": 166,
|
"spriteId": 166,
|
||||||
|
|
||||||
"type": "berries"
|
"type": "berries"
|
||||||
},
|
},
|
||||||
"Berry Juice": {
|
"Berry Juice": {
|
||||||
|
@ -259,6 +265,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 404,
|
"spriteId": 404,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
}, "Black Belt": {
|
}, "Black Belt": {
|
||||||
"description": "The holder's Fighting-type attacks have their power multiplied by 1.2.",
|
"description": "The holder's Fighting-type attacks have their power multiplied by 1.2.",
|
||||||
|
@ -382,7 +389,6 @@
|
||||||
"Bug Gem": {
|
"Bug Gem": {
|
||||||
"description": "The holder's first successful Bug-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Bug-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 342,
|
"spriteId": 342,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -455,6 +461,7 @@
|
||||||
"mega-x"
|
"mega-x"
|
||||||
],
|
],
|
||||||
"spriteId": 390,
|
"spriteId": 390,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Charizardite Y": {
|
"Charizardite Y": {
|
||||||
|
@ -619,7 +626,6 @@
|
||||||
"Custap Berry": {
|
"Custap Berry": {
|
||||||
"description": "The holder moves first in its priority bracket if it has 1/4 or less of its maximum HP. Single use.",
|
"description": "The holder moves first in its priority bracket if it has 1/4 or less of its maximum HP. Single use.",
|
||||||
"flingPower": 10,
|
"flingPower": 10,
|
||||||
"unreleased": true,
|
|
||||||
"naturalGift": {
|
"naturalGift": {
|
||||||
"power": 100,
|
"power": 100,
|
||||||
"type": "Ghost"
|
"type": "Ghost"
|
||||||
|
@ -648,7 +654,6 @@
|
||||||
"Dark Gem": {
|
"Dark Gem": {
|
||||||
"description": "The holder's first successful Dark-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Dark-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 346,
|
"spriteId": 346,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -782,6 +787,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 404,
|
"spriteId": 404,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
}, "Douse Drive": {
|
}, "Douse Drive": {
|
||||||
"description": "The holder's Techno Blast is Water type.",
|
"description": "The holder's Techno Blast is Water type.",
|
||||||
|
@ -804,7 +810,6 @@
|
||||||
"Dragon Gem": {
|
"Dragon Gem": {
|
||||||
"description": "The holder's first successful Dragon-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Dragon-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 345,
|
"spriteId": 345,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -885,7 +890,6 @@
|
||||||
"Electric Gem": {
|
"Electric Gem": {
|
||||||
"description": "The holder's first successful Electric-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Electric-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 334,
|
"spriteId": 334,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -950,7 +954,6 @@
|
||||||
"Fairy Gem": {
|
"Fairy Gem": {
|
||||||
"description": "The holder's first successful Fairy-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Fairy-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 425,
|
"spriteId": 425,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -979,7 +982,6 @@
|
||||||
}, "Fighting Gem": {
|
}, "Fighting Gem": {
|
||||||
"description": "The holder's first successful Fighting-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Fighting-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 337,
|
"spriteId": 337,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -996,7 +998,6 @@
|
||||||
"Fire Gem": {
|
"Fire Gem": {
|
||||||
"description": "The holder's first successful Fire-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Fire-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 332,
|
"spriteId": 332,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -1048,7 +1049,6 @@
|
||||||
"Flying Gem": {
|
"Flying Gem": {
|
||||||
"description": "The holder's first successful Flying-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Flying-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": false,
|
|
||||||
"spriteId": 340,
|
"spriteId": 340,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -1102,6 +1102,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 404,
|
"spriteId": 404,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Ganlon Berry": {
|
"Ganlon Berry": {
|
||||||
|
@ -1122,6 +1123,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 413,
|
"spriteId": 413,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Gardevoirite": {
|
"Gardevoirite": {
|
||||||
|
@ -1132,6 +1134,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 387,
|
"spriteId": 387,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Gengarite": {
|
"Gengarite": {
|
||||||
|
@ -1153,7 +1156,6 @@
|
||||||
"Ghost Gem": {
|
"Ghost Gem": {
|
||||||
"description": "The holder's first successful Ghost-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Ghost-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 344,
|
"spriteId": 344,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -1194,7 +1196,6 @@
|
||||||
"Grass Gem": {
|
"Grass Gem": {
|
||||||
"description": "The holder's first successful Grass-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Grass-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 335,
|
"spriteId": 335,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -1248,7 +1249,6 @@
|
||||||
"Ground Gem": {
|
"Ground Gem": {
|
||||||
"description": "The holder's first successful Ground-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Ground-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 339,
|
"spriteId": 339,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -1272,6 +1272,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 406,
|
"spriteId": 406,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"HP Up": {
|
"HP Up": {
|
||||||
|
@ -1372,6 +1373,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 396,
|
"spriteId": 396,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Hyper Potion": {
|
"Hyper Potion": {
|
||||||
|
@ -1393,7 +1395,6 @@
|
||||||
"Ice Gem": {
|
"Ice Gem": {
|
||||||
"description": "The holder's first successful Ice-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Ice-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 336,
|
"spriteId": 336,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -1471,6 +1472,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 405,
|
"spriteId": 405,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Kasib Berry": {
|
"Kasib Berry": {
|
||||||
|
@ -1646,6 +1648,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 404,
|
"spriteId": 404,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Love Ball": {
|
"Love Ball": {
|
||||||
|
@ -1662,6 +1665,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 403,
|
"spriteId": 403,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Luck Incense": {
|
"Luck Incense": {
|
||||||
|
@ -1741,6 +1745,7 @@
|
||||||
"description": "No competitive use. Evolves Magmar into Magmortar when traded.",
|
"description": "No competitive use. Evolves Magmar into Magmortar when traded.",
|
||||||
"flingPower": 80,
|
"flingPower": 80,
|
||||||
"spriteId": 306,
|
"spriteId": 306,
|
||||||
|
"unreleased": true,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
"Magnet": {
|
"Magnet": {
|
||||||
|
@ -1777,6 +1782,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 412,
|
"spriteId": 412,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Maranga Berry": {
|
"Maranga Berry": {
|
||||||
|
@ -1859,6 +1865,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 395,
|
"spriteId": 395,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
}, "Meganiumite": {
|
}, "Meganiumite": {
|
||||||
"description": "If the holder is a Meganium, this item allows it to Mega Evolve into Mega Meganium in battle.",
|
"description": "If the holder is a Meganium, this item allows it to Mega Evolve into Mega Meganium in battle.",
|
||||||
|
@ -1868,6 +1875,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 404,
|
"spriteId": 404,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Mental Herb": {
|
"Mental Herb": {
|
||||||
|
@ -1927,7 +1935,6 @@
|
||||||
"Micle Berry": {
|
"Micle Berry": {
|
||||||
"description": "The holder's next move has its accuracy multiplied by 1.2 when it has 1/4 or less of its maximum HP. Single use.",
|
"description": "The holder's next move has its accuracy multiplied by 1.2 when it has 1/4 or less of its maximum HP. Single use.",
|
||||||
"flingPower": 10,
|
"flingPower": 10,
|
||||||
"unreleased": true,
|
|
||||||
"naturalGift": {
|
"naturalGift": {
|
||||||
"power": 100,
|
"power": 100,
|
||||||
"type": "Rock"
|
"type": "Rock"
|
||||||
|
@ -1941,6 +1948,7 @@
|
||||||
"Milotic",
|
"Milotic",
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
|
"unreleased": true,
|
||||||
"spriteId": 404,
|
"spriteId": 404,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
}, "Miltankite": {
|
}, "Miltankite": {
|
||||||
|
@ -2237,6 +2245,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 401,
|
"spriteId": 401,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Pixie Plate": {
|
"Pixie Plate": {
|
||||||
|
@ -2260,7 +2269,6 @@
|
||||||
"Poison Gem": {
|
"Poison Gem": {
|
||||||
"description": "The holder's first successful Poison-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Poison-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 338,
|
"spriteId": 338,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -2373,7 +2381,6 @@
|
||||||
"Psychic Gem": {
|
"Psychic Gem": {
|
||||||
"description": "The holder's first successful Psychic-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Psychic-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 341,
|
"spriteId": 341,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -2621,7 +2628,6 @@
|
||||||
"Rock Gem": {
|
"Rock Gem": {
|
||||||
"description": "The holder's first successful Rock-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Rock-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 343,
|
"spriteId": 343,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -2748,6 +2754,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 400,
|
"spriteId": 400,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Scope Lens": {
|
"Scope Lens": {
|
||||||
|
@ -2783,6 +2790,7 @@
|
||||||
"mega"
|
"mega"
|
||||||
],
|
],
|
||||||
"spriteId": 404,
|
"spriteId": 404,
|
||||||
|
"unreleased": true,
|
||||||
"type": "megastone"
|
"type": "megastone"
|
||||||
},
|
},
|
||||||
"Shed Shell": {
|
"Shed Shell": {
|
||||||
|
@ -3001,7 +3009,6 @@
|
||||||
"Steel Gem": {
|
"Steel Gem": {
|
||||||
"description": "The holder's first successful Steel-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Steel-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 347,
|
"spriteId": 347,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
@ -3227,7 +3234,6 @@
|
||||||
"Water Gem": {
|
"Water Gem": {
|
||||||
"description": "The holder's first successful Water-type attack has its power multiplied by 1.3. Single use.",
|
"description": "The holder's first successful Water-type attack has its power multiplied by 1.3. Single use.",
|
||||||
"flingPower": 0,
|
"flingPower": 0,
|
||||||
"unreleased": true,
|
|
||||||
"spriteId": 333,
|
"spriteId": 333,
|
||||||
"type": "misc"
|
"type": "misc"
|
||||||
},
|
},
|
||||||
|
|
|
@ -357,6 +357,23 @@ CLIENT_VERSION = assets.getVersion()
|
||||||
server.removePlayer(user.name)
|
server.removePlayer(user.name)
|
||||||
user.send("findBattleCanceled")
|
user.send("findBattleCanceled")
|
||||||
|
|
||||||
|
spark.on 'findBattleunranked', (format, team, altName=null) ->
|
||||||
|
return unless _.isString(format)
|
||||||
|
return unless _.isObject(team)
|
||||||
|
return unless !altName || _.isString(altName)
|
||||||
|
# Note: If altName == null, then isAltOwnedBy will return true
|
||||||
|
alts.isAltOwnedBy user.name, altName, (err, valid) ->
|
||||||
|
if not valid
|
||||||
|
user.error(errors.INVALID_ALT_NAME, "You do not own this alt")
|
||||||
|
else
|
||||||
|
validationErrors = server.queuePlayerunranked(user.name, team, format, altName)
|
||||||
|
if validationErrors.length > 0
|
||||||
|
user.error(errors.FIND_BATTLE, validationErrors)
|
||||||
|
|
||||||
|
spark.on 'cancelFindBattleunranked', ->
|
||||||
|
server.removePlayerunranked(user.name)
|
||||||
|
user.send("findBattleCanceledUnranked")
|
||||||
|
|
||||||
spark.on 'sendMove', (battleId, moveName, slot, forTurn, options, callback) ->
|
spark.on 'sendMove', (battleId, moveName, slot, forTurn, options, callback) ->
|
||||||
return unless _.isString(moveName)
|
return unless _.isString(moveName)
|
||||||
return unless _.isFinite(slot)
|
return unless _.isFinite(slot)
|
||||||
|
@ -425,7 +442,20 @@ CLIENT_VERSION = assets.getVersion()
|
||||||
lobby.message(message)
|
lobby.message(message)
|
||||||
setTimeout(battleSearch, 5 * 1000)
|
setTimeout(battleSearch, 5 * 1000)
|
||||||
|
|
||||||
|
battleSearchUnranked = ->
|
||||||
|
server.beginBattlesunranked (err, battleIds) ->
|
||||||
|
if err then return
|
||||||
|
for id in battleIds
|
||||||
|
battle = server.findBattle(id)
|
||||||
|
playerIds = battle.getPlayerIds()
|
||||||
|
ratingKeys = playerIds.map((id) -> battle.getPlayer(id).ratingKey)
|
||||||
|
ratings.getRanks ratingKeys, (err, fullRanks) ->
|
||||||
|
ranks = _.compact(fullRanks)
|
||||||
|
setTimeout(battleSearchUnranked, 5 * 1000)
|
||||||
|
|
||||||
|
|
||||||
battleSearch()
|
battleSearch()
|
||||||
|
battleSearchUnranked()
|
||||||
|
|
||||||
httpServer.listen(port)
|
httpServer.listen(port)
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ class @BattleQueue
|
||||||
@newPlayers = []
|
@newPlayers = []
|
||||||
@recentlyMatched = {}
|
@recentlyMatched = {}
|
||||||
@length = 0
|
@length = 0
|
||||||
|
@ranked = true
|
||||||
|
|
||||||
# Adds a player to the queue.
|
# Adds a player to the queue.
|
||||||
# "name" can either be the real name, or an alt
|
# "name" can either be the real name, or an alt
|
||||||
|
@ -40,6 +41,9 @@ class @BattleQueue
|
||||||
@newPlayers.push(player)
|
@newPlayers.push(player)
|
||||||
@length += 1
|
@length += 1
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
setUnranked: ->
|
||||||
|
@ranked = false
|
||||||
|
|
||||||
remove: (playerIds) ->
|
remove: (playerIds) ->
|
||||||
playerIds = Array(playerIds) if playerIds not instanceof Array
|
playerIds = Array(playerIds) if playerIds not instanceof Array
|
||||||
|
@ -71,23 +75,26 @@ class @BattleQueue
|
||||||
# An internal function which loads ratings for newly queued players
|
# An internal function which loads ratings for newly queued players
|
||||||
# and removes them from the newly queued list
|
# and removes them from the newly queued list
|
||||||
updateNewPlayers: (next) ->
|
updateNewPlayers: (next) ->
|
||||||
ratingKeys = (queued.player.ratingKey for queued in @newPlayers)
|
if @ranked == true
|
||||||
return next(null) if ratingKeys.length == 0
|
ratingKeys = (queued.player.ratingKey for queued in @newPlayers)
|
||||||
|
return next(null) if ratingKeys.length == 0
|
||||||
|
|
||||||
ratings.getRatings ratingKeys, (err, returnedRatings) =>
|
ratings.getRatings ratingKeys, (err, returnedRatings) =>
|
||||||
if err then return next(err)
|
|
||||||
|
|
||||||
ratings.setActive ratingKeys, (err) =>
|
|
||||||
if err then return next(err)
|
if err then return next(err)
|
||||||
|
|
||||||
# Update the ratings in the player objects
|
ratings.setActive ratingKeys, (err) =>
|
||||||
for rating, i in returnedRatings
|
if err then return next(err)
|
||||||
continue unless @hasUserId(@newPlayers[i].player.id)
|
|
||||||
@newPlayers[i].rating = rating
|
|
||||||
|
|
||||||
# reset the new players list, we're done
|
# Update the ratings in the player objects
|
||||||
@newPlayers.splice(0, @newPlayers.length)
|
for rating, i in returnedRatings
|
||||||
next(null)
|
continue unless @hasUserId(@newPlayers[i].player.id)
|
||||||
|
@newPlayers[i].rating = rating
|
||||||
|
|
||||||
|
# reset the new players list, we're done
|
||||||
|
@newPlayers.splice(0, @newPlayers.length)
|
||||||
|
next(null)
|
||||||
|
else
|
||||||
|
next(null)
|
||||||
|
|
||||||
# Returns an array of pairs. Each pair is a queue object that contains
|
# Returns an array of pairs. Each pair is a queue object that contains
|
||||||
# a player and team key, corresponding to the player socket and player's team.
|
# a player and team key, corresponding to the player socket and player's team.
|
||||||
|
@ -98,7 +105,8 @@ class @BattleQueue
|
||||||
if err then return next(err, null)
|
if err then return next(err, null)
|
||||||
|
|
||||||
sortedPlayers = (queued for id, queued of @queue)
|
sortedPlayers = (queued for id, queued of @queue)
|
||||||
sortedPlayers.sort((a, b) -> a.rating - b.rating)
|
if @ranked
|
||||||
|
sortedPlayers.sort((a, b) -> a.rating - b.rating)
|
||||||
|
|
||||||
alreadyMatched = (false for [0...sortedPlayers.length])
|
alreadyMatched = (false for [0...sortedPlayers.length])
|
||||||
|
|
||||||
|
@ -115,20 +123,19 @@ class @BattleQueue
|
||||||
rightPlayer = right.player
|
rightPlayer = right.player
|
||||||
|
|
||||||
# Continue if these two players already played
|
# Continue if these two players already played
|
||||||
continue if @hasRecentlyMatched(leftPlayer.id, rightPlayer.id)
|
continue if @hasRecentlyMatched(leftPlayer.id, rightPlayer.id) and @ranked
|
||||||
|
|
||||||
# If the rating difference is too large break out, we have no possible match for left
|
# If the rating difference is too large break out, we have no possible match for left
|
||||||
break unless left.intersectsWith(right)
|
break unless left.intersectsWith(right)
|
||||||
|
|
||||||
# Everything checks out, so make the pair and break out
|
# Everything checks out, so make the pair and break out
|
||||||
pairs.push([leftPlayer, rightPlayer])
|
pairs.push([leftPlayer, rightPlayer])
|
||||||
@remove([leftPlayer.id, rightPlayer.id])
|
@remove([leftPlayer.id, rightPlayer.id])
|
||||||
@addRecentMatch(leftPlayer.id, rightPlayer.id)
|
@addRecentMatch(leftPlayer.id, rightPlayer.id) if @ranked
|
||||||
alreadyMatched[leftIdx] = alreadyMatched[rightIdx] = true
|
alreadyMatched[leftIdx] = alreadyMatched[rightIdx] = true
|
||||||
break
|
break
|
||||||
|
|
||||||
# Expand the range of all unmatched players
|
# Expand the range of all unmatched players
|
||||||
queued.range += RANGE_INCREMENT for id, queued of @queue
|
queued.range += RANGE_INCREMENT for id, queued of @queue
|
||||||
|
|
||||||
# Return the list of paired players
|
# Return the list of paired players
|
||||||
|
|
||||||
next(null, pairs)
|
next(null, pairs)
|
||||||
|
|
|
@ -30,14 +30,28 @@ FIND_BATTLE_CONDITIONS = [
|
||||||
Conditions.UNRELEASED_BAN
|
Conditions.UNRELEASED_BAN
|
||||||
]
|
]
|
||||||
|
|
||||||
|
FIND_BATTLE_CONDITIONS_UNRANKED = [
|
||||||
|
Conditions.TEAM_PREVIEW
|
||||||
|
Conditions.TIMED_BATTLE
|
||||||
|
Conditions.SLEEP_CLAUSE
|
||||||
|
Conditions.EVASION_CLAUSE
|
||||||
|
Conditions.SPECIES_CLAUSE
|
||||||
|
Conditions.PRANKSTER_SWAGGER_CLAUSE
|
||||||
|
Conditions.OHKO_CLAUSE
|
||||||
|
Conditions.UNRELEASED_BAN
|
||||||
|
]
|
||||||
|
|
||||||
MAX_NICKNAME_LENGTH = 15
|
MAX_NICKNAME_LENGTH = 15
|
||||||
|
|
||||||
class @BattleServer
|
class @BattleServer
|
||||||
constructor: ->
|
constructor: ->
|
||||||
@queues = {}
|
@queues = {}
|
||||||
|
@unrankedqueues = {}
|
||||||
allformats = ConditionsFunc.Formats()
|
allformats = ConditionsFunc.Formats()
|
||||||
for format of allformats
|
for format of allformats
|
||||||
@queues[format] = new BattleQueue()
|
@queues[format] = new BattleQueue()
|
||||||
|
@unrankedqueues[format] = new BattleQueue()
|
||||||
|
@unrankedqueues[format].setUnranked()
|
||||||
@battles = {}
|
@battles = {}
|
||||||
|
|
||||||
# A hash mapping users to battles.
|
# A hash mapping users to battles.
|
||||||
|
@ -239,7 +253,46 @@ class @BattleServer
|
||||||
return next(err) if err
|
return next(err) if err
|
||||||
next(null, _.flatten(battleIds))
|
next(null, _.flatten(battleIds))
|
||||||
return true
|
return true
|
||||||
|
#########################################################################################
|
||||||
|
# Adds the player to the queue. Note that there is no validation on whether altName
|
||||||
|
# is correct, so make
|
||||||
|
queuePlayerunranked: (playerId, team, format = DEFAULT_FORMAT, altName) ->
|
||||||
|
if @isLockedDown()
|
||||||
|
err = ["The server is restarting after all battles complete. No new battles can start at this time."]
|
||||||
|
else
|
||||||
|
err = @validateTeam(team, format, FIND_BATTLE_CONDITIONS)
|
||||||
|
if err.length == 0
|
||||||
|
name = @users.get(playerId).name
|
||||||
|
ratingKey = alts.uniqueId(playerId, altName)
|
||||||
|
@unrankedqueues[format].add(playerId, altName || name, team, ratingKey)
|
||||||
|
return err
|
||||||
|
|
||||||
|
queuedPlayersunranked: (format = DEFAULT_FORMAT) ->
|
||||||
|
@unrankedqueues[format].queuedPlayers()
|
||||||
|
|
||||||
|
removePlayerunranked: (playerId, format = DEFAULT_FORMAT) ->
|
||||||
|
return false if format not of @unrankedqueues
|
||||||
|
@unrankedqueues[format].remove(playerId)
|
||||||
|
return true
|
||||||
|
|
||||||
|
beginBattlesunranked: (next) ->
|
||||||
|
allformats = ConditionsFunc.Formats()
|
||||||
|
array = for format in Object.keys(allformats)
|
||||||
|
do (format) => (callback) =>
|
||||||
|
@unrankedqueues[format].pairPlayers (err, pairs) =>
|
||||||
|
if err then console.log(err)
|
||||||
|
if err then return callback(err)
|
||||||
|
# Create a battle for each pair
|
||||||
|
battleIds = []
|
||||||
|
for pair in pairs
|
||||||
|
id = @createBattle(format, pair, FIND_BATTLE_CONDITIONS_UNRANKED)
|
||||||
|
battleIds.push(id)
|
||||||
|
callback(null, battleIds)
|
||||||
|
async.parallel array, (err, battleIds) ->
|
||||||
|
return next(err) if err
|
||||||
|
next(null, _.flatten(battleIds))
|
||||||
|
return true
|
||||||
|
#########################################################################################
|
||||||
# Creates a battle and returns its battleId
|
# Creates a battle and returns its battleId
|
||||||
createBattle: (rawFormat = DEFAULT_FORMAT, pair = [], conditions = []) ->
|
createBattle: (rawFormat = DEFAULT_FORMAT, pair = [], conditions = []) ->
|
||||||
allformats = ConditionsFunc.Formats()
|
allformats = ConditionsFunc.Formats()
|
||||||
|
|
Loading…
Reference in New Issue