From 2c8b7ed6c40dcedd5efcc97afac797e9a7e4f43f Mon Sep 17 00:00:00 2001 From: Ziggy Date: Thu, 30 Mar 2023 16:14:43 +0200 Subject: [PATCH] Converted some Combat XP testcases from Java to Kotlin --- .../experience/CombatLevelCalculatorTest.java | 50 -------------- .../experience/CombatLevelCalculatorTest.kt | 68 +++++++++++++++++++ .../experience/CombatXpCalculatorTest.java | 41 ----------- .../experience/CombatXpCalculatorTest.kt | 58 ++++++++++++++++ .../experience/FakeCombatLevelRepository.java | 22 ------ .../experience/FakeCombatLevelRepository.kt | 39 +++++++++++ .../FakeCombatXpMultiplierRepository.java | 22 ------ .../FakeCombatXpMultiplierRepository.kt | 39 +++++++++++ .../experience/HealthAddedCalculatorTest.java | 34 ---------- .../experience/HealthAddedCalculatorTest.kt | 55 +++++++++++++++ .../SdbCombatLevelRepositoryTest.java | 19 ------ .../SdbCombatLevelRepositoryTest.kt | 40 +++++++++++ .../SdbCombatXpMultiplierRepositoryTest.java | 30 -------- .../SdbCombatXpMultiplierRepositoryTest.kt | 50 ++++++++++++++ 14 files changed, 349 insertions(+), 218 deletions(-) delete mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatLevelCalculatorTest.java create mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatLevelCalculatorTest.kt delete mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatXpCalculatorTest.java create mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatXpCalculatorTest.kt delete mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatLevelRepository.java create mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatLevelRepository.kt delete mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatXpMultiplierRepository.java create mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatXpMultiplierRepository.kt delete mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/HealthAddedCalculatorTest.java create mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/HealthAddedCalculatorTest.kt delete mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatLevelRepositoryTest.java create mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatLevelRepositoryTest.kt delete mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatXpMultiplierRepositoryTest.java create mode 100644 src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatXpMultiplierRepositoryTest.kt diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatLevelCalculatorTest.java b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatLevelCalculatorTest.java deleted file mode 100644 index 943875ae4..000000000 --- a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatLevelCalculatorTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.projectswg.holocore.services.gameplay.player.experience; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class CombatLevelCalculatorTest { - private final CombatLevel combatLevel1 = new CombatLevel(1, 500, 0); - private final CombatLevel combatLevel2 = new CombatLevel(2, 1000, 50); - private final CombatLevel combatLevel3 = new CombatLevel(3, 6000, 75); - - private final FakeCombatLevelRepository repository = new FakeCombatLevelRepository(); - private final CombatLevelCalculator calculator = new CombatLevelCalculator(repository); - - @Test - public void combatLevelIsSelected_whenRequiredXpIsMatchedExactly() { - repository.addCombatLevel(combatLevel1); - repository.addCombatLevel(combatLevel2); - repository.addCombatLevel(combatLevel3); - - int exactXpForCombatLevel2 = combatLevel2.getRequiredCombatXp(); - CombatLevel combatLevel = calculator.calculate(exactXpForCombatLevel2); - - assertEquals(combatLevel2, combatLevel); - } - - @Test - public void smallestCombatLevelIsSelected_whenPlayerHasTooLittleXp() { - repository.addCombatLevel(combatLevel1); - repository.addCombatLevel(combatLevel2); - repository.addCombatLevel(combatLevel3); - - int notEnoughXpForCombatLevel1 = 10; - CombatLevel combatLevel = calculator.calculate(notEnoughXpForCombatLevel1); - - assertEquals(combatLevel1, combatLevel); - } - - @Test - public void biggestCombatLevelIsSelected_whenPlayerHasMuchXp() { - repository.addCombatLevel(combatLevel1); - repository.addCombatLevel(combatLevel2); - repository.addCombatLevel(combatLevel3); - - int muchXp = 100_000; - CombatLevel combatLevel = calculator.calculate(muchXp); - - assertEquals(combatLevel3, combatLevel); - } -} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatLevelCalculatorTest.kt b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatLevelCalculatorTest.kt new file mode 100644 index 000000000..601cb7c18 --- /dev/null +++ b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatLevelCalculatorTest.kt @@ -0,0 +1,68 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.services.gameplay.player.experience + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class CombatLevelCalculatorTest { + private val combatLevel1 = CombatLevel(1, 500, 0) + private val combatLevel2 = CombatLevel(2, 1000, 50) + private val combatLevel3 = CombatLevel(3, 6000, 75) + private val repository = FakeCombatLevelRepository() + private val calculator = CombatLevelCalculator(repository) + + @Test + fun combatLevelIsSelected_whenRequiredXpIsMatchedExactly() { + repository.addCombatLevel(combatLevel1) + repository.addCombatLevel(combatLevel2) + repository.addCombatLevel(combatLevel3) + val exactXpForCombatLevel2 = combatLevel2.requiredCombatXp + val combatLevel = calculator.calculate(exactXpForCombatLevel2) + Assertions.assertEquals(combatLevel2, combatLevel) + } + + @Test + fun smallestCombatLevelIsSelected_whenPlayerHasTooLittleXp() { + repository.addCombatLevel(combatLevel1) + repository.addCombatLevel(combatLevel2) + repository.addCombatLevel(combatLevel3) + val notEnoughXpForCombatLevel1 = 10 + val combatLevel = calculator.calculate(notEnoughXpForCombatLevel1) + Assertions.assertEquals(combatLevel1, combatLevel) + } + + @Test + fun biggestCombatLevelIsSelected_whenPlayerHasMuchXp() { + repository.addCombatLevel(combatLevel1) + repository.addCombatLevel(combatLevel2) + repository.addCombatLevel(combatLevel3) + val muchXp = 100000 + val combatLevel = calculator.calculate(muchXp) + Assertions.assertEquals(combatLevel3, combatLevel) + } +} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatXpCalculatorTest.java b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatXpCalculatorTest.java deleted file mode 100644 index ad3409348..000000000 --- a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatXpCalculatorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.projectswg.holocore.services.gameplay.player.experience; - -import org.junit.jupiter.api.Test; - -import java.util.Collection; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - -public class CombatXpCalculatorTest { - - private final FakeCombatXpMultiplierRepository repository = new FakeCombatXpMultiplierRepository(); - private final CombatXpCalculator calculator = new CombatXpCalculator(repository); - - @Test - public void xpTypeIsIgnored_whenMultiplierIsUndefined() { - Collection experienceCollection = List.of(new Experience("has_no_multiplier", 100)); - - int combatXp = calculator.calculate(experienceCollection); - - assertEquals(0, combatXp); - } - - @Test - public void xpTypeCounts_whenMultiplierIsDefined() { - repository.addMultiplier("has_multiplier", 1); - Collection experienceCollection = List.of(new Experience("has_multiplier", 100)); - int combatXp = calculator.calculate(experienceCollection); - - assertEquals(100, combatXp); - } - - @Test - public void xpIsMultiplied_whenMultiplierForTypeIsAboveOne() { - repository.addMultiplier("has_multiplier", 5); - Collection experienceCollection = List.of(new Experience("has_multiplier", 100)); - int combatXp = calculator.calculate(experienceCollection); - - assertEquals(500, combatXp); - } -} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatXpCalculatorTest.kt b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatXpCalculatorTest.kt new file mode 100644 index 000000000..b37826bb0 --- /dev/null +++ b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/CombatXpCalculatorTest.kt @@ -0,0 +1,58 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.services.gameplay.player.experience + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class CombatXpCalculatorTest { + private val repository = FakeCombatXpMultiplierRepository() + private val calculator = CombatXpCalculator(repository) + + @Test + fun xpTypeIsIgnored_whenMultiplierIsUndefined() { + val experienceCollection = listOf(Experience("has_no_multiplier", 100)) + val combatXp = calculator.calculate(experienceCollection) + Assertions.assertEquals(0, combatXp) + } + + @Test + fun xpTypeCounts_whenMultiplierIsDefined() { + repository.addMultiplier("has_multiplier", 1) + val experienceCollection = listOf(Experience("has_multiplier", 100)) + val combatXp = calculator.calculate(experienceCollection) + Assertions.assertEquals(100, combatXp) + } + + @Test + fun xpIsMultiplied_whenMultiplierForTypeIsAboveOne() { + repository.addMultiplier("has_multiplier", 5) + val experienceCollection = listOf(Experience("has_multiplier", 100)) + val combatXp = calculator.calculate(experienceCollection) + Assertions.assertEquals(500, combatXp) + } +} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatLevelRepository.java b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatLevelRepository.java deleted file mode 100644 index d9d9d000f..000000000 --- a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatLevelRepository.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.projectswg.holocore.services.gameplay.player.experience; - -import java.util.Collection; -import java.util.LinkedHashSet; - -class FakeCombatLevelRepository implements CombatLevelRepository { - - private final Collection combatLevels; - - public FakeCombatLevelRepository() { - combatLevels = new LinkedHashSet<>(); - } - - public void addCombatLevel(CombatLevel combatLevel) { - combatLevels.add(combatLevel); - } - - @Override - public Collection getCombatLevels() { - return combatLevels; - } -} diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatLevelRepository.kt b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatLevelRepository.kt new file mode 100644 index 000000000..57f1e571e --- /dev/null +++ b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatLevelRepository.kt @@ -0,0 +1,39 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.services.gameplay.player.experience + +internal class FakeCombatLevelRepository : CombatLevelRepository { + private val combatLevels = LinkedHashSet() + + fun addCombatLevel(combatLevel: CombatLevel) { + combatLevels.add(combatLevel) + } + + override fun getCombatLevels(): Collection { + return combatLevels + } +} diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatXpMultiplierRepository.java b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatXpMultiplierRepository.java deleted file mode 100644 index d1c3f8b9c..000000000 --- a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatXpMultiplierRepository.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.projectswg.holocore.services.gameplay.player.experience; - -import java.util.HashMap; -import java.util.Map; - -public class FakeCombatXpMultiplierRepository implements CombatXpMultiplierRepository { - - private final Map map; - - public FakeCombatXpMultiplierRepository() { - map = new HashMap<>(); - } - - public void addMultiplier(String xpType, int multiplier) { - map.put(xpType, multiplier); - } - - @Override - public int getMultiplier(String xpType) { - return map.getOrDefault(xpType, 0); - } -} diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatXpMultiplierRepository.kt b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatXpMultiplierRepository.kt new file mode 100644 index 000000000..28f3a32fe --- /dev/null +++ b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/FakeCombatXpMultiplierRepository.kt @@ -0,0 +1,39 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.services.gameplay.player.experience + +class FakeCombatXpMultiplierRepository : CombatXpMultiplierRepository { + private val map = mutableMapOf() + + fun addMultiplier(xpType: String, multiplier: Int) { + map[xpType] = multiplier + } + + override fun getMultiplier(xpType: String): Int { + return map.getOrDefault(xpType, 0) + } +} diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/HealthAddedCalculatorTest.java b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/HealthAddedCalculatorTest.java deleted file mode 100644 index 975cb982e..000000000 --- a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/HealthAddedCalculatorTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.projectswg.holocore.services.gameplay.player.experience; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class HealthAddedCalculatorTest { - - private final CombatLevel combatLevel1 = new CombatLevel(1, 500, 0); - private final CombatLevel combatLevel2 = new CombatLevel(2, 1000, 50); - private final CombatLevel combatLevel3 = new CombatLevel(2, 6000, 75); - private final HealthAddedCalculator healthAddedCalculator = new HealthAddedCalculator(); - - @Test - public void healthIsDecreased_whenLevelIsDecreased() { - int healthChange = healthAddedCalculator.calculate(combatLevel3, combatLevel1); - - assertEquals(-75, healthChange); - } - - @Test - public void healthIsIncreased_whenLevelIsIncreased() { - int healthChange = healthAddedCalculator.calculate(combatLevel2, combatLevel3); - - assertEquals(25, healthChange); - } - - @Test - public void healthIsUnchanged_whenLevelIsUnchanged() { - int healthChange = healthAddedCalculator.calculate(combatLevel2, combatLevel2); - - assertEquals(0, healthChange); - } -} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/HealthAddedCalculatorTest.kt b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/HealthAddedCalculatorTest.kt new file mode 100644 index 000000000..679a9e564 --- /dev/null +++ b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/HealthAddedCalculatorTest.kt @@ -0,0 +1,55 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.services.gameplay.player.experience + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class HealthAddedCalculatorTest { + private val combatLevel1 = CombatLevel(1, 500, 0) + private val combatLevel2 = CombatLevel(2, 1000, 50) + private val combatLevel3 = CombatLevel(2, 6000, 75) + private val healthAddedCalculator = HealthAddedCalculator() + + @Test + fun healthIsDecreased_whenLevelIsDecreased() { + val healthChange = healthAddedCalculator.calculate(combatLevel3, combatLevel1) + Assertions.assertEquals(-75, healthChange) + } + + @Test + fun healthIsIncreased_whenLevelIsIncreased() { + val healthChange = healthAddedCalculator.calculate(combatLevel2, combatLevel3) + Assertions.assertEquals(25, healthChange) + } + + @Test + fun healthIsUnchanged_whenLevelIsUnchanged() { + val healthChange = healthAddedCalculator.calculate(combatLevel2, combatLevel2) + Assertions.assertEquals(0, healthChange) + } +} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatLevelRepositoryTest.java b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatLevelRepositoryTest.java deleted file mode 100644 index d44b9e927..000000000 --- a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatLevelRepositoryTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.projectswg.holocore.services.gameplay.player.experience; - -import org.junit.jupiter.api.Test; - -import java.util.Collection; - -import static org.junit.jupiter.api.Assertions.*; - -public class SdbCombatLevelRepositoryTest { - - @Test - public void canLoadLevels() { - SdbCombatLevelRepository repository = new SdbCombatLevelRepository(); - Collection combatLevels = repository.getCombatLevels(); - int combatLevelCount = combatLevels.size(); - - assertEquals(80, combatLevelCount); - } -} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatLevelRepositoryTest.kt b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatLevelRepositoryTest.kt new file mode 100644 index 000000000..8642438fa --- /dev/null +++ b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatLevelRepositoryTest.kt @@ -0,0 +1,40 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.services.gameplay.player.experience + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class SdbCombatLevelRepositoryTest { + @Test + fun canLoadLevels() { + val repository = SdbCombatLevelRepository() + val combatLevels = repository.combatLevels + val combatLevelCount = combatLevels.size + Assertions.assertEquals(80, combatLevelCount) + } +} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatXpMultiplierRepositoryTest.java b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatXpMultiplierRepositoryTest.java deleted file mode 100644 index a6c3b1f04..000000000 --- a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatXpMultiplierRepositoryTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.projectswg.holocore.services.gameplay.player.experience; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class SdbCombatXpMultiplierRepositoryTest { - - private final SdbCombatXpMultiplierRepository repository = new SdbCombatXpMultiplierRepository(); - - @Test - public void multiplierIsAboveZero_whenXpTypeIsKnown() { - // These come from the SDB - String randomlySelectedXpType = "combat_general"; - int multiplierForRandomlySelectedXpType = 3; - - int multiplier = repository.getMultiplier(randomlySelectedXpType); - - assertEquals(multiplierForRandomlySelectedXpType, multiplier); - } - - @Test - public void multiplierIsZero_whenXpTypeIsUnknown() { - String randomlySelectedXpType = "unknown_xp_type"; - - int multiplier = repository.getMultiplier(randomlySelectedXpType); - - assertEquals(0, multiplier); - } -} \ No newline at end of file diff --git a/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatXpMultiplierRepositoryTest.kt b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatXpMultiplierRepositoryTest.kt new file mode 100644 index 000000000..9e88c8a91 --- /dev/null +++ b/src/test/java/com/projectswg/holocore/services/gameplay/player/experience/SdbCombatXpMultiplierRepositoryTest.kt @@ -0,0 +1,50 @@ +/*********************************************************************************** + * Copyright (c) 2023 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.services.gameplay.player.experience + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class SdbCombatXpMultiplierRepositoryTest { + private val repository = SdbCombatXpMultiplierRepository() + + @Test + fun multiplierIsAboveZero_whenXpTypeIsKnown() { + // These come from the SDB + val randomlySelectedXpType = "combat_general" + val multiplierForRandomlySelectedXpType = 3 + val multiplier = repository.getMultiplier(randomlySelectedXpType) + Assertions.assertEquals(multiplierForRandomlySelectedXpType, multiplier) + } + + @Test + fun multiplierIsZero_whenXpTypeIsUnknown() { + val randomlySelectedXpType = "unknown_xp_type" + val multiplier = repository.getMultiplier(randomlySelectedXpType) + Assertions.assertEquals(0, multiplier) + } +} \ No newline at end of file