Select the default combat mode from ordered equipped objects so bows request missile stance. Parse CreateObject parent metadata and ParentEvent, then render held objects as separate children composed from setup holding locations and placement frames each animation tick.
107 lines
3.3 KiB
C#
107 lines
3.3 KiB
C#
using AcDream.Core.Combat;
|
|
using AcDream.Core.Items;
|
|
|
|
namespace AcDream.Core.Tests.Combat;
|
|
|
|
public sealed class CombatInputPlannerTests
|
|
{
|
|
[Fact]
|
|
public void GetDefaultCombatMode_MissileCombatUseSelectsMissile()
|
|
{
|
|
var bow = Equipped(EquipMask.MissileWeapon, ItemType.MissileWeapon, combatUse: 2);
|
|
|
|
Assert.Equal(
|
|
CombatMode.Missile,
|
|
CombatInputPlanner.GetDefaultCombatMode([bow]));
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDefaultCombatMode_PrimaryWeaponOrderMatchesRetailInventoryPlacement()
|
|
{
|
|
var bow = Equipped(EquipMask.MissileWeapon, ItemType.MissileWeapon, combatUse: 2);
|
|
var sword = Equipped(EquipMask.MeleeWeapon, ItemType.MeleeWeapon, combatUse: 1);
|
|
|
|
Assert.Equal(
|
|
CombatMode.Missile,
|
|
CombatInputPlanner.GetDefaultCombatMode([bow, sword]));
|
|
Assert.Equal(
|
|
CombatMode.Melee,
|
|
CombatInputPlanner.GetDefaultCombatMode([sword, bow]));
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDefaultCombatMode_HeldCasterSelectsMagic()
|
|
{
|
|
var wand = Equipped(EquipMask.Held, ItemType.Caster, combatUse: 0);
|
|
|
|
Assert.Equal(
|
|
CombatMode.Magic,
|
|
CombatInputPlanner.GetDefaultCombatMode([wand]));
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDefaultCombatMode_HeldNonCasterCannotEnterCombat()
|
|
{
|
|
var held = Equipped(EquipMask.Held, ItemType.Misc, combatUse: 0);
|
|
|
|
Assert.Equal(
|
|
CombatMode.NonCombat,
|
|
CombatInputPlanner.GetDefaultCombatMode([held]));
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDefaultCombatMode_NoWeaponDefaultsToUnarmedMelee()
|
|
{
|
|
Assert.Equal(
|
|
CombatMode.Melee,
|
|
CombatInputPlanner.GetDefaultCombatMode([]));
|
|
}
|
|
|
|
[Fact]
|
|
public void ToggleMode_FromNonCombat_UsesDefaultCombatMode()
|
|
{
|
|
Assert.Equal(CombatMode.Melee, CombatInputPlanner.ToggleMode(CombatMode.NonCombat));
|
|
Assert.Equal(
|
|
CombatMode.Missile,
|
|
CombatInputPlanner.ToggleMode(CombatMode.NonCombat, CombatMode.Missile));
|
|
}
|
|
|
|
[Fact]
|
|
public void ToggleMode_FromCombat_ReturnsNonCombat()
|
|
{
|
|
Assert.Equal(CombatMode.NonCombat, CombatInputPlanner.ToggleMode(CombatMode.Melee));
|
|
Assert.Equal(CombatMode.NonCombat, CombatInputPlanner.ToggleMode(CombatMode.Magic));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(CombatAttackAction.Low, AttackHeight.Low)]
|
|
[InlineData(CombatAttackAction.Medium, AttackHeight.Medium)]
|
|
[InlineData(CombatAttackAction.High, AttackHeight.High)]
|
|
public void HeightFor_MapsRetailAttackKeys(CombatAttackAction action, AttackHeight expected)
|
|
{
|
|
Assert.Equal(expected, CombatInputPlanner.HeightFor(action));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(CombatMode.Melee, true)]
|
|
[InlineData(CombatMode.Missile, true)]
|
|
[InlineData(CombatMode.NonCombat, false)]
|
|
[InlineData(CombatMode.Magic, false)]
|
|
public void SupportsTargetedAttack_MatchesRetailExecuteAttackModes(
|
|
CombatMode mode,
|
|
bool expected)
|
|
{
|
|
Assert.Equal(expected, CombatInputPlanner.SupportsTargetedAttack(mode));
|
|
}
|
|
|
|
private static ClientObject Equipped(
|
|
EquipMask location,
|
|
ItemType type,
|
|
byte combatUse) => new()
|
|
{
|
|
ObjectId = 1,
|
|
CurrentlyEquippedLocation = location,
|
|
Type = type,
|
|
CombatUse = combatUse,
|
|
};
|
|
}
|