21 lines
4.2 KiB
Java
21 lines
4.2 KiB
Java
package games.dmg.fantasystick;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
import java.nio.file.Path;
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.io.TempDir;
|
|
|
|
class CharacterBossTargetEventsNativeTest {
|
|
@TempDir Path data;
|
|
@BeforeAll static void bootstrap()throws Exception{NativeRuntime.bootstrap();}
|
|
@Test void realAcceptedThreatFixatesDespiteLaterHigherThreatThenRetargetsWithOriginalNativeSystemFactsAndNoPulseSpam()throws Exception{
|
|
try(var fixture=new CharacterBossAuditNativeFixture(data)){
|
|
var b=fixture.base;fixture.authorAndAccept();var challenger=fixture.acceptedChallenger(data);b.actor.damage=(amount,source)->{};b.enter(b.boss);var shell=fixture.shell();fixture.damage(b.actor,shell,100,true);b.shared.pulse();assertNull(shell.target[0],"Prior native cancellation cannot establish accepted threat or a fantasy target");fixture.damage(b.actor,shell,3,false);b.shared.pulse();assertSame(b.actor.player,shell.target[0]);fixture.damage(challenger,shell,10,false);b.shared.pulse();assertSame(b.actor.player,shell.target[0],"Later higher accepted threat cannot steal actual fixation");b.actor.core.location.setX(100);b.shared.pulse();assertSame(challenger.player,shell.target[0],"Actual ineligible fixation retargets highest remaining eligible threat");for(int i=0;i<3;i++)b.shared.pulse();assertEquals(fixture.custody,b.directory.custody(fixture.template.id()).orElseThrow());fence(FantasyStickLifecycleNativeTest.Fixture.field(FantasyStickLifecycleNativeTest.Fixture.field(b.f.plugin,"characterBossEvents"),"outbox"));fence(FantasyStickLifecycleNativeTest.Fixture.field(b.f.plugin,"eventLog"));var rows=ReskillEventsNativeTest.records(data).stream().filter(row->row.get("type").getAsString().endsWith("dungeon.character_boss.target_changed")).toList();assertEquals(2,rows.size(),"Actual initial threat fixation and ineligible retarget need original system-owned transitions, not pulse/refusal spam or later actor reconstruction");
|
|
var initial=rows.stream().filter(row->row.getAsJsonObject("data").get("target_player_id").getAsString().equals(b.actor.core.id.toString())).findFirst().orElseThrow();var retarget=rows.stream().filter(row->row.getAsJsonObject("data").get("target_player_id").getAsString().equals(challenger.core.id.toString())).findFirst().orElseThrow();assertEquals("highest_accepted_threat",initial.getAsJsonObject("data").get("reason").getAsString());assertEquals("fixation_invalidated_retarget",retarget.getAsJsonObject("data").get("reason").getAsString());assertEquals(b.actor.core.record.id().toString(),initial.getAsJsonObject("data").get("target_character_id").getAsString());assertEquals(challenger.core.record.id().toString(),retarget.getAsJsonObject("data").get("target_character_id").getAsString());assertEquals(17.5,initial.getAsJsonObject("data").getAsJsonObject("target_location").get("x").getAsDouble());assertEquals(17.75,retarget.getAsJsonObject("data").getAsJsonObject("target_location").get("x").getAsDouble());assertEquals(3,initial.getAsJsonObject("data").get("accepted_threat").getAsDouble());assertEquals(10,retarget.getAsJsonObject("data").get("accepted_threat").getAsDouble());assertEquals(b.actor.core.id.toString(),retarget.getAsJsonObject("data").get("previous_target_player_id").getAsString());for(var row:rows){var values=row.getAsJsonObject("data");assertEquals("system",values.get("actor_kind").getAsString());assertEquals(fixture.template.id().toString(),values.get("subject_character_id").getAsString());assertEquals(shell.entity.getUniqueId().toString(),values.get("native_entity_id").getAsString());assertEquals(fixture.custody.operation().toString(),values.get("custody_operation_id").getAsString());assertEquals(b.quest.catalog().toString(),values.get("generation_id").getAsString());assertEquals(17.25,values.getAsJsonObject("source_location").get("x").getAsDouble());assertFalse(values.has("session_id"));assertFalse(row.has("playerid"));assertFalse(row.has("characterid"));}
|
|
}
|
|
}
|
|
private static void fence(Object owner)throws Exception{((java.util.concurrent.ExecutorService)FantasyStickLifecycleNativeTest.Fixture.field(owner,"worker")).submit(()->{}).get(5,java.util.concurrent.TimeUnit.SECONDS);}
|
|
}
|