74 lines
2.6 KiB
C#
74 lines
2.6 KiB
C#
using NUnit.Framework;
|
|
using PkmnLibSharp.Battling;
|
|
using PkmnLibSharp.Battling.ChoiceTurn;
|
|
|
|
namespace PkmnLibSharpTests.Battling.BattleTests
|
|
{
|
|
public class BasicBattleTests
|
|
{
|
|
[Test]
|
|
public void InitializeBattle()
|
|
{
|
|
var lib = BattleLibraryHelper.GetLibrary();
|
|
var battle = new BattleBuilder(lib, true, 2, 1).Build();
|
|
Assert.AreEqual(lib, battle.Library);
|
|
Assert.AreEqual(true, battle.CanFlee);
|
|
Assert.AreEqual(2, battle.SidesCount);
|
|
Assert.AreEqual(false, battle.HasEnded);
|
|
Assert.AreEqual(0, battle.PartiesCount);
|
|
battle.Dispose();
|
|
}
|
|
|
|
private static PokemonParty BuildTestParty(BattleLibrary lib)
|
|
{
|
|
var party = new PokemonParty();
|
|
party.SwapInto(0,
|
|
new PokemonBuilder(lib, "testSpecies", 50)
|
|
.LearnMove("testMove", MoveLearnMethod.Unknown)
|
|
.Build());
|
|
return party;
|
|
}
|
|
|
|
[Test]
|
|
public void InitializeBattleWithParties()
|
|
{
|
|
var lib = BattleLibraryHelper.GetLibrary();
|
|
var p1 = BuildTestParty(lib);
|
|
var p2 = BuildTestParty(lib);
|
|
var battle =
|
|
new BattleBuilder(lib, true, 2, 1)
|
|
.WithPartyOnPositions(p1, new BattlePosition(0, 0))
|
|
.WithPartyOnPositions(p2, new BattlePosition(1, 0))
|
|
.Build();
|
|
Assert.AreEqual(2, battle.PartiesCount);
|
|
Assert.AreEqual(p1, battle.Parties[0].Party);
|
|
Assert.AreEqual(p2, battle.Parties[1].Party);
|
|
battle.Dispose();
|
|
}
|
|
|
|
[Test]
|
|
public void RunTurn()
|
|
{
|
|
var lib = BattleLibraryHelper.GetLibrary();
|
|
var p1 = BuildTestParty(lib);
|
|
var p2 = BuildTestParty(lib);
|
|
var battle =
|
|
new BattleBuilder(lib, true, 2, 1)
|
|
.WithPartyOnPositions(p1, new BattlePosition(0, 0))
|
|
.WithPartyOnPositions(p2, new BattlePosition(1, 0))
|
|
.Build();
|
|
|
|
battle.SwitchPokemon(0, 0, p1.GetAtIndex(0));
|
|
battle.SwitchPokemon(1, 0, p2.GetAtIndex(0));
|
|
|
|
var moveTurn1 = new MoveTurnChoice(p1.GetAtIndex(0), p1.GetAtIndex(0).Moves[0], 1, 0 );
|
|
var moveTurn2 = new MoveTurnChoice(p2.GetAtIndex(0), p2.GetAtIndex(0).Moves[0], 0, 0 );
|
|
|
|
Assert.That(battle.TrySetChoice(moveTurn1));
|
|
Assert.That(battle.TrySetChoice(moveTurn2));
|
|
|
|
battle.Dispose();
|
|
}
|
|
|
|
}
|
|
} |