Skip to content

Commit

Permalink
refactor: dialogue tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada committed Aug 25, 2024
1 parent 154a668 commit cb35521
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/main/java/actionlogger/trackers/DialogueTracker.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package actionlogger.trackers;

import actionlogger.writers.JsonWriter;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.MenuAction;
Expand All @@ -25,6 +27,9 @@
@Slf4j
@RequiredArgsConstructor
public class DialogueTracker implements KeyListener {
private static final String DIALOGUE_STARTED = "DIALOGUE_STARTED";
private static final String DIALOGUE_ENDED = "DIALOGUE_ENDED";

private final JsonWriter writer;
private final Client client;
private @Nullable DialogueEndedData dialogueEndedData = null;
Expand Down Expand Up @@ -105,7 +110,7 @@ private void beginDialogue(String actorName, Integer actorID, String text, List<

var playerPosition = localPlayer.getWorldLocation();

this.writer.write(DialogueStartedData.TYPE, new DialogueStartedData(actorName, actorID, lastInteractedNpcName, lastInteractedNpcID, lastInteractedNpcPosition, playerPosition, text, options));
this.writer.write(DIALOGUE_STARTED, new DialogueStartedData(actorName, actorID, lastInteractedNpcName, lastInteractedNpcID, lastInteractedNpcPosition, playerPosition, text, options));

this.dialogueEndedData = new DialogueEndedData(actorName, actorID, lastInteractedNpcName, lastInteractedNpcID, lastInteractedNpcPosition, playerPosition, text, options);

Expand All @@ -116,7 +121,7 @@ private void beginDialogue(String actorName, Integer actorID, String text, List<
private void endDialogue() {
assert this.dialogueEndedData != null;

this.writer.write(DialogueEndedData.TYPE, this.dialogueEndedData);
this.writer.write(DIALOGUE_ENDED, this.dialogueEndedData);

this.dialogueEndedData = null;
}
Expand Down Expand Up @@ -216,24 +221,20 @@ public void onMenuOptionClicked(MenuOptionClicked e) {
}


@RequiredArgsConstructor
@Value
private static class DialogueStartedData {
public static final String TYPE = "DIALOGUE_STARTED";

private final String actorName;
private final Integer actorID;
private final String lastInteractedName;
private final Integer lastInteractedID;
private final WorldPoint lastInteractedPosition;
private final WorldPoint playerPosition;
private final String dialogueText;
private final List<String> dialogueOptions;
String actorName;
Integer actorID;
String lastInteractedName;
Integer lastInteractedID;
WorldPoint lastInteractedPosition;
WorldPoint playerPosition;
String dialogueText;
List<String> dialogueOptions;
}

@RequiredArgsConstructor
@Data
private static class DialogueEndedData {
public static final String TYPE = "DIALOGUE_ENDED";

private final String actorName;
private final Integer actorID;
private final String lastInteractedName;
Expand Down

0 comments on commit cb35521

Please sign in to comment.