From ed228067743388ab8ad6eb4aff742534ed589374 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 20 Feb 2016 17:25:41 +0100 Subject: [PATCH] Made Primal Evolution objects limit a condition --- public/js/app.js | 28 +++++++++++++++------------- public/js/replays.js | 28 +++++++++++++++------------- server/bw/battle.coffee | 7 ++++--- server/conditions.coffee | 11 +++++++++++ server/in/pokemon.coffee | 2 +- shared/conditions.coffee | 27 +++++++++++++++------------ 6 files changed, 61 insertions(+), 42 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 0bb8e0f..f02e942 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -301,13 +301,14 @@ PRANKSTER_SWAGGER_CLAUSE: 10, PBV_500: 11, VISIBLE_TEAM: 12, - TIER_LC: 13, - TIER_PU: 14, - TIER_NU: 15, - TIER_RU: 16, - TIER_UU: 17, - TIER_OU: 18, - TIER_Uber: 19 + PRIMAL_LIMIT: 13, + TIER_LC: 14, + TIER_PU: 15, + TIER_NU: 16, + TIER_RU: 17, + TIER_UU: 18, + TIER_OU: 19, + TIER_Uber: 20 }; this.SelectableConditions = [this.Conditions.VISIBLE_TEAM, this.Conditions.TIMED_BATTLE, this.Conditions.SLEEP_CLAUSE, this.Conditions.EVASION_CLAUSE, this.Conditions.SPECIES_CLAUSE, this.Conditions.PRANKSTER_SWAGGER_CLAUSE, this.Conditions.OHKO_CLAUSE, this.Conditions.UNRELEASED_BAN]; @@ -323,7 +324,8 @@ EVASION_CLAUSE: "Evasion Clause", OHKO_CLAUSE: "One-Hit KO Clause", UNRELEASED_BAN: "Unreleased Ban", - PRANKSTER_SWAGGER_CLAUSE: "Prankster + Swagger Clause" + PRANKSTER_SWAGGER_CLAUSE: "Prankster + Swagger Clause", + PRIMAL_LIMIT: "Primal Limit" } }; @@ -332,7 +334,7 @@ name: 'insur1000', humanName: 'Insurgence 1000', generation: 'in', - conditions: [this.Conditions.PBV_1000, this.Conditions.TEAM_PREVIEW], + conditions: [this.Conditions.PBV_1000, this.Conditions.TEAM_PREVIEW, this.Conditions.PRIMAL_LIMIT], playable: true, priority: 5, tierBased: false @@ -341,7 +343,7 @@ name: 'xy1000', humanName: '1,000 PBV XY', generation: 'xy', - conditions: [this.Conditions.PBV_1000, this.Conditions.TEAM_PREVIEW], + conditions: [this.Conditions.PBV_1000, this.Conditions.TEAM_PREVIEW, this.Conditions.PRIMAL_LIMIT], playable: true, priority: 10, tierBased: false @@ -350,7 +352,7 @@ name: 'xy500', humanName: '500 PBV XY', generation: 'xy', - conditions: [this.Conditions.PBV_500, this.Conditions.TEAM_PREVIEW], + conditions: [this.Conditions.PBV_500, this.Conditions.TEAM_PREVIEW, this.Conditions.PRIMAL_LIMIT], playable: true, priority: 10, tierBased: false @@ -398,12 +400,12 @@ tierbased = true; if (typeof window !== "undefined" && window !== null) { formatname = GenerationCondition[gen].conditionname + tier; - _conditions = [Conditions[key], Conditions.TEAM_PREVIEW]; + _conditions = [Conditions[key], Conditions.TEAM_PREVIEW, Conditions.PRIMAL_LIMIT]; priority = tierData.priority; humanname = "" + GenerationCondition[gen].humanName + " " + tierData.humanName; } else { formatname = this.GenerationCondition[gen].conditionname + tier; - _conditions = [this.Conditions[key], this.Conditions.TEAM_PREVIEW]; + _conditions = [this.Conditions[key], this.Conditions.TEAM_PREVIEW, this.Conditions.PRIMAL_LIMIT]; priority = tierData.priority; humanname = "" + this.GenerationCondition[gen].humanName + " " + tierData.humanName; } diff --git a/public/js/replays.js b/public/js/replays.js index 66a9770..828b8f9 100644 --- a/public/js/replays.js +++ b/public/js/replays.js @@ -301,13 +301,14 @@ PRANKSTER_SWAGGER_CLAUSE: 10, PBV_500: 11, VISIBLE_TEAM: 12, - TIER_LC: 13, - TIER_PU: 14, - TIER_NU: 15, - TIER_RU: 16, - TIER_UU: 17, - TIER_OU: 18, - TIER_Uber: 19 + PRIMAL_LIMIT: 13, + TIER_LC: 14, + TIER_PU: 15, + TIER_NU: 16, + TIER_RU: 17, + TIER_UU: 18, + TIER_OU: 19, + TIER_Uber: 20 }; this.SelectableConditions = [this.Conditions.VISIBLE_TEAM, this.Conditions.TIMED_BATTLE, this.Conditions.SLEEP_CLAUSE, this.Conditions.EVASION_CLAUSE, this.Conditions.SPECIES_CLAUSE, this.Conditions.PRANKSTER_SWAGGER_CLAUSE, this.Conditions.OHKO_CLAUSE, this.Conditions.UNRELEASED_BAN]; @@ -323,7 +324,8 @@ EVASION_CLAUSE: "Evasion Clause", OHKO_CLAUSE: "One-Hit KO Clause", UNRELEASED_BAN: "Unreleased Ban", - PRANKSTER_SWAGGER_CLAUSE: "Prankster + Swagger Clause" + PRANKSTER_SWAGGER_CLAUSE: "Prankster + Swagger Clause", + PRIMAL_LIMIT: "Primal Limit" } }; @@ -332,7 +334,7 @@ name: 'insur1000', humanName: 'Insurgence 1000', generation: 'in', - conditions: [this.Conditions.PBV_1000, this.Conditions.TEAM_PREVIEW], + conditions: [this.Conditions.PBV_1000, this.Conditions.TEAM_PREVIEW, this.Conditions.PRIMAL_LIMIT], playable: true, priority: 5, tierBased: false @@ -341,7 +343,7 @@ name: 'xy1000', humanName: '1,000 PBV XY', generation: 'xy', - conditions: [this.Conditions.PBV_1000, this.Conditions.TEAM_PREVIEW], + conditions: [this.Conditions.PBV_1000, this.Conditions.TEAM_PREVIEW, this.Conditions.PRIMAL_LIMIT], playable: true, priority: 10, tierBased: false @@ -350,7 +352,7 @@ name: 'xy500', humanName: '500 PBV XY', generation: 'xy', - conditions: [this.Conditions.PBV_500, this.Conditions.TEAM_PREVIEW], + conditions: [this.Conditions.PBV_500, this.Conditions.TEAM_PREVIEW, this.Conditions.PRIMAL_LIMIT], playable: true, priority: 10, tierBased: false @@ -398,12 +400,12 @@ tierbased = true; if (typeof window !== "undefined" && window !== null) { formatname = GenerationCondition[gen].conditionname + tier; - _conditions = [Conditions[key], Conditions.TEAM_PREVIEW]; + _conditions = [Conditions[key], Conditions.TEAM_PREVIEW, Conditions.PRIMAL_LIMIT]; priority = tierData.priority; humanname = "" + GenerationCondition[gen].humanName + " " + tierData.humanName; } else { formatname = this.GenerationCondition[gen].conditionname + tier; - _conditions = [this.Conditions[key], this.Conditions.TEAM_PREVIEW]; + _conditions = [this.Conditions[key], this.Conditions.TEAM_PREVIEW, this.Conditions.PRIMAL_LIMIT]; priority = tierData.priority; humanname = "" + this.GenerationCondition[gen].humanName + " " + tierData.humanName; } diff --git a/server/bw/battle.coffee b/server/bw/battle.coffee index 669da7f..f56947b 100644 --- a/server/bw/battle.coffee +++ b/server/bw/battle.coffee @@ -321,10 +321,11 @@ class @Battle extends Room # Passing -1 to turns makes the weather last forever. setWeather: (weatherName, turns=-1) -> - console.log(weatherName) - console.log(@weakWeather) if weatherName in @weakWeather and @weather in @strongWeather - @cannedText("WEATHER_FAIL") + switch @weather + when Weather.DELTASTREAM then "WEATHER_FAIL_AIR" + when Weather.HARSHSUN then "WEATHER_FAIL_SUN" + when Weather.HEAVYRAIN then "WEATHER_FAIL_RAIN" return cannedText = switch weatherName when Weather.SUN then "SUN_START" diff --git a/server/conditions.coffee b/server/conditions.coffee index 8c152ea..5f110b9 100644 --- a/server/conditions.coffee +++ b/server/conditions.coffee @@ -131,6 +131,17 @@ createCondition Conditions.EVASION_CLAUSE, return errors +createCondition Conditions.PRIMAL_LIMIT, + validateTeam: (team, genData) -> + errors = [] + items = team.map((p) -> p.item) + primalitems = ["Red Orb", "Blue Orb"] + i = 0 + for item in items + i++ if item in primalitems + errors.push("You can only have one Primal Evolution item in your team") if i > 1 + return errors + createCondition Conditions.OHKO_CLAUSE, validatePokemon: (pokemon, genData, prefix) -> {moves} = pokemon diff --git a/server/in/pokemon.coffee b/server/in/pokemon.coffee index 83baeac..ce89091 100644 --- a/server/in/pokemon.coffee +++ b/server/in/pokemon.coffee @@ -13,7 +13,7 @@ eval(coffee.compile(require('fs').readFileSync(path, 'utf8'), bare: true)) [ species, forme ] = @item.mega return false if @species != species || @forme != 'default' return false if @team.hasMegaEvolved and forme is "mega" - return false if @team.hasPrimalEvolved and forme is "primal" + #return false if @team.hasPrimalEvolved and forme is "primal" return true oldBlockSwitch = @Pokemon::blockSwitch diff --git a/shared/conditions.coffee b/shared/conditions.coffee index c5f9e11..584609c 100644 --- a/shared/conditions.coffee +++ b/shared/conditions.coffee @@ -13,13 +13,14 @@ self = (if window? then window.PokeBattle.conditions ?= {} else this) PRANKSTER_SWAGGER_CLAUSE : 10 PBV_500 : 11 VISIBLE_TEAM : 12 - TIER_LC : 13 - TIER_PU : 14 - TIER_NU : 15 - TIER_RU : 16 - TIER_UU : 17 - TIER_OU : 18 - TIER_Uber : 19 + PRIMAL_LIMIT : 13 + TIER_LC : 14 + TIER_PU : 15 + TIER_NU : 16 + TIER_RU : 17 + TIER_UU : 18 + TIER_OU : 19 + TIER_Uber : 20 @SelectableConditions = [ @Conditions.VISIBLE_TEAM @@ -44,13 +45,15 @@ self = (if window? then window.PokeBattle.conditions ?= {} else this) OHKO_CLAUSE : "One-Hit KO Clause" UNRELEASED_BAN : "Unreleased Ban" PRANKSTER_SWAGGER_CLAUSE : "Prankster + Swagger Clause" + PRIMAL_LIMIT : "Primal Limit" + self.PresetFormats = insur1000: name : 'insur1000' humanName : 'Insurgence 1000' generation : 'in' - conditions : [ @Conditions.PBV_1000, @Conditions.TEAM_PREVIEW ] + conditions : [ @Conditions.PBV_1000, @Conditions.TEAM_PREVIEW, @Conditions.PRIMAL_LIMIT] playable : true priority : 5 tierBased : false @@ -58,7 +61,7 @@ self.PresetFormats = name : 'xy1000' humanName : '1,000 PBV XY' generation : 'xy' - conditions : [ @Conditions.PBV_1000, @Conditions.TEAM_PREVIEW ] + conditions : [ @Conditions.PBV_1000, @Conditions.TEAM_PREVIEW, @Conditions.PRIMAL_LIMIT] playable : true priority : 10 tierBased : false @@ -66,7 +69,7 @@ self.PresetFormats = name : 'xy500' humanName : '500 PBV XY' generation : 'xy' - conditions : [ @Conditions.PBV_500, @Conditions.TEAM_PREVIEW ] + conditions : [ @Conditions.PBV_500, @Conditions.TEAM_PREVIEW, @Conditions.PRIMAL_LIMIT] playable : true priority : 10 tierBased : false @@ -105,12 +108,12 @@ self.setFormats = -> tierbased = true if window? formatname = GenerationCondition[gen].conditionname + tier - _conditions = [Conditions[key], Conditions.TEAM_PREVIEW] + _conditions = [Conditions[key], Conditions.TEAM_PREVIEW, Conditions.PRIMAL_LIMIT] priority = tierData.priority humanname = "#{GenerationCondition[gen].humanName} #{tierData.humanName}" else formatname = @GenerationCondition[gen].conditionname + tier - _conditions = [@Conditions[key], @Conditions.TEAM_PREVIEW] + _conditions = [@Conditions[key], @Conditions.TEAM_PREVIEW, @Conditions.PRIMAL_LIMIT] priority = tierData.priority humanname = "#{@GenerationCondition[gen].humanName} #{tierData.humanName}"