public void Run() throws InterruptedException , IOException{
// owThread.start();
// pwThread.start();
PlayWindow currentplayWnd;
Board board;
AnalystResult analystResult;
Boolean result;
int temp;
Logger logger = Logger.getLogger("General");
FileHandler fh = new FileHandler("c:\\temp\\poker\\general.log", true);
logger.addHandler(fh);
logger.setLevel(Level.ALL);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
Integer[] handles;
/*int MainHandle = 7080878;
temp = pControl.getProcID(pData.getRoomSettings().getProcessName());
if (temp !=0)
pData.setProcID(temp);
pData.setMainWnd(MainHandle,pControl.getWindowPosByHandle(MainHandle));
*/
// System.out.println("1: Fold, 2: Check, 3: Call, 4: Raise, 5: BuyIn, 6: SetBB, 7: WaitForBB 0: CLOSE");
gbTimeCounter = System.currentTimeMillis();
int counterForCloseEmptyWidows = 0;
while (true) {
if (System.currentTimeMillis() - gbTimeCounter >=gbTimeCounterDelay){
gbTimeCounter = System.currentTimeMillis();
System.gc();
}
counterForCloseEmptyWidows++;
int selector = 0;
Thread.sleep(this.pData.getProgramSettings().getDelayMainThreadMs());
if (this.pData.getMainWnd() == null) {
if (this.pData.getProcID() == null) {
temp = this.pControl.getProcID(this.pData.getRoomSettings().getProcessName());
if (temp != 0) {
this.pData.setProcID(temp);
}
}
if (this.pData.getProcID() != null) {
handles = this.pControl.getOpenWindowsHandles(this.pData.getProcID());
this.pControl.RegMainWindow(this.pData, handles);
}
} else {
handles = this.pControl.getOpenWindowsHandles(this.pData.getProcID());
this.pControl.killDeadTablesFromPosition(this.pData, handles);
this.pControl.updateWindowsFromWaitingList(this.pData);
currentplayWnd = this.pControl.getPlayWindowReadyForAction(this.pData,true);
if (currentplayWnd == null)
currentplayWnd = this.pControl.getPlayWindowReadyForAction(this.pData,false);
if(counterForCloseEmptyWidows > 20){
counterForCloseEmptyWidows = 0;
try {
this.pControl.getCloseEmptyWindows(this.pData);
} catch (Exception e) {
e.printStackTrace();
continue;
}
}
if (currentplayWnd != null) {
logger.log(Level.WARNING,currentplayWnd.getCurrentEvent().toString());
if (currentplayWnd.getCurrentEvent() == EventType.ET_NEED_WAIT_BB ){
analystResult = pControl.getReaction(pData, currentplayWnd);
}
else
if (currentplayWnd.getCurrentEvent() == EventType.ET_SYSTEM_MESSAGE ||
currentplayWnd.getCurrentEvent() == EventType.ET_SYSTEM_MESSAGE_2){
try {
analystResult = pControl.getReaction(pData, currentplayWnd);
} catch (Exception e) {
e.printStackTrace();
continue;
}
}
else
if (currentplayWnd.getCurrentEvent() == EventType.ET_SET_BB ){
try{
currentplayWnd = pControl.fillNotFullBoardForBB(pData, currentplayWnd);
}catch (Exception e) {
e.printStackTrace();
continue;
}
analystResult = pControl.getReaction(pData, currentplayWnd);
}else{
// System.out.println(currentplayWnd.getCurrentEvent());
//Thread.sleep(1000);
long time = System.currentTimeMillis();
try{
currentplayWnd = this.pControl.fillPlayWnd(this.pData, currentplayWnd);
}catch (Exception e) {
e.printStackTrace();
continue;
}
time = System.currentTimeMillis() - time;
analystResult = pControl.getReaction(pData, currentplayWnd);
//logger.log(Level.WARNING,analystResult.toString());
}
if (analystResult != null){
logger.log(Level.WARNING,analystResult.toString());
pControl.react(pData,currentplayWnd,analystResult);
}
currentplayWnd.setCurrentEvent(EventType.ET_IN_GAME);
continue;
}
if (this.pControl.isNewTableNeeds(this.pData) ) {