feat(vigilante): add followers and combat scaling
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package games.dmg.spigottyrant;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
final class FollowerServiceTest {
|
||||
private static final UUID TYRANT = UUID.fromString("11111111-1111-1111-1111-111111111111");
|
||||
private static final UUID VIGILANTE = UUID.fromString("22222222-2222-2222-2222-222222222222");
|
||||
private static final UUID FOLLOWER = UUID.fromString("33333333-3333-3333-3333-333333333333");
|
||||
private final FollowerService service = new FollowerService();
|
||||
|
||||
@Test
|
||||
void invitationRequiresAcceptanceAndPreservesTyrantClass() {
|
||||
GameState game = game();
|
||||
PlayerState target = new PlayerState(
|
||||
FOLLOWER, "Follower", Optional.empty(), Optional.empty(), TyrantClass.FIXER,
|
||||
Optional.empty(), Map.of(), Set.of(), java.util.List.of()
|
||||
);
|
||||
Map<UUID, PlayerState> players = Map.of(FOLLOWER, target);
|
||||
|
||||
FollowerResult invited = service.invite(game, players, VIGILANTE, FOLLOWER);
|
||||
FollowerResult accepted = service.accept(game, invited.players(), FOLLOWER);
|
||||
|
||||
assertEquals(FollowerStatus.INVITED, invited.status());
|
||||
assertEquals(Optional.empty(), invited.players().get(FOLLOWER).followerOf());
|
||||
assertEquals(FollowerStatus.JOINED, accepted.status());
|
||||
assertEquals(Optional.of(VIGILANTE), accepted.players().get(FOLLOWER).followerOf());
|
||||
assertEquals(TyrantClass.FIXER, accepted.players().get(FOLLOWER).tyrantClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
void vigilanteCanDismissAndFollowerCanLeave() {
|
||||
GameState game = game();
|
||||
PlayerState follower = withFollower(PlayerState.newPlayer(FOLLOWER, "Follower"));
|
||||
|
||||
FollowerResult dismissed = service.dismiss(
|
||||
game, Map.of(FOLLOWER, follower), VIGILANTE, FOLLOWER
|
||||
);
|
||||
FollowerResult left = service.leave(
|
||||
game, Map.of(FOLLOWER, follower), FOLLOWER
|
||||
);
|
||||
|
||||
assertEquals(FollowerStatus.DISMISSED, dismissed.status());
|
||||
assertEquals(Optional.empty(), dismissed.players().get(FOLLOWER).followerOf());
|
||||
assertEquals(FollowerStatus.LEFT, left.status());
|
||||
assertEquals(Optional.empty(), left.players().get(FOLLOWER).followerOf());
|
||||
}
|
||||
|
||||
private static GameState game() {
|
||||
return new GameState(
|
||||
GameLifecycle.RUNNING, Optional.of(TYRANT), Optional.of(VIGILANTE),
|
||||
Optional.empty(), Optional.empty(), Optional.empty(), Duration.ZERO,
|
||||
0, 0, Set.of()
|
||||
);
|
||||
}
|
||||
|
||||
private static PlayerState withFollower(PlayerState player) {
|
||||
return new PlayerState(
|
||||
player.playerId(), player.latestName(), player.lastLogin(), player.optedOutUntil(),
|
||||
player.tyrantClass(), Optional.of(VIGILANTE), player.cooldownEnds(),
|
||||
player.readyAbilityItems(), player.capturedMobs()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ final class PluginMetadataTest {
|
||||
assertNotNull(commands);
|
||||
assertNotNull(commands.get("tyrant"));
|
||||
assertNotNull(commands.get("tyrantadmin"));
|
||||
assertNotNull(commands.get("vigilante"));
|
||||
Map<?, ?> permissions = (Map<?, ?>) plugin.get("permissions");
|
||||
assertNotNull(permissions);
|
||||
Map<?, ?> admin = (Map<?, ?>) permissions.get("spigottyrant.admin");
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package games.dmg.spigottyrant;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
final class VigilantePowerTest {
|
||||
@Test
|
||||
void oneLevelPerNearbyFollowerIsCappedSafely() {
|
||||
assertEquals(new VigilantePower.Levels(3, 3), VigilantePower.forFollowers(3, 5, 4));
|
||||
assertEquals(new VigilantePower.Levels(5, 4), VigilantePower.forFollowers(10, 5, 4));
|
||||
assertEquals(new VigilantePower.Levels(0, 0), VigilantePower.forFollowers(0, 5, 4));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user