destroy for AI Player

This commit is contained in:
Luca Conte 2024-12-20 17:55:38 +01:00
parent 20732e730c
commit 65451d6912
1 changed files with 17 additions and 0 deletions

View File

@ -35,6 +35,7 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
} }
public void aiShoot() { public void aiShoot() {
if (!this.myTurn) return;
this.enemy.receiveShoot(RandomPoint()); this.enemy.receiveShoot(RandomPoint());
return; return;
} }
@ -93,4 +94,20 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
this.aiShoot(); this.aiShoot();
} }
@Override
public void destroy() {
super.destroy();
Iterator<Thread> 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();
}
}
}
} }