-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add returnee calendar manager to claim rewards
- Loading branch information
1 parent
dc62282
commit 7b9ec6b
Showing
5 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/com/github/manolo8/darkbot/core/manager/ReturneeManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/github/manolo8/darkbot/core/objects/facades/ReturneeCalendarProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/github/manolo8/darkbot/core/objects/facades/ReturneeLoginProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |