Добавить первую волну мира Physics
This commit is contained in:
@@ -13,7 +13,7 @@ public final class FoundationsFinaleContentTest {
|
||||
@Test
|
||||
public void finalFoundationsWaveMatchesTheApprovedMatrixAndClosesTheWorld() {
|
||||
List<LevelDefinition> levels = LevelCatalog.all();
|
||||
assertEquals(30, levels.size());
|
||||
assertTrue(levels.size() >= 30);
|
||||
|
||||
LevelDefinition keys = levels.get(26);
|
||||
assertIdentity(keys, 27, "foundations.two-keys", "Two Keys", 2, 65);
|
||||
|
||||
@@ -15,7 +15,7 @@ public final class LevelCatalogTest {
|
||||
@Test
|
||||
public void productionCatalogContainsMechanicsAndChallengeTeachingLevels() {
|
||||
List<LevelDefinition> levels = LevelCatalog.all();
|
||||
assertEquals(30, levels.size());
|
||||
assertEquals(34, levels.size());
|
||||
Set<String> titles = new HashSet<>();
|
||||
for (int i = 0; i < levels.size(); i++) {
|
||||
LevelDefinition level = levels.get(i);
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.projectsacrifice.game;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class PhysicalObjectStackResolverTest {
|
||||
@Test
|
||||
public void fallingObjectSettlesOnTheHighestCrossedObject() {
|
||||
PhysicalObjectState lower = object(650f, 800f, 160f, 80f);
|
||||
PhysicalObjectState middle = object(690f, 721f, 140f, 80f)
|
||||
.velocity(0f, 60f);
|
||||
PhysicalObjectState distant = object(1_200f, 700f, 100f, 100f);
|
||||
|
||||
boolean settled = PhysicalObjectStackResolver.settleFalling(
|
||||
middle, 720f, Arrays.asList(lower, middle, distant));
|
||||
|
||||
assertTrue(settled);
|
||||
assertEquals(720f, middle.weightedY(), 0f);
|
||||
assertEquals(0f, middle.velocityY(), 0f);
|
||||
assertTrue(middle.grounded());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void risingOrNonCrossingObjectIsNotTeleportedOntoAStack() {
|
||||
PhysicalObjectState lower = object(650f, 800f, 160f, 80f);
|
||||
PhysicalObjectState rising = object(690f, 700f, 120f, 80f)
|
||||
.velocity(0f, -40f);
|
||||
PhysicalObjectState beside = object(300f, 721f, 100f, 80f)
|
||||
.velocity(0f, 60f);
|
||||
|
||||
assertFalse(PhysicalObjectStackResolver.settleFalling(
|
||||
rising, 704f, Arrays.asList(lower, rising)));
|
||||
assertFalse(PhysicalObjectStackResolver.settleFalling(
|
||||
beside, 720f, Arrays.asList(lower, beside)));
|
||||
}
|
||||
|
||||
private static PhysicalObjectState object(float x, float y, float width, float height) {
|
||||
return new PhysicalObjectState(new LevelDefinition.PhysicalObject(
|
||||
LevelDefinition.PhysicalObjectType.BOX,
|
||||
new LevelDefinition.Box(x, y, width, height), 1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.projectsacrifice.game;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class PhysicsWaveOneContentTest {
|
||||
@Test
|
||||
public void firstPhysicsWaveMatchesTheExecutableMatrix() {
|
||||
List<LevelDefinition> levels = LevelCatalog.all();
|
||||
assertEquals(34, levels.size());
|
||||
|
||||
LevelDefinition mass = levels.get(30);
|
||||
assertIdentity(mass, 31, "physics.mass-basics", "Weight Class", 0, 45);
|
||||
assertFalse(mass.objects.isEmpty());
|
||||
assertTrue(mass.containsMechanic(LevelDefinition.SwitchType.PRESSURE));
|
||||
assertFalse(mass.doors.isEmpty());
|
||||
|
||||
LevelDefinition stack = levels.get(31);
|
||||
assertIdentity(stack, 32, "physics.stack-order", "Stack Order", 0, 50);
|
||||
assertTrue(stack.objects.size() >= 3);
|
||||
assertTrue("The authored staircase must contain an object supported by another",
|
||||
hasAuthoredObjectStack(stack));
|
||||
|
||||
LevelDefinition launch = levels.get(32);
|
||||
assertIdentity(launch, 33, "physics.launch-window", "Launch Window", 1, 55);
|
||||
assertTrue(launch.containsMechanic(LevelDefinition.HazardType.SAW));
|
||||
assertTrue(launch.hasMovingPlatform());
|
||||
|
||||
LevelDefinition crusher = levels.get(33);
|
||||
assertIdentity(crusher, 34, "physics.crusher-rhythm", "Press Cycle", 1, 55);
|
||||
assertTrue(crusher.containsMechanic(LevelDefinition.HazardType.CRUSHER));
|
||||
assertTrue(crusher.containsMechanic(LevelDefinition.SwitchType.PRESSURE));
|
||||
}
|
||||
|
||||
private static boolean hasAuthoredObjectStack(LevelDefinition level) {
|
||||
for (LevelDefinition.PhysicalObject upper : level.objects) {
|
||||
for (LevelDefinition.PhysicalObject lower : level.objects) {
|
||||
if (upper == lower) continue;
|
||||
boolean horizontalOverlap = upper.box.x < lower.box.right()
|
||||
&& upper.box.right() > lower.box.x;
|
||||
if (horizontalOverlap
|
||||
&& Math.abs(upper.box.bottom() - lower.box.y) <= 0.01f) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void assertIdentity(LevelDefinition level, int number, String id, String title,
|
||||
int targetDeaths, int targetSeconds) {
|
||||
assertEquals(number, level.number);
|
||||
assertEquals(id, level.levelId);
|
||||
assertEquals("physics", level.worldId);
|
||||
assertEquals(title, level.title);
|
||||
assertEquals(targetDeaths, level.targetDeaths);
|
||||
assertEquals(targetSeconds, level.targetSeconds);
|
||||
assertNotNull(level.collectible);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user