/*     */ package org.logic;
/*     */ 
/*     */ import org.run.ForcedStopException;
/*     */ import org.world.World;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class GyteController
/*     */ {
/*     */   private World world;
/*     */   private int coinCount;
/*     */   
/*     */   public GyteController(World world) {
/*  26 */     this.world = world;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public final void turnRight() throws ForcedStopException {
/*  35 */     this.world.getGytebot().turnRight();
/*     */     
/*  37 */     waitForGytebotApprove();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public final void turnLeft() throws ForcedStopException {
/*  46 */     this.world.getGytebot().turnLeft();
/*     */     
/*  48 */     waitForGytebotApprove();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public final void goForward() throws ForcedStopException {
/*  57 */     if (!this.world.isLocationObstructed(this.world.getGytebot().getForwardLocation())) {
/*  58 */       this.world.getGytebot().goForward();
/*     */     }
/*  60 */     waitForGytebotApprove();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public final void pickup() throws ForcedStopException {
/*  72 */     if (this.world.isCoinPlacedHere(this.world.getGytebot().getPosition())) {
/*     */ 
/*     */       
/*  75 */       this.world.removeObject(Math.round((this.world.getGytebot().getPosition()).x), Math.round((this.world.getGytebot().getPosition()).y));
/*  76 */       this.coinCount++;
/*     */     } 
/*     */     
/*  79 */     delay();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void delay() throws ForcedStopException {
/*     */     try {
/*  92 */       Thread.sleep(250L);
/*  93 */     } catch (InterruptedException e) {
/*     */       
/*  95 */       throw new ForcedStopException();
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public final void place() throws ForcedStopException {
/* 107 */     if (this.coinCount > 0) {
/*     */ 
/*     */       
/* 110 */       this.world.setCoin(Math.round((this.world.getGytebot().getPosition()).x), Math.round((this.world.getGytebot().getPosition()).y));
/* 111 */       this.coinCount--;
/*     */     } 
/* 113 */     delay();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void waitForGytebotApprove() throws ForcedStopException {
/* 123 */     while (!this.world.getGytebot().isReady()) {
/*     */       try {
/* 125 */         Thread.sleep(30L);
/*     */       }
/* 127 */       catch (InterruptedException e) {
/*     */         
/* 129 */         throw new ForcedStopException();
/*     */       } 
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public final boolean hasWallFront() throws ForcedStopException {
/* 141 */     return this.world.isLocationObstructed(this.world.getGytebot().getForwardLocation());
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public final boolean isOnCoin() throws ForcedStopException {
/* 151 */     return this.world.isCoinPlacedHere(this.world.getGytebot().getPosition());
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public final int getCoinCount() throws ForcedStopException {
/* 158 */     return this.coinCount;
/*     */   }
/*     */ }


/* Location:              /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/logic/GyteController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */