summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/pacman/Inky.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/physical/pacman/Inky.java')
-rw-r--r--src/ch/epfl/maze/physical/pacman/Inky.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/ch/epfl/maze/physical/pacman/Inky.java b/src/ch/epfl/maze/physical/pacman/Inky.java
index 05c712c..c716058 100644
--- a/src/ch/epfl/maze/physical/pacman/Inky.java
+++ b/src/ch/epfl/maze/physical/pacman/Inky.java
@@ -2,7 +2,6 @@ package ch.epfl.maze.physical.pacman;
2 2
3import ch.epfl.maze.physical.Animal; 3import ch.epfl.maze.physical.Animal;
4import ch.epfl.maze.physical.Daedalus; 4import ch.epfl.maze.physical.Daedalus;
5import ch.epfl.maze.physical.GhostPredator;
6import ch.epfl.maze.util.Vector2D; 5import ch.epfl.maze.util.Vector2D;
7 6
8import java.util.NoSuchElementException; 7import java.util.NoSuchElementException;
@@ -14,9 +13,9 @@ import java.util.NoSuchElementException;
14 * @author EPFL 13 * @author EPFL
15 * @author Pacien TRAN-GIRARD 14 * @author Pacien TRAN-GIRARD
16 */ 15 */
17public class Inky extends GhostPredator { 16public class Inky extends Ghost {
18 17
19 private GhostPredator companion; 18 private Ghost companion;
20 19
21 /** 20 /**
22 * Finds Inky's best friend (Blinky) in the Daedalus. 21 * Finds Inky's best friend (Blinky) in the Daedalus.
@@ -24,10 +23,10 @@ public class Inky extends GhostPredator {
24 * @param daedalus The Daedalus 23 * @param daedalus The Daedalus
25 * @return The companion if found, null otherwise 24 * @return The companion if found, null otherwise
26 */ 25 */
27 private static GhostPredator findCompanion(Daedalus daedalus) { 26 private static Ghost findCompanion(Daedalus daedalus) {
28 try { 27 try {
29 return (Blinky) daedalus 28 return (Blinky) daedalus
30 .getPredators() 29 .getPredatorSet()
31 .stream() 30 .stream()
32 .filter(pred -> pred instanceof Blinky) 31 .filter(pred -> pred instanceof Blinky)
33 .findFirst() 32 .findFirst()
@@ -43,7 +42,7 @@ public class Inky extends GhostPredator {
43 * @param position Starting position of Inky in the labyrinth 42 * @param position Starting position of Inky in the labyrinth
44 * @param companion Inky's accomplice 43 * @param companion Inky's accomplice
45 */ 44 */
46 public Inky(Vector2D position, GhostPredator companion) { 45 public Inky(Vector2D position, Ghost companion) {
47 super(position); 46 super(position);
48 this.companion = companion; 47 this.companion = companion;
49 } 48 }
@@ -63,7 +62,7 @@ public class Inky extends GhostPredator {
63 * @param daedalus The Daedalus 62 * @param daedalus The Daedalus
64 * @return Inky's companion if present, null otherwise 63 * @return Inky's companion if present, null otherwise
65 */ 64 */
66 private GhostPredator getCompanion(Daedalus daedalus) { 65 private Ghost getCompanion(Daedalus daedalus) {
67 if (this.companion == null) 66 if (this.companion == null)
68 this.companion = Inky.findCompanion(daedalus); 67 this.companion = Inky.findCompanion(daedalus);
69 68
@@ -77,7 +76,7 @@ public class Inky extends GhostPredator {
77 * @return Inky's companion's position if present, null otherwise 76 * @return Inky's companion's position if present, null otherwise
78 */ 77 */
79 private Vector2D getCompanionPosition(Daedalus daedalus) { 78 private Vector2D getCompanionPosition(Daedalus daedalus) {
80 GhostPredator companion = this.getCompanion(daedalus); 79 Ghost companion = this.getCompanion(daedalus);
81 if (companion == null) return new Vector2D(); 80 if (companion == null) return new Vector2D();
82 return companion.getPosition(); 81 return companion.getPosition();
83 } 82 }