From 16ac69171d710d9be91c4f3427c7e22829426c5d Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Wed, 10 Feb 2016 03:10:17 +0100 Subject: [PATCH] Added Find Battle Unranked --- client/app/css/core.styl | 2 +- client/app/js/concerns/main_buttons.coffee | 70 ++ client/app/js/helpers/challenge_pane.coffee | 21 +- .../app/js/views/battles/battle_view.coffee | 4 +- client/templates/index.jade | 6 +- client/templates/layout.jade | 2 +- client/views/battle_user_info.jade | 35 +- public/Sprites/Icons/iconempty.png | Bin 0 -> 301 bytes public/Sprites/favicon.png | Bin 0 -> 597 bytes public/css/main.css | 2 +- public/js/app.js | 84 ++- public/js/data.js | 2 +- public/js/replays.js | 34 +- public/js/templates.js | 58 +- server/bw/move.coffee | 3 - server/conditions.coffee | 631 +++++++++--------- server/database.coffee | 5 +- server/in/attachment.coffee | 2 + server/in/data/data_formes.json | 64 +- server/in/data/data_items.json | 46 +- server/index.coffee | 30 + server/queue.coffee | 43 +- server/server.coffee | 53 ++ 23 files changed, 778 insertions(+), 419 deletions(-) create mode 100644 public/Sprites/Icons/iconempty.png create mode 100644 public/Sprites/favicon.png diff --git a/client/app/css/core.styl b/client/app/css/core.styl index 444474a..ba5a4bf 100644 --- a/client/app/css/core.styl +++ b/client/app/css/core.styl @@ -14,7 +14,7 @@ html, body margin 0 font-size 100% normal-font() - background $background-color url("//media.pokebattle.com/img/bg.png") + background $background-color blue line-height normal ul, ol diff --git a/client/app/js/concerns/main_buttons.coffee b/client/app/js/concerns/main_buttons.coffee index 12b6165..c815d7f 100644 --- a/client/app/js/concerns/main_buttons.coffee +++ b/client/app/js/concerns/main_buttons.coffee @@ -4,6 +4,57 @@ $ -> $mainButtons.on 'click', '.teambuilder_button', (e) -> PokeBattle.navigation.showTeambuilder() + challengeobjunranked = + eventName: "findBattleunranked" + populate: $mainButtons.find('.find_battle_select_team') + button: $mainButtons.find('.find_battle_non_ranked') + defaultClauses: [ + Conditions.SLEEP_CLAUSE + Conditions.EVASION_CLAUSE + Conditions.SPECIES_CLAUSE + Conditions.OHKO_CLAUSE + Conditions.PRANKSTER_SWAGGER_CLAUSE + Conditions.UNRELEASED_BAN + Conditions.TIMED_BATTLE + ] + blockedClauses: true + + challengeobj = + eventName: "findBattle" + populate: $mainButtons.find('.find_battle_select_team') + button: $mainButtons.find('.find_battle') + defaultClauses: [ + Conditions.SLEEP_CLAUSE + Conditions.EVASION_CLAUSE + Conditions.SPECIES_CLAUSE + Conditions.OHKO_CLAUSE + Conditions.PRANKSTER_SWAGGER_CLAUSE + Conditions.UNRELEASED_BAN + Conditions.RATED_BATTLE + Conditions.TIMED_BATTLE + ] + blockedClauses: true + + challengepaneobjunranked = new challengePaneObject(challengeobjunranked) + challengePaneArray.push(challengepaneobjunranked) + challengepaneobj = new challengePaneObject(challengeobj) + challengePaneArray.push(challengepaneobj) + + createChallengePane + eventName: "findBattleunranked" + populate: $mainButtons.find('.find_battle_select_team') + button: $mainButtons.find('.find_battle_non_ranked') + defaultClauses: [ + Conditions.SLEEP_CLAUSE + Conditions.EVASION_CLAUSE + Conditions.SPECIES_CLAUSE + Conditions.OHKO_CLAUSE + Conditions.PRANKSTER_SWAGGER_CLAUSE + Conditions.UNRELEASED_BAN + Conditions.TIMED_BATTLE + ] + blockedClauses: true + createChallengePane eventName: "findBattle" populate: $mainButtons.find('.find_battle_select_team') @@ -26,6 +77,12 @@ $ -> .addClass('icon-spinner spinner-anim') .removeClass("icon-earth") + $mainButtons.find('.find_battle_non_ranked').on 'challenge', -> + $this = $(this) + $this.find('.find-icon') + .addClass('icon-spinner spinner-anim') + .removeClass("icon-earth") + $mainButtons.find('.display_credits').click -> $modal = PokeBattle.modal('modals/credits') $modal.find('.modal-footer button').first().focus() @@ -40,11 +97,24 @@ depressFindBattle = -> .addClass("icon-earth") $mainButtons.find('.find_battle_select_team .select').removeClass('disabled') +depressFindBattleUnranked = -> + $mainButtons = $('.main_buttons') + $button = $mainButtons.find('.find_battle_non_ranked') + $button.removeClass("disabled") + $button.find('.find-icon') + .removeClass("icon-spinner spinner-anim") + .addClass("icon-earth") + $mainButtons.find('.find_battle_select_team .select').removeClass('disabled') + $(window).load -> $mainButtons = $('.main_buttons') PokeBattle.battles.on 'add', (battle) -> if !battle.get('spectating') depressFindBattle() + depressFindBattleUnranked() PokeBattle.primus.on 'findBattleCanceled', depressFindBattle PokeBattle.events.on 'findBattleCanceled', depressFindBattle + + PokeBattle.primus.on 'findBattleCanceledUnranked', depressFindBattleUnranked + PokeBattle.events.on 'findBattleCanceledUnranked', depressFindBattleUnranked \ No newline at end of file diff --git a/client/app/js/helpers/challenge_pane.coffee b/client/app/js/helpers/challenge_pane.coffee index 4ec6df1..1f8ef0d 100644 --- a/client/app/js/helpers/challenge_pane.coffee +++ b/client/app/js/helpers/challenge_pane.coffee @@ -1,5 +1,16 @@ # eventName should be one of "challenge" or "find battle" # opts may include whether to enable clauses, for example +@challengePaneArray = [] + +class @challengePaneObject + constructor: (@object) -> + @event = @object.eventName + @button = @object.button + @populate = @object.populate + @clauses = @object.defaultClauses + @blockedClauses = @object.blockedClauses + + @createChallengePane = (opts) -> $wrapper = opts.populate $button = opts.button @@ -18,7 +29,7 @@ selectedTeamId = null selectedAlt = null - + $PaneArray = @challengePaneArray getSelectedTeam = -> PokeBattle.TeamStore.get(selectedTeamId) || PokeBattle.TeamStore.at(0) @@ -70,11 +81,13 @@ # Implement finding battle/challenging $button.on 'click.challenge', -> + thisChallenge = _.find($PaneArray, (butt) -> butt.button.selector is $button.selector) + console.log(thisChallenge) # Start requesting for notify permission here PokeBattle.requestNotifyPermission() - format = $selectFormat.data('format') - + if typeof format == "undefined" and typeof personId == "undefined" + format = $('.select-format').data('format') # Toggle state when you press the button. if !$button.hasClass('disabled') team = getSelectedTeam() @@ -90,7 +103,7 @@ $clauses = $wrapper.find('input:checked[type="checkbox"]') clauses = [] $clauses.each(-> clauses.push(parseInt($(this).val(), 10))) - PokeBattle.primus.send(eventName, personId, format, teamJSON, clauses, selectedAlt) + PokeBattle.primus.send(eventName, personId, format, teamJSON, thisChallenge.clauses, selectedAlt) else PokeBattle.primus.send(eventName, format, teamJSON, selectedAlt) $button.addClass('disabled').trigger('challenge') diff --git a/client/app/js/views/battles/battle_view.coffee b/client/app/js/views/battles/battle_view.coffee index 7f6e94f..aee69fb 100644 --- a/client/app/js/views/battles/battle_view.coffee +++ b/client/app/js/views/battles/battle_view.coffee @@ -161,7 +161,7 @@ class @BattleView extends Backbone.View team = $this.data('team') slot = $this.data('slot') pokemon = @model.getPokemon(team, slot) - @pokemonPopover($this, pokemon) + #@pokemonPopover($this, pokemon) @renderTimers() this @@ -278,6 +278,8 @@ class @BattleView extends Backbone.View $newPokemon.attr('data-slot', slot) $newPokemon.removeClass('hidden') @pokemonPopover($newSprite, pokemon) + + pokemon.set('beeninbattle', true) @cannedText('SENT_OUT', player, player, slot) diff --git a/client/templates/index.jade b/client/templates/index.jade index b9630da..efd38b7 100644 --- a/client/templates/index.jade +++ b/client/templates/index.jade @@ -6,9 +6,13 @@ block content .chat .main_buttons .section - .button.big.find_battle + .button.big.find_battle_non_ranked span.find-icon.icon-earth | Find battle + p + .button.big.find_battle + span.find-icon.icon-earth + | Ranked battle .find_battle_select_team .section .button.teambuilder_button diff --git a/client/templates/layout.jade b/client/templates/layout.jade index 59a6052..b5dbcd8 100644 --- a/client/templates/layout.jade +++ b/client/templates/layout.jade @@ -4,7 +4,7 @@ html meta(http-equiv="X-UA-Compatible", content="IE=Edge") meta(name="viewport", content="width=device-width, initial-scale=1.0, user-scalable=0") 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/main.css")) body(class = bodyClass) diff --git a/client/views/battle_user_info.jade b/client/views/battle_user_info.jade index e722ea0..5538625 100644 --- a/client/views/battle_user_info.jade +++ b/client/views/battle_user_info.jade @@ -9,17 +9,32 @@ each team in [ yourTeam, opponentTeam ] .pokemon_icons - var teamvisible = team.collection.parents[0].get('visibleteam') - var isdef = typeof teamvisible - if isdef != 'undefined' && teamvisible - - var orig = team.get('pokemon') - - var teamPokemon = team.getRandomOrder() - - for (var i = 0, len = teamPokemon.length; i < len; i += 1) - - var pokemon = teamPokemon[i] - if pokemon - .icon_wrapper - - var origpkmn = orig.findWhere({species: pokemon.species}); - - var faintClass = (origpkmn.isFainted() ? 'fainted' : '') - - var style = window.PokemonIconBackground(origpkmn) + - var orig = team.get('pokemon') + - var teamPokemon = team.getRandomOrder() + - for (var i = 0, len = teamPokemon.length; i < len; i += 1) + - var pokemon = teamPokemon[i] + if pokemon + .icon_wrapper + - var origpkmn = orig.findWhere({species: pokemon.species}); + - var faintClass = (origpkmn.isFainted() ? 'fainted' : '') + - 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) if !origpkmn.isFainted() .pokemon_hp_background .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()) diff --git a/public/Sprites/Icons/iconempty.png b/public/Sprites/Icons/iconempty.png new file mode 100644 index 0000000000000000000000000000000000000000..f548e82f287eff4c47a4d4b1131cab18331b11bd GIT binary patch literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDB3?!H8JlO)`1o(uwZrHHFz`(#GAfTe6VZnj} zH%@%`@#Dt~4~q=}7B?a+eoV0ValzsT!w)!e3_7I=)XP{BL$8fV95EA{7b=OIWEkrc?&fi^%DNmmU+NDb}h(CLC@}ZZKhf3w_r*DOn mH!K!=|L7L;kAL!C*QA}9cvU-Khn)t{g$$mqelF{r5}E+r8+xt) literal 0 HcmV?d00001 diff --git a/public/Sprites/favicon.png b/public/Sprites/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..efab97aaf5596d530a879b599d4625e029979371 GIT binary patch literal 597 zcmV-b0;>IqP)pF7<5HgbW?9;ba!ELWdLwtX>N2bZe?^J zG%heMHvEiZ-v9ss(@8`@R5(wiQ_G4PK@{z;$SR*PUobxr$ZRHmF^hrxg9*%52qFX` zlLwj6_R)5=uQ85@$wJ9WwADC662u3#dU9@+EgD?}vN%-tt#ePEd#c+4@LxDuJcdED ziD4#-scmDJOtEC@2SmZ3)xyBZ<9Eu&gbnj_8Y{;ElmZGK#;k?hgXSOEECNE4HC(g0 zF4pJB`Io<2r2E!o`xVq#opQ@V|c3B39q?072Ne*R%sRq2OXA zj$DObDU*ZMZ?`eaWVE#vPY~=kvo6l+_jvPBq46OJlsqiC=U48`9FL+dWJLjp#=uKZ&|PIzQcO)3it0B zP(kU`!%<{kqgqDb