Skip to content

Commit

Permalink
add returnee calendar manager to claim rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
anjeshshrestha committed Oct 19, 2024
1 parent dc62282 commit 7b9ec6b
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import com.github.manolo8.darkbot.core.objects.facades.InventoryProxy;
import com.github.manolo8.darkbot.core.objects.facades.LogMediator;
import com.github.manolo8.darkbot.core.objects.facades.NpcEventProxy;
import com.github.manolo8.darkbot.core.objects.facades.SeassonPassMediator;
import com.github.manolo8.darkbot.core.objects.facades.QuestProxy;
import com.github.manolo8.darkbot.core.objects.facades.ReturneeCalendarProxy;
import com.github.manolo8.darkbot.core.objects.facades.ReturneeLoginProxy;
import com.github.manolo8.darkbot.core.objects.facades.SeassonPassMediator;
import com.github.manolo8.darkbot.core.objects.facades.SettingsProxy;
import com.github.manolo8.darkbot.core.objects.facades.SlotBarsProxy;
import com.github.manolo8.darkbot.core.objects.facades.SpaceMapWindowProxy;
Expand Down Expand Up @@ -98,6 +100,8 @@ public FacadeManager(PluginAPI pluginApi) {
registerProxy("QuestProxy", QuestProxy.class);
registerMediator("diminish_quests", DiminishQuestMediator.class);
registerMediator("seasonPass", SeassonPassMediator.class);
registerProxy("returnee_login_overview", ReturneeLoginProxy.class);
registerProxy("returnee_login_calendar", ReturneeCalendarProxy.class);

npcEvents.put(EventType.GENERIC, this.npcEventProxy = registerProxy("npc_event", NpcEventProxy.class));
npcEvents.put(EventType.AGATUS, registerProxy("agatus_event", NpcEventProxy.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public GuiManager(Main main, PluginAPI pluginAPI, RepairManager repairManager) {
register("popup_generic_icon_ok", DispatchIconOkGui.class);
this.assembly = register("assembly");

register("returnee_login", ReturneeManager.class);
register("ggBuilder", GateSpinnerGui.class);
register("diminish_quests", DiminishQuestGui.class);
register("refinement_count");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.github.manolo8.darkbot.core.manager;

import com.github.manolo8.darkbot.core.objects.Gui;
import com.github.manolo8.darkbot.core.objects.facades.ReturneeCalendarProxy;
import com.github.manolo8.darkbot.core.objects.facades.ReturneeLoginProxy;
import eu.darkbot.api.managers.BotAPI;
import eu.darkbot.api.managers.ReturneeAPI;
import eu.darkbot.util.Timer;
import lombok.RequiredArgsConstructor;

import java.util.List;

@RequiredArgsConstructor
public class ReturneeManager extends Gui implements ReturneeAPI {
private final ReturneeLoginProxy returneeLoginProxy;
private final ReturneeCalendarProxy returneeCalendarProxy;
private final BotAPI bot;

private final Timer guiUsed = Timer.getRandom(19_000, 1000);

@Override
public void update() {
super.update();
// Last gui usage >20s ago, close gui
if (bot.isRunning() && guiUsed.isInactive()) {
this.show(false);
}
}

@Override
public boolean show(boolean value) {
if (value) guiUsed.activate();
return super.show(value);
}

public boolean clickOverview() {
if (show(true)) {
this.click(320, 37);
return true;
}
return false;
}

public boolean clickDailyLogin() {
if (show(true)) {
this.click(420, 37);
return true;
}
return false;
}

public boolean clickClaim() {
if (show(true)) {
this.click(300, 410);
return true;
}
return false;
}

@Override
public boolean isLoginClaimable() {
return returneeLoginProxy.isClaimable();
}

@Override
public List<? extends LoginRewardList> getLoginRewardList() {
return returneeLoginProxy.getRewardList();
}

@Override
public boolean isCalendarClaimable() {
return returneeCalendarProxy.isClaimable();
}

@Override
public List<? extends CalendarRewardList> getCalendarRewardList() {
return returneeCalendarProxy.getCalendarList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.github.manolo8.darkbot.core.objects.facades;

import com.github.manolo8.darkbot.core.itf.Updatable;
import com.github.manolo8.darkbot.core.objects.swf.FlashList;
import eu.darkbot.api.API;
import eu.darkbot.api.managers.ReturneeAPI;
import lombok.Getter;
import lombok.ToString;

@Getter
public class ReturneeCalendarProxy extends Updatable implements API.Singleton {
private int daysClaimed = -1;
private boolean claimable = false;
private final FlashList<CalendarList> calendarList = FlashList.ofVector(CalendarList::new);

@Override
public void update() {
this.daysClaimed = readInt(0x30, 0x40);
this.claimable = readBoolean(0x30, 0x50, 0x20);
this.calendarList.update(readAtom(0x30, 0x58));
}

@Getter
@ToString
private static class CalendarList extends Auto implements ReturneeAPI.CalendarRewardList {
private String lootId;
private int amount;
private boolean claimed;

@Override
public void update() {
this.amount = readInt(0x20);
this.lootId = readString(0x30);
this.claimed = readBoolean(0x2C);
}

@Override
public boolean getClaimed() {
return claimed;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.manolo8.darkbot.core.objects.facades;

import com.github.manolo8.darkbot.core.itf.Updatable;
import com.github.manolo8.darkbot.core.objects.swf.FlashList;
import eu.darkbot.api.API;
import eu.darkbot.api.managers.ReturneeAPI;
import lombok.Getter;
import lombok.ToString;

@Getter
public class ReturneeLoginProxy extends Updatable implements API.Singleton{

private boolean claimable = false;
private final FlashList<RewardList> rewardList = FlashList.ofVector(RewardList::new);

@Override
public void update() {
this.claimable = readBoolean(0x30, 0x40, 0x20);
this.rewardList.update(readAtom(0x30, 0x48));
}

@Getter
@ToString
private static class RewardList extends Auto implements ReturneeAPI.LoginRewardList {
private String lootId;
private double amount;

@Override
public void update() {
this.amount = readDouble(0x70);
this.lootId = readString(0x48);
}
}
}

0 comments on commit 7b9ec6b

Please sign in to comment.