-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
5 deletions.
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
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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/github/manolo8/darkbot/core/objects/facades/DiminishQuestMediator.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,55 @@ | ||
package com.github.manolo8.darkbot.core.objects.facades; | ||
|
||
import com.github.manolo8.darkbot.core.itf.Updatable; | ||
import com.github.manolo8.darkbot.core.objects.gui.DiminishQuestGui; | ||
import eu.darkbot.api.API; | ||
import eu.darkbot.api.managers.QuestAPI; | ||
|
||
import static com.github.manolo8.darkbot.Main.API; | ||
|
||
public class DiminishQuestMediator extends Updatable implements API.Singleton { | ||
private State state = State.NOT_EXIST; | ||
private final DiminishQuestGui diminishQuestGui; | ||
private final QuestProxy.Quest diminishQuest = new QuestProxy.Quest(); | ||
private static final State[] STATES = State.values(); | ||
|
||
public DiminishQuestMediator(DiminishQuestGui diminishQuestGui) { | ||
this.diminishQuestGui = diminishQuestGui; | ||
} | ||
|
||
@Override | ||
public void update() { | ||
if (!isValid()) return; | ||
int stateIndex = API.readInt(address, 0x50, 0x40) + 1; | ||
if (stateIndex >= 0 && stateIndex < STATES.length) { | ||
state = STATES[stateIndex]; | ||
diminishQuest.update(API.readAtom(address, 0x50, 0x60)); | ||
} else { | ||
state = State.NOT_EXIST; | ||
} | ||
} | ||
|
||
public QuestAPI.Quest getDiminishQuest() { | ||
return diminishQuest; | ||
} | ||
|
||
public boolean isWaitAccepting() { | ||
return isValid() && State.WAIT_ACCEPTING.equals(state); | ||
} | ||
|
||
public boolean isAccepted() { | ||
return isValid() && State.ACCEPTED.equals(state); | ||
} | ||
|
||
public void accept() { | ||
diminishQuestGui.accept(); | ||
} | ||
|
||
private enum State { | ||
NOT_EXIST, | ||
WAIT_ACCEPTING, | ||
UNKNOWN, | ||
ACCEPTED, | ||
DONE, | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/github/manolo8/darkbot/core/objects/gui/DiminishQuestGui.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,10 @@ | ||
package com.github.manolo8.darkbot.core.objects.gui; | ||
|
||
import eu.darkbot.api.API; | ||
|
||
public class DiminishQuestGui extends SizableGui implements API.Singleton { | ||
public void accept() { | ||
if (address == 0) return; | ||
if (show(true)) click((int) getWidth()/2, (int) getHeight()-10); | ||
} | ||
} |
5 changes: 1 addition & 4 deletions
5
src/main/java/com/github/manolo8/darkbot/core/objects/gui/PopupGui.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 |
---|---|---|
@@ -1,16 +1,13 @@ | ||
package com.github.manolo8.darkbot.core.objects.gui; | ||
|
||
import com.github.manolo8.darkbot.Main; | ||
import com.github.manolo8.darkbot.core.objects.Gui; | ||
import eu.darkbot.api.API; | ||
|
||
class PopupGui extends Gui implements API.Singleton { | ||
class PopupGui extends SizableGui implements API.Singleton { | ||
@Override | ||
public void update() { | ||
if (address == 0) return; | ||
super.update(); | ||
width = (int) Main.API.readDouble(address + 0x1F8); | ||
height = (int) Main.API.readDouble(address + 0x200); | ||
visible = Main.API.readLong(address + 0x180) != 0; // isVisible, sprite object is set | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/github/manolo8/darkbot/core/objects/gui/SizableGui.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,13 @@ | ||
package com.github.manolo8.darkbot.core.objects.gui; | ||
|
||
import com.github.manolo8.darkbot.Main; | ||
import com.github.manolo8.darkbot.core.objects.Gui; | ||
|
||
public class SizableGui extends Gui { | ||
public void update() { | ||
if (address == 0) return; | ||
super.update(); | ||
width = (int) Main.API.readDouble(address + 0x1F8); | ||
height = (int) Main.API.readDouble(address + 0x200); | ||
} | ||
} |