feat: add stature potions and tiny-player launchers
This commit is contained in:
commit
7bccc727b1
37 files changed
+1490
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package games.dmg.spigotheights;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class HeightMathTest {
|
||||
private static final HeightSettings SETTINGS = new HeightSettings(0.4, 2.0, 0.1, 0.5, 1.5, 20);
|
||||
|
||||
@Test
|
||||
void randomSelectionCanReachBothInclusiveEndpoints() {
|
||||
assertEquals(0.4, HeightMath.randomScale(SETTINGS, bound -> 0), 0.000001);
|
||||
assertEquals(2.0, HeightMath.randomScale(SETTINGS, bound -> bound - 1), 0.000001);
|
||||
}
|
||||
|
||||
@Test
|
||||
void adjustmentsClampAtLimitsWithoutFloatingPointDrift() {
|
||||
assertEquals(2.0, HeightMath.grow(1.95, SETTINGS), 0.000001);
|
||||
assertEquals(0.4, HeightMath.shrink(0.42, SETTINGS), 0.000001);
|
||||
assertEquals(1.1, HeightMath.grow(1.0, SETTINGS), 0.000001);
|
||||
}
|
||||
|
||||
@Test
|
||||
void missingAndStoredValuesAreSafelyClamped() {
|
||||
assertEquals(1.0, HeightMath.safeStoredScale(null, SETTINGS), 0.000001);
|
||||
assertEquals(0.4, HeightMath.safeStoredScale(-2.0, SETTINGS), 0.000001);
|
||||
assertEquals(2.0, HeightMath.safeStoredScale(4.0, SETTINGS), 0.000001);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package games.dmg.spigotheights;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class HeightSettingsTest {
|
||||
@Test
|
||||
void acceptsDocumentedDefaults() {
|
||||
HeightSettings settings = new HeightSettings(0.4, 2.0, 0.1, 0.5, 1.5, 20);
|
||||
assertEquals(0.4, settings.minimum());
|
||||
assertEquals(16, settings.randomStepCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsInvalidRangesAndNumbers() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new HeightSettings(2.0, 0.4, 0.1, 0.5, 1.5, 20));
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new HeightSettings(0.4, 2.0, 0.0, 0.5, 1.5, 20));
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new HeightSettings(0.4, 2.0, 0.1, 2.1, 1.5, 20));
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new HeightSettings(0.4, Double.NaN, 0.1, 0.5, 1.5, 20));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package games.dmg.spigotheights;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
class HeightStoreTest {
|
||||
@TempDir
|
||||
Path temporaryDirectory;
|
||||
|
||||
@Test
|
||||
void storesByUuidAndPreservesUnknownYamlFields() throws Exception {
|
||||
UUID playerId = UUID.randomUUID();
|
||||
Path stateFile = temporaryDirectory.resolve("state.yml");
|
||||
Files.writeString(stateFile, "future-setting: retained\n");
|
||||
HeightStore store = new HeightStore(temporaryDirectory.toFile());
|
||||
|
||||
store.save(playerId, 0.7);
|
||||
|
||||
HeightStore reloaded = new HeightStore(temporaryDirectory.toFile());
|
||||
assertEquals(0.7, reloaded.find(playerId));
|
||||
assertEquals(true, Files.readString(stateFile).contains("future-setting: retained"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package games.dmg.spigotheights;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class LaunchVectorTest {
|
||||
@Test
|
||||
void supportsEveryDispenserAxisAtConfiguredSpeed() {
|
||||
assertVector(1.5, 0.0, 0.0, LaunchVector.fromDirection(1, 0, 0, 1.5));
|
||||
assertVector(-1.5, 0.0, 0.0, LaunchVector.fromDirection(-1, 0, 0, 1.5));
|
||||
assertVector(0.0, 1.5, 0.0, LaunchVector.fromDirection(0, 1, 0, 1.5));
|
||||
assertVector(0.0, -1.5, 0.0, LaunchVector.fromDirection(0, -1, 0, 1.5));
|
||||
assertVector(0.0, 0.0, 1.5, LaunchVector.fromDirection(0, 0, 1, 1.5));
|
||||
assertVector(0.0, 0.0, -1.5, LaunchVector.fromDirection(0, 0, -1, 1.5));
|
||||
}
|
||||
|
||||
private static void assertVector(double x, double y, double z, LaunchVector actual) {
|
||||
assertEquals(x, actual.x(), 0.000001);
|
||||
assertEquals(y, actual.y(), 0.000001);
|
||||
assertEquals(z, actual.z(), 0.000001);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package games.dmg.spigotheights;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class LauncherPolicyTest {
|
||||
@Test
|
||||
void thresholdIsStrictlyExclusive() {
|
||||
assertTrue(LauncherPolicy.isSmallEnough(0.4999, 0.5));
|
||||
assertFalse(LauncherPolicy.isSmallEnough(0.5, 0.5));
|
||||
assertFalse(LauncherPolicy.isSmallEnough(1.0, 0.5));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cooldownExpiresAtConfiguredTick() {
|
||||
assertFalse(LauncherPolicy.cooldownExpired(100L, 119, 20));
|
||||
assertTrue(LauncherPolicy.cooldownExpired(100L, 120, 20));
|
||||
assertTrue(LauncherPolicy.cooldownExpired(null, 1, 20));
|
||||
}
|
||||
|
||||
@Test
|
||||
void onlyEmptyDispenserExitsAreSafe() {
|
||||
assertTrue(LauncherPolicy.isSafeExit(true));
|
||||
assertFalse(LauncherPolicy.isSafeExit(false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package games.dmg.spigotheights;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class PotionRecipesTest {
|
||||
@Test
|
||||
void recipesUseApprovedShapes() {
|
||||
assertArrayEquals(new String[] {"ACA", "AWA", "ACA"}, PotionRecipes.SHIFTING_SHAPE);
|
||||
assertArrayEquals(new String[] {"GAG", "ASA", "GRG"}, PotionRecipes.GROWTH_SHAPE);
|
||||
assertArrayEquals(new String[] {"GAG", "ASA", "GFG"}, PotionRecipes.DIMINUTION_SHAPE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void everyPotionHasASeparatePersistentIdentity() {
|
||||
assertNotEquals(StaturePotion.SHIFTING.name(), StaturePotion.GROWTH.name());
|
||||
assertNotEquals(StaturePotion.GROWTH.name(), StaturePotion.DIMINUTION.name());
|
||||
assertNotEquals(StaturePotion.DIMINUTION.name(), StaturePotion.SHIFTING.name());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user