32 lines
939 B
C#
32 lines
939 B
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using PkmnLib.Static.Utils;
|
||
|
|
||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||
|
|
||
|
[Script(ScriptCategory.Move, "set_weather")]
|
||
|
public class SetWeather : Script
|
||
|
{
|
||
|
private string _weather = null!;
|
||
|
private int _defaultTurns = 5;
|
||
|
|
||
|
/// <inheritdoc />
|
||
|
public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
|
||
|
{
|
||
|
if (!parameters!.TryGetValue("weather", out var weather) || weather is null)
|
||
|
{
|
||
|
throw new Exception("Weather not provided.");
|
||
|
}
|
||
|
_weather = weather!.ToString();
|
||
|
if (parameters.TryGetValue("turns", out var turns) && turns is int turn)
|
||
|
{
|
||
|
_defaultTurns = turn;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <inheritdoc />
|
||
|
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||
|
{
|
||
|
target.BattleData?.Battle.SetWeather(_weather, _defaultTurns);
|
||
|
}
|
||
|
}
|