Tales-of-PKMN/game/battle/battle_field.gd

67 lines
2.3 KiB
GDScript

class_name BattleField
extends RefCounted
#etat du terrain, commun aux deux camps : meteo (terrains et barrieres viendront plus tard).
#les talents (Crachin, Sechesse...) et les capacites (Danse Pluie...) la modifient via Battle.set_weather().
enum Weather { NONE, SUN, RAIN, SANDSTORM, SNOW }
const DEFAULT_WEATHER_TURNS : int = 5
#capacites qui changent la meteo (nom d'API)
const WEATHER_MOVES : Dictionary = {
"sunny-day": Weather.SUN,
"rain-dance": Weather.RAIN,
"sandstorm": Weather.SANDSTORM,
"hail": Weather.SNOW,
"snowscape": Weather.SNOW,
}
var weather : Weather = Weather.NONE
var weather_turns : int = 0
static func weather_for_move(move_api_name : String) -> int:
return int(WEATHER_MOVES.get(move_api_name, Weather.NONE))
func set_weather(new_weather : Weather, turns : int = DEFAULT_WEATHER_TURNS) -> void:
weather = new_weather
weather_turns = turns if new_weather != Weather.NONE else 0
## Multiplicateur de degats selon la meteo et le type de la capacite.
func damage_multiplier(move_type : String) -> float:
match weather:
Weather.SUN:
if move_type == "fire": return 1.5
if move_type == "water": return 0.5
Weather.RAIN:
if move_type == "water": return 1.5
if move_type == "fire": return 0.5
return 1.0
## Bonus defensifs de la meteo : tempete de sable (Roche, Def. Spe. x1.5), neige (Glace, Defense x1.5).
func modify_stat(mon : BattleMon, stat : PokemonNature.Stat, value : float) -> float:
if weather == Weather.SANDSTORM and stat == PokemonNature.Stat.SP_DEFENSE and mon.get_types().has("rock"):
return value * 1.5
if weather == Weather.SNOW and stat == PokemonNature.Stat.DEFENSE and mon.get_types().has("ice"):
return value * 1.5
return value
static func is_sandstorm_immune(types : Array[String]) -> bool:
return types.has("rock") or types.has("ground") or types.has("steel")
static func start_message(w : int) -> String:
match w:
Weather.SUN: return "Les rayons du soleil brillent !"
Weather.RAIN: return "Il commence à pleuvoir !"
Weather.SANDSTORM: return "Une tempête de sable se lève !"
Weather.SNOW: return "Il commence à neiger !"
return ""
static func end_message(w : int) -> String:
match w:
Weather.SUN: return "Le soleil se couche."
Weather.RAIN: return "La pluie s'arrête."
Weather.SANDSTORM: return "La tempête de sable se calme."
Weather.SNOW: return "La neige s'arrête."
return ""