Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: dialogue tracker #13

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading