This commit is contained in:
1 parent
793245e890
commit
f2a6043d08
3 files changed
+28
-28
No files matched your search
@@ -53,10 +53,12 @@ class AdventureQuestNativeTest {
|
||||
var stale=mock(InventoryClickEvent.class);when(stale.getWhoClicked()).thenReturn(actor.player);when(stale.getInventory()).thenReturn(menu);when(stale.getCurrentItem()).thenReturn(menu.getItem(0));controller.click(stale);drainOne(f);assertTrue(actor.messages.getLast().contains("stale"));
|
||||
f.dispatcher.accept(new PlayerInteractEntityEvent(actor.player,giver,EquipmentSlot.HAND));drainOne(f);menu=actor.inventories.getLast();var click=mock(InventoryClickEvent.class);when(click.getWhoClicked()).thenReturn(actor.player);when(click.getInventory()).thenReturn(menu);when(click.getCurrentItem()).thenReturn(menu.getItem(0));controller.click(click);drainOne(f);
|
||||
assertTrue(actor.messages.stream().anyMatch(message -> message.equals(
|
||||
"Accepted Dawn Camp at Adventure Realm (12, 70, -8); expires "
|
||||
+ directory.active().getFirst().expiresAt() + ".")));
|
||||
"Accepted Dawn Camp; expires " + directory.active().getFirst().expiresAt()
|
||||
+ ". Follow the Quest Compass.")));
|
||||
f.command.execute(actor.player,"fantasystick",new String[]{"adventure"});
|
||||
assertTrue(actor.messages.getLast().startsWith("Dawn Camp at Adventure Realm (12, 70, -8); state="));
|
||||
assertEquals("Dawn Camp; state=waiting; expires "+directory.active().getFirst().expiresAt()
|
||||
+"; Quest Compass guidance=on.",actor.messages.getLast());
|
||||
assertFalse(actor.messages.getLast().contains("(12, 70, -8)"));assertFalse(actor.messages.getLast().contains(worldId.toString()));
|
||||
var siteRecord=directory.snapshot().sites().getFirst();assertEquals(games.dmg.fantasystick.adventure.AdventureQuestState.Arena.rectangle(20,60),siteRecord.arena());actor.core.location.setZ(siteRecord.z()+25);
|
||||
var partyA=new FantasyStickLifecycleNativeTest.Actor(data);var partyB=new FantasyStickLifecycleNativeTest.Actor(data);partyA.core.location.setWorld(actor.world);partyB.core.location.setWorld(actor.world);f.players.put(partyA.core.id,partyA.player);f.players.put(partyB.core.id,partyB.player);f.activate(partyA);f.activate(partyB);var parties=PartyLifecycleNativeTest.parties(f);var party=parties.create(partyA.core.id).orElseThrow();assertTrue(parties.accept(partyB.core.id,parties.invite(partyA.core.id,party.id(),partyB.core.id).orElseThrow().id()));var catalog=directory.snapshot().catalog();var siteId=catalog.sites().getFirst();assertEquals(games.dmg.fantasystick.adventure.AdventureQuestDirectory.Acceptance.APPLIED,directory.accept(catalog.revision(),siteId,games.dmg.fantasystick.adventure.AdventureQuestState.UnitType.PARTY,party.id(),Set.of(partyA.core.record.id(),partyB.core.record.id())).get(5,java.util.concurrent.TimeUnit.SECONDS).status());
|
||||
var storage=(games.dmg.fantasystick.persistence.CharacterStorage)FantasyStickLifecycleNativeTest.Fixture.field(f.plugin,"characters");var actorCoins=storage.find(actor.core.record.id()).get().orElseThrow().coins();var partyACoins=storage.find(partyA.core.record.id()).get().orElseThrow().coins();var partyBCoins=storage.find(partyB.core.record.id()).get().orElseThrow().coins();
|
||||
@@ -297,21 +299,20 @@ class AdventureQuestNativeTest {
|
||||
drainOne(f);
|
||||
var quest = directory.active().getFirst();
|
||||
String accepted = actor.messages.getLast();
|
||||
assertTrue(accepted.startsWith("Accepted Monster Camp at Adventure Realm (12, -1, -9); expires "));
|
||||
for (UUID internal : List.of(worldId, site.id(), directory.snapshot().catalog().revision(),
|
||||
quest.id(), quest.unit(), actor.core.record.id())) {
|
||||
assertFalse(accepted.contains(internal.toString()));
|
||||
assertEquals("Accepted Monster Camp; expires "+quest.expiresAt()+". Follow the Quest Compass.",accepted);
|
||||
for (String hidden : List.of("(12, -1, -9)", worldId.toString(), site.id().toString(),
|
||||
directory.snapshot().catalog().revision().toString(), quest.id().toString(),
|
||||
quest.unit().toString(), actor.core.record.id().toString())) {
|
||||
assertFalse(accepted.contains(hidden));
|
||||
}
|
||||
f.command.execute(actor.player, "fantasystick", new String[]{"adventure"});
|
||||
String inspected = actor.messages.getLast();
|
||||
assertTrue(inspected.startsWith("Monster Camp at Adventure Realm (12, -1, -9); state="));
|
||||
assertFalse(inspected.contains(worldId.toString()));
|
||||
assertFalse(inspected.contains(site.id().toString()));
|
||||
assertFalse(inspected.contains(quest.id().toString()));
|
||||
assertEquals("Monster Camp; state=waiting; expires "+quest.expiresAt()+"; Quest Compass guidance=on.",inspected);
|
||||
for(String hidden:List.of("(12, -1, -9)",worldId.toString(),site.id().toString(),quest.id().toString()))assertFalse(inspected.contains(hidden));
|
||||
|
||||
when(actor.world.getUID()).thenReturn(UUID.randomUUID());
|
||||
f.command.execute(actor.player, "fantasystick", new String[]{"adventure"});
|
||||
assertTrue(actor.messages.getLast().startsWith("Monster Camp at unavailable world (12, -1, -9); state="));
|
||||
assertEquals("Monster Camp; state=waiting; expires "+quest.expiresAt()+"; Quest Compass guidance=on.",actor.messages.getLast());
|
||||
assertFalse(actor.messages.getLast().contains(worldId.toString()));
|
||||
f.command.execute(actor.player, "fantasystick", new String[]{"adventure-site", "list"});
|
||||
assertTrue(actor.messages.getLast().contains(site.id().toString()));
|
||||
@@ -359,9 +360,9 @@ class AdventureQuestNativeTest {
|
||||
verify(actor.player,never()).setCompassTarget(any(Location.class));
|
||||
String lore=compass.getItemMeta().lore().stream().map(net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText()::serialize).reduce("",(a,b)->a+"\n"+b);
|
||||
assertTrue(lore.contains("Compass Camp"));assertTrue(lore.contains("Monster camp"));
|
||||
assertTrue(lore.contains("Adventure Realm (10, 69, -11)"));assertTrue(lore.contains("Distance: 15 blocks"));
|
||||
assertTrue(lore.contains("World: Adventure Realm"));assertTrue(lore.contains("Distance: 15 blocks"));
|
||||
assertTrue(lore.contains("Expires: "+quest.expiresAt()));
|
||||
assertFalse(lore.contains(site.id().toString()));assertFalse(lore.contains(quest.id().toString()));
|
||||
for(String hidden:List.of("(10, 69, -11)",targetWorld.toString(),site.id().toString(),quest.id().toString()))assertFalse(lore.contains(hidden));
|
||||
assertEquals(List.of("Compass Camp — 15 blocks NE · ↑ +6"),actor.actionBars);
|
||||
|
||||
var use=new org.bukkit.event.player.PlayerInteractEvent(actor.player,org.bukkit.event.block.Action.RIGHT_CLICK_AIR,
|
||||
@@ -392,10 +393,10 @@ class AdventureQuestNativeTest {
|
||||
var other=mock(World.class);when(other.getUID()).thenReturn(otherWorld);actor.core.location.setWorld(other);
|
||||
f.players.put(targetWorldActor.core.id,targetWorldActor.player);
|
||||
for(Runnable pulse:List.copyOf(f.pulses))pulse.run();
|
||||
assertEquals("Travel to Adventure Realm (10, 69, -11)",actor.actionBars.getLast());
|
||||
assertEquals("Travel to Adventure Realm",actor.actionBars.getLast());
|
||||
f.players.remove(targetWorldActor.core.id);
|
||||
for(Runnable pulse:List.copyOf(f.pulses))pulse.run();
|
||||
assertEquals("Travel to unavailable world (10, 69, -11)",actor.actionBars.getLast());
|
||||
assertEquals("Travel to unavailable world",actor.actionBars.getLast());
|
||||
|
||||
assertTrue(directory.abandon(quest.id(),quest.unit()).get(5,java.util.concurrent.TimeUnit.SECONDS));
|
||||
for(Runnable pulse:List.copyOf(f.pulses))pulse.run();
|
||||
@@ -433,8 +434,8 @@ class AdventureQuestNativeTest {
|
||||
for(Runnable pulse:List.copyOf(f.pulses))pulse.run();
|
||||
assertEquals(Material.COMPASS,actor.core.inventory.getItem(0).getType());assertTrue(actor.actionBars.isEmpty());
|
||||
String visible=actor.core.inventory.getItem(0).getItemMeta().lore().stream().map(net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText()::serialize).reduce("",String::concat);
|
||||
assertTrue(visible.contains("Dungeon entrance"));assertTrue(visible.contains("Dungeon Realm (40, 70, -20)"));
|
||||
for(UUID hidden:List.of(entrance.id(),quest.id(),quest.catalog(),quest.unit(),actor.core.record.id()))assertFalse(visible.contains(hidden.toString()));
|
||||
assertTrue(visible.contains("Dungeon entrance"));assertTrue(visible.contains("World: Dungeon Realm"));
|
||||
for(String hidden:List.of("(40, 70, -20)",world.toString(),entrance.id().toString(),quest.id().toString(),quest.catalog().toString(),quest.unit().toString(),actor.core.record.id().toString()))assertFalse(visible.contains(hidden));
|
||||
inside.set(false);for(Runnable pulse:List.copyOf(f.pulses))pulse.run();
|
||||
assertEquals(List.of("Deep Keep — 45 blocks NE · ↑ +10"),actor.actionBars);
|
||||
assertTrue(directory.closeOffer(entrance.id()).get(5,java.util.concurrent.TimeUnit.SECONDS));
|
||||
|
||||
Reference in new issue
Block a user