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

Revamped Challenge Buttons completely, Added primal abilities, items and primals themselves

This commit is contained in:
Deukhoofd
2016-02-10 23:43:15 +01:00
parent 5fdcc4b285
commit 19558607f3
31 changed files with 902 additions and 273 deletions

View File

@@ -126,6 +126,10 @@ class @Battle extends Room
@logger = logger.withContext(battleId: @id)
@weakWeather = [Weather.SUN, Weather.RAIN, Weather.SAND, Weather.HAIL, Weather.MOON]
@strongWeather = [Weather.DELTASTREAM, Weather.HARSHSUN, Weather.HEAVYRAIN]
# Creates a new log messages with context
debug: (message, context) ->
# TODO: Add more context. Elements such as the turn.
@@ -303,12 +307,18 @@ 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)
return
cannedText = switch weatherName
when Weather.SUN then "SUN_START"
when Weather.RAIN then "RAIN_START"
when Weather.SAND then "SAND_START"
when Weather.HAIL then "HAIL_START"
when Weather.MOON then "MOON_START"
when Weather.DELTASTREAM then "DELTASTREAM_START"
else
switch @weather
when Weather.SUN then "SUN_END"
@@ -316,6 +326,7 @@ class @Battle extends Room
when Weather.SAND then "SAND_END"
when Weather.HAIL then "HAIL_END"
when Weather.MOON then "MOON_END"
when Weather.DELTASTREAM then "DELTASTREAM_END"
@cannedText(cannedText) if cannedText
@weather = weatherName
@weatherDuration = turns
@@ -339,10 +350,24 @@ class @Battle extends Room
else if @weatherDuration > 1
@weatherDuration--
activePokemon = @getActivePokemon().filter((p) -> !p.isFainted())
#Handles removing strong weather if there is no pokemon to keep it up anymore
if @weather in @strongWeather
weatherability = switch @weather
when Weather.DELTASTREAM then "Delta Stream"
when Weather.HARSHSUN then "Desolate Land"
when Weather.HEAVYRAIN then "Primordial Sea"
abilityarr = []
for pokemon in activePokemon
abilityarr.push(pokemon.ability)
console.log(abilityarr)
if !weatherability in abilityarr
@setWeather(Weather.NONE)
cannedText = @weatherCannedText()
@cannedText(cannedText) if cannedText?
activePokemon = @getActivePokemon().filter((p) -> !p.isFainted())
for pokemon in activePokemon
continue if pokemon.isWeatherDamageImmune(@weather)
damage = pokemon.stat('hp') >> 4
@@ -352,6 +377,7 @@ class @Battle extends Room
else if @hasWeather(Weather.SAND)
if pokemon.damage(damage)
@cannedText('SAND_HURT', pokemon)
hasWeatherCancelAbilityOnField: ->
_.any @getActivePokemon(), (pokemon) ->

View File

@@ -131,6 +131,13 @@ class @Move
@afterMiss(battle, user, target)
return false
if battle.hasWeather(Weather.HARSHSUN) and @getType(battle, user, target) == "Water"
battle.cannedText('HARSHSUN_MOVEFAIL')
return false
if battle.hasWeather(Weather.HEAVYRAIN) and @getType(battle, user, target) == "Fire"
battle.cannedText('HEAVYRAIN_MOVEFAIL')
return false
# Calculates damage, deals damage, and returns the amount of damage dealt
hit: (battle, user, target, hitNumber, isDirect) ->
damage = @calculateDamage(battle, user, target, hitNumber, isDirect)
@@ -297,6 +304,14 @@ class @Move
typeEffectiveness: (battle, user, target) ->
type = @getType(battle, user, target)
effect = target.effectivenessOf(type, user: user, move: this)
if battle.hasWeather(Weather.DELTASTREAM) and target.hasType("Flying")
neweffect = 1
for targettype in target.types
typeeffect = util.typeEffectiveness(type, targettype)
if targettype == "Flying" and typeeffect > 1
typeeffect = 1
neweffect * typeeffect
effect = neweffect
if target.hasAbility("Ethereal Shroud")
ghosteffect = util.typeEffectiveness(type, ["Ghost"])
if ghosteffect < 1