diff --git a/src/AiPlayer.java b/src/AiPlayer.java index 724233c..d51e41e 100644 --- a/src/AiPlayer.java +++ b/src/AiPlayer.java @@ -35,6 +35,7 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable { } public void aiShoot() { + if (!this.myTurn) return; this.enemy.receiveShoot(RandomPoint()); return; } @@ -93,4 +94,20 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable { this.aiShoot(); } + + @Override + public void destroy() { + super.destroy(); + Iterator i = this.shootThreads.iterator(); + while(i.hasNext()) { + Thread thread = i.next(); + try { + thread.join(); + i.remove(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } } \ No newline at end of file