From eb5357335d313120ce35e74d9ad1634379ec0385 Mon Sep 17 00:00:00 2001 From: davpapp Date: Wed, 31 Jan 2018 00:04:07 -0500 Subject: [PATCH] Timing now working, will need refactoring --- bin/Constants.class | Bin 0 -> 419 bytes bin/Cursor.class | Bin 5231 -> 4703 bytes bin/CursorDataFileParser.class | Bin 3438 -> 3437 bytes bin/CursorPath.class | Bin 4120 -> 4584 bytes bin/CursorPoint.class | Bin 401 -> 1005 bytes bin/CursorTask.class | Bin 0 -> 514 bytes bin/main.class | Bin 612 -> 495 bytes src/Constants.java | 7 +++++++ src/Cursor.java | 9 ++++----- src/CursorDataFileParser.java | 2 +- src/CursorPath.java | 19 ++++++++++++++++--- src/CursorPoint.java | 14 +++++++++++--- src/CursorTask.java | 16 ++++++++++++++++ src/main.java | 10 ++++------ 14 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 bin/Constants.class create mode 100644 bin/CursorTask.class create mode 100644 src/Constants.java create mode 100644 src/CursorTask.java diff --git a/bin/Constants.class b/bin/Constants.class new file mode 100644 index 0000000000000000000000000000000000000000..46c394e0c5100fc288c568bd30bcc2e67c5ab8ec GIT binary patch literal 419 zcmZ9I%Syvg5QhJ0(#EFudc&nVbzxVo6hYe925JHtQe4StJ?JShfh6_4TnR3G0H4IC z5a(3mrJEVPx%_i^`*?W;aD;6OB|^2I#91!lJhNaD+H>(JdXb3ldj51SXE~uWJiBmi zCayQ|C+r5nh(Io(QFMkPT1W#h-U;2m#UsZZjsil<^+LxB{LAa2zx^92iYg~6R{1Hx z*xL^YWt3TqEMtt^LNn9?^Q;qjf?HFV}gB^ zEYg`gSGukFlR4DKVi!DpQvB{B*(cQtIFE}wE^vt5CmoQSKFMF{EU&7S zCAWx6xXi{P%NlsJa#*0_(m~a^Q}Os!3tG@F;<~2H9TL!iTRd*g(R7(oNv#rb8=V{? zTuOk0(NUCEq*-d$_}wCUbS&WUYsHX=UR|wT(+&x=^oxkW0PD9Tn+HWapmf@jy5`ZG z**ewZbCyYdx3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FlJEykGdOi^J^{lL-~ZFLi1-Wt2>6@E>LPEJa0cxRLfn)gO7e<9EtLo< z>(nUqGmom|&3P>>f9F6Rv%A``678tN)%?zUrQ|4b;iBno_2d{BGO)hcF$zCFlV6^8 zH#Rwoop)!k#pBqGTNt*?9T_L69e&y?AkZFw2iKw!>&SNEFyXDJ@TRw}0wZaj`m63>j8+L|P){Bkbfn0$gd#W7>+N)Uh;O8ZRyboalVyZ6 zSsdg8h5o#^7KHQQFdr+dC^bw-IMY{PUNA3`oyFUHw$N970b7p4bjwC*;@Gs1tbtCm z0YVl>41CNRi!M)pPJ+*uvYARTo6>GyGm6F?n4QA0o}%w2@k7-FRxdNKVINjm&pTf9 zvw>g8bKJo12L8N@v1KNPf?MZi7RRKB7y*@p+lU4_+Yq%zqhvmhIU1D&u+hw1N%}IY R(E@B|k<04n^Q;v-_b;+JeH8!z diff --git a/bin/CursorDataFileParser.class b/bin/CursorDataFileParser.class index fa10e4db124179cfcbe7e51ebc826aa1e254d86d..b038cc98df491f2ed5a77818d3d3fcdbaf96ccaf 100644 GIT binary patch delta 47 zcmV+~0MP&L8tode!wCUilf(&k0Y;NN3K;<`lU53;0WOjY#{*gb29wGQCIk8a5wr9Q FdI5^L4}$;z delta 48 zcmV-00MGyJ8txjf!wCUjlf(&k0VtC^3K;VFr>(_S^l=?w)h@+dbv| zz1H>Pe^b{0+=uTbTwOMw3j!TFc3`GJO;<45H53gd!-04r*&c~TBZ+WVJQi9Pjs}Ml zvftK`>e3N{OQ3Av4iFbw(5<5fs|6|&;pCl`5fG6A;`Zq1Qwxdxs@Jb0X7q;D8Us3J z;7I{TeQRrL!#07!cz3t4o-Yzh3d~Ln^#_8<-mQ`TaAF`B%cGi5f`)YL#Xh;&UM26f zmoFIB@f7xvb5A(AJ{F3^de#mNCgOvEI9F5nXLLM^19H&b>Ntq!G#rvQ?4{P{aajIr zuX7&6h>n-ou{##pj_Nojn;i>mujx1;gAAmOlk$k;`clRG9Ubq&BcO#Mi2<5c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JTbED4$-`Sf^CT^*RiZ9vl5$!V86V?KEQ;1k7*_!&I1t5m|rcnd0@T zI9H9#LU9}Fi-p>#t!&~6%L=ks4r8aEtr8aJ${QPoqh7h8^pG6-(nAY4a<$mbAVt7x za=Jf;fDiK^&Xwa*;EJ*vB5;1REXiEtx_%ta%q?2ON+sd|z2VOrf zZTL)#nzbV1<)YeWu+PO6vz~PcuP?yPi2H=M zOPugVJGTcH(^cutxGCdXNayT#D&f;RlPg(pT{g(LG zJdP92;z|}*DYcv7?4!RPXU)FeXy`w mZ9M<*#tRz{(A8g1M<;#q!S)Dcu)AnKE^GtZ2`nlrZvGExFAlN* diff --git a/bin/CursorPoint.class b/bin/CursorPoint.class index 3f540e1ec05f141d07903b6ffd83b5c9fb06af10..a982697acd2673b31c2a95dc8ce38807e0a33093 100644 GIT binary patch literal 1005 zcmaJm)v zi6%aP4`n>F+Xx2YkKH+QXYM)Y-nqYifBy+!13Ly%0%N;_AoPPhUwM&%jKJiP^U0~Z zj(1ppdvGK>k%0KjugULNpwjol=(TcP70Qn9bze%?VK}>`JQZydSj}d$))vU@`dwK- z8sjGNm=H)?wRRp9FmVN0jY=kr1XWDrkQFGllqcT|dIvIi=N!0_cUpeOaobLy^nMh~ zL?2ZsFy1<6z9BFh%4qLWdl@VCWOP;7r{6plaMQqzf2!R-4kOt!QN<$7`U4g|-HMx` z{Q6$N{_IDAbb1W~x2Sd2CWe)F_+p^kt_*UxBan;RxmmReSi(JBzeO@DVT)UvcgP#YEX2Lkq6?o2A3fq4Gu2I1) delta 43 zcmaFMK9QO0)W2Q(7#J8#8Kft2nX;B@p@`in1APpY> ztDdMUL8cYiy~`teFb%O|3B??4Cf1*g~0(vH$ACW9qMAncaCNnA9y0X(&>ag)v4##{5<7ojt)Ks~Sq* Ds_kR( literal 0 HcmV?d00001 diff --git a/bin/main.class b/bin/main.class index 8af913e423e8744aad6dd778893a59f61bdd9438..8417973d7d5d7213d70179fb1fbd0dec1fcbc2b6 100644 GIT binary patch delta 105 zcmaFD@}8ON)W2Q(7#J8#8DuANy`3D+*ucm(`39r5k0S#U5Hc`u?q(2)+|D58vk}N) rV&DRjTwn<<1`Y;Z25ul<45E-hoIwJ}<6vN9kYtbol8g+}U_CMbr4J6B delta 222 zcmaFQ{Dg(;)W2Q(7#J8#8Pq0ny-i?ekYHrs%StRu)K4rg(GSSa%q!ty5ND9$VPIvD zW@KR1@buIS<6;nDkmX^JV~}TL5YNpoOLZ4rFG|VGODst(W@Hf7@If`m zS~G0o_XbAR$rX&+iD5tknSd5c?Pd^(+|D58qrIC!JW`M;N04#Jb_U693^E&mvP=wI wK$4Gv8Ax(5a4>K)NHXvPNd^Wnh;9Z221Ou`gF%Qvi9wlx5eQX)d?p4}0OTVq0RR91 diff --git a/src/Constants.java b/src/Constants.java new file mode 100644 index 0000000..573c239 --- /dev/null +++ b/src/Constants.java @@ -0,0 +1,7 @@ + +public class Constants { + public static final int GAME_WINDOW_WIDTH = 1000; + public static final int GAME_WINDOW_HEIGHT = 1000; + public static final int INVENTORY_WIDTH = 1000; + public static final int INVENTORY_HEIGHT = 1000; +} diff --git a/src/Cursor.java b/src/Cursor.java index 410df74..cd64374 100644 --- a/src/Cursor.java +++ b/src/Cursor.java @@ -60,6 +60,7 @@ public class Cursor { double angleToMoveCursor = calculateThetaBetweenPoints(startingCursorPoint, goalPoint); CursorPath cursorPathToFollow = chooseCursorPathToFollowBasedOnDistance(distanceToMoveCursor); + //cursorPathToFollow.displayCursorPoints(); double angleToTranslatePathBy = angleToMoveCursor - cursorPathToFollow.getCursorPathTheta(); followCursorPath(startingCursorPoint, angleToTranslatePathBy, cursorPathToFollow); } @@ -68,8 +69,7 @@ public class Cursor { for (CursorPoint untranslatedCursorPoint : cursorPathToFollow.getCursorPathPoints()) { Point translatedPointToClick = translatePoint(startingCursorPoint, angleToTranslatePathBy, untranslatedCursorPoint); robotMouseMove(translatedPointToClick); - int millisecondsToSleep = 50; - Thread.sleep(millisecondsToSleep); + Thread.sleep(untranslatedCursorPoint.postMillisecondDelay); } } @@ -100,10 +100,9 @@ public class Cursor { return MouseInfo.getPointerInfo().getLocation(); } - - public void displaycursorPathsByDistance() { + /*public void displaycursorPathsByDistance() { for (int i = 0; i < cursorPathsByDistance.size(); i++) { System.out.println("There are " + cursorPathsByDistance.get(i).size() + " CursorPaths of length " + i); } - } + }*/ } \ No newline at end of file diff --git a/src/CursorDataFileParser.java b/src/CursorDataFileParser.java index bb6274c..bd4accb 100644 --- a/src/CursorDataFileParser.java +++ b/src/CursorDataFileParser.java @@ -43,8 +43,8 @@ public class CursorDataFileParser { else { numberOfRepeats = 0; currentCursorPath.add(newCursorPoint); + lastCursorPoint = newCursorPoint; } - lastCursorPoint = newCursorPoint; } else { System.out.println("Skipping invalid REGEX: " + line); diff --git a/src/CursorPath.java b/src/CursorPath.java index 633dadf..7433980 100644 --- a/src/CursorPath.java +++ b/src/CursorPath.java @@ -27,15 +27,27 @@ public class CursorPath { for (CursorPoint cursorPoint : cursorPoints) { cursorPointsCopy.add(getOffsetCursorPoint(cursorPoint, startingCursorPoint)); } + calculatePostMillisecondDelays(cursorPointsCopy); return cursorPointsCopy; } + private void calculatePostMillisecondDelays(ArrayList cursorPoints) { + for (int i = 1; i < cursorPoints.size(); i++) { + cursorPoints.get(i - 1).setPostMillisecondDelay(cursorPoints.get(i).postMillisecondDelay - cursorPoints.get(i - 1).postMillisecondDelay); + } + cursorPoints.get(cursorPoints.size() - 1).setPostMillisecondDelay(0); + } + private CursorPoint getOffsetCursorPoint(CursorPoint cursorPoint, CursorPoint offsetPoint) { - return new CursorPoint(cursorPoint.x - offsetPoint.x, cursorPoint.y - offsetPoint.y,cursorPoint.time - offsetPoint.time); + return new CursorPoint(cursorPoint.x - offsetPoint.x, cursorPoint.y - offsetPoint.y, cursorPoint.postMillisecondDelay); } private int calculateCursorPathTimespan() { - return getEndingCursorPoint().time - getStartingCursorPoint().time; + int sumPathTimespanMilliseconds = 0; + for (CursorPoint cursorPoint : this.pathCursorPoints) { + sumPathTimespanMilliseconds += cursorPoint.postMillisecondDelay; + } + return sumPathTimespanMilliseconds; } private int calculateCursorPathDistance() { @@ -90,8 +102,9 @@ public class CursorPath { public void displayCursorPoints() { for (CursorPoint p : pathCursorPoints) { - System.out.println("(" + p.x + ", " + p.y + "), " + p.time); + p.display(); } System.out.println("Length:" + pathNumPoints + ", Timespan:" + pathTimespanMilliseconds); + System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Path ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } } \ No newline at end of file diff --git a/src/CursorPoint.java b/src/CursorPoint.java index 2921208..d507062 100644 --- a/src/CursorPoint.java +++ b/src/CursorPoint.java @@ -2,11 +2,19 @@ public class CursorPoint { public int x; public int y; - public int time; + public int postMillisecondDelay; // how much to sleep for after moving here - public CursorPoint(int x, int y, int time) { + public CursorPoint(int x, int y, int postMillisecondDelay) { this.x = x; this.y = y; - this.time = time; + this.postMillisecondDelay = postMillisecondDelay; + } + + public void setPostMillisecondDelay(int postMillisecondDelay) { + this.postMillisecondDelay = postMillisecondDelay; + } + + public void display() { + System.out.println("Point: (" + x + "," + y + "), delay: " + postMillisecondDelay); } } \ No newline at end of file diff --git a/src/CursorTask.java b/src/CursorTask.java new file mode 100644 index 0000000..e8edb20 --- /dev/null +++ b/src/CursorTask.java @@ -0,0 +1,16 @@ +import java.awt.AWTException; + +public class CursorTask extends Cursor { + + public CursorTask() throws AWTException { + super(); + } + + public void dropAllItemsInInventory() { + for (int inventoryColumn = 0; inventoryColumn < 7; inventoryColumn++) { + for (int inventoryRow = 0; inventoryRow < 4; inventoryRow++) { + + } + } + } +} diff --git a/src/main.java b/src/main.java index a664f88..1cdbce8 100644 --- a/src/main.java +++ b/src/main.java @@ -2,15 +2,13 @@ import java.awt.AWTException; import java.awt.Point; import java.net.URL; + public class main { public static void main(String[] args) throws AWTException, InterruptedException { - // TODO Auto-generated method stub - - Cursor cursor = new Cursor(); - cursor.moveCursorToCoordinates(new Point(620, 420)); - //cursor.displaycursorPathsByDistance(); - //System.out.println("Finished..."); + Cursor cursor = new Cursor(); + //cursor.moveCursorToCoordinates(new Point(620, 420)); + } }