package com.projectsacrifice.game; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; public final class VolunteerRigTest { @Test public void skinsReuseTheSameNamedSkeletonAndOnlyChangePalette() { VolunteerRig.Pose brass = VolunteerRig.pose( VolunteerRig.Skin.BRASS_SCOUT, VolunteerRig.Motion.IDLE, 0f, 1); VolunteerRig.Pose verdigris = VolunteerRig.pose( VolunteerRig.Skin.VERDIGRIS_KEEPER, VolunteerRig.Motion.IDLE, 0f, 1); assertEquals(VolunteerRig.Joint.values().length, brass.jointCount()); for (VolunteerRig.Joint joint : VolunteerRig.Joint.values()) { assertEquals(brass.x(joint), verdigris.x(joint), 0f); assertEquals(brass.y(joint), verdigris.y(joint), 0f); assertTrue(brass.x(joint) >= 0f && brass.x(joint) <= 1f); assertTrue(brass.y(joint) >= 0f && brass.y(joint) <= 1f); } assertNotEquals(brass.palette().shell(), verdigris.palette().shell()); assertNotEquals(brass.palette().cloth(), verdigris.palette().cloth()); } @Test public void motionChangesLimbsWithoutChangingCollisionOrRootContract() { VolunteerRig.Pose idle = VolunteerRig.pose( VolunteerRig.Skin.EMBER_COURIER, VolunteerRig.Motion.IDLE, 0f, 1); VolunteerRig.Pose run = VolunteerRig.pose( VolunteerRig.Skin.EMBER_COURIER, VolunteerRig.Motion.RUN, 0.25f, 1); VolunteerRig.Pose mirrored = VolunteerRig.pose( VolunteerRig.Skin.EMBER_COURIER, VolunteerRig.Motion.RUN, 0.25f, -1); assertEquals(62f, idle.collisionWidth(), 0f); assertEquals(100f, idle.collisionHeight(), 0f); assertEquals(idle.x(VolunteerRig.Joint.ROOT), run.x(VolunteerRig.Joint.ROOT), 0f); assertNotEquals(idle.x(VolunteerRig.Joint.LEFT_HAND), run.x(VolunteerRig.Joint.LEFT_HAND), 0.001f); assertEquals(1f - run.x(VolunteerRig.Joint.LEFT_HAND), mirrored.x(VolunteerRig.Joint.LEFT_HAND), 0.001f); } @Test public void gameplayStatesHaveNonColorVisualSignals() { VolunteerRig.Pose dead = VolunteerRig.pose( VolunteerRig.Skin.BRASS_SCOUT, VolunteerRig.Motion.DEAD, 0f, 1); VolunteerRig.Pose frozen = VolunteerRig.pose( VolunteerRig.Skin.BRASS_SCOUT, VolunteerRig.Motion.FROZEN, 0f, 1); VolunteerRig.Pose conductive = VolunteerRig.pose( VolunteerRig.Skin.BRASS_SCOUT, VolunteerRig.Motion.CONDUCTIVE, 0f, 1); VolunteerRig.Pose pinned = VolunteerRig.pose( VolunteerRig.Skin.BRASS_SCOUT, VolunteerRig.Motion.PINNED, 0f, 1); VolunteerRig.Pose respawn = VolunteerRig.pose( VolunteerRig.Skin.BRASS_SCOUT, VolunteerRig.Motion.RESPAWN, 0.5f, 1); assertFalse(dead.visorLit()); assertTrue(frozen.frozenShell()); assertTrue(conductive.conductiveArcs()); assertTrue(pinned.anchorBolt()); assertEquals(0.5f, respawn.assemblyProgress(), 0f); } @Test public void gameplayMotionIsDerivedFromGroundVelocityAndBodyState() { assertEquals(VolunteerRig.Motion.IDLE, VolunteerRig.aliveMotion(true, 0f, 0f)); assertEquals(VolunteerRig.Motion.RUN, VolunteerRig.aliveMotion(true, 370f, 0f)); assertEquals(VolunteerRig.Motion.JUMP, VolunteerRig.aliveMotion(false, 120f, -400f)); assertEquals(VolunteerRig.Motion.FALL, VolunteerRig.aliveMotion(false, 120f, 200f)); assertEquals(VolunteerRig.Motion.FROZEN, VolunteerRig.bodyMotion(true, true, true)); assertEquals(VolunteerRig.Motion.CONDUCTIVE, VolunteerRig.bodyMotion(false, true, true)); assertEquals(VolunteerRig.Motion.PINNED, VolunteerRig.bodyMotion(false, false, true)); assertEquals(VolunteerRig.Motion.DEAD, VolunteerRig.bodyMotion(false, false, false)); } @Test public void everyLivingCharacterStateHasAnExplicitAnimationMotion() { for (CharacterStateMachine.State state : CharacterStateMachine.State.values()) { assertEquals(state.name(), VolunteerRig.motionFor(state).name()); } } @Test public void transientCharacterStatesHaveNonColorPoseSignals() { VolunteerRig.Skin skin = VolunteerRig.Skin.BRASS_SCOUT; VolunteerRig.Pose idle = VolunteerRig.pose(skin, VolunteerRig.Motion.IDLE, 0.25f, 1); VolunteerRig.Pose turn = VolunteerRig.pose(skin, VolunteerRig.Motion.TURN, 0.25f, 1); VolunteerRig.Pose land = VolunteerRig.pose(skin, VolunteerRig.Motion.LAND, 0.25f, 1); VolunteerRig.Pose interact = VolunteerRig.pose( skin, VolunteerRig.Motion.INTERACT, 0.25f, 1); VolunteerRig.Pose stunned = VolunteerRig.pose( skin, VolunteerRig.Motion.STUNNED, 0.25f, 1); assertNotEquals(idle.x(VolunteerRig.Joint.LEFT_HAND), turn.x(VolunteerRig.Joint.LEFT_HAND), 0.001f); assertNotEquals(idle.y(VolunteerRig.Joint.ROOT), land.y(VolunteerRig.Joint.ROOT), 0.001f); assertNotEquals(idle.x(VolunteerRig.Joint.RIGHT_HAND), interact.x(VolunteerRig.Joint.RIGHT_HAND), 0.001f); assertNotEquals(idle.y(VolunteerRig.Joint.LEFT_HAND), stunned.y(VolunteerRig.Joint.LEFT_HAND), 0.001f); } }