commit 6e6e189efe5342c407d0eddc4fed942dfca087e8 Author: Guillem Date: Sat Jan 14 19:29:53 2023 +0100 Initial Commit diff --git a/assets/images/blinky.png b/assets/images/blinky.png new file mode 100644 index 0000000..6d884a3 Binary files /dev/null and b/assets/images/blinky.png differ diff --git a/assets/images/clyde.png b/assets/images/clyde.png new file mode 100644 index 0000000..1d5e426 Binary files /dev/null and b/assets/images/clyde.png differ diff --git a/assets/images/dot.png b/assets/images/dot.png new file mode 100644 index 0000000..ef1e048 Binary files /dev/null and b/assets/images/dot.png differ diff --git a/assets/images/energizer.png b/assets/images/energizer.png new file mode 100644 index 0000000..005b229 Binary files /dev/null and b/assets/images/energizer.png differ diff --git a/assets/images/frightened.png b/assets/images/frightened.png new file mode 100644 index 0000000..8526ff1 Binary files /dev/null and b/assets/images/frightened.png differ diff --git a/assets/images/inky.png b/assets/images/inky.png new file mode 100644 index 0000000..6bf498c Binary files /dev/null and b/assets/images/inky.png differ diff --git a/assets/images/life.png b/assets/images/life.png new file mode 100644 index 0000000..a217030 Binary files /dev/null and b/assets/images/life.png differ diff --git a/assets/images/pac_down.png b/assets/images/pac_down.png new file mode 100644 index 0000000..0ac1d38 Binary files /dev/null and b/assets/images/pac_down.png differ diff --git a/assets/images/pac_left.png b/assets/images/pac_left.png new file mode 100644 index 0000000..bfa1055 Binary files /dev/null and b/assets/images/pac_left.png differ diff --git a/assets/images/pac_right.png b/assets/images/pac_right.png new file mode 100644 index 0000000..a88b192 Binary files /dev/null and b/assets/images/pac_right.png differ diff --git a/assets/images/pac_up.png b/assets/images/pac_up.png new file mode 100644 index 0000000..f215191 Binary files /dev/null and b/assets/images/pac_up.png differ diff --git a/assets/images/pacman_logo.png b/assets/images/pacman_logo.png new file mode 100644 index 0000000..91280a2 Binary files /dev/null and b/assets/images/pacman_logo.png differ diff --git a/assets/images/path.png b/assets/images/path.png new file mode 100644 index 0000000..7ac7d52 Binary files /dev/null and b/assets/images/path.png differ diff --git a/assets/images/pinky.png b/assets/images/pinky.png new file mode 100644 index 0000000..54b9fd7 Binary files /dev/null and b/assets/images/pinky.png differ diff --git a/assets/images/wall.png b/assets/images/wall.png new file mode 100644 index 0000000..f968497 Binary files /dev/null and b/assets/images/wall.png differ diff --git a/assets/levels/level1.txt b/assets/levels/level1.txt new file mode 100644 index 0000000..04e87d0 --- /dev/null +++ b/assets/levels/level1.txt @@ -0,0 +1,17 @@ +;width +8 +;height +8 +;board +######## +# . . L# +# # +# # +# # +# # +# # +######## +;pacman +1,1,RIGHT,NORMAL +;ghosts +clyde,2,2,LEFT,SCATTER \ No newline at end of file diff --git a/assets/levels/level2.txt b/assets/levels/level2.txt new file mode 100644 index 0000000..32cdd8a --- /dev/null +++ b/assets/levels/level2.txt @@ -0,0 +1,17 @@ +;width +26 +;height +8 +;board +########################## +# .......................# +#..#...#..######..#####..# +#..#...#..# #..#..o...# +#o.#...#.o# #..#......# +#..#####..######..#####..# +#........................# +########################## +;pacman +1,1,RIGHT,NORMAL +;ghosts +blinky,6,1,LEFT,CHASE \ No newline at end of file diff --git a/assets/levels/level3.txt b/assets/levels/level3.txt new file mode 100644 index 0000000..346c314 --- /dev/null +++ b/assets/levels/level3.txt @@ -0,0 +1,20 @@ +;width +26 +;height +8 +;board +########################## +# .......................# +#..#...#..######..#####..# +#..#...#..# #..#..o...# +#o.#...#.o# #..#......# +#..#####..######..#####..# +#........................# +########################## +;pacman +1,1,RIGHT,NORMAL +;ghosts +blinky,6,1,LEFT,CHASE +inky,1,5,UP,CHASE +pinky,1,6,DOWN,CHASE +clyde,2,6,RIGHT,SCATTER \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..52cc503 --- /dev/null +++ b/build.gradle @@ -0,0 +1,89 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "PACLIB" + gdxVersion = '1.11.0' + roboVMVersion = '2.3.16' + box2DLightsVersion = '1.5' + ashleyVersion = '1.7.4' + aiVersion = '1.8.2' + gdxControllersVersion = '2.2.1' + } + + repositories { + mavenLocal() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + mavenCentral() + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" + api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" + api "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion" + + } + + +} + + +project(":core") { + apply plugin: "java-library" + + test { + useJUnitPlatform() + } + + dependencies { + + testImplementation 'org.mockito:mockito-core:4.8.0' + testImplementation 'org.mockito:mockito-junit-jupiter:4.6.1' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + //testImplementation "junit:junit:4.11" + + testImplementation "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion" + testImplementation "com.badlogicgames.gdx:gdx:$gdxVersion" + testImplementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + testImplementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" + testImplementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" + + api "com.badlogicgames.gdx:gdx:$gdxVersion" + api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" + api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" + api "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion" + + } +} + + diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 0000000..f6824a1 --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,48 @@ +sourceCompatibility = 17 +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/main/java" ] +sourceSets.test.java.srcDirs = [ "src/test/java" ] + +eclipse.project.name = appName + "-core" + +task testSanity(type: Test) { + group = "Verification" + useJUnitPlatform { + includeTags "sanity" + } +} + +task testBasic(type: Test) { + group = "Verification" + useJUnitPlatform { + includeTags "basic" + } +} + +task testSanityBasic(type: Test) { + group = "Verification" + useJUnitPlatform { + includeTags "sanity", "basic" + } +} + +task testAdvanced(type: Test) { + group = "Verification" + useJUnitPlatform { + includeTags "advanced" + } +} + +task testExpert(type: Test) { + group = "Verification" + useJUnitPlatform { + includeTags "expert" + } +} + +javadoc { + source = sourceSets.main.allJava + options.memberLevel = JavadocMemberLevel.PRIVATE + destinationDir = file("/docs/") +} \ No newline at end of file diff --git a/core/docs/allclasses-index.html b/core/docs/allclasses-index.html new file mode 100644 index 0000000..0234355 --- /dev/null +++ b/core/docs/allclasses-index.html @@ -0,0 +1,224 @@ + + + + +All Classes and Interfaces (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

All Classes and Interfaces

+
+
+
+
+
+
Class
+
Description
+ +
+
Behaviour defines the different behaviour which a ghost can be in.
+
+ +
+
Represents a Blinky (red) ghost.
+
+ +
+
A character is any entity that is able to move and hit.
+
+ +
+
It implements the ChaseBehaviour interface according to an aggressive behaviour.
+ Its target position is directly Pacman's position.
+
+ +
+
It implements the ChaseBehaviour interface according to an ambush behaviour.
+ Its target position is four steps ahead of Pacman's position in the direction Pacman is facing.
+
+ +
+
Defines the methods that any character (namely, ghost) must have to chase.
+ Thanks to this interface, we are using the Strategy design pattern.
+
+ +
+
It implements the ChaseBehaviour interface according to a coward behaviour.
+ It has two different modes which it constantly switches back and forth between, + based on its proximity to Pacman.
+
+ +
+
It implements the ChaseBehaviour interface according to an aggressive behaviour.
+ In order to locate Inky's target position, we first start by selecting + the position TILES_OFFSET tiles in front of Pac-Man in his current + direction of travel, similar to Pinky's targeting method.
+
+ +
+
Represents a Clyde (orange) ghost.
+
+ +
+
Direction that Pacman and ghosts face.
+ RESPECT The order of the values: RIGHT, DOWN, LEFT, UP.
+
+ +
+
Represents a dot in the labyrinth/map.
+
+ +
+
Represents an energizer in the labyrinth/map.
+
+ +
+
Represents any item that appears in the game.
+
+ +
+
Controller class of the game.
+
+ +
 
+ +
 
+ +
+
Represents an abstract Ghost class which defines a specific Character entity.
+
+ +
+
Ghost Simple Factory class.
+
+ +
+
Defines the methods that any hitable entity must have.
+
+ +
+
Represents an Inky (bluish) ghost.
+
+ +
 
+ +
+
Represents a level in the game.
+
+ +
+
Level Exception class.
+ In order to know the text of each message, please click on the "Constant Field Values" link + that you'll find in the description of each constant.
+
+ +
+
Represents a life in the labyrinth/map.
+
+ +
+
Abstract class that represents any labyrinth/map item.
+
+ +
+
Entity Simple Factory class.
+
+ +
+
Defines the methods that any movable entity must have.
+
+ +
+
Represents the player object that appears in the game, which is called Pacman.
+
+ +
 
+ +
+
Represents a path in the labyrinth/map.
+
+ +
+
Defines the methods that any pickable item must have.
+
+ +
+
Represents a Pinky ghost.
+
+ +
+
Stores a 2D position/point/coordinate.
+
+ +
+
Defines the methods that any scorable entity must have.
+
+ +
+
Sprite that stores the configuration file symbol and the image's path.
+
+ +
+
Represents the three state which Pacman can have.
+
+ +
 
+ +
+
Represents a wall in the labyrinth/map.
+
+ +
 
+
+
+
+
+
+
+ + diff --git a/core/docs/allpackages-index.html b/core/docs/allpackages-index.html new file mode 100644 index 0000000..bc0a7bd --- /dev/null +++ b/core/docs/allpackages-index.html @@ -0,0 +1,83 @@ + + + + +All Packages (core 1.0 API) + + + + + + + + + + + + + + +
+ + +
+ + diff --git a/core/docs/constant-values.html b/core/docs/constant-values.html new file mode 100644 index 0000000..1693806 --- /dev/null +++ b/core/docs/constant-values.html @@ -0,0 +1,246 @@ + + + + +Constant Field Values (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Constant Field Values

+
+

Contents

+ +
+
+
+

edu.uoc.*

+
    +
  • +
    edu.uoc.pacman.controller.Game
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    3
    +
    +
  • +
+
    +
  • +
    edu.uoc.pacman.model.Level
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    8
    +
    private static final int
    + +
    8
    +
    private static final int
    + +
    30
    +
    +
  • +
+
    +
  • +
    edu.uoc.pacman.model.entities.characters.ghosts.Blinky
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    400
    +
    +
  • +
  • +
    edu.uoc.pacman.model.entities.characters.ghosts.Clyde
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    100
    +
    +
  • +
  • +
    edu.uoc.pacman.model.entities.characters.ghosts.Inky
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    200
    +
    +
  • +
  • +
    edu.uoc.pacman.model.entities.characters.ghosts.Pinky
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    300
    +
    +
  • +
+
    +
  • +
    edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAmbush
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    4
    +
    +
  • +
  • +
    edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseCoward
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    8
    +
    +
  • +
  • +
    edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    2
    +
    private static final int
    + +
    2
    +
    +
  • +
+
    +
  • +
    edu.uoc.pacman.model.entities.items.Dot
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    1
    +
    +
  • +
  • +
    edu.uoc.pacman.model.entities.items.Energizer
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    private static final int
    + +
    5
    +
    +
  • +
+
    +
  • +
    edu.uoc.pacman.model.exceptions.LevelException
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    public static final String
    + +
    "[ERROR] This level does not contain any ghost!!"
    +
    public static final String
    + +
    "[ERROR] There was an error while loading the current level file!!"
    +
    public static final String
    + +
    "[ERROR] There must be one pickable item (i.e. dot or energizer) at least!!"
    +
    public static final String
    + +
    "[ERROR] Board\'s size must be equal or greater than 8!!"
    +
    +
  • +
+
    +
  • +
    edu.uoc.pacman.view.PacmanGame
    +
    +
    Modifier and Type
    +
    Constant Field
    +
    Value
    +
    public static final int
    + +
    35
    +
    public static final int
    + +
    768
    +
    public static final int
    + +
    915
    +
    +
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/controller/Game.html b/core/docs/edu/uoc/pacman/controller/Game.html new file mode 100644 index 0000000..553a3d9 --- /dev/null +++ b/core/docs/edu/uoc/pacman/controller/Game.html @@ -0,0 +1,572 @@ + + + + +Game (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Game

+
+
java.lang.Object +
edu.uoc.pacman.controller.Game
+
+
+
+
public class Game +extends Object
+
Controller class of the game. It is the middleware (or bridge) between the model and view classes. +
+ This class is called from the view classes in order to access/modify the model data. + This class controls the logic of the game.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private int
    + +
    +
    Number of the current level.
    +
    +
    private String
    + +
    +
    Name of the folder in which level files are
    +
    +
    private Level
    + +
    +
    Level object that contains the information of the current level.
    +
    +
    private final int
    + +
    +
    Maximum amount of levels that the game has.
    +
    +
    private static final int
    + +
    +
    Number of lives which each level has when it starts.
    +
    +
    private int
    + +
    +
    Total score of the game, i.e. the sum of the levels' scores.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Game(String fileFolder)
    +
    +
    Constructor with argument.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    int
    + +
    +
    Getter of the attribute currentLevel.
    +
    +
    private String
    + +
    +
    Getter of the attribute fileFolder.
    +
    + + +
    +
    Gets the list of Ghosts which are present in the level.
    +
    + + +
    +
    Gets an Iterator of the itemMapList
    +
    +
    int
    + +
    +
    Gets the current score of the level that the player is playing.
    +
    +
    int
    + +
    +
    Returns the number of lives that the player has in the current level.
    +
    + + +
    +
    Gests the @link Pacman} object which is present in the current level.
    +
    +
    int
    + +
    +
    Getter of the attribute "score" (Game score).
    +
    +
    boolean
    + +
    +
    Checks if the player has lost, i.e. the number of lives is zero.
    +
    +
    boolean
    + +
    +
    Indicates if the game is finished (true) or not (false).
    +
    +
    boolean
    + +
    +
    Checks if the level is completed, i.e. the player has collected all the dots and energizers of the map.
    +
    +
    private void
    + +
    +
    Loads a new level by using the value of the attribute currentLevel.
    +
    +
    boolean
    + +
    +
    Checks if there is a new level to play and loads it.
    + If the game is finished, it returns false.
    +
    +
    void
    + +
    +
    Reloads the current level, i.e. load the level again.
    +
    +
    void
    + +
    +
    Resets the game so that it starts again.
    +
    +
    private void
    +
    setFileFolder(String fileFolder)
    +
    +
    Setter of the attribute fileFolder.
    +
    +
    void
    + +
    +
    This method allows us to change Pacman's direction according to the user input (i.e. the pressed key).
    +
    +
    private void
    +
    setScore(int score)
    +
    +
    Setter of the attribute "score" (Game score).
    +
    +
    void
    + +
    +
    Update the game, namely the level.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      NUM_LIVES

      +
      private static final int NUM_LIVES
      +
      Number of lives which each level has when it starts.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      fileFolder

      +
      private String fileFolder
      +
      Name of the folder in which level files are
      +
      +
    • +
    • +
      +

      currentLevel

      +
      private int currentLevel
      +
      Number of the current level.
      +
      +
    • +
    • +
      +

      maxLevels

      +
      private final int maxLevels
      +
      Maximum amount of levels that the game has.
      +
      +
    • +
    • +
      +

      score

      +
      private int score
      +
      Total score of the game, i.e. the sum of the levels' scores.
      +
      +
    • +
    • +
      +

      level

      +
      private Level level
      +
      Level object that contains the information of the current level.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Game

      +
      public Game(String fileFolder) + throws IOException
      +
      Constructor with argument.
      +
      +
      Parameters:
      +
      fileFolder - Folder name where the configuration/level files are.
      +
      Throws:
      +
      IOException - When there is a problem while retrieving number of levels
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      setFileFolder

      +
      private void setFileFolder(String fileFolder)
      +
      Setter of the attribute fileFolder.
      +
      +
      Parameters:
      +
      fileFolder - Folder name where the configuration/level files are.
      +
      +
      +
    • +
    • +
      +

      getItemMapListIterator

      +
      public Iterator<MapItem> getItemMapListIterator()
      +
      Gets an Iterator of the itemMapList
      +
      +
      Returns:
      +
      Iterator of the itemMapList
      +
      +
      +
    • +
    • +
      +

      getFileFolder

      +
      private String getFileFolder()
      +
      Getter of the attribute fileFolder.
      +
      +
      Returns:
      +
      Value of the attribute fileFolder.
      +
      +
      +
    • +
    • +
      +

      getLevelScore

      +
      public int getLevelScore()
      +
      Gets the current score of the level that the player is playing.
      +
      +
      Returns:
      +
      Current score of the current level.
      +
      +
      +
    • +
    • +
      +

      getScore

      +
      public int getScore()
      +
      Getter of the attribute "score" (Game score).
      +
      +
      Returns:
      +
      Value of the attribute "score"
      +
      +
      +
    • +
    • +
      +

      setScore

      +
      private void setScore(int score)
      +
      Setter of the attribute "score" (Game score).
      +
      +
      Parameters:
      +
      score - New value for the attribute "score"
      +
      +
      +
    • +
    • +
      +

      getPacman

      +
      public Pacman getPacman()
      +
      Gests the @link Pacman} object which is present in the current level.
      +
      +
      Returns:
      +
      Reference to the Pacman object in the current level.
      +
      +
      +
    • +
    • +
      +

      getGhosts

      +
      public List<Ghost> getGhosts()
      +
      Gets the list of Ghosts which are present in the level.
      +
      +
      Returns:
      +
      List which contains all the ghosts in the current live.
      +
      +
      +
    • +
    • +
      +

      getNumLives

      +
      public int getNumLives()
      +
      Returns the number of lives that the player has in the current level.
      +
      +
      Returns:
      +
      Number of lives in the current level.
      +
      +
      +
    • +
    • +
      +

      isFinished

      +
      public boolean isFinished()
      +
      Indicates if the game is finished (true) or not (false). +

      The game is finished when the attribute currentLevel is equal to attribute maxLevels + 1. +

      +
      +
      Returns:
      +
      true if there are no more levels and therefore the game is finished. Otherwise, false.
      +
      +
      +
    • +
    • +
      +

      getCurrentLevel

      +
      public int getCurrentLevel()
      +
      Getter of the attribute currentLevel.
      +
      +
      Returns:
      +
      Value of the attribute currentLevel that indicates which level the player is playing.
      +
      +
      +
    • +
    • +
      +

      nextLevel

      +
      public boolean nextLevel() + throws LevelException
      +
      Checks if there is a new level to play and loads it.
      + If the game is finished, it returns false. Otherwise, it returns true.
      + The game score must be updated when a level is finished. + Thus, when the player is playing the first level, game's score is zero.
      +
      +
      Returns:
      +
      true if there is a next level, and it has been loaded correctly. Otherwise, it returns false.
      +
      Throws:
      +
      LevelException - When there is a level exception/problem loading the new level.
      +
      +
      +
    • +
    • +
      +

      loadLevel

      +
      private void loadLevel() + throws LevelException
      +
      Loads a new level by using the value of the attribute currentLevel. +

      + The pattern of the filename is: fileFolder+"level" + numberLevel + ".txt". +

      +
      +
      Throws:
      +
      LevelException - When there is a level exception/problem.
      +
      +
      +
    • +
    • +
      +

      isLevelCompleted

      +
      public boolean isLevelCompleted()
      +
      Checks if the level is completed, i.e. the player has collected all the dots and energizers of the map.
      +
      +
      Returns:
      +
      true if this level is beaten, otherwise false.
      +
      +
      +
    • +
    • +
      +

      hasLost

      +
      public boolean hasLost()
      +
      Checks if the player has lost, i.e. the number of lives is zero.
      +
      +
      Returns:
      +
      true if this the player has lost, otherwise false.
      +
      +
      +
    • +
    • +
      +

      reload

      +
      public void reload() + throws LevelException
      +
      Reloads the current level, i.e. load the level again.
      +
      +
      Throws:
      +
      LevelException - When there is a level exception/problem.
      +
      +
      +
    • +
    • +
      +

      setPacmanDirection

      +
      public void setPacmanDirection(Direction direction)
      +
      This method allows us to change Pacman's direction according to the user input (i.e. the pressed key).
      +
      +
      Parameters:
      +
      direction - New direction to set to Pacman.
      +
      +
      +
    • +
    • +
      +

      reset

      +
      public void reset()
      +
      Resets the game so that it starts again.
      +
      +
    • +
    • +
      +

      update

      +
      public void update()
      +
      Update the game, namely the level.
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/controller/package-summary.html b/core/docs/edu/uoc/pacman/controller/package-summary.html new file mode 100644 index 0000000..7e805ff --- /dev/null +++ b/core/docs/edu/uoc/pacman/controller/package-summary.html @@ -0,0 +1,83 @@ + + + + +edu.uoc.pacman.controller (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.controller

+
+
+
package edu.uoc.pacman.controller
+
+
    +
  • +
    +
    Classes
    +
    +
    Class
    +
    Description
    + +
    +
    Controller class of the game.
    +
    +
    +
    +
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/controller/package-tree.html b/core/docs/edu/uoc/pacman/controller/package-tree.html new file mode 100644 index 0000000..2f0dd2c --- /dev/null +++ b/core/docs/edu/uoc/pacman/controller/package-tree.html @@ -0,0 +1,70 @@ + + + + +edu.uoc.pacman.controller Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.controller

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • edu.uoc.pacman.controller.Game
    • +
    +
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/Level.html b/core/docs/edu/uoc/pacman/model/Level.html new file mode 100644 index 0000000..950374a --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/Level.html @@ -0,0 +1,797 @@ + + + + +Level (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Level

+
+
java.lang.Object +
edu.uoc.pacman.model.Level
+
+
+
+
public class Level +extends Object
+
Represents a level in the game.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private String
    + +
    +
    The name of the level configuration file.
    +
    +
    private List<Ghost>
    + +
    +
    Ghosts that are part of the level.
    +
    +
    private int
    + +
    +
    The height of the map/labyrinth.
    +
    +
    private int
    + +
    +
    Number of lives in the level.
    +
    +
    private List<MapItem>
    + +
    +
    Stores the items which are part of the map/labyrinth.
    +
    +
    private static final int
    + +
    +
    The minimum height that the map must have.
    +
    +
    private static final int
    + +
    +
    The minimum width that the map must have.
    +
    +
    private Pacman
    + +
    +
    Reference to Pacman object, i.e. the player.
    +
    +
    private int
    + +
    +
    Level's score.
    +
    +
    private int
    + +
    +
    Number that allows us to manage when the actions happen.
    +
    +
    private static final int
    + +
    +
    It is the refresh time.
    +
    +
    private int
    + +
    +
    The width of the map/labyrinth.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Level(String filename, + int lives)
    +
    +
    Constructor with argument.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    + +
    +
    Adds item to the mapItemList as long as item is not null.
    +
    +
    void
    +
    addPoints(int points)
    +
    +
    Add the value of points to the attribute score as long as points is greater than 0.
    +
    +
    void
    + +
    +
    Decreases 1 the number of lives as long as the number of lives is not zero.
    +
    + + +
    +
    Gets the first Blinky object in the Ghost list of the level.
    +
    + + +
    +
    Getter of the attribute fileName
    +
    +
    private String
    + +
    +
    This is a helper method for parse() which returns + the first non-empty and non-comment line from the reader.
    +
    + + +
    +
    Getter of the attribute ghostList.
    +
    +
    int
    + +
    +
    Getter of the attribute height.
    +
    +
    int
    + +
    +
    Getter of the attribute lives.
    +
    + +
    getMapItem(int x, + int y)
    +
    +
    Returns the map/labyrinth item which is in the position (x,y).
    +
    + +
    getMapItem(Position position)
    +
    +
    Returns the map/labyrinth item which is in position.
    +
    +
    private List<MapItem>
    + +
    +
    Getter of the attribute mapItemList.
    +
    + + +
    +
    Returns an Iterator of the attribute mapItemList.
    +
    + + +
    +
    Getter ot the attribute pacman.
    +
    +
    int
    + +
    +
    Getter of the attribute score.
    +
    +
    int
    + +
    +
    Getter of the attribute width.
    +
    +
    boolean
    + +
    +
    Checks if the level was finished.
    +
    +
    void
    + +
    +
    Increases 1 the number of lives.
    +
    +
    boolean
    +
    isPathable(Position position)
    +
    +
    Given a position, it indicates if such a position is pathable or not.
    +
    +
    private void
    + +
    +
    Parses/Reads level's data from the given file.
    + It also checks which the board's requirements are met.
    +
    +
    void
    + +
    +
    Removes item from the mapItemList.
    +
    +
    private void
    +
    setFileName(String fileName)
    +
    +
    Setter of the attribute fileName.
    +
    +
    void
    + +
    +
    Sets the behaviour of all the ghosts in the level to FRIGHTENED.
    +
    +
    private void
    +
    setHeight(int height)
    +
    +
    Setter of the attribute height.
    +
    +
    private void
    +
    setLives(int lives)
    +
    +
    Setter of the attribute lives.
    +
    +
    private void
    +
    setWidth(int width)
    +
    +
    Setter of the attribute width.
    +
    +
    void
    + +
    +
    Refreshes/Updates the game when needed.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      MIN_WIDTH

      +
      private static final int MIN_WIDTH
      +
      The minimum width that the map must have.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      MIN_HEIGHT

      +
      private static final int MIN_HEIGHT
      +
      The minimum height that the map must have.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      fileName

      +
      private String fileName
      +
      The name of the level configuration file.
      +
      +
    • +
    • +
      +

      width

      +
      private int width
      +
      The width of the map/labyrinth.
      +
      +
    • +
    • +
      +

      height

      +
      private int height
      +
      The height of the map/labyrinth.
      +
      +
    • +
    • +
      +

      mapItemList

      +
      private List<MapItem> mapItemList
      +
      Stores the items which are part of the map/labyrinth.
      +
      +
    • +
    • +
      +

      pacman

      +
      private Pacman pacman
      +
      Reference to Pacman object, i.e. the player.
      +
      +
    • +
    • +
      +

      ghostList

      +
      private List<Ghost> ghostList
      +
      Ghosts that are part of the level.
      +
      +
    • +
    • +
      +

      score

      +
      private int score
      +
      Level's score.
      +
      +
    • +
    • +
      +

      lives

      +
      private int lives
      +
      Number of lives in the level.
      +
      +
    • +
    • +
      +

      tick

      +
      private int tick
      +
      Number that allows us to manage when the actions happen. An action will be performed, when tick == UPDATE_GAME.
      +
      +
    • +
    • +
      +

      UPDATE_GAME

      +
      private static final int UPDATE_GAME
      +
      It is the refresh time. In other words, it is the speed of the game.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Level

      +
      public Level(String filename, + int lives) + throws LevelException
      +
      Constructor with argument.
      +
      +
      Parameters:
      +
      filename - Value for the attribute fileName.
      +
      lives - Initial number of lives in the level.
      +
      Throws:
      +
      LevelException - If there are any problems while parsing the level configuration file.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      setFileName

      +
      private void setFileName(String fileName)
      +
      Setter of the attribute fileName.
      +
      +
      Parameters:
      +
      fileName - New value for the attribute fileName.
      +
      +
      +
    • +
    • +
      +

      getFileName

      +
      public String getFileName()
      +
      Getter of the attribute fileName
      +
      +
      Returns:
      +
      Current value of the attribute fileName
      +
      +
      +
    • +
    • +
      +

      getLives

      +
      public int getLives()
      +
      Getter of the attribute lives.
      +
      +
      Returns:
      +
      The value of the attribute lives.
      +
      +
      +
    • +
    • +
      +

      setLives

      +
      private void setLives(int lives)
      +
      Setter of the attribute lives.
      +
      +
      Parameters:
      +
      lives - Number of lives to assign to the attribute lives.
      +
      +
      +
    • +
    • +
      +

      increaseLives

      +
      public void increaseLives()
      +
      Increases 1 the number of lives.
      +
      +
    • +
    • +
      +

      decreaseLives

      +
      public void decreaseLives()
      +
      Decreases 1 the number of lives as long as the number of lives is not zero.
      +
      +
    • +
    • +
      +

      parse

      +
      private void parse() + throws LevelException
      +
      Parses/Reads level's data from the given file.
      + It also checks which the board's requirements are met.
      +
      +
      Throws:
      +
      LevelException - When there is any error while parsing the file + or some board's requirement is not satisfied.
      +
      +
      +
    • +
    • +
      +

      getFirstNonEmptyLine

      +
      private String getFirstNonEmptyLine(BufferedReader br) + throws IOException
      +
      This is a helper method for parse() which returns + the first non-empty and non-comment line from the reader.
      +
      +
      Parameters:
      +
      br - BufferedReader object to read from.
      +
      Returns:
      +
      First line that is a parsable line, or null there are no lines to read.
      +
      Throws:
      +
      IOException - if the reader fails to read a line.
      +
      +
      +
    • +
    • +
      +

      getWidth

      +
      public int getWidth()
      +
      Getter of the attribute width.
      +
      +
      Returns:
      +
      The current value of the attribute width.
      +
      +
      +
    • +
    • +
      +

      setWidth

      +
      private void setWidth(int width) + throws LevelException
      +
      Setter of the attribute width.
      +
      +
      Parameters:
      +
      width - New value for the attribute width.
      +
      Throws:
      +
      LevelException - When width is less than MIN_WIDTH.
      +
      +
      +
    • +
    • +
      +

      getHeight

      +
      public int getHeight()
      +
      Getter of the attribute height.
      +
      +
      Returns:
      +
      The current value of the attribute height.
      +
      +
      +
    • +
    • +
      +

      setHeight

      +
      private void setHeight(int height) + throws LevelException
      +
      Setter of the attribute height.
      +
      +
      Parameters:
      +
      height - New value for the attribute height.
      +
      Throws:
      +
      LevelException - When height is less than MIN_HEIGHT.
      +
      +
      +
    • +
    • +
      +

      getMapItemList

      +
      private List<MapItem> getMapItemList()
      +
      Getter of the attribute mapItemList.
      +
      +
      Returns:
      +
      The current value of the attribute mapItemList.
      +
      +
      +
    • +
    • +
      +

      getMapItemListIterator

      +
      public Iterator<MapItem> getMapItemListIterator()
      +
      Returns an Iterator of the attribute mapItemList.
      +
      +
      Returns:
      +
      Iterator of the attribute mapItemList.
      +
      +
      +
    • +
    • +
      +

      getMapItem

      +
      public MapItem getMapItem(int x, + int y)
      +
      Returns the map/labyrinth item which is in the position (x,y).
      +
      +
      Parameters:
      +
      x - Value of the position in the X axis.
      +
      y - Value of the position in the Y axis.
      +
      Returns:
      +
      If any, the item which is the position (x,y). Otherwise, null.
      +
      +
      +
    • +
    • +
      +

      getMapItem

      +
      public MapItem getMapItem(Position position) + throws NullPointerException
      +
      Returns the map/labyrinth item which is in position.
      +
      +
      Parameters:
      +
      position - The position where the item that we want to get is.
      +
      Returns:
      +
      If any, the item which is position. Otherwise, null.
      +
      Throws:
      +
      NullPointerException - When position is null.
      +
      +
      +
    • +
    • +
      +

      addMapItem

      +
      public void addMapItem(MapItem item)
      +
      Adds item to the mapItemList as long as item is not null.
      +
      +
      Parameters:
      +
      item - Item which we want to add.
      +
      +
      +
    • +
    • +
      +

      removeMapItem

      +
      public void removeMapItem(MapItem item)
      +
      Removes item from the mapItemList.
      +
      +
      Parameters:
      +
      item - Item which we want to remove.
      +
      +
      +
    • +
    • +
      +

      getGhostList

      +
      public List<Ghost> getGhostList()
      +
      Getter of the attribute ghostList.
      +
      +
      Returns:
      +
      The current value of the attribute ghostList.
      +
      +
      +
    • +
    • +
      +

      getScore

      +
      public int getScore()
      +
      Getter of the attribute score.
      +
      +
      Returns:
      +
      The current value of the attribute score.
      +
      +
      +
    • +
    • +
      +

      addPoints

      +
      public void addPoints(int points)
      +
      Add the value of points to the attribute score as long as points is greater than 0.
      +
      +
      Parameters:
      +
      points - Number to add to the attribute score.
      +
      +
      +
    • +
    • +
      +

      getPacman

      +
      public Pacman getPacman()
      +
      Getter ot the attribute pacman.
      +
      +
      Returns:
      +
      The current value of the attribute pacman.
      +
      +
      +
    • +
    • +
      +

      getBlinky

      +
      public Blinky getBlinky()
      +
      Gets the first Blinky object in the Ghost list of the level.
      +
      +
      Returns:
      +
      The first Blinky object in the level, + or null if there are not Blinky ghosts in the level.
      +
      +
      +
    • +
    • +
      +

      isPathable

      +
      public boolean isPathable(Position position)
      +
      Given a position, it indicates if such a position is pathable or not.
      +
      +
      Parameters:
      +
      position - Position which must be checked.
      +
      Returns:
      +
      true if the position is pathable. Otherwise, false.
      +
      +
      +
    • +
    • +
      +

      setGhostsFrightened

      +
      public void setGhostsFrightened()
      +
      Sets the behaviour of all the ghosts in the level to FRIGHTENED.
      +
      +
    • +
    • +
      +

      hasWon

      +
      public boolean hasWon()
      +
      Checks if the level was finished. This happens when all the objects + that are Scorable and Pickable have been picked.
      +
      +
      Returns:
      +
      true if the level was finished/won. Otherwise, false.
      +
      +
      +
    • +
    • +
      +

      update

      +
      public void update()
      +
      Refreshes/Updates the game when needed.
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/Entity.html b/core/docs/edu/uoc/pacman/model/entities/Entity.html new file mode 100644 index 0000000..feeca56 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/Entity.html @@ -0,0 +1,320 @@ + + + + +Entity (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Entity

+
+
java.lang.Object +
edu.uoc.pacman.model.entities.Entity
+
+
+
+
Direct Known Subclasses:
+
Character, MapItem
+
+
+
public abstract class Entity +extends Object
+
Represents any item that appears in the game.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private boolean
    + +
    +
    Indicates if the entity is pathable or not.
    +
    +
    private Position
    + +
    +
    Position where the entity is.
    +
    +
    private Sprite
    + +
    +
    Value of Sprite linked to the entity.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Modifier
    +
    Constructor
    +
    Description
    +
    protected
    +
    Entity(Position position, + boolean pathable, + Sprite sprite)
    +
    +
    Constructor with arguments.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    + + +
    +
    Gets the current position of the entity.
    +
    + + +
    +
    Getter of the attribute sprite.
    +
    +
    boolean
    + +
    +
    Getter of the attribute pathable.
    +
    +
    void
    +
    setPathable(boolean pathable)
    +
    +
    Setter of the attribute pathable.
    +
    +
    void
    + +
    +
    Sets the position of the entity.
    +
    +
    protected void
    +
    setSprite(Sprite sprite)
    +
    +
    Setter of the attribute sprite.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      position

      +
      private Position position
      +
      Position where the entity is.
      +
      +
    • +
    • +
      +

      pathable

      +
      private boolean pathable
      +
      Indicates if the entity is pathable or not.
      +
      +
    • +
    • +
      +

      sprite

      +
      private Sprite sprite
      +
      Value of Sprite linked to the entity.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Entity

      +
      protected Entity(Position position, + boolean pathable, + Sprite sprite)
      +
      Constructor with arguments.
      +
      +
      Parameters:
      +
      position - Initial value of the attribute position.
      +
      pathable - Initial value of the attribute pathable.
      +
      sprite - Initial value of the attribute sprite.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getPosition

      +
      public Position getPosition()
      +
      Gets the current position of the entity.
      +
      +
      Returns:
      +
      current position.
      +
      +
      +
    • +
    • +
      +

      setPosition

      +
      public void setPosition(Position position)
      +
      Sets the position of the entity. If position is null, then the position is not set.
      +
      +
      Parameters:
      +
      position - to set to the entity
      +
      +
      +
    • +
    • +
      +

      isPathable

      +
      public boolean isPathable()
      +
      Getter of the attribute pathable.
      +
      +
      Returns:
      +
      Current value of pathable.
      +
      +
      +
    • +
    • +
      +

      setPathable

      +
      public void setPathable(boolean pathable)
      +
      Setter of the attribute pathable.
      +
      +
      Parameters:
      +
      pathable - New value for the attribute pathable.
      +
      +
      +
    • +
    • +
      +

      getSprite

      +
      public Sprite getSprite()
      +
      Getter of the attribute sprite.
      +
      +
      Returns:
      +
      Current value of sprite.
      +
      +
      +
    • +
    • +
      +

      setSprite

      +
      protected void setSprite(Sprite sprite)
      +
      Setter of the attribute sprite.
      +
      +
      Parameters:
      +
      sprite - New value for the attribute sprite.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/Scorable.html b/core/docs/edu/uoc/pacman/model/entities/Scorable.html new file mode 100644 index 0000000..c4b105f --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/Scorable.html @@ -0,0 +1,135 @@ + + + + +Scorable (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface Scorable

+
+
+
+
All Known Implementing Classes:
+
Blinky, Clyde, Dot, Energizer, Ghost, Inky, Pinky
+
+
+
public interface Scorable
+
Defines the methods that any scorable entity must have.
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    int
    + +
    +
    Gets points.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getPoints

      +
      int getPoints()
      +
      Gets points.
      +
      +
      Returns:
      +
      The number of points that the entity gives.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/Character.html b/core/docs/edu/uoc/pacman/model/entities/characters/Character.html new file mode 100644 index 0000000..ac69753 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/Character.html @@ -0,0 +1,504 @@ + + + + +Character (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Character

+
+
java.lang.Object +
edu.uoc.pacman.model.entities.Entity +
edu.uoc.pacman.model.entities.characters.Character
+
+
+
+
+
All Implemented Interfaces:
+
Hitable, Movable
+
+
+
Direct Known Subclasses:
+
Ghost, Pacman
+
+
+
public abstract class Character +extends Entity +implements Movable, Hitable
+
A character is any entity that is able to move and hit. As a result, it can traverse the + game board and interact with other entities.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private boolean
    + +
    +
    Indicates if the character is dead (true) or not (false).
    +
    +
    private Direction
    + +
    +
    The direction that the character faces.
    +
    +
    private int
    + +
    +
    Left time so that the ghost changes its current behaviour or the Pacman changes its current state.
    +
    +
    private Level
    + +
    +
    Reference to the current level object.
    +
    +
    private Position
    + +
    +
    Stores the initial/start position of the character.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Character(Position position, + Direction direction, + Sprite sprite, + Level level)
    +
    +
    Creates a character at the given position facing in the given direction.
    + Any character is pathable.
    + If the position is null, then the position will be (0,0).
    + Take into consideration that the value of the parameter position is also + the start/initial position of the character.
    + If the direction is null, then the direction will be UP.
    + By default, any character is alive.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    + +
    +
    Sets the attribute dead to false.
    +
    + + +
    +
    Gets the direction that the character is facing.
    +
    +
    protected int
    + +
    +
    Getter of the attribute duration.
    +
    + + +
    +
    Getter of the attribute level.
    +
    +
    protected Position
    + +
    +
    Getter of the attribute startPosition.
    +
    +
    boolean
    + +
    +
    Getter of the attribute dead.
    +
    +
    void
    + +
    +
    Sets the attribute dead to true.
    +
    +
    void
    + +
    +
    Resets the character.
    +
    +
    private void
    +
    setDead(boolean dead)
    +
    +
    Setter of the attribute dead.
    +
    +
    void
    + +
    +
    Sets the direction of the character.
    + If the direction is null, then the direction is not set and remains the same.
    +
    +
    protected void
    +
    setDuration(int duration)
    +
    +
    Setter of the attribute duration.
    +
    +
    void
    +
    setLevel(Level level)
    +
    +
    Setter of the attribute level.
    +
    +
    private void
    +
    setStartPosition(Position startPosition)
    +
    +
    Setter of the attribute startPosition.
    +
    + + +
    +
    Represents this entity in a comma-separated string format.
    + Format is: "x,y,DIRECTION", where DIRECTION is uppercase enum type value.
    + Example: 4,5,LEFT
    +
    +
    +
    +
    +
    +

    Methods inherited from class edu.uoc.pacman.model.entities.Entity

    +getPosition, getSprite, isPathable, setPathable, setPosition, setSprite
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    +
    +

    Methods inherited from interface edu.uoc.pacman.model.entities.characters.Hitable

    +hit
    +
    +

    Methods inherited from interface edu.uoc.pacman.model.entities.characters.Movable

    +move
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      direction

      +
      private Direction direction
      +
      The direction that the character faces.
      +
      +
    • +
    • +
      +

      duration

      +
      private int duration
      +
      Left time so that the ghost changes its current behaviour or the Pacman changes its current state.
      +
      +
    • +
    • +
      +

      dead

      +
      private boolean dead
      +
      Indicates if the character is dead (true) or not (false).
      +
      +
    • +
    • +
      +

      startPosition

      +
      private Position startPosition
      +
      Stores the initial/start position of the character. + Its value is the one which is provided by the level configuration file.
      +
      +
    • +
    • +
      +

      level

      +
      private Level level
      +
      Reference to the current level object.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Character

      +
      public Character(Position position, + Direction direction, + Sprite sprite, + Level level)
      +
      Creates a character at the given position facing in the given direction.
      + Any character is pathable.
      + If the position is null, then the position will be (0,0).
      + Take into consideration that the value of the parameter position is also + the start/initial position of the character.
      + If the direction is null, then the direction will be UP.
      + By default, any character is alive.
      +
      +
      Parameters:
      +
      position - to be set to.
      +
      direction - to be facing.
      +
      sprite - to be set to.
      +
      level - Reference to the current level
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      reset

      +
      public void reset()
      +
      Resets the character. + This means that the character is placed in the start position and is alive.
      +
      +
    • +
    • +
      +

      getDirection

      +
      public Direction getDirection()
      +
      Gets the direction that the character is facing.
      +
      +
      Returns:
      +
      The current direction of the character.
      +
      +
      +
    • +
    • +
      +

      setDirection

      +
      public void setDirection(Direction direction)
      +
      Sets the direction of the character.
      + If the direction is null, then the direction is not set and remains the same.
      +
      +
      Specified by:
      +
      setDirection in interface Movable
      +
      Parameters:
      +
      direction - New value for the attribute direction.
      +
      Since:
      +
      setDirection in interface Movable.
      +
      +
      +
    • +
    • +
      +

      getDuration

      +
      protected int getDuration()
      +
      Getter of the attribute duration.
      +
      +
      Returns:
      +
      Current value of the attribute duration.
      +
      +
      +
    • +
    • +
      +

      setDuration

      +
      protected void setDuration(int duration)
      +
      Setter of the attribute duration.
      +
      +
      Parameters:
      +
      duration - New value for the attribute duration.
      +
      +
      +
    • +
    • +
      +

      setDead

      +
      private void setDead(boolean dead)
      +
      Setter of the attribute dead.
      +
      +
      Parameters:
      +
      dead - New value of the attribute dead.
      +
      +
      +
    • +
    • +
      +

      isDead

      +
      public boolean isDead()
      +
      Getter of the attribute dead.
      +
      +
      Returns:
      +
      The current value of the attribute dead.
      +
      +
      +
    • +
    • +
      +

      setStartPosition

      +
      private void setStartPosition(Position startPosition)
      +
      Setter of the attribute startPosition.
      +
      +
      Parameters:
      +
      startPosition - New value of the attribute startPosition.
      +
      +
      +
    • +
    • +
      +

      getStartPosition

      +
      protected Position getStartPosition()
      +
      Getter of the attribute startPosition.
      +
      +
      Returns:
      +
      Current value of the attribute startPosition.
      +
      +
      +
    • +
    • +
      +

      kill

      +
      public void kill()
      +
      Sets the attribute dead to true.
      +
      +
    • +
    • +
      +

      alive

      +
      public void alive()
      +
      Sets the attribute dead to false.
      +
      +
    • +
    • +
      +

      getLevel

      +
      public Level getLevel()
      +
      Getter of the attribute level.
      +
      +
      Returns:
      +
      The current value of the attribute level.
      +
      +
      +
    • +
    • +
      +

      setLevel

      +
      public void setLevel(Level level)
      +
      Setter of the attribute level.
      +
      +
      Parameters:
      +
      level - New value for the attribute level.
      +
      +
      +
    • +
    • +
      +

      toString

      +
      public String toString()
      +
      Represents this entity in a comma-separated string format.
      + Format is: "x,y,DIRECTION", where DIRECTION is uppercase enum type value.
      + Example: 4,5,LEFT
      +
      +
      Overrides:
      +
      toString in class Object
      +
      Returns:
      +
      "x,y,DIRECTION"
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/Hitable.html b/core/docs/edu/uoc/pacman/model/entities/characters/Hitable.html new file mode 100644 index 0000000..3a2bbba --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/Hitable.html @@ -0,0 +1,135 @@ + + + + +Hitable (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface Hitable

+
+
+
+
All Known Implementing Classes:
+
Blinky, Character, Clyde, Ghost, Inky, Pacman, Pinky
+
+
+
public interface Hitable
+
Defines the methods that any hitable entity must have.
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    boolean
    +
    hit()
    +
    +
    Defines the signature of the method that manages the hit action of any hitable entity.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      hit

      +
      boolean hit()
      +
      Defines the signature of the method that manages the hit action of any hitable entity.
      +
      +
      Returns:
      +
      true if the entity has hit any other entity. Otherwise, false.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/Movable.html b/core/docs/edu/uoc/pacman/model/entities/characters/Movable.html new file mode 100644 index 0000000..44e7cf9 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/Movable.html @@ -0,0 +1,147 @@ + + + + +Movable (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface Movable

+
+
+
+
All Known Implementing Classes:
+
Blinky, Character, Clyde, Ghost, Inky, Pacman, Pinky
+
+
+
public interface Movable
+
Defines the methods that any movable entity must have.
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    + +
    +
    Defines the signature of the method that manages the movement of any movable entity.
    +
    +
    void
    + +
    +
    Defines the signatures of the method that manages the direction in which any movable entity moves.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      move

      +
      void move()
      +
      Defines the signature of the method that manages the movement of any movable entity.
      +
      +
    • +
    • +
      +

      setDirection

      +
      void setDirection(Direction direction)
      +
      Defines the signatures of the method that manages the direction in which any movable entity moves.
      +
      +
      Parameters:
      +
      direction - New direction to set
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Behaviour.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Behaviour.html new file mode 100644 index 0000000..7c9a4ed --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Behaviour.html @@ -0,0 +1,359 @@ + + + + +Behaviour (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Enum Class Behaviour

+
+
java.lang.Object +
java.lang.Enum<Behaviour> +
edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
+
+
+
All Implemented Interfaces:
+
Serializable, Comparable<Behaviour>, Constable
+
+
+
public enum Behaviour +extends Enum<Behaviour>
+
Behaviour defines the different behaviour which a ghost can be in. The behaviour are defined + as "CHASE", "SCATTER", "FRIGHTENED" and "INACTIVE". +
    +
  • "CHASE" - Behaviour where the ghosts chase Pacman. Has a duration of 20.
  • +
  • "FRIGHTENED" - Behaviour where the ghosts are frightened and confused. + It has a duration of 30.
  • +
  • "SCATTER" - Behaviour where the ghosts run home (scatter position). IT has a duration of 10.
  • +
  • "INACTIVE" - Behaviour where the ghosts don't do anything and Pacman cannot kill them.
  • +
+
+
+
    + +
  • +
    +

    Nested Class Summary

    +
    +

    Nested classes/interfaces inherited from class java.lang.Enum

    +Enum.EnumDesc<E extends Enum<E>>
    +
    +
  • + +
  • +
    +

    Enum Constant Summary

    +
    Enum Constants
    +
    +
    Enum Constant
    +
    Description
    + +
    +
    Behaviour where the ghosts chase Pacman.
    +
    + +
    +
    Behaviour where the ghosts are frightened and confused.
    +
    + +
    +
    Behaviour where the ghosts don't do anything and Pacman cannot kill them.
    +
    + +
    +
    Behaviour where the ghosts run home (scatter position).
    +
    +
    +
    +
  • + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private final int
    + +
    +
    Stores the duration of the behaviour.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Modifier
    +
    Constructor
    +
    Description
    +
    private
    +
    Behaviour(int duration)
    +
    +
    Constructor with arguments.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    int
    + +
    +
    Gets the duration of the behaviour.
    +
    + + +
    +
    Returns a String with information of the Behaviour.
    +
    +
    static Behaviour
    + +
    +
    Returns the enum constant of this class with the specified name.
    +
    +
    static Behaviour[]
    + +
    +
    Returns an array containing the constants of this enum class, in +the order they are declared.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Enum

    +clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
    +
    +

    Methods inherited from class java.lang.Object

    +getClass, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Enum Constant Details

    +
      +
    • +
      +

      CHASE

      +
      public static final Behaviour CHASE
      +
      Behaviour where the ghosts chase Pacman. Has a duration of 20
      +
      +
    • +
    • +
      +

      FRIGHTENED

      +
      public static final Behaviour FRIGHTENED
      +
      Behaviour where the ghosts are frightened and confused. It has a duration of 30
      +
      +
    • +
    • +
      +

      SCATTER

      +
      public static final Behaviour SCATTER
      +
      Behaviour where the ghosts run home (scatter position). IT has a duration of 10.
      +
      +
    • +
    • +
      +

      INACTIVE

      +
      public static final Behaviour INACTIVE
      +
      Behaviour where the ghosts don't do anything and Pacman cannot kill them.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      duration

      +
      private final int duration
      +
      Stores the duration of the behaviour.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Behaviour

      +
      private Behaviour(int duration)
      +
      Constructor with arguments.
      +
      +
      Parameters:
      +
      duration - Value to set to the behaviour.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      values

      +
      public static Behaviour[] values()
      +
      Returns an array containing the constants of this enum class, in +the order they are declared.
      +
      +
      Returns:
      +
      an array containing the constants of this enum class, in the order they are declared
      +
      +
      +
    • +
    • +
      +

      valueOf

      +
      public static Behaviour valueOf(String name)
      +
      Returns the enum constant of this class with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this class. (Extraneous whitespace characters are +not permitted.)
      +
      +
      Parameters:
      +
      name - the name of the enum constant to be returned.
      +
      Returns:
      +
      the enum constant with the specified name
      +
      Throws:
      +
      IllegalArgumentException - if this enum class has no constant with the specified name
      +
      NullPointerException - if the argument is null
      +
      +
      +
    • +
    • +
      +

      getDuration

      +
      public int getDuration()
      +
      Gets the duration of the behaviour.
      +
      +
      Returns:
      +
      duration of the behaviour.
      +
      +
      +
    • +
    • +
      +

      toString

      +
      public String toString()
      +
      Returns a String with information of the Behaviour. + Format: BEHAVIOUR:behaviourDuration + Example: "CHASE:20" + + Hint: Remember that toString() is already coded in Object.
      +
      +
      Overrides:
      +
      toString in class Enum<Behaviour>
      +
      Returns:
      +
      BEHAVIOUR:behaviourDuration
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Blinky.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Blinky.html new file mode 100644 index 0000000..9680f28 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Blinky.html @@ -0,0 +1,252 @@ + + + + +Blinky (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + + +
+
+
All Implemented Interfaces:
+
Hitable, Movable, Scorable
+
+
+
public class Blinky +extends Ghost
+
Represents a Blinky (red) ghost.
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      POINTS

      +
      private static final int POINTS
      +
      This attribute stores the amount of points that the Blinky ghost gives.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Blinky

      +
      public Blinky(Position startPosition, + Direction direction, + Behaviour behaviour, + Level level)
      +
      Constructor with arguments.
      + The value of the scatterPosition is (level.WIDTH,-1).
      + The value of the sprite is Sprite.BLINKY.
      + It assigns to chaseBehaviour a ChaseAggressive object.
      +
      +
      Parameters:
      +
      startPosition - The position where the ghost is in the beginning + (value given by the level configuration file).
      +
      direction - Direction which the ghost faces in the beginning.
      +
      behaviour - Current behaviour of the ghost.
      +
      level - Reference to the current level object.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getPoints

      +
      public int getPoints()
      +
      Getter of the attribute POINTS.
      +
      +
      Returns:
      +
      Returns the value of the attribute POINTS.
      +
      Since:
      +
      getPoints in interface Scorable.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Clyde.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Clyde.html new file mode 100644 index 0000000..09b65d7 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Clyde.html @@ -0,0 +1,252 @@ + + + + +Clyde (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + + +
+
+
All Implemented Interfaces:
+
Hitable, Movable, Scorable
+
+
+
public class Clyde +extends Ghost
+
Represents a Clyde (orange) ghost.
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      POINTS

      +
      private static final int POINTS
      +
      This attribute stores the amount of points that the Inky ghost gives.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Clyde

      +
      public Clyde(Position startPosition, + Direction direction, + Behaviour behaviour, + Level level)
      +
      Constructor with arguments.
      + The value of the scatterPosition is (-1,LEVEL.HEIGHT).
      + The value of the sprite is Sprite.CLYDE.
      + It assigns to chaseBehaviour a ChaseCoward object.
      +
      +
      Parameters:
      +
      startPosition - The position where the ghost is in the beginning + (value given by the level configuration file).
      +
      direction - Direction which the ghost faces in the beginning.
      +
      behaviour - Current behaviour of the ghost.
      +
      level - Reference to the current level object.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getPoints

      +
      public int getPoints()
      +
      Getter of the attribute POINTS.
      +
      +
      Returns:
      +
      Returns the value of the attribute POINTS.
      +
      Since:
      +
      getPoints in interface Scorable.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Ghost.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Ghost.html new file mode 100644 index 0000000..46a00fe --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Ghost.html @@ -0,0 +1,520 @@ + + + + +Ghost (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + + +
+
+
All Implemented Interfaces:
+
Hitable, Movable, Scorable
+
+
+
Direct Known Subclasses:
+
Blinky, Clyde, Inky, Pinky
+
+
+
public abstract class Ghost +extends Character +implements Scorable
+
Represents an abstract Ghost class which defines a specific Character entity.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private Behaviour
    + +
    +
    Behaviour in which the ghost is.
    +
    +
    protected ChaseBehaviour
    + +
    +
    Object that allows us to assign a specific ChaseBehaviour class.
    +
    +
    private Position
    + +
    +
    Position that the ghost tries to reach when its behaviour is SCATTER.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Modifier
    +
    Constructor
    +
    Description
    +
    protected
    +
    Ghost(Position startPosition, + Position scatterPosition, + Direction direction, + Behaviour behaviour, + Sprite sprite, + Level level)
    +
    +
    Constructor with arguments.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    boolean
    + +
    +
    Checks if another object instance is equal to this ghost.
    +
    + + +
    +
    Gets the behaviour that the ghost currently is in.
    +
    + + +
    +
    Getter of the attribute scatterPosition.
    +
    +
    private Position
    + +
    +
    Returns the target position of the ghosts according to its current behaviour.
    +
    +
    boolean
    +
    hit()
    +
    +
    Checks if the ghost hits Pacman, i.e. if ghost's position and Pacman's position are the same.
    +
    +
    void
    + +
    +
    Kills the ghost and add its points to the level's score.
    +
    +
    void
    + +
    +
    Moves the ghost according to the game rules.
    + If the targetPosition is null (e.g. because ghost's behavior is INACTIVE}, + then the ghost does not move.
    +
    +
    private void
    + +
    +
    Decreases the behaviour's duration and changes the ghost's behaviour to the + next behaviour if duration is 0.
    +
    +
    void
    + +
    +
    Resets the ghost back to its start position where it is "alive" (as the Character does) and also + with a behaviour of INACTIVE and facing UP.
    +
    +
    void
    + +
    +
    Sets the current behaviour of the ghost.
    + Its duration overrides the value of the attribute duration.
    +
    +
    private void
    +
    setScatterPosition(Position scatterPosition)
    +
    +
    Setter of the attribute scatterPosition.
    +
    + + +
    +
    Represents this ghost in a comma-separated string format.
    + Format is: "x,y,DIRECTION,BEHAVIOUR:behaviourDuration".
    + DIRECTION is the uppercase enum type value for Direction.
    + BEHAVIOUR is the uppercase enum type value for Behaviour.
    + Example:
    + "2,3,UP,SCATTER,3"
    +
    +
    +
    +
    +
    +

    Methods inherited from class edu.uoc.pacman.model.entities.characters.Character

    +alive, getDirection, getDuration, getLevel, getStartPosition, isDead, setDirection, setDuration, setLevel
    +
    +

    Methods inherited from class edu.uoc.pacman.model.entities.Entity

    +getPosition, getSprite, isPathable, setPathable, setPosition, setSprite
    +
    +

    Methods inherited from class java.lang.Object

    +clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    +
    +

    Methods inherited from interface edu.uoc.pacman.model.entities.Scorable

    +getPoints
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      behaviour

      +
      private Behaviour behaviour
      +
      Behaviour in which the ghost is.
      +
      +
    • +
    • +
      +

      scatterPosition

      +
      private Position scatterPosition
      +
      Position that the ghost tries to reach when its behaviour is SCATTER.
      +
      +
    • +
    • +
      +

      chaseBehaviour

      +
      protected ChaseBehaviour chaseBehaviour
      +
      Object that allows us to assign a specific ChaseBehaviour class.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Ghost

      +
      protected Ghost(Position startPosition, + Position scatterPosition, + Direction direction, + Behaviour behaviour, + Sprite sprite, + Level level)
      +
      Constructor with arguments.
      +
      +
      Parameters:
      +
      startPosition - The initial/start position of the ghost. + Its value is the one which is provided by the level configuration file.
      +
      scatterPosition - The position which the ghost tries to reach when its behaviour is SCATTER.
      +
      direction - The direction that the ghost faces.
      +
      behaviour - Current behaviour of the ghost.
      +
      sprite - Value of Sprite linked to the entity.
      +
      level - Reference to the current level object.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getBehaviour

      +
      public Behaviour getBehaviour()
      +
      Gets the behaviour that the ghost currently is in.
      +
      +
      Returns:
      +
      Current value of the attribute behaviour.
      +
      +
      +
    • +
    • +
      +

      setBehaviour

      +
      public void setBehaviour(Behaviour behaviour)
      +
      Sets the current behaviour of the ghost.
      + Its duration overrides the value of the attribute duration. + If the behaviour parameter is null, then no changes are made.
      +
      +
      Parameters:
      +
      behaviour - New value for the attribute behaviour.
      +
      +
      +
    • +
    • +
      +

      nextBehaviour

      +
      private void nextBehaviour()
      +
      Decreases the behaviour's duration and changes the ghost's behaviour to the + next behaviour if duration is 0. The value of the attribute duration cannot be negative. +
        +
      • CHASE goes to SCATTER
      • +
      • FRIGHTENED and SCATTER and INACTIVE go to CHASE.
      • +
      +
      +
    • +
    • +
      +

      reset

      +
      public void reset()
      +
      Resets the ghost back to its start position where it is "alive" (as the Character does) and also + with a behaviour of INACTIVE and facing UP.
      +
      +
      Overrides:
      +
      reset in class Character
      +
      +
      +
    • +
    • +
      +

      equals

      +
      public boolean equals(Object o)
      +
      Checks if another object instance is equal to this ghost. + Ghosts are equal if they have the same "dead status", behaviour, + direction, position (remember that Position overrides equals) + and its duration is identical.
      +
      +
      Overrides:
      +
      equals in class Object
      +
      Returns:
      +
      true if equal, false otherwise.
      +
      +
      +
    • +
    • +
      +

      toString

      +
      public String toString()
      +
      Represents this ghost in a comma-separated string format.
      + Format is: "x,y,DIRECTION,BEHAVIOUR:behaviourDuration".
      + DIRECTION is the uppercase enum type value for Direction.
      + BEHAVIOUR is the uppercase enum type value for Behaviour.
      + Example:
      + "2,3,UP,SCATTER,3"
      +
      +
      Overrides:
      +
      toString in class Character
      +
      Returns:
      +
      "x,y,DIRECTION,BEHAVIOUR:behaviourDuration"
      +
      +
      +
    • +
    • +
      +

      getScatterPosition

      +
      public Position getScatterPosition()
      +
      Getter of the attribute scatterPosition.
      +
      +
      Returns:
      +
      The current value of the attribute scatterPosition.
      +
      +
      +
    • +
    • +
      +

      setScatterPosition

      +
      private void setScatterPosition(Position scatterPosition)
      +
      Setter of the attribute scatterPosition.
      +
      +
      Parameters:
      +
      scatterPosition - New value for the attribute scatterPosition.
      +
      +
      +
    • +
    • +
      +

      getTargetPosition

      +
      private Position getTargetPosition()
      +
      Returns the target position of the ghosts according to its current behaviour. +
        +
      • + CHASE: the value returned by ChaseBehaviour's getChasePosition. +
      • +
      • + SCATTER, FRIGHTENED: the value returned by getScatterPosition. +
      • +
      • + Other values: null. +
      • +
      +
      +
      Returns:
      +
      The target position according to the ghost's current behaviour.
      +
      +
      +
    • +
    • +
      +

      move

      +
      public void move()
      +
      Moves the ghost according to the game rules.
      + If the targetPosition is null (e.g. because ghost's behavior is INACTIVE}, + then the ghost does not move. +

      + In order to decide how to reach the targetPosition, i.e in which direction the ghost should move, + this method calculates the euclidean distance of the 4 potential positions and choose the one with + the smallest distance. +

      + The new position is the one that meets the all three requirements below: + +

        +
      • It has the smallest distance to the targetPosition.
      • +
      • It is pathable, and
      • +
      • its direction is not opposite to the current one.
      • +
      • if two or more directions have the same distance to the targetPosition, then the new position + will be the last direction in the enum Direction.
      • +
      +

      + In addition to set the new position, this method sets the direction and + invokes the hit method in order to check if the ghost hits Pacman in the new position. +

      + In any case, this method invokes nextBehaviour. +

      + Hint: Use Double.MAX_VALUE.

      +
      +
      Specified by:
      +
      move in interface Movable
      +
      Since:
      +
      move in interface Movable.
      +
      +
      +
    • +
    • +
      +

      hit

      +
      public boolean hit()
      +
      Checks if the ghost hits Pacman, i.e. if ghost's position and Pacman's position are the same. +

      + If both positions are identical, then the ghost must be killed when its behaviour is FRIGHTENED. + Otherwise, if the ghost's behaviour is different to INACTIVE and Pacman's state is NORMAL, + then pacman must be killed. +

      + When either the ghost or Pacman are killed, then this method returns true. Otherwise, false.

      +
      +
      Specified by:
      +
      hit in interface Hitable
      +
      Returns:
      +
      true when the ghost and Pacman collide as long as the ghost is not INACTIVE. + Otherwise, it returns false.
      +
      Since:
      +
      kill in interface Hitable.
      +
      +
      +
    • +
    • +
      +

      kill

      +
      public void kill()
      +
      Kills the ghost and add its points to the level's score. + Moreover, it assigns INACTIVE to its behaviour.
      +
      +
      Overrides:
      +
      kill in class Character
      +
      Since:
      +
      kill in class Character.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/GhostFactory.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/GhostFactory.html new file mode 100644 index 0000000..f9ec84d --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/GhostFactory.html @@ -0,0 +1,185 @@ + + + + +GhostFactory (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class GhostFactory

+
+
java.lang.Object +
edu.uoc.pacman.model.entities.characters.ghosts.GhostFactory
+
+
+
+
public abstract class GhostFactory +extends Object
+
Ghost Simple Factory class.
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      GhostFactory

      +
      public GhostFactory()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getGhostInstance

      +
      public static Ghost getGhostInstance(int x, + int y, + String ghostClassName, + Direction direction, + Behaviour behaviour, + Level level) + throws IllegalStateException
      +
      Returns a new Ghost object.
      +
      +
      Parameters:
      +
      x - Column of the coordinate/position in which the item is in the board.
      +
      y - Row of the coordinate/position in which the item is in the board.
      +
      ghostClassName - String value of the MapItem enumeration that corresponds to the item of the map.
      +
      direction - Direction which the ghost faces in the beginning.
      +
      behaviour - Current behaviour of the ghost.
      +
      level - Reference to the Level object.
      +
      Returns:
      +
      MapItem object.
      +
      Throws:
      +
      IllegalStateException - When a wrong symbol is used as an argument.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Inky.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Inky.html new file mode 100644 index 0000000..06e7615 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Inky.html @@ -0,0 +1,252 @@ + + + + +Inky (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + + +
+
+
All Implemented Interfaces:
+
Hitable, Movable, Scorable
+
+
+
public class Inky +extends Ghost
+
Represents an Inky (bluish) ghost.
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      POINTS

      +
      private static final int POINTS
      +
      This attribute stores the amount of points that the Inky ghost gives.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Inky

      +
      public Inky(Position startPosition, + Direction direction, + Behaviour behaviour, + Level level)
      +
      Constructor with arguments.
      + The value of the scatterPosition is (LEVEL.WIDTH,LEVEL.HEIGHT).
      + The value of the sprite is Sprite.INKY.
      + It assigns to chaseBehaviour a ChasePatrol object.
      +
      +
      Parameters:
      +
      startPosition - The position where the ghost is in the beginning + (value given by the level configuration file).
      +
      direction - Direction which the ghost faces in the beginning.
      +
      behaviour - Current behaviour of the ghost.
      +
      level - Reference to the current level object.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getPoints

      +
      public int getPoints()
      +
      Getter of the attribute POINTS.
      +
      +
      Returns:
      +
      Returns the value of the attribute POINTS.
      +
      Since:
      +
      getPoints in interface Scorable.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Pinky.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Pinky.html new file mode 100644 index 0000000..8336a78 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/Pinky.html @@ -0,0 +1,252 @@ + + + + +Pinky (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + + +
+
+
All Implemented Interfaces:
+
Hitable, Movable, Scorable
+
+
+
public class Pinky +extends Ghost
+
Represents a Pinky ghost.
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      POINTS

      +
      private static final int POINTS
      +
      This attribute stores the amount of points that the Pinky ghost gives.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Pinky

      +
      public Pinky(Position startPosition, + Direction direction, + Behaviour behaviour, + Level level)
      +
      Constructor with arguments.
      + The value of the scatterPosition is (-1,-1).
      + The value of the sprite is Sprite.PINKY.
      + It assigns to chaseBehaviour a ChaseAmbush object.
      +
      +
      Parameters:
      +
      startPosition - The position where the ghost is in the beginning + (value given by the level configuration file).
      +
      direction - Direction which the ghost faces in the beginning.
      +
      behaviour - Current behaviour of the ghost.
      +
      level - Reference to the current level object.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getPoints

      +
      public int getPoints()
      +
      Getter of the attribute POINTS.
      +
      +
      Returns:
      +
      Returns the value of the attribute POINTS.
      +
      Since:
      +
      getPoints in interface Scorable.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAggressive.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAggressive.html new file mode 100644 index 0000000..08fef73 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAggressive.html @@ -0,0 +1,177 @@ + + + + +ChaseAggressive (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class ChaseAggressive

+
+
java.lang.Object +
edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAggressive
+
+
+
+
All Implemented Interfaces:
+
ChaseBehaviour
+
+
+
public class ChaseAggressive +extends Object +implements ChaseBehaviour
+
It implements the ChaseBehaviour interface according to an aggressive behaviour.
+ Its target position is directly Pacman's position.
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      ChaseAggressive

      +
      public ChaseAggressive()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getChasePosition

      +
      public Position getChasePosition(Ghost ghost)
      +
      The ghost will chase the Pacman's current direction.
      +
      +
      Specified by:
      +
      getChasePosition in interface ChaseBehaviour
      +
      Parameters:
      +
      ghost - Ghost object that chases.
      +
      Returns:
      +
      Pacman's current position.
      +
      Since:
      +
      getChasePosition in interface ChaseBehaviour.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAmbush.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAmbush.html new file mode 100644 index 0000000..503ab29 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAmbush.html @@ -0,0 +1,220 @@ + + + + +ChaseAmbush (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + +
java.lang.Object +
edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAmbush
+
+
+
+
All Implemented Interfaces:
+
ChaseBehaviour
+
+
+
public class ChaseAmbush +extends Object +implements ChaseBehaviour
+
It implements the ChaseBehaviour interface according to an ambush behaviour.
+ Its target position is four steps ahead of Pacman's position in the direction Pacman is facing.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private static final int
    + +
    +
    The amount of tiles/cells/positions/steps that must be added to the Pacman's position.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    + +
     
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    + + +
    +
    The ghost will chase the position which is TILES_OFFSET steps/tiles/cells/positions + ahead of Pacman's position in the direction Pacman is facing.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      TILES_OFFSET

      +
      private static final int TILES_OFFSET
      +
      The amount of tiles/cells/positions/steps that must be added to the Pacman's position.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      ChaseAmbush

      +
      public ChaseAmbush()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getChasePosition

      +
      public Position getChasePosition(Ghost ghost)
      +
      The ghost will chase the position which is TILES_OFFSET steps/tiles/cells/positions + ahead of Pacman's position in the direction Pacman is facing.
      +
      +
      Specified by:
      +
      getChasePosition in interface ChaseBehaviour
      +
      Parameters:
      +
      ghost - Ghost object that chases.
      +
      Returns:
      +
      Position where the ghost must go, i.e. the position which is TILES_OFFSET steps ahead of Pacman’s position + in the direction Pacman is facing.
      +
      Since:
      +
      getChasePosition in interface ChaseBehaviour.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseBehaviour.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseBehaviour.html new file mode 100644 index 0000000..f1e481f --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseBehaviour.html @@ -0,0 +1,141 @@ + + + + +ChaseBehaviour (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface ChaseBehaviour

+
+
+
+
All Known Implementing Classes:
+
ChaseAggressive, ChaseAmbush, ChaseCoward, ChasePatrol
+
+
+
public interface ChaseBehaviour
+
Defines the methods that any character (namely, ghost) must have to chase.
+ Thanks to this interface, we are using the Strategy design pattern. + More info here.
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    + + +
    +
    Defines the signature of the method to be used to get the position where + any character (namely, ghosts) must to go to.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getChasePosition

      +
      Position getChasePosition(Ghost ghost)
      +
      Defines the signature of the method to be used to get the position where + any character (namely, ghosts) must to go to.
      +
      +
      Parameters:
      +
      ghost - Ghost object that wants to chase.
      +
      Returns:
      +
      Position where the ghost must go to.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseCoward.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseCoward.html new file mode 100644 index 0000000..7d82612 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseCoward.html @@ -0,0 +1,221 @@ + + + + +ChaseCoward (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + +
java.lang.Object +
edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseCoward
+
+
+
+
All Implemented Interfaces:
+
ChaseBehaviour
+
+
+
public class ChaseCoward +extends Object +implements ChaseBehaviour
+
It implements the ChaseBehaviour interface according to a coward behaviour.
+ It has two different modes which it constantly switches back and forth between, + based on its proximity to Pacman.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private static final int
    + +
    +
    Distance in tiles to decide which position is the target one.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    + +
     
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    + + +
    +
    The ghost will target Pacman's position if the euclidean distance between position is equal to or greater than + a distance of TILES_TO_CHASE.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      TILES_TO_CHASE

      +
      private static final int TILES_TO_CHASE
      +
      Distance in tiles to decide which position is the target one.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      ChaseCoward

      +
      public ChaseCoward()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getChasePosition

      +
      public Position getChasePosition(Ghost ghost)
      +
      The ghost will target Pacman's position if the euclidean distance between position is equal to or greater than + a distance of TILES_TO_CHASE. Otherwise, the ghost will target its scatter position.
      +
      +
      Specified by:
      +
      getChasePosition in interface ChaseBehaviour
      +
      Parameters:
      +
      ghost - Ghost object that chases.
      +
      Returns:
      +
      Position where the ghost must go. Pacman's position if the euclidena distance + is equal to or greater than TILES_TO_CHASE. Otherwise, ghost's scatter position.
      +
      Since:
      +
      getChasePosition in interface ChaseBehaviour.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChasePatrol.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChasePatrol.html new file mode 100644 index 0000000..1e009b5 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChasePatrol.html @@ -0,0 +1,253 @@ + + + + +ChasePatrol (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + +
java.lang.Object +
edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol
+
+
+
+
All Implemented Interfaces:
+
ChaseBehaviour
+
+
+
public class ChasePatrol +extends Object +implements ChaseBehaviour
+
It implements the ChaseBehaviour interface according to an aggressive behaviour.
+ In order to locate Inky's target position, we first start by selecting + the position TILES_OFFSET tiles in front of Pac-Man in his current + direction of travel, similar to Pinky's targeting method. + From there, imagine drawing a vector from Blinky's position + to this tile, and then doubling (i.e. the value of VECTOR_INCREASE the length of the vector. + The tile that this new, extended vector ends on will be Inky's actual target.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private static final int
    + +
    +
    The amount of tiles/cells/positions/steps that must be added to the Pacman's position.
    +
    +
    private static final int
    + +
    +
    The amount which the vector equals to + targetPositionBlinky - FIRST_BLINKY_POSITION must be extended (multiplied).
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    + +
     
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    + + +
    +
    The ghost will chase twice a vector equals to:
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      TILES_OFFSET

      +
      private static final int TILES_OFFSET
      +
      The amount of tiles/cells/positions/steps that must be added to the Pacman's position.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      VECTOR_INCREASE

      +
      private static final int VECTOR_INCREASE
      +
      The amount which the vector equals to + targetPositionBlinky - FIRST_BLINKY_POSITION must be extended (multiplied).
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      ChasePatrol

      +
      public ChasePatrol()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getChasePosition

      +
      public Position getChasePosition(Ghost ghost)
      +
      The ghost will chase twice a vector equals to:
      +

      + targetBlinkyPosition - FIRST_BLINKY_POSITION + + targetBlinkyPosition is the position which is TILES_OFFSET steps/tiles/cells/positions + ahead of Pacman's position in the direction Pacman is facing.

      +
      +
      Specified by:
      +
      getChasePosition in interface ChaseBehaviour
      +
      Parameters:
      +
      ghost - Ghost object that chases.
      +
      Returns:
      +
      Position where the ghost must go:
      +

      + VECTOR_INCREASE * (targetBlinkyPosition - FIRST_BLINKY_POSITION) +

      + If there are no Blinky ghosts, then it returns targetBlinkyPosition.

      +
      Since:
      +
      getChasePosition in interface ChaseBehaviour.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/package-summary.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/package-summary.html new file mode 100644 index 0000000..da98c82 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/package-summary.html @@ -0,0 +1,124 @@ + + + + +edu.uoc.pacman.model.entities.characters.ghosts.chase (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model.entities.characters.ghosts.chase

+
+
+
package edu.uoc.pacman.model.entities.characters.ghosts.chase
+
+
    +
  • + +
  • +
  • +
    +
    +
    +
    +
    Class
    +
    Description
    + +
    +
    It implements the ChaseBehaviour interface according to an aggressive behaviour.
    + Its target position is directly Pacman's position.
    +
    + +
    +
    It implements the ChaseBehaviour interface according to an ambush behaviour.
    + Its target position is four steps ahead of Pacman's position in the direction Pacman is facing.
    +
    + +
    +
    Defines the methods that any character (namely, ghost) must have to chase.
    + Thanks to this interface, we are using the Strategy design pattern.
    +
    + +
    +
    It implements the ChaseBehaviour interface according to a coward behaviour.
    + It has two different modes which it constantly switches back and forth between, + based on its proximity to Pacman.
    +
    + +
    +
    It implements the ChaseBehaviour interface according to an aggressive behaviour.
    + In order to locate Inky's target position, we first start by selecting + the position TILES_OFFSET tiles in front of Pac-Man in his current + direction of travel, similar to Pinky's targeting method.
    +
    +
    +
    +
    +
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/package-tree.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/package-tree.html new file mode 100644 index 0000000..9402f71 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/chase/package-tree.html @@ -0,0 +1,79 @@ + + + + +edu.uoc.pacman.model.entities.characters.ghosts.chase Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model.entities.characters.ghosts.chase

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAggressive (implements edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour)
    • +
    • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAmbush (implements edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour)
    • +
    • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseCoward (implements edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour)
    • +
    • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol (implements edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour)
    • +
    +
  • +
+
+
+

Interface Hierarchy

+
    +
  • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/package-summary.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/package-summary.html new file mode 100644 index 0000000..c4b87f5 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/package-summary.html @@ -0,0 +1,128 @@ + + + + +edu.uoc.pacman.model.entities.characters.ghosts (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model.entities.characters.ghosts

+
+
+
package edu.uoc.pacman.model.entities.characters.ghosts
+
+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/package-tree.html b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/package-tree.html new file mode 100644 index 0000000..8219d7c --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/ghosts/package-tree.html @@ -0,0 +1,100 @@ + + + + +edu.uoc.pacman.model.entities.characters.ghosts Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model.entities.characters.ghosts

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • edu.uoc.pacman.model.entities.Entity +
        +
      • edu.uoc.pacman.model.entities.characters.Character (implements edu.uoc.pacman.model.entities.characters.Hitable, edu.uoc.pacman.model.entities.characters.Movable) +
          +
        • edu.uoc.pacman.model.entities.characters.ghosts.Ghost (implements edu.uoc.pacman.model.entities.Scorable) +
            +
          • edu.uoc.pacman.model.entities.characters.ghosts.Blinky
          • +
          • edu.uoc.pacman.model.entities.characters.ghosts.Clyde
          • +
          • edu.uoc.pacman.model.entities.characters.ghosts.Inky
          • +
          • edu.uoc.pacman.model.entities.characters.ghosts.Pinky
          • +
          +
        • +
        +
      • +
      +
    • +
    • edu.uoc.pacman.model.entities.characters.ghosts.GhostFactory
    • +
    +
  • +
+
+
+

Enum Class Hierarchy

+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/package-summary.html b/core/docs/edu/uoc/pacman/model/entities/characters/package-summary.html new file mode 100644 index 0000000..b8dcd7c --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/package-summary.html @@ -0,0 +1,114 @@ + + + + +edu.uoc.pacman.model.entities.characters (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model.entities.characters

+
+
+
package edu.uoc.pacman.model.entities.characters
+
+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/package-tree.html b/core/docs/edu/uoc/pacman/model/entities/characters/package-tree.html new file mode 100644 index 0000000..9f6206d --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/package-tree.html @@ -0,0 +1,81 @@ + + + + +edu.uoc.pacman.model.entities.characters Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model.entities.characters

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • edu.uoc.pacman.model.entities.Entity +
        +
      • edu.uoc.pacman.model.entities.characters.Character (implements edu.uoc.pacman.model.entities.characters.Hitable, edu.uoc.pacman.model.entities.characters.Movable)
      • +
      +
    • +
    +
  • +
+
+
+

Interface Hierarchy

+
    +
  • edu.uoc.pacman.model.entities.characters.Hitable
  • +
  • edu.uoc.pacman.model.entities.characters.Movable
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/pacman/Pacman.html b/core/docs/edu/uoc/pacman/model/entities/characters/pacman/Pacman.html new file mode 100644 index 0000000..94cd130 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/pacman/Pacman.html @@ -0,0 +1,400 @@ + + + + +Pacman (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + + +
+
+
All Implemented Interfaces:
+
Hitable, Movable
+
+
+
public class Pacman +extends Character
+
Represents the player object that appears in the game, which is called Pacman.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private State
    + +
    +
    Stores the state of the Pacman.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Pacman(Position startPosition, + Direction direction, + State state, + Level level)
    +
    +
    Constructor with arguments.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    private void
    +
    eat()
    +
    +
    Performs the eat action.
    +
    + + +
    +
    Getter of the attribute state.
    +
    +
    boolean
    +
    hit()
    +
    +
    Checks if Pacman is in the same position which any ghost.
    +
    +
    void
    + +
    +
    Kills Pacman and decreases one life in the current level.
    +
    +
    void
    + +
    +
    Moves Pacman across the board only one step.
    +
    +
    private void
    + +
    +
    Decreases the behaviour's duration and changes the ghost's behaviour to the + next behaviour if duration is 0.
    +
    +
    void
    + +
    +
    Resets Pacman back to its start position where it is "alive" (as Character does) and also with a + state of INVINCIBLE and facing UP.
    +
    +
    void
    + +
    +
    Sets the direction of Pacman.
    + If the new direction is null, then the direction is not set and remains the same.

    + Because Pacman has 4 different sprites depending on its direction, this method also updates the + value of the attribute sprite, i.e.
    +
    +
    void
    +
    setState(State state)
    +
    +
    Setter of the attribute state.
    + If the new state is null, then the state is not set and remains the same.
    +
    +
    +
    +
    +
    +

    Methods inherited from class edu.uoc.pacman.model.entities.characters.Character

    +alive, getDirection, getDuration, getLevel, getStartPosition, isDead, setDuration, setLevel, toString
    +
    +

    Methods inherited from class edu.uoc.pacman.model.entities.Entity

    +getPosition, getSprite, isPathable, setPathable, setPosition, setSprite
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      state

      +
      private State state
      +
      Stores the state of the Pacman.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Pacman

      +
      public Pacman(Position startPosition, + Direction direction, + State state, + Level level)
      +
      Constructor with arguments.
      +
      +
      Parameters:
      +
      startPosition - The initial/start position of the Pacman. + Its value is the one which is provided by the level configuration file.
      +
      direction - The direction that the Pacman faces.
      +
      state - The initial state of Pacman.
      +
      level - Reference to the current level object.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getState

      +
      public State getState()
      +
      Getter of the attribute state.
      +
      +
      Returns:
      +
      The current value of the attribute state.
      +
      +
      +
    • +
    • +
      +

      setState

      +
      public void setState(State state)
      +
      Setter of the attribute state.
      + If the new state is null, then the state is not set and remains the same.
      +
      +
      Parameters:
      +
      state - New value for the attribute state.
      +
      +
      +
    • +
    • +
      +

      nextState

      +
      private void nextState()
      +
      Decreases the behaviour's duration and changes the ghost's behaviour to the + next behaviour if duration is 0. The value of the attribute duration cannot be negative. +
        +
      • CHASE goes to SCATTER
      • +
      • FRIGHTENED and SCATTER and INACTIVE go to CHASE.
      • +
      +
      +
    • +
    • +
      +

      reset

      +
      public void reset()
      +
      Resets Pacman back to its start position where it is "alive" (as Character does) and also with a + state of INVINCIBLE and facing UP.
      +
      +
      Overrides:
      +
      reset in class Character
      +
      +
      +
    • +
    • +
      +

      move

      +
      public void move()
      +
      Moves Pacman across the board only one step.
      +

      + If the MapItem which is in the potential new position + is pathable, then this method moves Pacman into this position. + Otherwise, Pacman stays in its current position.
      +

      + After moving, Pacman will eat the item that occupies the cell/tile/position and + will add its score to the game score.
      +

      + Lastly, it will invoke the hit method. +

      + In any case, this method invokes nextState.

      +
      +
    • +
    • +
      +

      setDirection

      +
      public void setDirection(Direction direction)
      +
      Sets the direction of Pacman.
      + If the new direction is null, then the direction is not set and remains the same.

      + Because Pacman has 4 different sprites depending on its direction, this method also updates the + value of the attribute sprite, i.e. PACMAN_UP, PACMAN_LEFT, PACMAN_RIGHT and PACMAN_DOWN.
      +
      +
      Specified by:
      +
      setDirection in interface Movable
      +
      Overrides:
      +
      setDirection in class Character
      +
      Parameters:
      +
      direction - New value for the attribute direction.
      +
      Since:
      +
      setDirection in interface Movable.
      +
      +
      +
    • +
    • +
      +

      eat

      +
      private void eat()
      +
      Performs the eat action. This means which picks Pickable objects up and add its points to + the level's score, if it is needed. Remember that some Pickable objects are Scorable ones as well.
      +

      + If Pacman picks an energizer up, then the behaviour of all the ghosts must be FRIGHTENED. + Moreover, Pacman's state must be EATER. +

      + If Pacman picks a life up, then one life is increased for the current level. +

      + When any Pickable objects is picked up, then it is removed from the labyrinth/map + and replaced by a Path item.

      +
      +
    • +
    • +
      +

      hit

      +
      public boolean hit()
      +
      Checks if Pacman is in the same position which any ghost. If this happens, then checks ghost's status: +
        +
      • If Pacman's state is INVINCIBLE, then nothing happens and this method returns false.
      • +
      • + If the ghost is FRIGHTENED, then the ghost is killed. This method returns true. +
      • +
      • + If the ghost is INACTIVE, then nothing happens and this method returns false. +
      • +
      +
      +
      Returns:
      +
      true if Pacman collides with any ghost and the aforesaid cases are met. Otherwise, false.
      +
      Since:
      +
      hit in interface Hitable.
      +
      +
      +
    • +
    • +
      +

      kill

      +
      public void kill()
      +
      Kills Pacman and decreases one life in the current level. + Moreover, it assigns INVINCIBLE to its state.
      +
      +
      Overrides:
      +
      kill in class Character
      +
      Since:
      +
      kill in class Character.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/pacman/State.html b/core/docs/edu/uoc/pacman/model/entities/characters/pacman/State.html new file mode 100644 index 0000000..77bd7fb --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/pacman/State.html @@ -0,0 +1,350 @@ + + + + +State (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ + +
java.lang.Object +
java.lang.Enum<State> +
edu.uoc.pacman.model.entities.characters.pacman.State
+
+
+
+
+
All Implemented Interfaces:
+
Serializable, Comparable<State>, Constable
+
+
+
public enum State +extends Enum<State>
+
Represents the three state which Pacman can have. The behaviour are defined + as "NORMAL", "EATER" and "INVINCIBLE". +
    +
  • "NORMAL" - Its the most frequent state. Its duration is Integer.MAX_VALUE.
  • +
  • "EATER" - Pacman can kill ghosts. It has a duration of 30, the same as the ghosts's frightened behaviour.
  • +
  • "INVINCIBLE" - Pacman cannot be killed by ghosts, but it does not kill ghosts either. Duration = 5.
  • +
+
+
+
    + +
  • +
    +

    Nested Class Summary

    +
    +

    Nested classes/interfaces inherited from class java.lang.Enum

    +Enum.EnumDesc<E extends Enum<E>>
    +
    +
  • + +
  • +
    +

    Enum Constant Summary

    +
    Enum Constants
    +
    +
    Enum Constant
    +
    Description
    + +
    +
    State when Pacman eats an energizer and is able to eat/kill ghosts.
    +
    + +
    +
    State when Pacman has been killed, and it cannot neither be killed nor kill ghosts.
    +
    + +
    +
    State in which Pacman is usually.
    +
    +
    +
    +
  • + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private final int
    + +
    +
    Stores the duration of the state.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Modifier
    +
    Constructor
    +
    Description
    +
    private
    +
    State(int duration)
    +
    +
    Constructor with arguments.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    int
    + +
    +
    Gets the duration of the state.
    +
    + + +
    +
    Returns a String with information of the State.
    + Format: STATE:stateDuration
    + Example: "INVINCIBLE:5"

    + + Hint: Remember that toString() is already coded in Object.
    +
    +
    static State
    + +
    +
    Returns the enum constant of this class with the specified name.
    +
    +
    static State[]
    + +
    +
    Returns an array containing the constants of this enum class, in +the order they are declared.
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Enum

    +clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
    +
    +

    Methods inherited from class java.lang.Object

    +getClass, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Enum Constant Details

    +
      +
    • +
      +

      NORMAL

      +
      public static final State NORMAL
      +
      State in which Pacman is usually.
      +
      +
    • +
    • +
      +

      EATER

      +
      public static final State EATER
      +
      State when Pacman eats an energizer and is able to eat/kill ghosts.
      +
      +
    • +
    • +
      +

      INVINCIBLE

      +
      public static final State INVINCIBLE
      +
      State when Pacman has been killed, and it cannot neither be killed nor kill ghosts.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      duration

      +
      private final int duration
      +
      Stores the duration of the state.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      State

      +
      private State(int duration)
      +
      Constructor with arguments.
      +
      +
      Parameters:
      +
      duration - Value to set to the state.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      values

      +
      public static State[] values()
      +
      Returns an array containing the constants of this enum class, in +the order they are declared.
      +
      +
      Returns:
      +
      an array containing the constants of this enum class, in the order they are declared
      +
      +
      +
    • +
    • +
      +

      valueOf

      +
      public static State valueOf(String name)
      +
      Returns the enum constant of this class with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this class. (Extraneous whitespace characters are +not permitted.)
      +
      +
      Parameters:
      +
      name - the name of the enum constant to be returned.
      +
      Returns:
      +
      the enum constant with the specified name
      +
      Throws:
      +
      IllegalArgumentException - if this enum class has no constant with the specified name
      +
      NullPointerException - if the argument is null
      +
      +
      +
    • +
    • +
      +

      getDuration

      +
      public int getDuration()
      +
      Gets the duration of the state.
      +
      +
      Returns:
      +
      duration of the state.
      +
      +
      +
    • +
    • +
      +

      toString

      +
      public String toString()
      +
      Returns a String with information of the State.
      + Format: STATE:stateDuration
      + Example: "INVINCIBLE:5"

      + + Hint: Remember that toString() is already coded in Object.
      +
      +
      Overrides:
      +
      toString in class Enum<State>
      +
      Returns:
      +
      State:stateDuration
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/pacman/package-summary.html b/core/docs/edu/uoc/pacman/model/entities/characters/pacman/package-summary.html new file mode 100644 index 0000000..272a56c --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/pacman/package-summary.html @@ -0,0 +1,106 @@ + + + + +edu.uoc.pacman.model.entities.characters.pacman (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model.entities.characters.pacman

+
+
+
package edu.uoc.pacman.model.entities.characters.pacman
+
+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/characters/pacman/package-tree.html b/core/docs/edu/uoc/pacman/model/entities/characters/pacman/package-tree.html new file mode 100644 index 0000000..ee9f053 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/characters/pacman/package-tree.html @@ -0,0 +1,92 @@ + + + + +edu.uoc.pacman.model.entities.characters.pacman Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model.entities.characters.pacman

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • edu.uoc.pacman.model.entities.Entity +
        +
      • edu.uoc.pacman.model.entities.characters.Character (implements edu.uoc.pacman.model.entities.characters.Hitable, edu.uoc.pacman.model.entities.characters.Movable) +
          +
        • edu.uoc.pacman.model.entities.characters.pacman.Pacman
        • +
        +
      • +
      +
    • +
    +
  • +
+
+
+

Enum Class Hierarchy

+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/Dot.html b/core/docs/edu/uoc/pacman/model/entities/items/Dot.html new file mode 100644 index 0000000..200a3a1 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/Dot.html @@ -0,0 +1,283 @@ + + + + +Dot (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Dot

+
+ +
+
+
All Implemented Interfaces:
+
Pickable, Scorable
+
+
+
public class Dot +extends MapItem +implements Pickable, Scorable
+
Represents a dot in the labyrinth/map.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private boolean
    + +
    +
    This attribute allows us to manage if the dot has been picked or not.
    +
    +
    private static final int
    + +
    +
    This attribute stores the amount of points that the dot gives.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Dot(Position position)
    +
    +
    Constructor with argument.
    + The value for pathable is true and for sprite is Sprite.DOT.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    int
    + +
    +
    Getter of the attribute POINTS.
    +
    +
    boolean
    + +
    +
    Getter of the attribute picked.
    +
    +
    void
    +
    setPicked(boolean picked)
    +
    +
    Setter of the attribute pickled.
    +
    +
    +
    +
    +
    +

    Methods inherited from class edu.uoc.pacman.model.entities.Entity

    +getPosition, getSprite, isPathable, setPathable, setPosition, setSprite
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      picked

      +
      private boolean picked
      +
      This attribute allows us to manage if the dot has been picked or not. + Its initial/default value is false.
      +
      +
    • +
    • +
      +

      POINTS

      +
      private static final int POINTS
      +
      This attribute stores the amount of points that the dot gives.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Dot

      +
      public Dot(Position position)
      +
      Constructor with argument.
      + The value for pathable is true and for sprite is Sprite.DOT.
      +
      +
      Parameters:
      +
      position - The position where the dot is.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      isPicked

      +
      public boolean isPicked()
      +
      Getter of the attribute picked.
      +
      +
      Specified by:
      +
      isPicked in interface Pickable
      +
      Returns:
      +
      The current value of the attribute picked.
      +
      Since:
      +
      isPicked in interface Pickable.
      +
      +
      +
    • +
    • +
      +

      setPicked

      +
      public void setPicked(boolean picked)
      +
      Setter of the attribute pickled.
      +
      +
      Specified by:
      +
      setPicked in interface Pickable
      +
      Parameters:
      +
      picked - New value for the attribute picked.
      +
      Since:
      +
      setPicked in interface Pickable.
      +
      +
      +
    • +
    • +
      +

      getPoints

      +
      public int getPoints()
      +
      Getter of the attribute POINTS.
      +
      +
      Specified by:
      +
      getPoints in interface Scorable
      +
      Returns:
      +
      Returns the value of the attribute POINTS.
      +
      Since:
      +
      getPoints in interface Scorable.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/Energizer.html b/core/docs/edu/uoc/pacman/model/entities/items/Energizer.html new file mode 100644 index 0000000..ad59942 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/Energizer.html @@ -0,0 +1,283 @@ + + + + +Energizer (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Energizer

+
+ +
+
+
All Implemented Interfaces:
+
Pickable, Scorable
+
+
+
public class Energizer +extends MapItem +implements Pickable, Scorable
+
Represents an energizer in the labyrinth/map.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private boolean
    + +
    +
    This attribute allows us to manage if the energizer has been picked or not.
    +
    +
    private static final int
    + +
    +
    This attribute stores the amount of points that the energizer gives.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Energizer(Position position)
    +
    +
    Constructor with argument.
    + The value for pathable is true and for sprite is Sprite.ENERGIZER.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    int
    + +
    +
    Getter of the attribute POINTS.
    +
    +
    boolean
    + +
    +
    Getter of the attribute picked.
    +
    +
    void
    +
    setPicked(boolean picked)
    +
    +
    Setter of the attribute pickled.
    +
    +
    +
    +
    +
    +

    Methods inherited from class edu.uoc.pacman.model.entities.Entity

    +getPosition, getSprite, isPathable, setPathable, setPosition, setSprite
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      picked

      +
      private boolean picked
      +
      This attribute allows us to manage if the energizer has been picked or not. + Its initial/default value is false.
      +
      +
    • +
    • +
      +

      POINTS

      +
      private static final int POINTS
      +
      This attribute stores the amount of points that the energizer gives.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Energizer

      +
      public Energizer(Position position)
      +
      Constructor with argument.
      + The value for pathable is true and for sprite is Sprite.ENERGIZER.
      +
      +
      Parameters:
      +
      position - The position where the energizer is.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      isPicked

      +
      public boolean isPicked()
      +
      Getter of the attribute picked.
      +
      +
      Specified by:
      +
      isPicked in interface Pickable
      +
      Returns:
      +
      The current value of the attribute picked.
      +
      Since:
      +
      isPicked in interface Pickable.
      +
      +
      +
    • +
    • +
      +

      setPicked

      +
      public void setPicked(boolean picked)
      +
      Setter of the attribute pickled.
      +
      +
      Specified by:
      +
      setPicked in interface Pickable
      +
      Parameters:
      +
      picked - New value for the attribute picked.
      +
      Since:
      +
      setPicked in interface Pickable.
      +
      +
      +
    • +
    • +
      +

      getPoints

      +
      public int getPoints()
      +
      Getter of the attribute POINTS.
      +
      +
      Specified by:
      +
      getPoints in interface Scorable
      +
      Returns:
      +
      Returns the value of the attribute POINTS.
      +
      Since:
      +
      getPoints in interface Scorable.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/Life.html b/core/docs/edu/uoc/pacman/model/entities/items/Life.html new file mode 100644 index 0000000..832ada8 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/Life.html @@ -0,0 +1,243 @@ + + + + +Life (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Life

+
+ +
+
+
All Implemented Interfaces:
+
Pickable
+
+
+
public class Life +extends MapItem +implements Pickable
+
Represents a life in the labyrinth/map.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private boolean
    + +
    +
    This attribute allows us to manage if the life has been picked or not.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Life(Position position)
    +
    +
    Constructor with argument.
    + The value for pathable is true and for sprite is Sprite.LIFE.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    boolean
    + +
    +
    Getter of the attribute picked.
    +
    +
    void
    +
    setPicked(boolean picked)
    +
    +
    Setter of the attribute pickled.
    +
    +
    +
    +
    +
    +

    Methods inherited from class edu.uoc.pacman.model.entities.Entity

    +getPosition, getSprite, isPathable, setPathable, setPosition, setSprite
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      picked

      +
      private boolean picked
      +
      This attribute allows us to manage if the life has been picked or not. + Its initial/default value is false.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Life

      +
      public Life(Position position)
      +
      Constructor with argument.
      + The value for pathable is true and for sprite is Sprite.LIFE.
      +
      +
      Parameters:
      +
      position - The position where the life is.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      isPicked

      +
      public boolean isPicked()
      +
      Getter of the attribute picked.
      +
      +
      Specified by:
      +
      isPicked in interface Pickable
      +
      Returns:
      +
      The current value of the attribute picked.
      +
      Since:
      +
      isPicked in interface Pickable.
      +
      +
      +
    • +
    • +
      +

      setPicked

      +
      public void setPicked(boolean picked)
      +
      Setter of the attribute pickled.
      +
      +
      Specified by:
      +
      setPicked in interface Pickable
      +
      Parameters:
      +
      picked - New value for the attribute picked.
      +
      Since:
      +
      setPicked in interface Pickable.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/MapItem.html b/core/docs/edu/uoc/pacman/model/entities/items/MapItem.html new file mode 100644 index 0000000..89d6ce3 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/MapItem.html @@ -0,0 +1,151 @@ + + + + +MapItem (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class MapItem

+
+
java.lang.Object +
edu.uoc.pacman.model.entities.Entity +
edu.uoc.pacman.model.entities.items.MapItem
+
+
+
+
+
Direct Known Subclasses:
+
Dot, Energizer, Life, Path, Wall
+
+
+
public abstract class MapItem +extends Entity
+
Abstract class that represents any labyrinth/map item.
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      MapItem

      +
      protected MapItem(Position position, + boolean pathable, + Sprite sprite)
      +
      Constructor with arguments.
      +
      +
      Parameters:
      +
      position - Position where the item is.
      +
      pathable - Indicates if the item is pathable or not.
      +
      sprite - Value linked to the file configuration symbol and image.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/MapItemFactory.html b/core/docs/edu/uoc/pacman/model/entities/items/MapItemFactory.html new file mode 100644 index 0000000..5caca8b --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/MapItemFactory.html @@ -0,0 +1,176 @@ + + + + +MapItemFactory (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class MapItemFactory

+
+
java.lang.Object +
edu.uoc.pacman.model.entities.items.MapItemFactory
+
+
+
+
public abstract class MapItemFactory +extends Object
+
Entity Simple Factory class.
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      MapItemFactory

      +
      public MapItemFactory()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getItemMapInstance

      +
      public static MapItem getItemMapInstance(int x, + int y, + char itemMapSymbol) + throws IllegalStateException
      +
      Returns a new MapItem object.
      +
      +
      Parameters:
      +
      x - Column of the coordinate/position in which the item is in the board.
      +
      y - Row of the coordinate/position in which the item is in the board.
      +
      itemMapSymbol - String value of the MapItem enumeration that corresponds to the item of the map.
      +
      Returns:
      +
      MapItem object.
      +
      Throws:
      +
      IllegalStateException - When a wrong symbol is used as an argument.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/Path.html b/core/docs/edu/uoc/pacman/model/entities/items/Path.html new file mode 100644 index 0000000..12ad238 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/Path.html @@ -0,0 +1,143 @@ + + + + +Path (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Path

+
+ +
+
+
public class Path +extends MapItem
+
Represents a path in the labyrinth/map.
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Path

      +
      public Path(Position position)
      +
      Constructor with arguments.
      + The value for pathable is true and for sprite is Sprite.PATH.
      +
      +
      Parameters:
      +
      position - Position where the path is.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/Pickable.html b/core/docs/edu/uoc/pacman/model/entities/items/Pickable.html new file mode 100644 index 0000000..24af1df --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/Pickable.html @@ -0,0 +1,151 @@ + + + + +Pickable (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Interface Pickable

+
+
+
+
All Known Implementing Classes:
+
Dot, Energizer, Life
+
+
+
public interface Pickable
+
Defines the methods that any pickable item must have.
+
+
+
    + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    boolean
    + +
    +
    Method that allows us to know if the item has been picked or not.
    +
    +
    void
    +
    setPicked(boolean picked)
    +
    +
    Sets the item as picked/unpicked.
    +
    +
    +
    +
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      isPicked

      +
      boolean isPicked()
      +
      Method that allows us to know if the item has been picked or not.
      +
      +
      Returns:
      +
      true if the item has been picked. Otherwise, false.
      +
      +
      +
    • +
    • +
      +

      setPicked

      +
      void setPicked(boolean picked)
      +
      Sets the item as picked/unpicked.
      +
      +
      Parameters:
      +
      picked - State: true if the item was picked. Otherwise, false.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/Wall.html b/core/docs/edu/uoc/pacman/model/entities/items/Wall.html new file mode 100644 index 0000000..8f8294e --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/Wall.html @@ -0,0 +1,143 @@ + + + + +Wall (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Wall

+
+ +
+
+
public class Wall +extends MapItem
+
Represents a wall in the labyrinth/map.
+
+
+ +
+
+
    + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Wall

      +
      public Wall(Position position)
      +
      Constructor with arguments.
      + The value for pathable is false and for sprite is Sprite.WALL.
      +
      +
      Parameters:
      +
      position - Position where the wall is.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/package-summary.html b/core/docs/edu/uoc/pacman/model/entities/items/package-summary.html new file mode 100644 index 0000000..3d9edf1 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/package-summary.html @@ -0,0 +1,130 @@ + + + + +edu.uoc.pacman.model.entities.items (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model.entities.items

+
+
+
package edu.uoc.pacman.model.entities.items
+
+
    +
  • + +
  • +
  • +
    +
    +
    +
    +
    Class
    +
    Description
    + +
    +
    Represents a dot in the labyrinth/map.
    +
    + +
    +
    Represents an energizer in the labyrinth/map.
    +
    + +
    +
    Represents a life in the labyrinth/map.
    +
    + +
    +
    Abstract class that represents any labyrinth/map item.
    +
    + +
    +
    Entity Simple Factory class.
    +
    + +
    +
    Represents a path in the labyrinth/map.
    +
    + +
    +
    Defines the methods that any pickable item must have.
    +
    + +
    +
    Represents a wall in the labyrinth/map.
    +
    +
    +
    +
    +
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/items/package-tree.html b/core/docs/edu/uoc/pacman/model/entities/items/package-tree.html new file mode 100644 index 0000000..946e489 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/items/package-tree.html @@ -0,0 +1,89 @@ + + + + +edu.uoc.pacman.model.entities.items Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model.entities.items

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • edu.uoc.pacman.model.entities.Entity +
        +
      • edu.uoc.pacman.model.entities.items.MapItem +
          +
        • edu.uoc.pacman.model.entities.items.Dot (implements edu.uoc.pacman.model.entities.items.Pickable, edu.uoc.pacman.model.entities.Scorable)
        • +
        • edu.uoc.pacman.model.entities.items.Energizer (implements edu.uoc.pacman.model.entities.items.Pickable, edu.uoc.pacman.model.entities.Scorable)
        • +
        • edu.uoc.pacman.model.entities.items.Life (implements edu.uoc.pacman.model.entities.items.Pickable)
        • +
        • edu.uoc.pacman.model.entities.items.Path
        • +
        • edu.uoc.pacman.model.entities.items.Wall
        • +
        +
      • +
      +
    • +
    • edu.uoc.pacman.model.entities.items.MapItemFactory
    • +
    +
  • +
+
+
+

Interface Hierarchy

+
    +
  • edu.uoc.pacman.model.entities.items.Pickable
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/package-summary.html b/core/docs/edu/uoc/pacman/model/entities/package-summary.html new file mode 100644 index 0000000..ed25a1a --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/package-summary.html @@ -0,0 +1,112 @@ + + + + +edu.uoc.pacman.model.entities (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model.entities

+
+
+
package edu.uoc.pacman.model.entities
+
+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/entities/package-tree.html b/core/docs/edu/uoc/pacman/model/entities/package-tree.html new file mode 100644 index 0000000..de6951a --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/entities/package-tree.html @@ -0,0 +1,76 @@ + + + + +edu.uoc.pacman.model.entities Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model.entities

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • edu.uoc.pacman.model.entities.Entity
    • +
    +
  • +
+
+
+

Interface Hierarchy

+
    +
  • edu.uoc.pacman.model.entities.Scorable
  • +
+
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/exceptions/LevelException.html b/core/docs/edu/uoc/pacman/model/exceptions/LevelException.html new file mode 100644 index 0000000..56b9ee7 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/exceptions/LevelException.html @@ -0,0 +1,255 @@ + + + + +LevelException (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class LevelException

+
+
java.lang.Object +
java.lang.Throwable +
java.lang.Exception +
edu.uoc.pacman.model.exceptions.LevelException
+
+
+
+
+
+
All Implemented Interfaces:
+
Serializable
+
+
+
public class LevelException +extends Exception
+
Level Exception class.
+ In order to know the text of each message, please click on the "Constant Field Values" link + that you'll find in the description of each constant.
+
+
See Also:
+
+ +
+
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      PARSING_LEVEL_FILE_ERROR

      +
      public static final String PARSING_LEVEL_FILE_ERROR
      +
      Error message when there is an error while parsing/loading the level configuration file.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      PICKABLE_ERROR

      +
      public static final String PICKABLE_ERROR
      +
      Error message when there are not any dot or energizer.
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      SIZE_ERROR

      +
      public static final String SIZE_ERROR
      +
      Error message when the size of the board does not meet the minimum
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      GHOSTS_ERROR

      +
      public static final String GHOSTS_ERROR
      +
      Error message when there isn't any ghost
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      LevelException

      +
      public LevelException(String message)
      +
      Constructor with argument.
      +
      +
      Parameters:
      +
      message - Text that is displayed when the exception is thrown.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/exceptions/package-summary.html b/core/docs/edu/uoc/pacman/model/exceptions/package-summary.html new file mode 100644 index 0000000..b0ef678 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/exceptions/package-summary.html @@ -0,0 +1,100 @@ + + + + +edu.uoc.pacman.model.exceptions (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model.exceptions

+
+
+
package edu.uoc.pacman.model.exceptions
+
+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/exceptions/package-tree.html b/core/docs/edu/uoc/pacman/model/exceptions/package-tree.html new file mode 100644 index 0000000..94c7341 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/exceptions/package-tree.html @@ -0,0 +1,78 @@ + + + + +edu.uoc.pacman.model.exceptions Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model.exceptions

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/package-summary.html b/core/docs/edu/uoc/pacman/model/package-summary.html new file mode 100644 index 0000000..59ad526 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/package-summary.html @@ -0,0 +1,98 @@ + + + + +edu.uoc.pacman.model (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model

+
+
+
package edu.uoc.pacman.model
+
+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/package-tree.html b/core/docs/edu/uoc/pacman/model/package-tree.html new file mode 100644 index 0000000..e010d36 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/package-tree.html @@ -0,0 +1,70 @@ + + + + +edu.uoc.pacman.model Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/utils/Direction.html b/core/docs/edu/uoc/pacman/model/utils/Direction.html new file mode 100644 index 0000000..fac698e --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/utils/Direction.html @@ -0,0 +1,433 @@ + + + + +Direction (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Enum Class Direction

+
+
java.lang.Object +
java.lang.Enum<Direction> +
edu.uoc.pacman.model.utils.Direction
+
+
+
+
+
All Implemented Interfaces:
+
Serializable, Comparable<Direction>, Constable
+
+
+
public enum Direction +extends Enum<Direction>
+
Direction that Pacman and ghosts face.
+ RESPECT The order of the values: RIGHT, DOWN, LEFT, UP. +
+ The methods valueOf(String name) and values() are provided by Java Enumeration. + You don't have to create them!!
+
+
+
    + +
  • +
    +

    Nested Class Summary

    +
    +

    Nested classes/interfaces inherited from class java.lang.Enum

    +Enum.EnumDesc<E extends Enum<E>>
    +
    +
  • + +
  • +
    +

    Enum Constant Summary

    +
    Enum Constants
    +
    +
    Enum Constant
    +
    Description
    + +
    +
    DOWN direction. x = 0, y = 1 and keyCode = 20.
    +
    + +
    +
    LEFT direction. x = -1, y = 0 and keyCode = 21.
    +
    + +
    +
    RIGHT direction. x = 1, y = 0 and keyCode = 22.
    +
    + +
    +
    UP direction. x = 0, y = -1 and keyCode = 19.
    +
    +
    +
    +
  • + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private final int
    + +
    +
    Intenger value that is given by libgdx + to a key pressed by the user
    +
    +
    private final int
    + +
    +
    Offset in X axis
    +
    +
    private final int
    + +
    +
    Offset in Y axis
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Modifier
    +
    Constructor
    +
    Description
    +
    private
    +
    Direction(int x, + int y, + int keyCode)
    +
     
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    static Direction
    +
    getDirectionByKeyCode(int keyCode)
    +
    +
    Given the value of keyCode, + it returns the corresponding Direction value.
    +
    +
    int
    + +
    +
    Getter of the attibute keyCode
    +
    +
    int
    + +
    +
    Getter of the attibute x
    +
    +
    int
    + +
    +
    Getter of the attibute y
    +
    + + +
    +
    Gets the opposite direction of the + direction that invokes this method.
    +
    +
    static Direction
    + +
    +
    Returns the enum constant of this class with the specified name.
    +
    +
    static Direction[]
    + +
    +
    Returns an array containing the constants of this enum class, in +the order they are declared.
    +
    +
    +
    +
    + +
    +

    Methods inherited from class java.lang.Object

    +getClass, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Enum Constant Details

    +
      +
    • + +
    • +
    • +
      +

      DOWN

      +
      public static final Direction DOWN
      +
      DOWN direction. x = 0, y = 1 and keyCode = 20.
      +
      +
    • +
    • +
      +

      LEFT

      +
      public static final Direction LEFT
      +
      LEFT direction. x = -1, y = 0 and keyCode = 21.
      +
      +
    • +
    • +
      +

      UP

      +
      public static final Direction UP
      +
      UP direction. x = 0, y = -1 and keyCode = 19.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      x

      +
      private final int x
      +
      Offset in X axis
      +
      +
    • +
    • +
      +

      y

      +
      private final int y
      +
      Offset in Y axis
      +
      +
    • +
    • +
      +

      keyCode

      +
      private final int keyCode
      +
      Intenger value that is given by libgdx + to a key pressed by the user
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Direction

      +
      private Direction(int x, + int y, + int keyCode)
      +
      +
      Parameters:
      +
      x - Value of the attribute x
      +
      y - Value of the attribute y
      +
      keyCode - Value of the attribute keyCode
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      values

      +
      public static Direction[] values()
      +
      Returns an array containing the constants of this enum class, in +the order they are declared.
      +
      +
      Returns:
      +
      an array containing the constants of this enum class, in the order they are declared
      +
      +
      +
    • +
    • +
      +

      valueOf

      +
      public static Direction valueOf(String name)
      +
      Returns the enum constant of this class with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this class. (Extraneous whitespace characters are +not permitted.)
      +
      +
      Parameters:
      +
      name - the name of the enum constant to be returned.
      +
      Returns:
      +
      the enum constant with the specified name
      +
      Throws:
      +
      IllegalArgumentException - if this enum class has no constant with the specified name
      +
      NullPointerException - if the argument is null
      +
      +
      +
    • +
    • +
      +

      getX

      +
      public int getX()
      +
      Getter of the attibute x
      +
      +
      Returns:
      +
      The value of the attribute x
      +
      +
      +
    • +
    • +
      +

      getY

      +
      public int getY()
      +
      Getter of the attibute y
      +
      +
      Returns:
      +
      The value of the attribute y
      +
      +
      +
    • +
    • +
      +

      getKeyCode

      +
      public int getKeyCode()
      +
      Getter of the attibute keyCode
      +
      +
      Returns:
      +
      The value of the attribute keyCode
      +
      +
      +
    • +
    • +
      +

      getDirectionByKeyCode

      +
      public static Direction getDirectionByKeyCode(int keyCode)
      +
      Given the value of keyCode, + it returns the corresponding Direction value.
      +
      +
      Parameters:
      +
      keyCode - Integer value of a key.
      +
      Returns:
      +
      The Direction value linked to keyCode. + If any, then returns null.
      +
      +
      +
    • +
    • +
      +

      opposite

      +
      public Direction opposite()
      +
      Gets the opposite direction of the + direction that invokes this method.
      +
      +
      Returns:
      +
      Opposite direction to the current direction.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/utils/Position.html b/core/docs/edu/uoc/pacman/model/utils/Position.html new file mode 100644 index 0000000..e8fdf27 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/utils/Position.html @@ -0,0 +1,371 @@ + + + + +Position (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class Position

+
+
java.lang.Object +
edu.uoc.pacman.model.utils.Position
+
+
+
+
public class Position +extends Object
+
Stores a 2D position/point/coordinate.
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private int
    + +
    +
    Value of the attribute X axis
    +
    +
    private int
    + +
    +
    Value of the attribute Y axis
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    Position(int x, + int y)
    +
    +
    Constructor with arguments.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    static Position
    +
    add(Position p1, + Position p2)
    +
    +
    Creates a new Position object as a result to add p1 and p2.
    +
    +
    double
    + +
    +
    Calculates the Euclidean distance from this point to other given point.
    +
    +
    boolean
    +
    equals(Object other)
    +
    +
    Checks if two positions are equal.
    +
    +
    int
    + +
    +
    Getter of the attribute x
    +
    +
    int
    + +
    +
    Getter of the attribute y
    +
    +
    int
    + +
    +
    Returns the hash of a Position object.
    +
    +
    void
    +
    setX(int x)
    +
    +
    Setter of the attribute x
    +
    +
    void
    +
    setY(int y)
    +
    +
    Setter of the attribute y
    +
    + + +
    +
    Returns a comma-seperated string representation of a Position.
    + Format: "x,y"
    + Example: "3,4"
    +
    +
    +
    +
    +
    +

    Methods inherited from class java.lang.Object

    +clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      x

      +
      private int x
      +
      Value of the attribute X axis
      +
      +
    • +
    • +
      +

      y

      +
      private int y
      +
      Value of the attribute Y axis
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Position

      +
      public Position(int x, + int y)
      +
      Constructor with arguments.
      +
      +
      Parameters:
      +
      x - Initial value of the attribute x
      +
      y - Initial value of the attribute y
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      getX

      +
      public int getX()
      +
      Getter of the attribute x
      +
      +
      Returns:
      +
      The current value of the attribute x
      +
      +
      +
    • +
    • +
      +

      setX

      +
      public void setX(int x)
      +
      Setter of the attribute x
      +
      +
      Parameters:
      +
      x - New value for the attribute x
      +
      +
      +
    • +
    • +
      +

      getY

      +
      public int getY()
      +
      Getter of the attribute y
      +
      +
      Returns:
      +
      The current value of the attribute y
      +
      +
      +
    • +
    • +
      +

      setY

      +
      public void setY(int y)
      +
      Setter of the attribute y
      +
      +
      Parameters:
      +
      y - New value for the attribute y
      +
      +
      +
    • +
    • +
      +

      distance

      +
      public double distance(Position other)
      +
      Calculates the Euclidean distance from this point to other given point.
      +
      +
      Parameters:
      +
      other - Second position to calculate distance.
      +
      Returns:
      +
      The Euclidean distance between the position which invokes the method + and the other position. If other is null, then it returns 0.
      +
      +
      +
    • +
    • +
      +

      add

      +
      public static Position add(Position p1, + Position p2) + throws NullPointerException
      +
      Creates a new Position object as a result to add p1 and p2.
      +
      +
      Parameters:
      +
      p1 - First position
      +
      p2 - Second position
      +
      Returns:
      +
      New Position with x = p1.x + p2.x and y = p1.y and p2.y.
      +
      Throws:
      +
      NullPointerException - When either p1 or p2 are null.
      +
      +
      +
    • +
    • +
      +

      equals

      +
      public boolean equals(Object other)
      +
      Checks if two positions are equal.
      +
      +
      Overrides:
      +
      equals in class Object
      +
      Parameters:
      +
      other - object to compare against.
      +
      Returns:
      +
      true if the type of other is Position + and x == this.x and also y == this.y, false otherwise.
      +
      +
      +
    • +
    • +
      +

      hashCode

      +
      public int hashCode()
      +
      Returns the hash of a Position object.
      +
      +
      Overrides:
      +
      hashCode in class Object
      +
      Returns:
      +
      The result of applying Objects.hash on x and y.
      +
      +
      +
    • +
    • +
      +

      toString

      +
      public String toString()
      +
      Returns a comma-seperated string representation of a Position.
      + Format: "x,y"
      + Example: "3,4"
      +
      +
      Overrides:
      +
      toString in class Object
      +
      Returns:
      +
      "x,y"
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/utils/Sprite.html b/core/docs/edu/uoc/pacman/model/utils/Sprite.html new file mode 100644 index 0000000..9b4e9d5 --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/utils/Sprite.html @@ -0,0 +1,459 @@ + + + + +Sprite (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Enum Class Sprite

+
+
java.lang.Object +
java.lang.Enum<Sprite> +
edu.uoc.pacman.model.utils.Sprite
+
+
+
+
+
All Implemented Interfaces:
+
Serializable, Comparable<Sprite>, Constable
+
+
+
public enum Sprite +extends Enum<Sprite>
+
Sprite that stores the configuration file symbol and the image's path.
+
+
+
    + +
  • +
    +

    Nested Class Summary

    +
    +

    Nested classes/interfaces inherited from class java.lang.Enum

    +Enum.EnumDesc<E extends Enum<E>>
    +
    +
  • + +
  • +
    +

    Enum Constant Summary

    +
    Enum Constants
    +
    +
    Enum Constant
    +
    Description
    + +
    +
    Sprite for a Blinky ghost.
    +
    + +
    +
    Sprite for a Clyde ghost.
    +
    + +
    +
    Sprite for a dot.
    +
    + +
    +
    Sprite for an energizer.
    +
    + +
    +
    Sprite for an Inky ghost.
    +
    + +
    +
    Sprite for a life.
    +
    + +
    +
    Sprite when Pacman is facing down.
    +
    + +
    +
    Sprite when Pacman is facing left.
    +
    + +
    +
    Sprite when Pacman is facing right.
    +
    + +
    +
    Sprite when Pacman is facing up.
    +
    + +
    +
    Sprite for a piece of path.
    +
    + +
    +
    Sprite for a Pinky ghost.
    +
    + +
    +
    Sprite for a wall.
    +
    +
    +
    +
  • + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    private final String
    + +
    +
    Value of the image path.
    +
    +
    private final char
    + +
    +
    Value in the configuration file.
    +
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Modifier
    +
    Constructor
    +
    Description
    +
    private
    +
    Sprite(char symbol, + String imageSrc)
    +
    +
    Constructor with arguments.
    +
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    + + +
    +
    Getter of the attribute imageSrc.
    +
    +
    char
    + +
    +
    Getter of the attribute symbol.
    +
    +
    static Sprite
    + +
    +
    Returns the enum constant of this class with the specified name.
    +
    +
    static Sprite[]
    + +
    +
    Returns an array containing the constants of this enum class, in +the order they are declared.
    +
    +
    +
    +
    + +
    +

    Methods inherited from class java.lang.Object

    +getClass, notify, notifyAll, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Enum Constant Details

    +
      +
    • +
      +

      PACMAN_RIGHT

      +
      public static final Sprite PACMAN_RIGHT
      +
      Sprite when Pacman is facing right.
      +
      +
    • +
    • +
      +

      PACMAN_LEFT

      +
      public static final Sprite PACMAN_LEFT
      +
      Sprite when Pacman is facing left.
      +
      +
    • +
    • +
      +

      PACMAN_UP

      +
      public static final Sprite PACMAN_UP
      +
      Sprite when Pacman is facing up.
      +
      +
    • +
    • +
      +

      PACMAN_DOWN

      +
      public static final Sprite PACMAN_DOWN
      +
      Sprite when Pacman is facing down.
      +
      +
    • +
    • +
      +

      BLINKY

      +
      public static final Sprite BLINKY
      +
      Sprite for a Blinky ghost.
      +
      +
    • +
    • +
      +

      PINKY

      +
      public static final Sprite PINKY
      +
      Sprite for a Pinky ghost.
      +
      +
    • +
    • +
      +

      INKY

      +
      public static final Sprite INKY
      +
      Sprite for an Inky ghost.
      +
      +
    • +
    • +
      +

      CLYDE

      +
      public static final Sprite CLYDE
      +
      Sprite for a Clyde ghost.
      +
      +
    • +
    • +
      +

      DOT

      +
      public static final Sprite DOT
      +
      Sprite for a dot.
      +
      +
    • +
    • +
      +

      ENERGIZER

      +
      public static final Sprite ENERGIZER
      +
      Sprite for an energizer.
      +
      +
    • +
    • +
      +

      WALL

      +
      public static final Sprite WALL
      +
      Sprite for a wall.
      +
      +
    • +
    • +
      +

      PATH

      +
      public static final Sprite PATH
      +
      Sprite for a piece of path.
      +
      +
    • +
    • +
      +

      LIFE

      +
      public static final Sprite LIFE
      +
      Sprite for a life.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      symbol

      +
      private final char symbol
      +
      Value in the configuration file.
      +
      +
    • +
    • +
      +

      imageSrc

      +
      private final String imageSrc
      +
      Value of the image path.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      Sprite

      +
      private Sprite(char symbol, + String imageSrc)
      +
      Constructor with arguments.
      +
      +
      Parameters:
      +
      symbol - Value of the configuration file symbol.
      +
      imageSrc - Value of the image path.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      values

      +
      public static Sprite[] values()
      +
      Returns an array containing the constants of this enum class, in +the order they are declared.
      +
      +
      Returns:
      +
      an array containing the constants of this enum class, in the order they are declared
      +
      +
      +
    • +
    • +
      +

      valueOf

      +
      public static Sprite valueOf(String name)
      +
      Returns the enum constant of this class with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this class. (Extraneous whitespace characters are +not permitted.)
      +
      +
      Parameters:
      +
      name - the name of the enum constant to be returned.
      +
      Returns:
      +
      the enum constant with the specified name
      +
      Throws:
      +
      IllegalArgumentException - if this enum class has no constant with the specified name
      +
      NullPointerException - if the argument is null
      +
      +
      +
    • +
    • +
      +

      getSymbol

      +
      public char getSymbol()
      +
      Getter of the attribute symbol.
      +
      +
      Returns:
      +
      Current value of the attribute symbol.
      +
      +
      +
    • +
    • +
      +

      getImageSrc

      +
      public String getImageSrc()
      +
      Getter of the attribute imageSrc.
      +
      +
      Returns:
      +
      Current value of the attribute imageSrc.
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/utils/package-summary.html b/core/docs/edu/uoc/pacman/model/utils/package-summary.html new file mode 100644 index 0000000..31e4e3c --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/utils/package-summary.html @@ -0,0 +1,113 @@ + + + + +edu.uoc.pacman.model.utils (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.model.utils

+
+
+
package edu.uoc.pacman.model.utils
+
+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/model/utils/package-tree.html b/core/docs/edu/uoc/pacman/model/utils/package-tree.html new file mode 100644 index 0000000..bb924bb --- /dev/null +++ b/core/docs/edu/uoc/pacman/model/utils/package-tree.html @@ -0,0 +1,85 @@ + + + + +edu.uoc.pacman.model.utils Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.model.utils

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+
+

Enum Class Hierarchy

+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/view/GameOverScreen.html b/core/docs/edu/uoc/pacman/view/GameOverScreen.html new file mode 100644 index 0000000..68b63fd --- /dev/null +++ b/core/docs/edu/uoc/pacman/view/GameOverScreen.html @@ -0,0 +1,284 @@ + + + + +GameOverScreen (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class GameOverScreen

+
+
java.lang.Object +
edu.uoc.pacman.view.GameOverScreen
+
+
+
+
All Implemented Interfaces:
+
com.badlogic.gdx.Screen
+
+
+
public class GameOverScreen +extends Object +implements com.badlogic.gdx.Screen
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      game

      +
      final PacmanGame game
      +
      +
    • +
    • +
      +

      camera

      +
      com.badlogic.gdx.graphics.OrthographicCamera camera
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      GameOverScreen

      +
      public GameOverScreen(PacmanGame game)
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      show

      +
      public void show()
      +
      +
      Specified by:
      +
      show in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      render

      +
      public void render(float delta)
      +
      +
      Specified by:
      +
      render in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      resize

      +
      public void resize(int width, + int height)
      +
      +
      Specified by:
      +
      resize in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      pause

      +
      public void pause()
      +
      +
      Specified by:
      +
      pause in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      resume

      +
      public void resume()
      +
      +
      Specified by:
      +
      resume in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      hide

      +
      public void hide()
      +
      +
      Specified by:
      +
      hide in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      dispose

      +
      public void dispose()
      +
      +
      Specified by:
      +
      dispose in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/view/GameScreen.html b/core/docs/edu/uoc/pacman/view/GameScreen.html new file mode 100644 index 0000000..2751ac7 --- /dev/null +++ b/core/docs/edu/uoc/pacman/view/GameScreen.html @@ -0,0 +1,300 @@ + + + + +GameScreen (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class GameScreen

+
+
java.lang.Object +
edu.uoc.pacman.view.GameScreen
+
+
+
+
All Implemented Interfaces:
+
com.badlogic.gdx.Screen
+
+
+
public class GameScreen +extends Object +implements com.badlogic.gdx.Screen
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      game

      +
      private final PacmanGame game
      +
      +
    • +
    • +
      +

      gameController

      +
      private final Game gameController
      +
      +
    • +
    • +
      +

      loaded

      +
      boolean loaded
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    + +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      show

      +
      public void show()
      +
      +
      Specified by:
      +
      show in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      render

      +
      public void render(float delta)
      +
      +
      Specified by:
      +
      render in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      resize

      +
      public void resize(int width, + int height)
      +
      +
      Specified by:
      +
      resize in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      pause

      +
      public void pause()
      +
      +
      Specified by:
      +
      pause in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      resume

      +
      public void resume()
      +
      +
      Specified by:
      +
      resume in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      hide

      +
      public void hide()
      +
      +
      Specified by:
      +
      hide in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      dispose

      +
      public void dispose()
      +
      +
      Specified by:
      +
      dispose in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/view/InterLevelsScreen.html b/core/docs/edu/uoc/pacman/view/InterLevelsScreen.html new file mode 100644 index 0000000..ae6cfb0 --- /dev/null +++ b/core/docs/edu/uoc/pacman/view/InterLevelsScreen.html @@ -0,0 +1,284 @@ + + + + +InterLevelsScreen (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class InterLevelsScreen

+
+
java.lang.Object +
edu.uoc.pacman.view.InterLevelsScreen
+
+
+
+
All Implemented Interfaces:
+
com.badlogic.gdx.Screen
+
+
+
public class InterLevelsScreen +extends Object +implements com.badlogic.gdx.Screen
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      game

      +
      final PacmanGame game
      +
      +
    • +
    • +
      +

      camera

      +
      com.badlogic.gdx.graphics.OrthographicCamera camera
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      InterLevelsScreen

      +
      public InterLevelsScreen(PacmanGame game)
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      show

      +
      public void show()
      +
      +
      Specified by:
      +
      show in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      render

      +
      public void render(float delta)
      +
      +
      Specified by:
      +
      render in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      resize

      +
      public void resize(int width, + int height)
      +
      +
      Specified by:
      +
      resize in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      pause

      +
      public void pause()
      +
      +
      Specified by:
      +
      pause in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      resume

      +
      public void resume()
      +
      +
      Specified by:
      +
      resume in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      hide

      +
      public void hide()
      +
      +
      Specified by:
      +
      hide in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      dispose

      +
      public void dispose()
      +
      +
      Specified by:
      +
      dispose in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/view/PacmanGame.html b/core/docs/edu/uoc/pacman/view/PacmanGame.html new file mode 100644 index 0000000..51bd1b7 --- /dev/null +++ b/core/docs/edu/uoc/pacman/view/PacmanGame.html @@ -0,0 +1,472 @@ + + + + +PacmanGame (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class PacmanGame

+
+
java.lang.Object +
com.badlogic.gdx.Game +
edu.uoc.pacman.view.PacmanGame
+
+
+
+
+
All Implemented Interfaces:
+
com.badlogic.gdx.ApplicationListener
+
+
+
public class PacmanGame +extends com.badlogic.gdx.Game
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    static com.badlogic.gdx.assets.AssetManager
    + +
     
    +
    (package private) com.badlogic.gdx.graphics.g2d.SpriteBatch
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static final int
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    (package private) com.badlogic.gdx.graphics.g2d.BitmapFont
    + +
     
    +
    (package private) Game
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    +
    static final int
    + +
     
    +
    static final int
    + +
     
    +
    +
    +

    Fields inherited from class com.badlogic.gdx.Game

    +screen
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    + +
     
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    void
    + +
     
    +
    void
    + +
     
    +
    (package private) void
    +
    drawImage(Sprite sprite, + int x, + int y)
    +
     
    +
    (package private) com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture>
    + +
     
    + + +
     
    +
    void
    + +
     
    +
    void
    + +
     
    +
    +
    +
    +
    +

    Methods inherited from class com.badlogic.gdx.Game

    +getScreen, pause, resize, resume, setScreen
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      WINDOW_WIDTH

      +
      public static final int WINDOW_WIDTH
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      WINDOW_HEIGHT

      +
      public static final int WINDOW_HEIGHT
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    • +
      +

      batch

      +
      com.badlogic.gdx.graphics.g2d.SpriteBatch batch
      +
      +
    • +
    • +
      +

      gameController

      +
      Game gameController
      +
      +
    • +
    • +
      +

      pacmanRightAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> pacmanRightAsset
      +
      +
    • +
    • +
      +

      pacmanLeftAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> pacmanLeftAsset
      +
      +
    • +
    • +
      +

      pacmanUpAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> pacmanUpAsset
      +
      +
    • +
    • +
      +

      pacmanDownAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> pacmanDownAsset
      +
      +
    • +
    • +
      +

      blinkyAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> blinkyAsset
      +
      +
    • +
    • +
      +

      inkyAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> inkyAsset
      +
      +
    • +
    • +
      +

      pinkyAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> pinkyAsset
      +
      +
    • +
    • +
      +

      clydeAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> clydeAsset
      +
      +
    • +
    • +
      +

      dotAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> dotAsset
      +
      +
    • +
    • +
      +

      energizerAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> energizerAsset
      +
      +
    • +
    • +
      +

      wallAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> wallAsset
      +
      +
    • +
    • +
      +

      pathAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> pathAsset
      +
      +
    • +
    • +
      +

      lifeAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> lifeAsset
      +
      +
    • +
    • +
      +

      logoAsset

      +
      public static com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> logoAsset
      +
      +
    • +
    • +
      +

      assetManager

      +
      public static com.badlogic.gdx.assets.AssetManager assetManager
      +
      +
    • +
    • +
      +

      font

      +
      com.badlogic.gdx.graphics.g2d.BitmapFont font
      +
      +
    • +
    • +
      +

      CELL_SIZE

      +
      public static final int CELL_SIZE
      +
      +
      See Also:
      +
      + +
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      PacmanGame

      +
      public PacmanGame()
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      create

      +
      public void create()
      +
      +
    • +
    • +
      +

      dispose

      +
      public void dispose()
      +
      +
      Specified by:
      +
      dispose in interface com.badlogic.gdx.ApplicationListener
      +
      Overrides:
      +
      dispose in class com.badlogic.gdx.Game
      +
      +
      +
    • +
    • +
      +

      render

      +
      public void render()
      +
      +
      Specified by:
      +
      render in interface com.badlogic.gdx.ApplicationListener
      +
      Overrides:
      +
      render in class com.badlogic.gdx.Game
      +
      +
      +
    • +
    • +
      +

      loadImages

      +
      public void loadImages()
      +
      +
    • +
    • +
      +

      getAssertBySprite

      +
      com.badlogic.gdx.assets.AssetDescriptor<com.badlogic.gdx.graphics.Texture> getAssertBySprite(Sprite sprite)
      +
      +
    • +
    • +
      +

      drawImage

      +
      void drawImage(Sprite sprite, + int x, + int y)
      +
      +
    • +
    • +
      +

      getGameController

      +
      public Game getGameController()
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/view/UserInputProcessor.html b/core/docs/edu/uoc/pacman/view/UserInputProcessor.html new file mode 100644 index 0000000..e4fb24f --- /dev/null +++ b/core/docs/edu/uoc/pacman/view/UserInputProcessor.html @@ -0,0 +1,216 @@ + + + + +UserInputProcessor (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class UserInputProcessor

+
+
java.lang.Object +
com.badlogic.gdx.InputAdapter +
edu.uoc.pacman.view.UserInputProcessor
+
+
+
+
+
All Implemented Interfaces:
+
com.badlogic.gdx.InputProcessor
+
+
+
public class UserInputProcessor +extends com.badlogic.gdx.InputAdapter
+
+
+
    + +
  • +
    +

    Field Summary

    +
    Fields
    +
    +
    Modifier and Type
    +
    Field
    +
    Description
    +
    (package private) Game
    + +
     
    +
    +
    +
  • + +
  • +
    +

    Constructor Summary

    +
    Constructors
    +
    +
    Constructor
    +
    Description
    +
    UserInputProcessor(Game gameController)
    +
     
    +
    +
    +
  • + +
  • +
    +

    Method Summary

    +
    +
    +
    +
    +
    Modifier and Type
    +
    Method
    +
    Description
    +
    boolean
    +
    keyDown(int keycode)
    +
     
    +
    boolean
    +
    keyUp(int keycode)
    +
     
    +
    +
    +
    +
    +

    Methods inherited from class com.badlogic.gdx.InputAdapter

    +keyTyped, mouseMoved, scrolled, touchDown, touchDragged, touchUp
    +
    +

    Methods inherited from class java.lang.Object

    +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    +
    +
  • +
+
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      gameController

      +
      Game gameController
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      UserInputProcessor

      +
      public UserInputProcessor(Game gameController)
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      keyDown

      +
      public boolean keyDown(int keycode)
      +
      +
      Specified by:
      +
      keyDown in interface com.badlogic.gdx.InputProcessor
      +
      Overrides:
      +
      keyDown in class com.badlogic.gdx.InputAdapter
      +
      +
      +
    • +
    • +
      +

      keyUp

      +
      public boolean keyUp(int keycode)
      +
      +
      Specified by:
      +
      keyUp in interface com.badlogic.gdx.InputProcessor
      +
      Overrides:
      +
      keyUp in class com.badlogic.gdx.InputAdapter
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/view/WelcomeScreen.html b/core/docs/edu/uoc/pacman/view/WelcomeScreen.html new file mode 100644 index 0000000..4d80fdd --- /dev/null +++ b/core/docs/edu/uoc/pacman/view/WelcomeScreen.html @@ -0,0 +1,284 @@ + + + + +WelcomeScreen (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+ +

Class WelcomeScreen

+
+
java.lang.Object +
edu.uoc.pacman.view.WelcomeScreen
+
+
+
+
All Implemented Interfaces:
+
com.badlogic.gdx.Screen
+
+
+
public class WelcomeScreen +extends Object +implements com.badlogic.gdx.Screen
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      game

      +
      final PacmanGame game
      +
      +
    • +
    • +
      +

      camera

      +
      com.badlogic.gdx.graphics.OrthographicCamera camera
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      WelcomeScreen

      +
      public WelcomeScreen(PacmanGame game)
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      show

      +
      public void show()
      +
      +
      Specified by:
      +
      show in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      render

      +
      public void render(float delta)
      +
      +
      Specified by:
      +
      render in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      resize

      +
      public void resize(int width, + int height)
      +
      +
      Specified by:
      +
      resize in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      pause

      +
      public void pause()
      +
      +
      Specified by:
      +
      pause in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      resume

      +
      public void resume()
      +
      +
      Specified by:
      +
      resume in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      hide

      +
      public void hide()
      +
      +
      Specified by:
      +
      hide in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    • +
      +

      dispose

      +
      public void dispose()
      +
      +
      Specified by:
      +
      dispose in interface com.badlogic.gdx.Screen
      +
      +
      +
    • +
    +
    +
  • +
+
+ +
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/view/package-summary.html b/core/docs/edu/uoc/pacman/view/package-summary.html new file mode 100644 index 0000000..579e18a --- /dev/null +++ b/core/docs/edu/uoc/pacman/view/package-summary.html @@ -0,0 +1,91 @@ + + + + +edu.uoc.pacman.view (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Package edu.uoc.pacman.view

+
+
+
package edu.uoc.pacman.view
+
+ +
+
+
+
+ + diff --git a/core/docs/edu/uoc/pacman/view/package-tree.html b/core/docs/edu/uoc/pacman/view/package-tree.html new file mode 100644 index 0000000..43afc3b --- /dev/null +++ b/core/docs/edu/uoc/pacman/view/package-tree.html @@ -0,0 +1,83 @@ + + + + +edu.uoc.pacman.view Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package edu.uoc.pacman.view

+Package Hierarchies: + +
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • com.badlogic.gdx.Game (implements com.badlogic.gdx.ApplicationListener) + +
    • +
    • edu.uoc.pacman.view.GameOverScreen (implements com.badlogic.gdx.Screen)
    • +
    • edu.uoc.pacman.view.GameScreen (implements com.badlogic.gdx.Screen)
    • +
    • com.badlogic.gdx.InputAdapter (implements com.badlogic.gdx.InputProcessor) + +
    • +
    • edu.uoc.pacman.view.InterLevelsScreen (implements com.badlogic.gdx.Screen)
    • +
    • edu.uoc.pacman.view.WelcomeScreen (implements com.badlogic.gdx.Screen)
    • +
    +
  • +
+
+
+
+
+ + diff --git a/core/docs/element-list b/core/docs/element-list new file mode 100644 index 0000000..feffe67 --- /dev/null +++ b/core/docs/element-list @@ -0,0 +1,11 @@ +edu.uoc.pacman.controller +edu.uoc.pacman.model +edu.uoc.pacman.model.entities +edu.uoc.pacman.model.entities.characters +edu.uoc.pacman.model.entities.characters.ghosts +edu.uoc.pacman.model.entities.characters.ghosts.chase +edu.uoc.pacman.model.entities.characters.pacman +edu.uoc.pacman.model.entities.items +edu.uoc.pacman.model.exceptions +edu.uoc.pacman.model.utils +edu.uoc.pacman.view diff --git a/core/docs/help-doc.html b/core/docs/help-doc.html new file mode 100644 index 0000000..2285cd4 --- /dev/null +++ b/core/docs/help-doc.html @@ -0,0 +1,185 @@ + + + + +API Help (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+

JavaDoc Help

+ +
+
+

Navigation

+Starting from the Overview page, you can browse the documentation using the links in each page, and in the navigation bar at the top of each page. The Index and Search box allow you to navigate to specific declarations and summary pages, including: All Packages, All Classes and Interfaces + +
+
+
+

Kinds of Pages

+The following sections describe the different kinds of pages in this collection. +
+

Overview

+

The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

+
+
+

Package

+

Each package has a page that contains a list of its classes and interfaces, with a summary for each. These pages may contain the following categories:

+
    +
  • Interfaces
  • +
  • Classes
  • +
  • Enum Classes
  • +
  • Exceptions
  • +
  • Errors
  • +
  • Annotation Interfaces
  • +
+
+
+

Class or Interface

+

Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a declaration and description, member summary tables, and detailed member descriptions. Entries in each of these sections are omitted if they are empty or not applicable.

+
    +
  • Class Inheritance Diagram
  • +
  • Direct Subclasses
  • +
  • All Known Subinterfaces
  • +
  • All Known Implementing Classes
  • +
  • Class or Interface Declaration
  • +
  • Class or Interface Description
  • +
+
+
    +
  • Nested Class Summary
  • +
  • Enum Constant Summary
  • +
  • Field Summary
  • +
  • Property Summary
  • +
  • Constructor Summary
  • +
  • Method Summary
  • +
  • Required Element Summary
  • +
  • Optional Element Summary
  • +
+
+
    +
  • Enum Constant Details
  • +
  • Field Details
  • +
  • Property Details
  • +
  • Constructor Details
  • +
  • Method Details
  • +
  • Element Details
  • +
+

Note: Annotation interfaces have required and optional elements, but not methods. Only enum classes have enum constants. The components of a record class are displayed as part of the declaration of the record class. Properties are a feature of JavaFX.

+

The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

+
+
+

Other Files

+

Packages and modules may contain pages with additional information related to the declarations nearby.

+
+
+

Tree (Class Hierarchy)

+

There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. Classes are organized by inheritance structure starting with java.lang.Object. Interfaces do not inherit from java.lang.Object.

+
    +
  • When viewing the Overview page, clicking on TREE displays the hierarchy for all packages.
  • +
  • When viewing a particular package, class or interface page, clicking on TREE displays the hierarchy for only that package.
  • +
+
+
+

Constant Field Values

+

The Constant Field Values page lists the static final fields and their values.

+
+
+

Serialized Form

+

Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to those who implement rather than use the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See Also" section of the class description.

+
+
+

All Packages

+

The All Packages page contains an alphabetic index of all packages contained in the documentation.

+
+
+

All Classes and Interfaces

+

The All Classes and Interfaces page contains an alphabetic index of all classes and interfaces contained in the documentation, including annotation interfaces, enum classes, and record classes.

+
+
+

Index

+

The Index contains an alphabetic index of all classes, interfaces, constructors, methods, and fields in the documentation, as well as summary pages such as All Packages, All Classes and Interfaces.

+
+
+
+This help file applies to API documentation generated by the standard doclet.
+
+
+ + diff --git a/core/docs/index-all.html b/core/docs/index-all.html new file mode 100644 index 0000000..3e26ba9 --- /dev/null +++ b/core/docs/index-all.html @@ -0,0 +1,1491 @@ + + + + +Index (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+
+

Index

+
+A B C D E F G H I K L M N O P R S T U V W X Y 
All Classes and Interfaces|All Packages|Constant Field Values|Serialized Form +

A

+
+
add(Position, Position) - Static method in class edu.uoc.pacman.model.utils.Position
+
+
Creates a new Position object as a result to add p1 and p2.
+
+
addMapItem(MapItem) - Method in class edu.uoc.pacman.model.Level
+
+
Adds item to the mapItemList as long as item is not null.
+
+
addPoints(int) - Method in class edu.uoc.pacman.model.Level
+
+
Add the value of points to the attribute score as long as points is greater than 0.
+
+
alive() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Sets the attribute dead to false.
+
+
assetManager - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
+

B

+
+
batch - Variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
behaviour - Variable in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Behaviour in which the ghost is.
+
+
Behaviour - Enum Class in edu.uoc.pacman.model.entities.characters.ghosts
+
+
Behaviour defines the different behaviour which a ghost can be in.
+
+
Behaviour(int) - Constructor for enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Constructor with arguments.
+
+
Blinky - Class in edu.uoc.pacman.model.entities.characters.ghosts
+
+
Represents a Blinky (red) ghost.
+
+
Blinky(Position, Direction, Behaviour, Level) - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.Blinky
+
+
Constructor with arguments.
+ The value of the scatterPosition is (level.WIDTH,-1).
+ The value of the sprite is Sprite.BLINKY.
+ It assigns to chaseBehaviour a ChaseAggressive object.
+
+
BLINKY - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for a Blinky ghost.
+
+
blinkyAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
+

C

+
+
camera - Variable in class edu.uoc.pacman.view.GameOverScreen
+
 
+
camera - Variable in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
camera - Variable in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
CELL_SIZE - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
Character - Class in edu.uoc.pacman.model.entities.characters
+
+
A character is any entity that is able to move and hit.
+
+
Character(Position, Direction, Sprite, Level) - Constructor for class edu.uoc.pacman.model.entities.characters.Character
+
+
Creates a character at the given position facing in the given direction.
+ Any character is pathable.
+ If the position is null, then the position will be (0,0).
+ Take into consideration that the value of the parameter position is also + the start/initial position of the character.
+ If the direction is null, then the direction will be UP.
+ By default, any character is alive.
+
+
CHASE - Enum constant in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Behaviour where the ghosts chase Pacman.
+
+
ChaseAggressive - Class in edu.uoc.pacman.model.entities.characters.ghosts.chase
+
+
It implements the ChaseBehaviour interface according to an aggressive behaviour.
+ Its target position is directly Pacman's position.
+
+
ChaseAggressive() - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAggressive
+
 
+
ChaseAmbush - Class in edu.uoc.pacman.model.entities.characters.ghosts.chase
+
+
It implements the ChaseBehaviour interface according to an ambush behaviour.
+ Its target position is four steps ahead of Pacman's position in the direction Pacman is facing.
+
+
ChaseAmbush() - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAmbush
+
 
+
chaseBehaviour - Variable in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Object that allows us to assign a specific ChaseBehaviour class.
+
+
ChaseBehaviour - Interface in edu.uoc.pacman.model.entities.characters.ghosts.chase
+
+
Defines the methods that any character (namely, ghost) must have to chase.
+ Thanks to this interface, we are using the Strategy design pattern.
+
+
ChaseCoward - Class in edu.uoc.pacman.model.entities.characters.ghosts.chase
+
+
It implements the ChaseBehaviour interface according to a coward behaviour.
+ It has two different modes which it constantly switches back and forth between, + based on its proximity to Pacman.
+
+
ChaseCoward() - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseCoward
+
 
+
ChasePatrol - Class in edu.uoc.pacman.model.entities.characters.ghosts.chase
+
+
It implements the ChaseBehaviour interface according to an aggressive behaviour.
+ In order to locate Inky's target position, we first start by selecting + the position TILES_OFFSET tiles in front of Pac-Man in his current + direction of travel, similar to Pinky's targeting method.
+
+
ChasePatrol() - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol
+
 
+
Clyde - Class in edu.uoc.pacman.model.entities.characters.ghosts
+
+
Represents a Clyde (orange) ghost.
+
+
Clyde(Position, Direction, Behaviour, Level) - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.Clyde
+
+
Constructor with arguments.
+ The value of the scatterPosition is (-1,LEVEL.HEIGHT).
+ The value of the sprite is Sprite.CLYDE.
+ It assigns to chaseBehaviour a ChaseCoward object.
+
+
CLYDE - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for a Clyde ghost.
+
+
clydeAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
create() - Method in class edu.uoc.pacman.view.PacmanGame
+
 
+
currentLevel - Variable in class edu.uoc.pacman.controller.Game
+
+
Number of the current level.
+
+
+

D

+
+
dead - Variable in class edu.uoc.pacman.model.entities.characters.Character
+
+
Indicates if the character is dead (true) or not (false).
+
+
decreaseLives() - Method in class edu.uoc.pacman.model.Level
+
+
Decreases 1 the number of lives as long as the number of lives is not zero.
+
+
direction - Variable in class edu.uoc.pacman.model.entities.characters.Character
+
+
The direction that the character faces.
+
+
Direction - Enum Class in edu.uoc.pacman.model.utils
+
+
Direction that Pacman and ghosts face.
+ RESPECT The order of the values: RIGHT, DOWN, LEFT, UP.
+
+
Direction(int, int, int) - Constructor for enum class edu.uoc.pacman.model.utils.Direction
+
 
+
dispose() - Method in class edu.uoc.pacman.view.GameOverScreen
+
 
+
dispose() - Method in class edu.uoc.pacman.view.GameScreen
+
 
+
dispose() - Method in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
dispose() - Method in class edu.uoc.pacman.view.PacmanGame
+
 
+
dispose() - Method in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
distance(Position) - Method in class edu.uoc.pacman.model.utils.Position
+
+
Calculates the Euclidean distance from this point to other given point.
+
+
Dot - Class in edu.uoc.pacman.model.entities.items
+
+
Represents a dot in the labyrinth/map.
+
+
Dot(Position) - Constructor for class edu.uoc.pacman.model.entities.items.Dot
+
+
Constructor with argument.
+ The value for pathable is true and for sprite is Sprite.DOT.
+
+
DOT - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for a dot.
+
+
dotAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
DOWN - Enum constant in enum class edu.uoc.pacman.model.utils.Direction
+
+
DOWN direction. x = 0, y = 1 and keyCode = 20.
+
+
drawImage(Sprite, int, int) - Method in class edu.uoc.pacman.view.PacmanGame
+
 
+
duration - Variable in class edu.uoc.pacman.model.entities.characters.Character
+
+
Left time so that the ghost changes its current behaviour or the Pacman changes its current state.
+
+
duration - Variable in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Stores the duration of the behaviour.
+
+
duration - Variable in enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
Stores the duration of the state.
+
+
+

E

+
+
eat() - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Performs the eat action.
+
+
EATER - Enum constant in enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
State when Pacman eats an energizer and is able to eat/kill ghosts.
+
+
edu.uoc.pacman.controller - package edu.uoc.pacman.controller
+
 
+
edu.uoc.pacman.model - package edu.uoc.pacman.model
+
 
+
edu.uoc.pacman.model.entities - package edu.uoc.pacman.model.entities
+
 
+
edu.uoc.pacman.model.entities.characters - package edu.uoc.pacman.model.entities.characters
+
 
+
edu.uoc.pacman.model.entities.characters.ghosts - package edu.uoc.pacman.model.entities.characters.ghosts
+
 
+
edu.uoc.pacman.model.entities.characters.ghosts.chase - package edu.uoc.pacman.model.entities.characters.ghosts.chase
+
 
+
edu.uoc.pacman.model.entities.characters.pacman - package edu.uoc.pacman.model.entities.characters.pacman
+
 
+
edu.uoc.pacman.model.entities.items - package edu.uoc.pacman.model.entities.items
+
 
+
edu.uoc.pacman.model.exceptions - package edu.uoc.pacman.model.exceptions
+
 
+
edu.uoc.pacman.model.utils - package edu.uoc.pacman.model.utils
+
 
+
edu.uoc.pacman.view - package edu.uoc.pacman.view
+
 
+
Energizer - Class in edu.uoc.pacman.model.entities.items
+
+
Represents an energizer in the labyrinth/map.
+
+
Energizer(Position) - Constructor for class edu.uoc.pacman.model.entities.items.Energizer
+
+
Constructor with argument.
+ The value for pathable is true and for sprite is Sprite.ENERGIZER.
+
+
ENERGIZER - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for an energizer.
+
+
energizerAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
Entity - Class in edu.uoc.pacman.model.entities
+
+
Represents any item that appears in the game.
+
+
Entity(Position, boolean, Sprite) - Constructor for class edu.uoc.pacman.model.entities.Entity
+
+
Constructor with arguments.
+
+
equals(Object) - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Checks if another object instance is equal to this ghost.
+
+
equals(Object) - Method in class edu.uoc.pacman.model.utils.Position
+
+
Checks if two positions are equal.
+
+
+

F

+
+
fileFolder - Variable in class edu.uoc.pacman.controller.Game
+
+
Name of the folder in which level files are
+
+
fileName - Variable in class edu.uoc.pacman.model.Level
+
+
The name of the level configuration file.
+
+
font - Variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
FRIGHTENED - Enum constant in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Behaviour where the ghosts are frightened and confused.
+
+
+

G

+
+
game - Variable in class edu.uoc.pacman.view.GameOverScreen
+
 
+
game - Variable in class edu.uoc.pacman.view.GameScreen
+
 
+
game - Variable in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
game - Variable in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
Game - Class in edu.uoc.pacman.controller
+
+
Controller class of the game.
+
+
Game(String) - Constructor for class edu.uoc.pacman.controller.Game
+
+
Constructor with argument.
+
+
gameController - Variable in class edu.uoc.pacman.view.GameScreen
+
 
+
gameController - Variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
gameController - Variable in class edu.uoc.pacman.view.UserInputProcessor
+
 
+
GameOverScreen - Class in edu.uoc.pacman.view
+
 
+
GameOverScreen(PacmanGame) - Constructor for class edu.uoc.pacman.view.GameOverScreen
+
 
+
GameScreen - Class in edu.uoc.pacman.view
+
 
+
GameScreen(PacmanGame) - Constructor for class edu.uoc.pacman.view.GameScreen
+
 
+
getAssertBySprite(Sprite) - Method in class edu.uoc.pacman.view.PacmanGame
+
 
+
getBehaviour() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Gets the behaviour that the ghost currently is in.
+
+
getBlinky() - Method in class edu.uoc.pacman.model.Level
+
+
Gets the first Blinky object in the Ghost list of the level.
+
+
getChasePosition(Ghost) - Method in class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAggressive
+
+
The ghost will chase the Pacman's current direction.
+
+
getChasePosition(Ghost) - Method in class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAmbush
+
+
The ghost will chase the position which is TILES_OFFSET steps/tiles/cells/positions + ahead of Pacman's position in the direction Pacman is facing.
+
+
getChasePosition(Ghost) - Method in interface edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour
+
+
Defines the signature of the method to be used to get the position where + any character (namely, ghosts) must to go to.
+
+
getChasePosition(Ghost) - Method in class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseCoward
+
+
The ghost will target Pacman's position if the euclidean distance between position is equal to or greater than + a distance of TILES_TO_CHASE.
+
+
getChasePosition(Ghost) - Method in class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol
+
+
The ghost will chase twice a vector equals to:
+
+
getCurrentLevel() - Method in class edu.uoc.pacman.controller.Game
+
+
Getter of the attribute currentLevel.
+
+
getDirection() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Gets the direction that the character is facing.
+
+
getDirectionByKeyCode(int) - Static method in enum class edu.uoc.pacman.model.utils.Direction
+
+
Given the value of keyCode, + it returns the corresponding Direction value.
+
+
getDuration() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Getter of the attribute duration.
+
+
getDuration() - Method in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Gets the duration of the behaviour.
+
+
getDuration() - Method in enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
Gets the duration of the state.
+
+
getFileFolder() - Method in class edu.uoc.pacman.controller.Game
+
+
Getter of the attribute fileFolder.
+
+
getFileName() - Method in class edu.uoc.pacman.model.Level
+
+
Getter of the attribute fileName
+
+
getFirstNonEmptyLine(BufferedReader) - Method in class edu.uoc.pacman.model.Level
+
+
This is a helper method for Level.parse() which returns + the first non-empty and non-comment line from the reader.
+
+
getGameController() - Method in class edu.uoc.pacman.view.PacmanGame
+
 
+
getGhostInstance(int, int, String, Direction, Behaviour, Level) - Static method in class edu.uoc.pacman.model.entities.characters.ghosts.GhostFactory
+
+
Returns a new Ghost object.
+
+
getGhostList() - Method in class edu.uoc.pacman.model.Level
+
+
Getter of the attribute ghostList.
+
+
getGhosts() - Method in class edu.uoc.pacman.controller.Game
+
+
Gets the list of Ghosts which are present in the level.
+
+
getHeight() - Method in class edu.uoc.pacman.model.Level
+
+
Getter of the attribute height.
+
+
getImageSrc() - Method in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Getter of the attribute imageSrc.
+
+
getItemMapInstance(int, int, char) - Static method in class edu.uoc.pacman.model.entities.items.MapItemFactory
+
+
Returns a new MapItem object.
+
+
getItemMapListIterator() - Method in class edu.uoc.pacman.controller.Game
+
+
Gets an Iterator of the itemMapList
+
+
getKeyCode() - Method in enum class edu.uoc.pacman.model.utils.Direction
+
+
Getter of the attibute keyCode
+
+
getLevel() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Getter of the attribute level.
+
+
getLevelScore() - Method in class edu.uoc.pacman.controller.Game
+
+
Gets the current score of the level that the player is playing.
+
+
getLives() - Method in class edu.uoc.pacman.model.Level
+
+
Getter of the attribute lives.
+
+
getMapItem(int, int) - Method in class edu.uoc.pacman.model.Level
+
+
Returns the map/labyrinth item which is in the position (x,y).
+
+
getMapItem(Position) - Method in class edu.uoc.pacman.model.Level
+
+
Returns the map/labyrinth item which is in position.
+
+
getMapItemList() - Method in class edu.uoc.pacman.model.Level
+
+
Getter of the attribute mapItemList.
+
+
getMapItemListIterator() - Method in class edu.uoc.pacman.model.Level
+
+
Returns an Iterator of the attribute mapItemList.
+
+
getNumLives() - Method in class edu.uoc.pacman.controller.Game
+
+
Returns the number of lives that the player has in the current level.
+
+
getPacman() - Method in class edu.uoc.pacman.controller.Game
+
+
Gests the @link Pacman} object which is present in the current level.
+
+
getPacman() - Method in class edu.uoc.pacman.model.Level
+
+
Getter ot the attribute pacman.
+
+
getPoints() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Blinky
+
+
Getter of the attribute POINTS.
+
+
getPoints() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Clyde
+
+
Getter of the attribute POINTS.
+
+
getPoints() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Inky
+
+
Getter of the attribute POINTS.
+
+
getPoints() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Pinky
+
+
Getter of the attribute POINTS.
+
+
getPoints() - Method in class edu.uoc.pacman.model.entities.items.Dot
+
+
Getter of the attribute POINTS.
+
+
getPoints() - Method in class edu.uoc.pacman.model.entities.items.Energizer
+
+
Getter of the attribute POINTS.
+
+
getPoints() - Method in interface edu.uoc.pacman.model.entities.Scorable
+
+
Gets points.
+
+
getPosition() - Method in class edu.uoc.pacman.model.entities.Entity
+
+
Gets the current position of the entity.
+
+
getScatterPosition() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Getter of the attribute scatterPosition.
+
+
getScore() - Method in class edu.uoc.pacman.controller.Game
+
+
Getter of the attribute "score" (Game score).
+
+
getScore() - Method in class edu.uoc.pacman.model.Level
+
+
Getter of the attribute score.
+
+
getSprite() - Method in class edu.uoc.pacman.model.entities.Entity
+
+
Getter of the attribute sprite.
+
+
getStartPosition() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Getter of the attribute startPosition.
+
+
getState() - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Getter of the attribute state.
+
+
getSymbol() - Method in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Getter of the attribute symbol.
+
+
getTargetPosition() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Returns the target position of the ghosts according to its current behaviour.
+
+
getWidth() - Method in class edu.uoc.pacman.model.Level
+
+
Getter of the attribute width.
+
+
getX() - Method in enum class edu.uoc.pacman.model.utils.Direction
+
+
Getter of the attibute x
+
+
getX() - Method in class edu.uoc.pacman.model.utils.Position
+
+
Getter of the attribute x
+
+
getY() - Method in enum class edu.uoc.pacman.model.utils.Direction
+
+
Getter of the attibute y
+
+
getY() - Method in class edu.uoc.pacman.model.utils.Position
+
+
Getter of the attribute y
+
+
Ghost - Class in edu.uoc.pacman.model.entities.characters.ghosts
+
+
Represents an abstract Ghost class which defines a specific Character entity.
+
+
Ghost(Position, Position, Direction, Behaviour, Sprite, Level) - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Constructor with arguments.
+
+
GhostFactory - Class in edu.uoc.pacman.model.entities.characters.ghosts
+
+
Ghost Simple Factory class.
+
+
GhostFactory() - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.GhostFactory
+
 
+
ghostList - Variable in class edu.uoc.pacman.model.Level
+
+
Ghosts that are part of the level.
+
+
GHOSTS_ERROR - Static variable in exception edu.uoc.pacman.model.exceptions.LevelException
+
+
Error message when there isn't any ghost
+
+
+

H

+
+
hashCode() - Method in class edu.uoc.pacman.model.utils.Position
+
+
Returns the hash of a Position object.
+
+
hasLost() - Method in class edu.uoc.pacman.controller.Game
+
+
Checks if the player has lost, i.e. the number of lives is zero.
+
+
hasWon() - Method in class edu.uoc.pacman.model.Level
+
+
Checks if the level was finished.
+
+
height - Variable in class edu.uoc.pacman.model.Level
+
+
The height of the map/labyrinth.
+
+
hide() - Method in class edu.uoc.pacman.view.GameOverScreen
+
 
+
hide() - Method in class edu.uoc.pacman.view.GameScreen
+
 
+
hide() - Method in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
hide() - Method in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
hit() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Checks if the ghost hits Pacman, i.e. if ghost's position and Pacman's position are the same.
+
+
hit() - Method in interface edu.uoc.pacman.model.entities.characters.Hitable
+
+
Defines the signature of the method that manages the hit action of any hitable entity.
+
+
hit() - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Checks if Pacman is in the same position which any ghost.
+
+
Hitable - Interface in edu.uoc.pacman.model.entities.characters
+
+
Defines the methods that any hitable entity must have.
+
+
+

I

+
+
imageSrc - Variable in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Value of the image path.
+
+
INACTIVE - Enum constant in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Behaviour where the ghosts don't do anything and Pacman cannot kill them.
+
+
increaseLives() - Method in class edu.uoc.pacman.model.Level
+
+
Increases 1 the number of lives.
+
+
Inky - Class in edu.uoc.pacman.model.entities.characters.ghosts
+
+
Represents an Inky (bluish) ghost.
+
+
Inky(Position, Direction, Behaviour, Level) - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.Inky
+
+
Constructor with arguments.
+ The value of the scatterPosition is (LEVEL.WIDTH,LEVEL.HEIGHT).
+ The value of the sprite is Sprite.INKY.
+ It assigns to chaseBehaviour a ChasePatrol object.
+
+
INKY - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for an Inky ghost.
+
+
inkyAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
InterLevelsScreen - Class in edu.uoc.pacman.view
+
 
+
InterLevelsScreen(PacmanGame) - Constructor for class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
INVINCIBLE - Enum constant in enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
State when Pacman has been killed, and it cannot neither be killed nor kill ghosts.
+
+
isDead() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Getter of the attribute dead.
+
+
isFinished() - Method in class edu.uoc.pacman.controller.Game
+
+
Indicates if the game is finished (true) or not (false).
+
+
isLevelCompleted() - Method in class edu.uoc.pacman.controller.Game
+
+
Checks if the level is completed, i.e. the player has collected all the dots and energizers of the map.
+
+
isPathable() - Method in class edu.uoc.pacman.model.entities.Entity
+
+
Getter of the attribute pathable.
+
+
isPathable(Position) - Method in class edu.uoc.pacman.model.Level
+
+
Given a position, it indicates if such a position is pathable or not.
+
+
isPicked() - Method in class edu.uoc.pacman.model.entities.items.Dot
+
+
Getter of the attribute picked.
+
+
isPicked() - Method in class edu.uoc.pacman.model.entities.items.Energizer
+
+
Getter of the attribute picked.
+
+
isPicked() - Method in class edu.uoc.pacman.model.entities.items.Life
+
+
Getter of the attribute picked.
+
+
isPicked() - Method in interface edu.uoc.pacman.model.entities.items.Pickable
+
+
Method that allows us to know if the item has been picked or not.
+
+
+

K

+
+
keyCode - Variable in enum class edu.uoc.pacman.model.utils.Direction
+
+
Intenger value that is given by libgdx + to a key pressed by the user
+
+
keyDown(int) - Method in class edu.uoc.pacman.view.UserInputProcessor
+
 
+
keyUp(int) - Method in class edu.uoc.pacman.view.UserInputProcessor
+
 
+
kill() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Sets the attribute dead to true.
+
+
kill() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Kills the ghost and add its points to the level's score.
+
+
kill() - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Kills Pacman and decreases one life in the current level.
+
+
+

L

+
+
LEFT - Enum constant in enum class edu.uoc.pacman.model.utils.Direction
+
+
LEFT direction. x = -1, y = 0 and keyCode = 21.
+
+
level - Variable in class edu.uoc.pacman.controller.Game
+
+
Level object that contains the information of the current level.
+
+
level - Variable in class edu.uoc.pacman.model.entities.characters.Character
+
+
Reference to the current level object.
+
+
Level - Class in edu.uoc.pacman.model
+
+
Represents a level in the game.
+
+
Level(String, int) - Constructor for class edu.uoc.pacman.model.Level
+
+
Constructor with argument.
+
+
LevelException - Exception in edu.uoc.pacman.model.exceptions
+
+
Level Exception class.
+ In order to know the text of each message, please click on the "Constant Field Values" link + that you'll find in the description of each constant.
+
+
LevelException(String) - Constructor for exception edu.uoc.pacman.model.exceptions.LevelException
+
+
Constructor with argument.
+
+
Life - Class in edu.uoc.pacman.model.entities.items
+
+
Represents a life in the labyrinth/map.
+
+
Life(Position) - Constructor for class edu.uoc.pacman.model.entities.items.Life
+
+
Constructor with argument.
+ The value for pathable is true and for sprite is Sprite.LIFE.
+
+
LIFE - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for a life.
+
+
lifeAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
lives - Variable in class edu.uoc.pacman.model.Level
+
+
Number of lives in the level.
+
+
loaded - Variable in class edu.uoc.pacman.view.GameScreen
+
 
+
loadImages() - Method in class edu.uoc.pacman.view.PacmanGame
+
 
+
loadLevel() - Method in class edu.uoc.pacman.controller.Game
+
+
Loads a new level by using the value of the attribute currentLevel.
+
+
logoAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
+

M

+
+
MapItem - Class in edu.uoc.pacman.model.entities.items
+
+
Abstract class that represents any labyrinth/map item.
+
+
MapItem(Position, boolean, Sprite) - Constructor for class edu.uoc.pacman.model.entities.items.MapItem
+
+
Constructor with arguments.
+
+
MapItemFactory - Class in edu.uoc.pacman.model.entities.items
+
+
Entity Simple Factory class.
+
+
MapItemFactory() - Constructor for class edu.uoc.pacman.model.entities.items.MapItemFactory
+
 
+
mapItemList - Variable in class edu.uoc.pacman.model.Level
+
+
Stores the items which are part of the map/labyrinth.
+
+
maxLevels - Variable in class edu.uoc.pacman.controller.Game
+
+
Maximum amount of levels that the game has.
+
+
MIN_HEIGHT - Static variable in class edu.uoc.pacman.model.Level
+
+
The minimum height that the map must have.
+
+
MIN_WIDTH - Static variable in class edu.uoc.pacman.model.Level
+
+
The minimum width that the map must have.
+
+
Movable - Interface in edu.uoc.pacman.model.entities.characters
+
+
Defines the methods that any movable entity must have.
+
+
move() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Moves the ghost according to the game rules.
+ If the targetPosition is null (e.g. because ghost's behavior is INACTIVE}, + then the ghost does not move.
+
+
move() - Method in interface edu.uoc.pacman.model.entities.characters.Movable
+
+
Defines the signature of the method that manages the movement of any movable entity.
+
+
move() - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Moves Pacman across the board only one step.
+
+
+

N

+
+
nextBehaviour() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Decreases the behaviour's duration and changes the ghost's behaviour to the + next behaviour if duration is 0.
+
+
nextLevel() - Method in class edu.uoc.pacman.controller.Game
+
+
Checks if there is a new level to play and loads it.
+ If the game is finished, it returns false.
+
+
nextState() - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Decreases the behaviour's duration and changes the ghost's behaviour to the + next behaviour if duration is 0.
+
+
NORMAL - Enum constant in enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
State in which Pacman is usually.
+
+
NUM_LIVES - Static variable in class edu.uoc.pacman.controller.Game
+
+
Number of lives which each level has when it starts.
+
+
+

O

+
+
opposite() - Method in enum class edu.uoc.pacman.model.utils.Direction
+
+
Gets the opposite direction of the + direction that invokes this method.
+
+
+

P

+
+
pacman - Variable in class edu.uoc.pacman.model.Level
+
+
Reference to Pacman object, i.e. the player.
+
+
Pacman - Class in edu.uoc.pacman.model.entities.characters.pacman
+
+
Represents the player object that appears in the game, which is called Pacman.
+
+
Pacman(Position, Direction, State, Level) - Constructor for class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Constructor with arguments.
+
+
PACMAN_DOWN - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite when Pacman is facing down.
+
+
PACMAN_LEFT - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite when Pacman is facing left.
+
+
PACMAN_RIGHT - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite when Pacman is facing right.
+
+
PACMAN_UP - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite when Pacman is facing up.
+
+
pacmanDownAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
PacmanGame - Class in edu.uoc.pacman.view
+
 
+
PacmanGame() - Constructor for class edu.uoc.pacman.view.PacmanGame
+
 
+
pacmanLeftAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
pacmanRightAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
pacmanUpAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
parse() - Method in class edu.uoc.pacman.model.Level
+
+
Parses/Reads level's data from the given file.
+ It also checks which the board's requirements are met.
+
+
PARSING_LEVEL_FILE_ERROR - Static variable in exception edu.uoc.pacman.model.exceptions.LevelException
+
+
Error message when there is an error while parsing/loading the level configuration file.
+
+
Path - Class in edu.uoc.pacman.model.entities.items
+
+
Represents a path in the labyrinth/map.
+
+
Path(Position) - Constructor for class edu.uoc.pacman.model.entities.items.Path
+
+
Constructor with arguments.
+ The value for pathable is true and for sprite is Sprite.PATH.
+
+
PATH - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for a piece of path.
+
+
pathable - Variable in class edu.uoc.pacman.model.entities.Entity
+
+
Indicates if the entity is pathable or not.
+
+
pathAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
pause() - Method in class edu.uoc.pacman.view.GameOverScreen
+
 
+
pause() - Method in class edu.uoc.pacman.view.GameScreen
+
 
+
pause() - Method in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
pause() - Method in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
Pickable - Interface in edu.uoc.pacman.model.entities.items
+
+
Defines the methods that any pickable item must have.
+
+
PICKABLE_ERROR - Static variable in exception edu.uoc.pacman.model.exceptions.LevelException
+
+
Error message when there are not any dot or energizer.
+
+
picked - Variable in class edu.uoc.pacman.model.entities.items.Dot
+
+
This attribute allows us to manage if the dot has been picked or not.
+
+
picked - Variable in class edu.uoc.pacman.model.entities.items.Energizer
+
+
This attribute allows us to manage if the energizer has been picked or not.
+
+
picked - Variable in class edu.uoc.pacman.model.entities.items.Life
+
+
This attribute allows us to manage if the life has been picked or not.
+
+
Pinky - Class in edu.uoc.pacman.model.entities.characters.ghosts
+
+
Represents a Pinky ghost.
+
+
Pinky(Position, Direction, Behaviour, Level) - Constructor for class edu.uoc.pacman.model.entities.characters.ghosts.Pinky
+
+
Constructor with arguments.
+ The value of the scatterPosition is (-1,-1).
+ The value of the sprite is Sprite.PINKY.
+ It assigns to chaseBehaviour a ChaseAmbush object.
+
+
PINKY - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for a Pinky ghost.
+
+
pinkyAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
POINTS - Static variable in class edu.uoc.pacman.model.entities.characters.ghosts.Blinky
+
+
This attribute stores the amount of points that the Blinky ghost gives.
+
+
POINTS - Static variable in class edu.uoc.pacman.model.entities.characters.ghosts.Clyde
+
+
This attribute stores the amount of points that the Inky ghost gives.
+
+
POINTS - Static variable in class edu.uoc.pacman.model.entities.characters.ghosts.Inky
+
+
This attribute stores the amount of points that the Inky ghost gives.
+
+
POINTS - Static variable in class edu.uoc.pacman.model.entities.characters.ghosts.Pinky
+
+
This attribute stores the amount of points that the Pinky ghost gives.
+
+
POINTS - Static variable in class edu.uoc.pacman.model.entities.items.Dot
+
+
This attribute stores the amount of points that the dot gives.
+
+
POINTS - Static variable in class edu.uoc.pacman.model.entities.items.Energizer
+
+
This attribute stores the amount of points that the energizer gives.
+
+
position - Variable in class edu.uoc.pacman.model.entities.Entity
+
+
Position where the entity is.
+
+
Position - Class in edu.uoc.pacman.model.utils
+
+
Stores a 2D position/point/coordinate.
+
+
Position(int, int) - Constructor for class edu.uoc.pacman.model.utils.Position
+
+
Constructor with arguments.
+
+
+

R

+
+
reload() - Method in class edu.uoc.pacman.controller.Game
+
+
Reloads the current level, i.e. load the level again.
+
+
removeMapItem(MapItem) - Method in class edu.uoc.pacman.model.Level
+
+
Removes item from the mapItemList.
+
+
render() - Method in class edu.uoc.pacman.view.PacmanGame
+
 
+
render(float) - Method in class edu.uoc.pacman.view.GameOverScreen
+
 
+
render(float) - Method in class edu.uoc.pacman.view.GameScreen
+
 
+
render(float) - Method in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
render(float) - Method in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
reset() - Method in class edu.uoc.pacman.controller.Game
+
+
Resets the game so that it starts again.
+
+
reset() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Resets the character.
+
+
reset() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Resets the ghost back to its start position where it is "alive" (as the Character does) and also + with a behaviour of INACTIVE and facing UP.
+
+
reset() - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Resets Pacman back to its start position where it is "alive" (as Character does) and also with a + state of INVINCIBLE and facing UP.
+
+
resize(int, int) - Method in class edu.uoc.pacman.view.GameOverScreen
+
 
+
resize(int, int) - Method in class edu.uoc.pacman.view.GameScreen
+
 
+
resize(int, int) - Method in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
resize(int, int) - Method in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
resume() - Method in class edu.uoc.pacman.view.GameOverScreen
+
 
+
resume() - Method in class edu.uoc.pacman.view.GameScreen
+
 
+
resume() - Method in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
resume() - Method in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
RIGHT - Enum constant in enum class edu.uoc.pacman.model.utils.Direction
+
+
RIGHT direction. x = 1, y = 0 and keyCode = 22.
+
+
+

S

+
+
SCATTER - Enum constant in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Behaviour where the ghosts run home (scatter position).
+
+
scatterPosition - Variable in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Position that the ghost tries to reach when its behaviour is SCATTER.
+
+
Scorable - Interface in edu.uoc.pacman.model.entities
+
+
Defines the methods that any scorable entity must have.
+
+
score - Variable in class edu.uoc.pacman.controller.Game
+
+
Total score of the game, i.e. the sum of the levels' scores.
+
+
score - Variable in class edu.uoc.pacman.model.Level
+
+
Level's score.
+
+
setBehaviour(Behaviour) - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Sets the current behaviour of the ghost.
+ Its duration overrides the value of the attribute duration.
+
+
setDead(boolean) - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Setter of the attribute dead.
+
+
setDirection(Direction) - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Sets the direction of the character.
+ If the direction is null, then the direction is not set and remains the same.
+
+
setDirection(Direction) - Method in interface edu.uoc.pacman.model.entities.characters.Movable
+
+
Defines the signatures of the method that manages the direction in which any movable entity moves.
+
+
setDirection(Direction) - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Sets the direction of Pacman.
+ If the new direction is null, then the direction is not set and remains the same.

+ Because Pacman has 4 different sprites depending on its direction, this method also updates the + value of the attribute sprite, i.e.
+
+
setDuration(int) - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Setter of the attribute duration.
+
+
setFileFolder(String) - Method in class edu.uoc.pacman.controller.Game
+
+
Setter of the attribute fileFolder.
+
+
setFileName(String) - Method in class edu.uoc.pacman.model.Level
+
+
Setter of the attribute fileName.
+
+
setGhostsFrightened() - Method in class edu.uoc.pacman.model.Level
+
+
Sets the behaviour of all the ghosts in the level to FRIGHTENED.
+
+
setHeight(int) - Method in class edu.uoc.pacman.model.Level
+
+
Setter of the attribute height.
+
+
setLevel(Level) - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Setter of the attribute level.
+
+
setLives(int) - Method in class edu.uoc.pacman.model.Level
+
+
Setter of the attribute lives.
+
+
setPacmanDirection(Direction) - Method in class edu.uoc.pacman.controller.Game
+
+
This method allows us to change Pacman's direction according to the user input (i.e. the pressed key).
+
+
setPathable(boolean) - Method in class edu.uoc.pacman.model.entities.Entity
+
+
Setter of the attribute pathable.
+
+
setPicked(boolean) - Method in class edu.uoc.pacman.model.entities.items.Dot
+
+
Setter of the attribute pickled.
+
+
setPicked(boolean) - Method in class edu.uoc.pacman.model.entities.items.Energizer
+
+
Setter of the attribute pickled.
+
+
setPicked(boolean) - Method in class edu.uoc.pacman.model.entities.items.Life
+
+
Setter of the attribute pickled.
+
+
setPicked(boolean) - Method in interface edu.uoc.pacman.model.entities.items.Pickable
+
+
Sets the item as picked/unpicked.
+
+
setPosition(Position) - Method in class edu.uoc.pacman.model.entities.Entity
+
+
Sets the position of the entity.
+
+
setScatterPosition(Position) - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Setter of the attribute scatterPosition.
+
+
setScore(int) - Method in class edu.uoc.pacman.controller.Game
+
+
Setter of the attribute "score" (Game score).
+
+
setSprite(Sprite) - Method in class edu.uoc.pacman.model.entities.Entity
+
+
Setter of the attribute sprite.
+
+
setStartPosition(Position) - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Setter of the attribute startPosition.
+
+
setState(State) - Method in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Setter of the attribute state.
+ If the new state is null, then the state is not set and remains the same.
+
+
setWidth(int) - Method in class edu.uoc.pacman.model.Level
+
+
Setter of the attribute width.
+
+
setX(int) - Method in class edu.uoc.pacman.model.utils.Position
+
+
Setter of the attribute x
+
+
setY(int) - Method in class edu.uoc.pacman.model.utils.Position
+
+
Setter of the attribute y
+
+
show() - Method in class edu.uoc.pacman.view.GameOverScreen
+
 
+
show() - Method in class edu.uoc.pacman.view.GameScreen
+
 
+
show() - Method in class edu.uoc.pacman.view.InterLevelsScreen
+
 
+
show() - Method in class edu.uoc.pacman.view.WelcomeScreen
+
 
+
SIZE_ERROR - Static variable in exception edu.uoc.pacman.model.exceptions.LevelException
+
+
Error message when the size of the board does not meet the minimum
+
+
sprite - Variable in class edu.uoc.pacman.model.entities.Entity
+
+
Value of Sprite linked to the entity.
+
+
Sprite - Enum Class in edu.uoc.pacman.model.utils
+
+
Sprite that stores the configuration file symbol and the image's path.
+
+
Sprite(char, String) - Constructor for enum class edu.uoc.pacman.model.utils.Sprite
+
+
Constructor with arguments.
+
+
startPosition - Variable in class edu.uoc.pacman.model.entities.characters.Character
+
+
Stores the initial/start position of the character.
+
+
state - Variable in class edu.uoc.pacman.model.entities.characters.pacman.Pacman
+
+
Stores the state of the Pacman.
+
+
State - Enum Class in edu.uoc.pacman.model.entities.characters.pacman
+
+
Represents the three state which Pacman can have.
+
+
State(int) - Constructor for enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
Constructor with arguments.
+
+
symbol - Variable in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Value in the configuration file.
+
+
+

T

+
+
tick - Variable in class edu.uoc.pacman.model.Level
+
+
Number that allows us to manage when the actions happen.
+
+
TILES_OFFSET - Static variable in class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAmbush
+
+
The amount of tiles/cells/positions/steps that must be added to the Pacman's position.
+
+
TILES_OFFSET - Static variable in class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol
+
+
The amount of tiles/cells/positions/steps that must be added to the Pacman's position.
+
+
TILES_TO_CHASE - Static variable in class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseCoward
+
+
Distance in tiles to decide which position is the target one.
+
+
toString() - Method in class edu.uoc.pacman.model.entities.characters.Character
+
+
Represents this entity in a comma-separated string format.
+ Format is: "x,y,DIRECTION", where DIRECTION is uppercase enum type value.
+ Example: 4,5,LEFT
+
+
toString() - Method in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Returns a String with information of the Behaviour.
+
+
toString() - Method in class edu.uoc.pacman.model.entities.characters.ghosts.Ghost
+
+
Represents this ghost in a comma-separated string format.
+ Format is: "x,y,DIRECTION,BEHAVIOUR:behaviourDuration".
+ DIRECTION is the uppercase enum type value for Direction.
+ BEHAVIOUR is the uppercase enum type value for Behaviour.
+ Example:
+ "2,3,UP,SCATTER,3"
+
+
toString() - Method in enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
Returns a String with information of the State.
+ Format: STATE:stateDuration
+ Example: "INVINCIBLE:5"

+ + Hint: Remember that toString() is already coded in Object.
+
+
toString() - Method in class edu.uoc.pacman.model.utils.Position
+
+
Returns a comma-seperated string representation of a Position.
+ Format: "x,y"
+ Example: "3,4"
+
+
+

U

+
+
UP - Enum constant in enum class edu.uoc.pacman.model.utils.Direction
+
+
UP direction. x = 0, y = -1 and keyCode = 19.
+
+
update() - Method in class edu.uoc.pacman.controller.Game
+
+
Update the game, namely the level.
+
+
update() - Method in class edu.uoc.pacman.model.Level
+
+
Refreshes/Updates the game when needed.
+
+
UPDATE_GAME - Static variable in class edu.uoc.pacman.model.Level
+
+
It is the refresh time.
+
+
UserInputProcessor - Class in edu.uoc.pacman.view
+
 
+
UserInputProcessor(Game) - Constructor for class edu.uoc.pacman.view.UserInputProcessor
+
 
+
+

V

+
+
valueOf(String) - Static method in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Returns the enum constant of this class with the specified name.
+
+
valueOf(String) - Static method in enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
Returns the enum constant of this class with the specified name.
+
+
valueOf(String) - Static method in enum class edu.uoc.pacman.model.utils.Direction
+
+
Returns the enum constant of this class with the specified name.
+
+
valueOf(String) - Static method in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Returns the enum constant of this class with the specified name.
+
+
values() - Static method in enum class edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
+
+
Returns an array containing the constants of this enum class, in +the order they are declared.
+
+
values() - Static method in enum class edu.uoc.pacman.model.entities.characters.pacman.State
+
+
Returns an array containing the constants of this enum class, in +the order they are declared.
+
+
values() - Static method in enum class edu.uoc.pacman.model.utils.Direction
+
+
Returns an array containing the constants of this enum class, in +the order they are declared.
+
+
values() - Static method in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Returns an array containing the constants of this enum class, in +the order they are declared.
+
+
VECTOR_INCREASE - Static variable in class edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol
+
+
The amount which the vector equals to + targetPositionBlinky - FIRST_BLINKY_POSITION must be extended (multiplied).
+
+
+

W

+
+
Wall - Class in edu.uoc.pacman.model.entities.items
+
+
Represents a wall in the labyrinth/map.
+
+
Wall(Position) - Constructor for class edu.uoc.pacman.model.entities.items.Wall
+
+
Constructor with arguments.
+ The value for pathable is false and for sprite is Sprite.WALL.
+
+
WALL - Enum constant in enum class edu.uoc.pacman.model.utils.Sprite
+
+
Sprite for a wall.
+
+
wallAsset - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
WelcomeScreen - Class in edu.uoc.pacman.view
+
 
+
WelcomeScreen(PacmanGame) - Constructor for class edu.uoc.pacman.view.WelcomeScreen
+
 
+
width - Variable in class edu.uoc.pacman.model.Level
+
+
The width of the map/labyrinth.
+
+
WINDOW_HEIGHT - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
WINDOW_WIDTH - Static variable in class edu.uoc.pacman.view.PacmanGame
+
 
+
+

X

+
+
x - Variable in enum class edu.uoc.pacman.model.utils.Direction
+
+
Offset in X axis
+
+
x - Variable in class edu.uoc.pacman.model.utils.Position
+
+
Value of the attribute X axis
+
+
+

Y

+
+
y - Variable in enum class edu.uoc.pacman.model.utils.Direction
+
+
Offset in Y axis
+
+
y - Variable in class edu.uoc.pacman.model.utils.Position
+
+
Value of the attribute Y axis
+
+
+A B C D E F G H I K L M N O P R S T U V W X Y 
All Classes and Interfaces|All Packages|Constant Field Values|Serialized Form
+
+
+ + diff --git a/core/docs/index.html b/core/docs/index.html new file mode 100644 index 0000000..32b2d3b --- /dev/null +++ b/core/docs/index.html @@ -0,0 +1,85 @@ + + + + +Overview (core 1.0 API) + + + + + + + + + + + + + + +
+ + +
+ + diff --git a/core/docs/jquery-ui.overrides.css b/core/docs/jquery-ui.overrides.css new file mode 100644 index 0000000..a46bfe7 --- /dev/null +++ b/core/docs/jquery-ui.overrides.css @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +.ui-state-active, +.ui-widget-content .ui-state-active, +.ui-widget-header .ui-state-active, +a.ui-button:active, +.ui-button:active, +.ui-button.ui-state-active:hover { + /* Overrides the color of selection used in jQuery UI */ + background: #F8981D; +} diff --git a/core/docs/legal/ADDITIONAL_LICENSE_INFO b/core/docs/legal/ADDITIONAL_LICENSE_INFO new file mode 100644 index 0000000..3f7e921 --- /dev/null +++ b/core/docs/legal/ADDITIONAL_LICENSE_INFO @@ -0,0 +1 @@ +Please see ..\java.base\ADDITIONAL_LICENSE_INFO diff --git a/core/docs/legal/ASSEMBLY_EXCEPTION b/core/docs/legal/ASSEMBLY_EXCEPTION new file mode 100644 index 0000000..e09f918 --- /dev/null +++ b/core/docs/legal/ASSEMBLY_EXCEPTION @@ -0,0 +1 @@ +Please see ..\java.base\ASSEMBLY_EXCEPTION diff --git a/core/docs/legal/LICENSE b/core/docs/legal/LICENSE new file mode 100644 index 0000000..940481e --- /dev/null +++ b/core/docs/legal/LICENSE @@ -0,0 +1 @@ +Please see ..\java.base\LICENSE diff --git a/core/docs/legal/jquery.md b/core/docs/legal/jquery.md new file mode 100644 index 0000000..8054a34 --- /dev/null +++ b/core/docs/legal/jquery.md @@ -0,0 +1,72 @@ +## jQuery v3.5.1 + +### jQuery License +``` +jQuery v 3.5.1 +Copyright JS Foundation and other contributors, https://js.foundation/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************** + +The jQuery JavaScript Library v3.5.1 also includes Sizzle.js + +Sizzle.js includes the following license: + +Copyright JS Foundation and other contributors, https://js.foundation/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/sizzle + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. + +********************* + +``` diff --git a/core/docs/legal/jqueryUI.md b/core/docs/legal/jqueryUI.md new file mode 100644 index 0000000..8031bdb --- /dev/null +++ b/core/docs/legal/jqueryUI.md @@ -0,0 +1,49 @@ +## jQuery UI v1.12.1 + +### jQuery UI License +``` +Copyright jQuery Foundation and other contributors, https://jquery.org/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/jquery-ui + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +Copyright and related rights for sample code are waived via CC0. Sample +code is defined as all source code contained within the demos directory. + +CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +==== + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. + +``` diff --git a/core/docs/member-search-index.js b/core/docs/member-search-index.js new file mode 100644 index 0000000..5bec240 --- /dev/null +++ b/core/docs/member-search-index.js @@ -0,0 +1 @@ +memberSearchIndex = [{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"add(Position, Position)","u":"add(edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"addMapItem(MapItem)","u":"addMapItem(edu.uoc.pacman.model.entities.items.MapItem)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"addPoints(int)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"alive()"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"assetManager"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"batch"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"behaviour"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"Behaviour(int)","u":"%3Cinit%3E(int)"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"BLINKY"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Blinky","l":"Blinky(Position, Direction, Behaviour, Level)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Direction,edu.uoc.pacman.model.entities.characters.ghosts.Behaviour,edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"blinkyAsset"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"camera"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"camera"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"camera"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"CELL_SIZE"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"Character(Position, Direction, Sprite, Level)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Direction,edu.uoc.pacman.model.utils.Sprite,edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"CHASE"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseAggressive","l":"ChaseAggressive()","u":"%3Cinit%3E()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseAmbush","l":"ChaseAmbush()","u":"%3Cinit%3E()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"chaseBehaviour"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseCoward","l":"ChaseCoward()","u":"%3Cinit%3E()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChasePatrol","l":"ChasePatrol()","u":"%3Cinit%3E()"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"CLYDE"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Clyde","l":"Clyde(Position, Direction, Behaviour, Level)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Direction,edu.uoc.pacman.model.entities.characters.ghosts.Behaviour,edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"clydeAsset"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"create()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"currentLevel"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"dead"},{"p":"edu.uoc.pacman.model","c":"Level","l":"decreaseLives()"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"direction"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"Direction(int, int, int)","u":"%3Cinit%3E(int,int,int)"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"dispose()"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"dispose()"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"dispose()"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"dispose()"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"dispose()"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"distance(Position)","u":"distance(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"DOT"},{"p":"edu.uoc.pacman.model.entities.items","c":"Dot","l":"Dot(Position)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"dotAsset"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"DOWN"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"drawImage(Sprite, int, int)","u":"drawImage(edu.uoc.pacman.model.utils.Sprite,int,int)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"duration"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"duration"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"duration"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"eat()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"EATER"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"ENERGIZER"},{"p":"edu.uoc.pacman.model.entities.items","c":"Energizer","l":"Energizer(Position)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"energizerAsset"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"Entity(Position, boolean, Sprite)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,boolean,edu.uoc.pacman.model.utils.Sprite)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"equals(Object)","u":"equals(java.lang.Object)"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"equals(Object)","u":"equals(java.lang.Object)"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"fileFolder"},{"p":"edu.uoc.pacman.model","c":"Level","l":"fileName"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"font"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"FRIGHTENED"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"game"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"game"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"game"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"game"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"Game(String)","u":"%3Cinit%3E(java.lang.String)"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"gameController"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"gameController"},{"p":"edu.uoc.pacman.view","c":"UserInputProcessor","l":"gameController"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"GameOverScreen(PacmanGame)","u":"%3Cinit%3E(edu.uoc.pacman.view.PacmanGame)"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"GameScreen(PacmanGame)","u":"%3Cinit%3E(edu.uoc.pacman.view.PacmanGame)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"getAssertBySprite(Sprite)","u":"getAssertBySprite(edu.uoc.pacman.model.utils.Sprite)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"getBehaviour()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getBlinky()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseAggressive","l":"getChasePosition(Ghost)","u":"getChasePosition(edu.uoc.pacman.model.entities.characters.ghosts.Ghost)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseAmbush","l":"getChasePosition(Ghost)","u":"getChasePosition(edu.uoc.pacman.model.entities.characters.ghosts.Ghost)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseBehaviour","l":"getChasePosition(Ghost)","u":"getChasePosition(edu.uoc.pacman.model.entities.characters.ghosts.Ghost)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseCoward","l":"getChasePosition(Ghost)","u":"getChasePosition(edu.uoc.pacman.model.entities.characters.ghosts.Ghost)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChasePatrol","l":"getChasePosition(Ghost)","u":"getChasePosition(edu.uoc.pacman.model.entities.characters.ghosts.Ghost)"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"getCurrentLevel()"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"getDirection()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"getDirectionByKeyCode(int)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"getDuration()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"getDuration()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"getDuration()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"getFileFolder()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getFileName()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getFirstNonEmptyLine(BufferedReader)","u":"getFirstNonEmptyLine(java.io.BufferedReader)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"getGameController()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"GhostFactory","l":"getGhostInstance(int, int, String, Direction, Behaviour, Level)","u":"getGhostInstance(int,int,java.lang.String,edu.uoc.pacman.model.utils.Direction,edu.uoc.pacman.model.entities.characters.ghosts.Behaviour,edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getGhostList()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"getGhosts()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getHeight()"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"getImageSrc()"},{"p":"edu.uoc.pacman.model.entities.items","c":"MapItemFactory","l":"getItemMapInstance(int, int, char)","u":"getItemMapInstance(int,int,char)"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"getItemMapListIterator()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"getKeyCode()"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"getLevel()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"getLevelScore()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getLives()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getMapItem(int, int)","u":"getMapItem(int,int)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getMapItem(Position)","u":"getMapItem(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getMapItemList()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getMapItemListIterator()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"getNumLives()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"getPacman()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getPacman()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Blinky","l":"getPoints()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Clyde","l":"getPoints()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Inky","l":"getPoints()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Pinky","l":"getPoints()"},{"p":"edu.uoc.pacman.model.entities.items","c":"Dot","l":"getPoints()"},{"p":"edu.uoc.pacman.model.entities.items","c":"Energizer","l":"getPoints()"},{"p":"edu.uoc.pacman.model.entities","c":"Scorable","l":"getPoints()"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"getPosition()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"getScatterPosition()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"getScore()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getScore()"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"getSprite()"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"getStartPosition()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"getState()"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"getSymbol()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"getTargetPosition()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"getWidth()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"getX()"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"getX()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"getY()"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"getY()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"Ghost(Position, Position, Direction, Behaviour, Sprite, Level)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Direction,edu.uoc.pacman.model.entities.characters.ghosts.Behaviour,edu.uoc.pacman.model.utils.Sprite,edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"GhostFactory","l":"GhostFactory()","u":"%3Cinit%3E()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"ghostList"},{"p":"edu.uoc.pacman.model.exceptions","c":"LevelException","l":"GHOSTS_ERROR"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"hashCode()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"hasLost()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"hasWon()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"height"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"hide()"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"hide()"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"hide()"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"hide()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"hit()"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Hitable","l":"hit()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"hit()"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"imageSrc"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"INACTIVE"},{"p":"edu.uoc.pacman.model","c":"Level","l":"increaseLives()"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"INKY"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Inky","l":"Inky(Position, Direction, Behaviour, Level)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Direction,edu.uoc.pacman.model.entities.characters.ghosts.Behaviour,edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"inkyAsset"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"InterLevelsScreen(PacmanGame)","u":"%3Cinit%3E(edu.uoc.pacman.view.PacmanGame)"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"INVINCIBLE"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"isDead()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"isFinished()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"isLevelCompleted()"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"isPathable()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"isPathable(Position)","u":"isPathable(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.model.entities.items","c":"Dot","l":"isPicked()"},{"p":"edu.uoc.pacman.model.entities.items","c":"Energizer","l":"isPicked()"},{"p":"edu.uoc.pacman.model.entities.items","c":"Life","l":"isPicked()"},{"p":"edu.uoc.pacman.model.entities.items","c":"Pickable","l":"isPicked()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"keyCode"},{"p":"edu.uoc.pacman.view","c":"UserInputProcessor","l":"keyDown(int)"},{"p":"edu.uoc.pacman.view","c":"UserInputProcessor","l":"keyUp(int)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"kill()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"kill()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"kill()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"LEFT"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"level"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"level"},{"p":"edu.uoc.pacman.model","c":"Level","l":"Level(String, int)","u":"%3Cinit%3E(java.lang.String,int)"},{"p":"edu.uoc.pacman.model.exceptions","c":"LevelException","l":"LevelException(String)","u":"%3Cinit%3E(java.lang.String)"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"LIFE"},{"p":"edu.uoc.pacman.model.entities.items","c":"Life","l":"Life(Position)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"lifeAsset"},{"p":"edu.uoc.pacman.model","c":"Level","l":"lives"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"loaded"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"loadImages()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"loadLevel()"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"logoAsset"},{"p":"edu.uoc.pacman.model.entities.items","c":"MapItem","l":"MapItem(Position, boolean, Sprite)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,boolean,edu.uoc.pacman.model.utils.Sprite)"},{"p":"edu.uoc.pacman.model.entities.items","c":"MapItemFactory","l":"MapItemFactory()","u":"%3Cinit%3E()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"mapItemList"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"maxLevels"},{"p":"edu.uoc.pacman.model","c":"Level","l":"MIN_HEIGHT"},{"p":"edu.uoc.pacman.model","c":"Level","l":"MIN_WIDTH"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"move()"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Movable","l":"move()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"move()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"nextBehaviour()"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"nextLevel()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"nextState()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"NORMAL"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"NUM_LIVES"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"opposite()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"pacman"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"PACMAN_DOWN"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"PACMAN_LEFT"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"PACMAN_RIGHT"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"PACMAN_UP"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"Pacman(Position, Direction, State, Level)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Direction,edu.uoc.pacman.model.entities.characters.pacman.State,edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"pacmanDownAsset"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"PacmanGame()","u":"%3Cinit%3E()"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"pacmanLeftAsset"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"pacmanRightAsset"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"pacmanUpAsset"},{"p":"edu.uoc.pacman.model","c":"Level","l":"parse()"},{"p":"edu.uoc.pacman.model.exceptions","c":"LevelException","l":"PARSING_LEVEL_FILE_ERROR"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"PATH"},{"p":"edu.uoc.pacman.model.entities.items","c":"Path","l":"Path(Position)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"pathable"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"pathAsset"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"pause()"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"pause()"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"pause()"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"pause()"},{"p":"edu.uoc.pacman.model.exceptions","c":"LevelException","l":"PICKABLE_ERROR"},{"p":"edu.uoc.pacman.model.entities.items","c":"Dot","l":"picked"},{"p":"edu.uoc.pacman.model.entities.items","c":"Energizer","l":"picked"},{"p":"edu.uoc.pacman.model.entities.items","c":"Life","l":"picked"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"PINKY"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Pinky","l":"Pinky(Position, Direction, Behaviour, Level)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position,edu.uoc.pacman.model.utils.Direction,edu.uoc.pacman.model.entities.characters.ghosts.Behaviour,edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"pinkyAsset"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Blinky","l":"POINTS"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Clyde","l":"POINTS"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Inky","l":"POINTS"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Pinky","l":"POINTS"},{"p":"edu.uoc.pacman.model.entities.items","c":"Dot","l":"POINTS"},{"p":"edu.uoc.pacman.model.entities.items","c":"Energizer","l":"POINTS"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"position"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"Position(int, int)","u":"%3Cinit%3E(int,int)"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"reload()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"removeMapItem(MapItem)","u":"removeMapItem(edu.uoc.pacman.model.entities.items.MapItem)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"render()"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"render(float)"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"render(float)"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"render(float)"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"render(float)"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"reset()"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"reset()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"reset()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"reset()"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"resize(int, int)","u":"resize(int,int)"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"resize(int, int)","u":"resize(int,int)"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"resize(int, int)","u":"resize(int,int)"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"resize(int, int)","u":"resize(int,int)"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"resume()"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"resume()"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"resume()"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"resume()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"RIGHT"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"SCATTER"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"scatterPosition"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"score"},{"p":"edu.uoc.pacman.model","c":"Level","l":"score"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"setBehaviour(Behaviour)","u":"setBehaviour(edu.uoc.pacman.model.entities.characters.ghosts.Behaviour)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"setDead(boolean)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"setDirection(Direction)","u":"setDirection(edu.uoc.pacman.model.utils.Direction)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Movable","l":"setDirection(Direction)","u":"setDirection(edu.uoc.pacman.model.utils.Direction)"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"setDirection(Direction)","u":"setDirection(edu.uoc.pacman.model.utils.Direction)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"setDuration(int)"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"setFileFolder(String)","u":"setFileFolder(java.lang.String)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"setFileName(String)","u":"setFileName(java.lang.String)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"setGhostsFrightened()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"setHeight(int)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"setLevel(Level)","u":"setLevel(edu.uoc.pacman.model.Level)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"setLives(int)"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"setPacmanDirection(Direction)","u":"setPacmanDirection(edu.uoc.pacman.model.utils.Direction)"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"setPathable(boolean)"},{"p":"edu.uoc.pacman.model.entities.items","c":"Dot","l":"setPicked(boolean)"},{"p":"edu.uoc.pacman.model.entities.items","c":"Energizer","l":"setPicked(boolean)"},{"p":"edu.uoc.pacman.model.entities.items","c":"Life","l":"setPicked(boolean)"},{"p":"edu.uoc.pacman.model.entities.items","c":"Pickable","l":"setPicked(boolean)"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"setPosition(Position)","u":"setPosition(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"setScatterPosition(Position)","u":"setScatterPosition(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"setScore(int)"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"setSprite(Sprite)","u":"setSprite(edu.uoc.pacman.model.utils.Sprite)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"setStartPosition(Position)","u":"setStartPosition(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"setState(State)","u":"setState(edu.uoc.pacman.model.entities.characters.pacman.State)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"setWidth(int)"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"setX(int)"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"setY(int)"},{"p":"edu.uoc.pacman.view","c":"GameOverScreen","l":"show()"},{"p":"edu.uoc.pacman.view","c":"GameScreen","l":"show()"},{"p":"edu.uoc.pacman.view","c":"InterLevelsScreen","l":"show()"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"show()"},{"p":"edu.uoc.pacman.model.exceptions","c":"LevelException","l":"SIZE_ERROR"},{"p":"edu.uoc.pacman.model.entities","c":"Entity","l":"sprite"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"Sprite(char, String)","u":"%3Cinit%3E(char,java.lang.String)"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"startPosition"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"Pacman","l":"state"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"State(int)","u":"%3Cinit%3E(int)"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"symbol"},{"p":"edu.uoc.pacman.model","c":"Level","l":"tick"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseAmbush","l":"TILES_OFFSET"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChasePatrol","l":"TILES_OFFSET"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChaseCoward","l":"TILES_TO_CHASE"},{"p":"edu.uoc.pacman.model.entities.characters","c":"Character","l":"toString()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"toString()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Ghost","l":"toString()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"toString()"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"toString()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"UP"},{"p":"edu.uoc.pacman.model","c":"Level","l":"UPDATE_GAME"},{"p":"edu.uoc.pacman.controller","c":"Game","l":"update()"},{"p":"edu.uoc.pacman.model","c":"Level","l":"update()"},{"p":"edu.uoc.pacman.view","c":"UserInputProcessor","l":"UserInputProcessor(Game)","u":"%3Cinit%3E(edu.uoc.pacman.controller.Game)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"valueOf(String)","u":"valueOf(java.lang.String)"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"valueOf(String)","u":"valueOf(java.lang.String)"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"valueOf(String)","u":"valueOf(java.lang.String)"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"valueOf(String)","u":"valueOf(java.lang.String)"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","c":"Behaviour","l":"values()"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","c":"State","l":"values()"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"values()"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"values()"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","c":"ChasePatrol","l":"VECTOR_INCREASE"},{"p":"edu.uoc.pacman.model.utils","c":"Sprite","l":"WALL"},{"p":"edu.uoc.pacman.model.entities.items","c":"Wall","l":"Wall(Position)","u":"%3Cinit%3E(edu.uoc.pacman.model.utils.Position)"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"wallAsset"},{"p":"edu.uoc.pacman.view","c":"WelcomeScreen","l":"WelcomeScreen(PacmanGame)","u":"%3Cinit%3E(edu.uoc.pacman.view.PacmanGame)"},{"p":"edu.uoc.pacman.model","c":"Level","l":"width"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"WINDOW_HEIGHT"},{"p":"edu.uoc.pacman.view","c":"PacmanGame","l":"WINDOW_WIDTH"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"x"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"x"},{"p":"edu.uoc.pacman.model.utils","c":"Direction","l":"y"},{"p":"edu.uoc.pacman.model.utils","c":"Position","l":"y"}];updateSearchResults(); \ No newline at end of file diff --git a/core/docs/module-search-index.js b/core/docs/module-search-index.js new file mode 100644 index 0000000..0d59754 --- /dev/null +++ b/core/docs/module-search-index.js @@ -0,0 +1 @@ +moduleSearchIndex = [];updateSearchResults(); \ No newline at end of file diff --git a/core/docs/overview-summary.html b/core/docs/overview-summary.html new file mode 100644 index 0000000..e4fb1a8 --- /dev/null +++ b/core/docs/overview-summary.html @@ -0,0 +1,25 @@ + + + + +core 1.0 API + + + + + + + + + + +
+ +

index.html

+
+ + diff --git a/core/docs/overview-tree.html b/core/docs/overview-tree.html new file mode 100644 index 0000000..6be5dfc --- /dev/null +++ b/core/docs/overview-tree.html @@ -0,0 +1,164 @@ + + + + +Class Hierarchy (core 1.0 API) + + + + + + + + + + + + + + +
+ +
+
+ +
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAggressive (implements edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour)
    • +
    • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAmbush (implements edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour)
    • +
    • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseCoward (implements edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour)
    • +
    • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol (implements edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour)
    • +
    • edu.uoc.pacman.model.entities.Entity +
        +
      • edu.uoc.pacman.model.entities.characters.Character (implements edu.uoc.pacman.model.entities.characters.Hitable, edu.uoc.pacman.model.entities.characters.Movable) +
          +
        • edu.uoc.pacman.model.entities.characters.ghosts.Ghost (implements edu.uoc.pacman.model.entities.Scorable) +
            +
          • edu.uoc.pacman.model.entities.characters.ghosts.Blinky
          • +
          • edu.uoc.pacman.model.entities.characters.ghosts.Clyde
          • +
          • edu.uoc.pacman.model.entities.characters.ghosts.Inky
          • +
          • edu.uoc.pacman.model.entities.characters.ghosts.Pinky
          • +
          +
        • +
        • edu.uoc.pacman.model.entities.characters.pacman.Pacman
        • +
        +
      • +
      • edu.uoc.pacman.model.entities.items.MapItem +
          +
        • edu.uoc.pacman.model.entities.items.Dot (implements edu.uoc.pacman.model.entities.items.Pickable, edu.uoc.pacman.model.entities.Scorable)
        • +
        • edu.uoc.pacman.model.entities.items.Energizer (implements edu.uoc.pacman.model.entities.items.Pickable, edu.uoc.pacman.model.entities.Scorable)
        • +
        • edu.uoc.pacman.model.entities.items.Life (implements edu.uoc.pacman.model.entities.items.Pickable)
        • +
        • edu.uoc.pacman.model.entities.items.Path
        • +
        • edu.uoc.pacman.model.entities.items.Wall
        • +
        +
      • +
      +
    • +
    • com.badlogic.gdx.Game (implements com.badlogic.gdx.ApplicationListener) + +
    • +
    • edu.uoc.pacman.controller.Game
    • +
    • edu.uoc.pacman.view.GameOverScreen (implements com.badlogic.gdx.Screen)
    • +
    • edu.uoc.pacman.view.GameScreen (implements com.badlogic.gdx.Screen)
    • +
    • edu.uoc.pacman.model.entities.characters.ghosts.GhostFactory
    • +
    • com.badlogic.gdx.InputAdapter (implements com.badlogic.gdx.InputProcessor) + +
    • +
    • edu.uoc.pacman.view.InterLevelsScreen (implements com.badlogic.gdx.Screen)
    • +
    • edu.uoc.pacman.model.Level
    • +
    • edu.uoc.pacman.model.entities.items.MapItemFactory
    • +
    • edu.uoc.pacman.model.utils.Position
    • +
    • java.lang.Throwable (implements java.io.Serializable) + +
    • +
    • edu.uoc.pacman.view.WelcomeScreen (implements com.badlogic.gdx.Screen)
    • +
    +
  • +
+
+
+

Interface Hierarchy

+
    +
  • edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour
  • +
  • edu.uoc.pacman.model.entities.characters.Hitable
  • +
  • edu.uoc.pacman.model.entities.characters.Movable
  • +
  • edu.uoc.pacman.model.entities.items.Pickable
  • +
  • edu.uoc.pacman.model.entities.Scorable
  • +
+
+
+

Enum Class Hierarchy

+ +
+
+
+
+ + diff --git a/core/docs/package-search-index.js b/core/docs/package-search-index.js new file mode 100644 index 0000000..71b0052 --- /dev/null +++ b/core/docs/package-search-index.js @@ -0,0 +1 @@ +packageSearchIndex = [{"l":"All Packages","u":"allpackages-index.html"},{"l":"edu.uoc.pacman.controller"},{"l":"edu.uoc.pacman.model"},{"l":"edu.uoc.pacman.model.entities"},{"l":"edu.uoc.pacman.model.entities.characters"},{"l":"edu.uoc.pacman.model.entities.characters.ghosts"},{"l":"edu.uoc.pacman.model.entities.characters.ghosts.chase"},{"l":"edu.uoc.pacman.model.entities.characters.pacman"},{"l":"edu.uoc.pacman.model.entities.items"},{"l":"edu.uoc.pacman.model.exceptions"},{"l":"edu.uoc.pacman.model.utils"},{"l":"edu.uoc.pacman.view"}];updateSearchResults(); \ No newline at end of file diff --git a/core/docs/resources/glass.png b/core/docs/resources/glass.png new file mode 100644 index 0000000..a7f591f Binary files /dev/null and b/core/docs/resources/glass.png differ diff --git a/core/docs/resources/x.png b/core/docs/resources/x.png new file mode 100644 index 0000000..30548a7 Binary files /dev/null and b/core/docs/resources/x.png differ diff --git a/core/docs/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png b/core/docs/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png new file mode 100644 index 0000000..34abd18 Binary files /dev/null and b/core/docs/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png differ diff --git a/core/docs/script-dir/images/ui-bg_glass_65_dadada_1x400.png b/core/docs/script-dir/images/ui-bg_glass_65_dadada_1x400.png new file mode 100644 index 0000000..f058a93 Binary files /dev/null and b/core/docs/script-dir/images/ui-bg_glass_65_dadada_1x400.png differ diff --git a/core/docs/script-dir/images/ui-bg_glass_75_dadada_1x400.png b/core/docs/script-dir/images/ui-bg_glass_75_dadada_1x400.png new file mode 100644 index 0000000..2ce04c1 Binary files /dev/null and b/core/docs/script-dir/images/ui-bg_glass_75_dadada_1x400.png differ diff --git a/core/docs/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png b/core/docs/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png new file mode 100644 index 0000000..a90afb8 Binary files /dev/null and b/core/docs/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png differ diff --git a/core/docs/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png b/core/docs/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png new file mode 100644 index 0000000..dbe091f Binary files /dev/null and b/core/docs/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png differ diff --git a/core/docs/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/core/docs/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png new file mode 100644 index 0000000..5dc3593 Binary files /dev/null and b/core/docs/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png differ diff --git a/core/docs/script-dir/images/ui-icons_222222_256x240.png b/core/docs/script-dir/images/ui-icons_222222_256x240.png new file mode 100644 index 0000000..e723e17 Binary files /dev/null and b/core/docs/script-dir/images/ui-icons_222222_256x240.png differ diff --git a/core/docs/script-dir/images/ui-icons_2e83ff_256x240.png b/core/docs/script-dir/images/ui-icons_2e83ff_256x240.png new file mode 100644 index 0000000..1f5f497 Binary files /dev/null and b/core/docs/script-dir/images/ui-icons_2e83ff_256x240.png differ diff --git a/core/docs/script-dir/images/ui-icons_454545_256x240.png b/core/docs/script-dir/images/ui-icons_454545_256x240.png new file mode 100644 index 0000000..618f5b0 Binary files /dev/null and b/core/docs/script-dir/images/ui-icons_454545_256x240.png differ diff --git a/core/docs/script-dir/images/ui-icons_888888_256x240.png b/core/docs/script-dir/images/ui-icons_888888_256x240.png new file mode 100644 index 0000000..ee5e33f Binary files /dev/null and b/core/docs/script-dir/images/ui-icons_888888_256x240.png differ diff --git a/core/docs/script-dir/images/ui-icons_cd0a0a_256x240.png b/core/docs/script-dir/images/ui-icons_cd0a0a_256x240.png new file mode 100644 index 0000000..7e8ebc1 Binary files /dev/null and b/core/docs/script-dir/images/ui-icons_cd0a0a_256x240.png differ diff --git a/core/docs/script-dir/jquery-3.5.1.min.js b/core/docs/script-dir/jquery-3.5.1.min.js new file mode 100644 index 0000000..b061403 --- /dev/null +++ b/core/docs/script-dir/jquery-3.5.1.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.5.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.5.1",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function D(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||j,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,j=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function qe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function Le(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function He(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Oe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Ut,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xt.pop()||S.expando+"_"+Ct.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Vt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Vt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Xt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Ut=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Ut.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):("number"==typeof f.top&&(f.top+="px"),"number"==typeof f.left&&(f.left+="px"),c.css(f))}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=$e(y.pixelPosition,function(e,t){if(t)return t=Be(e,n),Me.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0a;a++)for(s in o[a])n=o[a][s],o[a].hasOwnProperty(s)&&void 0!==n&&(e[s]=t.isPlainObject(n)?t.isPlainObject(e[s])?t.widget.extend({},e[s],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,s){var n=s.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=i.call(arguments,1),l=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(l=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(l=i&&i.jquery?l.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):l=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new s(o,this))})),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(i,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),i),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var l=s.match(/^([\w:-]*)\s*(.*)$/),h=l[1]+o.eventNamespace,c=l[2];c?n.on(h,c,r):i.on(h,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,l=/top|center|bottom/,h=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.widthi?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};h>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),l.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,l=n-r,h=r+e.collisionWidth-a-n;e.collisionWidth>a?l>0&&0>=h?(i=t.left+l+e.collisionWidth-a-n,t.left+=l-i):t.left=h>0&&0>=l?n:l>h?n+a-e.collisionWidth:n:l>0?t.left+=l:h>0?t.left-=h:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,l=n-r,h=r+e.collisionHeight-a-n;e.collisionHeight>a?l>0&&0>=h?(i=t.top+l+e.collisionHeight-a-n,t.top+=l-i):t.top=h>0&&0>=l?n:l>h?n+a-e.collisionHeight:n:l>0?t.top+=l:h>0?t.top-=h:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,l=n.isWindow?n.scrollLeft:n.offset.left,h=t.left-e.collisionPosition.marginLeft,c=h-l,u=h+e.collisionWidth-r-l,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-l,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,l=n.isWindow?n.scrollTop:n.offset.top,h=t.top-e.collisionPosition.marginTop,c=h-l,u=h+e.collisionHeight-r-l,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,g=-2*e.offset[1];0>c?(s=t.top+p+f+g+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+g)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+g-l,(i>0||u>a(i))&&(t.top+=p+f+g))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.safeActiveElement=function(t){var e;try{e=t.activeElement}catch(i){e=t.body}return e||(e=t.body),e.nodeName||(e=t.body),e},t.widget("ui.menu",{version:"1.12.1",defaultElement:"
    ",delay:300,options:{icons:{submenu:"ui-icon-caret-1-e"},items:"> *",menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().attr({role:this.options.role,tabIndex:0}),this._addClass("ui-menu","ui-widget ui-widget-content"),this._on({"mousedown .ui-menu-item":function(t){t.preventDefault()},"click .ui-menu-item":function(e){var i=t(e.target),s=t(t.ui.safeActiveElement(this.document[0]));!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(e),e.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(e):!this.element.is(":focus")&&s.closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(e){if(!this.previousFilter){var i=t(e.target).closest(".ui-menu-item"),s=t(e.currentTarget);i[0]===s[0]&&(this._removeClass(s.siblings().children(".ui-state-active"),null,"ui-state-active"),this.focus(e,s))}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(t,e){var i=this.active||this.element.find(this.options.items).eq(0);e||this.focus(t,i)},blur:function(e){this._delay(function(){var i=!t.contains(this.element[0],t.ui.safeActiveElement(this.document[0]));i&&this.collapseAll(e)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){this._closeOnDocumentClick(t)&&this.collapseAll(t),this.mouseHandled=!1}})},_destroy:function(){var e=this.element.find(".ui-menu-item").removeAttr("role aria-disabled"),i=e.children(".ui-menu-item-wrapper").removeUniqueId().removeAttr("tabIndex role aria-haspopup");this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeAttr("role aria-labelledby aria-expanded aria-hidden aria-disabled tabIndex").removeUniqueId().show(),i.children().each(function(){var e=t(this);e.data("ui-menu-submenu-caret")&&e.remove()})},_keydown:function(e){var i,s,n,o,a=!0;switch(e.keyCode){case t.ui.keyCode.PAGE_UP:this.previousPage(e);break;case t.ui.keyCode.PAGE_DOWN:this.nextPage(e);break;case t.ui.keyCode.HOME:this._move("first","first",e);break;case t.ui.keyCode.END:this._move("last","last",e);break;case t.ui.keyCode.UP:this.previous(e);break;case t.ui.keyCode.DOWN:this.next(e);break;case t.ui.keyCode.LEFT:this.collapse(e);break;case t.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(e);break;case t.ui.keyCode.ENTER:case t.ui.keyCode.SPACE:this._activate(e);break;case t.ui.keyCode.ESCAPE:this.collapse(e);break;default:a=!1,s=this.previousFilter||"",o=!1,n=e.keyCode>=96&&105>=e.keyCode?""+(e.keyCode-96):String.fromCharCode(e.keyCode),clearTimeout(this.filterTimer),n===s?o=!0:n=s+n,i=this._filterMenuItems(n),i=o&&-1!==i.index(this.active.next())?this.active.nextAll(".ui-menu-item"):i,i.length||(n=String.fromCharCode(e.keyCode),i=this._filterMenuItems(n)),i.length?(this.focus(e,i),this.previousFilter=n,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}a&&e.preventDefault()},_activate:function(t){this.active&&!this.active.is(".ui-state-disabled")&&(this.active.children("[aria-haspopup='true']").length?this.expand(t):this.select(t))},refresh:function(){var e,i,s,n,o,a=this,r=this.options.icons.submenu,l=this.element.find(this.options.menus);this._toggleClass("ui-menu-icons",null,!!this.element.find(".ui-icon").length),s=l.filter(":not(.ui-menu)").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var e=t(this),i=e.prev(),s=t("").data("ui-menu-submenu-caret",!0);a._addClass(s,"ui-menu-icon","ui-icon "+r),i.attr("aria-haspopup","true").prepend(s),e.attr("aria-labelledby",i.attr("id"))}),this._addClass(s,"ui-menu","ui-widget ui-widget-content ui-front"),e=l.add(this.element),i=e.find(this.options.items),i.not(".ui-menu-item").each(function(){var e=t(this);a._isDivider(e)&&a._addClass(e,"ui-menu-divider","ui-widget-content")}),n=i.not(".ui-menu-item, .ui-menu-divider"),o=n.children().not(".ui-menu").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),this._addClass(n,"ui-menu-item")._addClass(o,"ui-menu-item-wrapper"),i.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!t.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(t,e){if("icons"===t){var i=this.element.find(".ui-menu-icon");this._removeClass(i,null,this.options.icons.submenu)._addClass(i,null,e.submenu)}this._super(t,e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",t+""),this._toggleClass(null,"ui-state-disabled",!!t)},focus:function(t,e){var i,s,n;this.blur(t,t&&"focus"===t.type),this._scrollIntoView(e),this.active=e.first(),s=this.active.children(".ui-menu-item-wrapper"),this._addClass(s,null,"ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),n=this.active.parent().closest(".ui-menu-item").children(".ui-menu-item-wrapper"),this._addClass(n,null,"ui-state-active"),t&&"keydown"===t.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=e.children(".ui-menu"),i.length&&t&&/^mouse/.test(t.type)&&this._startOpening(i),this.activeMenu=e.parent(),this._trigger("focus",t,{item:e})},_scrollIntoView:function(e){var i,s,n,o,a,r;this._hasScroll()&&(i=parseFloat(t.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(t.css(this.activeMenu[0],"paddingTop"))||0,n=e.offset().top-this.activeMenu.offset().top-i-s,o=this.activeMenu.scrollTop(),a=this.activeMenu.height(),r=e.outerHeight(),0>n?this.activeMenu.scrollTop(o+n):n+r>a&&this.activeMenu.scrollTop(o+n-a+r))},blur:function(t,e){e||clearTimeout(this.timer),this.active&&(this._removeClass(this.active.children(".ui-menu-item-wrapper"),null,"ui-state-active"),this._trigger("blur",t,{item:this.active}),this.active=null)},_startOpening:function(t){clearTimeout(this.timer),"true"===t.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(t)},this.delay))},_open:function(e){var i=t.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(e.parents(".ui-menu")).hide().attr("aria-hidden","true"),e.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(e,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:t(e&&e.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(e),this._removeClass(s.find(".ui-state-active"),null,"ui-state-active"),this.activeMenu=s},this.delay)},_close:function(t){t||(t=this.active?this.active.parent():this.element),t.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false")},_closeOnDocumentClick:function(e){return!t(e.target).closest(".ui-menu").length},_isDivider:function(t){return!/[^\-\u2014\u2013\s]/.test(t.text())},collapse:function(t){var e=this.active&&this.active.parent().closest(".ui-menu-item",this.element);e&&e.length&&(this._close(),this.focus(t,e))},expand:function(t){var e=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();e&&e.length&&(this._open(e.parent()),this._delay(function(){this.focus(t,e)}))},next:function(t){this._move("next","first",t)},previous:function(t){this._move("prev","last",t)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(t,e,i){var s;this.active&&(s="first"===t||"last"===t?this.active["first"===t?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[t+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.find(this.options.items)[e]()),this.focus(i,s)},nextPage:function(e){var i,s,n;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=t(this),0>i.offset().top-s-n}),this.focus(e,i)):this.focus(e,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())),void 0):(this.next(e),void 0)},previousPage:function(e){var i,s,n;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=t(this),i.offset().top-s+n>0}),this.focus(e,i)):this.focus(e,this.activeMenu.find(this.options.items).first())),void 0):(this.next(e),void 0)},_hasScroll:function(){return this.element.outerHeight()",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var e,i,s,n=this.element[0].nodeName.toLowerCase(),o="textarea"===n,a="input"===n;this.isMultiLine=o||!a&&this._isContentEditable(this.element),this.valueMethod=this.element[o||a?"val":"text"],this.isNewMenu=!0,this._addClass("ui-autocomplete-input"),this.element.attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return e=!0,s=!0,i=!0,void 0;e=!1,s=!1,i=!1;var o=t.ui.keyCode;switch(n.keyCode){case o.PAGE_UP:e=!0,this._move("previousPage",n);break;case o.PAGE_DOWN:e=!0,this._move("nextPage",n);break;case o.UP:e=!0,this._keyEvent("previous",n);break;case o.DOWN:e=!0,this._keyEvent("next",n);break;case o.ENTER:this.menu.active&&(e=!0,n.preventDefault(),this.menu.select(n));break;case o.TAB:this.menu.active&&this.menu.select(n);break;case o.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(e)return e=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),void 0;if(!i){var n=t.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(t){return s?(s=!1,t.preventDefault(),void 0):(this._searchTimeout(t),void 0)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){return this.cancelBlur?(delete this.cancelBlur,void 0):(clearTimeout(this.searching),this.close(t),this._change(t),void 0)}}),this._initSource(),this.menu=t("
      ").appendTo(this._appendTo()).menu({role:null}).hide().menu("instance"),this._addClass(this.menu.element,"ui-autocomplete","ui-front"),this._on(this.menu.element,{mousedown:function(e){e.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,this.element[0]!==t.ui.safeActiveElement(this.document[0])&&this.element.trigger("focus")})},menufocus:function(e,i){var s,n;return this.isNewMenu&&(this.isNewMenu=!1,e.originalEvent&&/^mouse/.test(e.originalEvent.type))?(this.menu.blur(),this.document.one("mousemove",function(){t(e.target).trigger(e.originalEvent)}),void 0):(n=i.item.data("ui-autocomplete-item"),!1!==this._trigger("focus",e,{item:n})&&e.originalEvent&&/^key/.test(e.originalEvent.type)&&this._value(n.value),s=i.item.attr("aria-label")||n.value,s&&t.trim(s).length&&(this.liveRegion.children().hide(),t("
      ").text(s).appendTo(this.liveRegion)),void 0)},menuselect:function(e,i){var s=i.item.data("ui-autocomplete-item"),n=this.previous;this.element[0]!==t.ui.safeActiveElement(this.document[0])&&(this.element.trigger("focus"),this.previous=n,this._delay(function(){this.previous=n,this.selectedItem=s})),!1!==this._trigger("select",e,{item:s})&&this._value(s.value),this.term=this._value(),this.close(e),this.selectedItem=s}}),this.liveRegion=t("
      ",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).appendTo(this.document[0].body),this._addClass(this.liveRegion,null,"ui-helper-hidden-accessible"),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(t,e){this._super(t,e),"source"===t&&this._initSource(),"appendTo"===t&&this.menu.element.appendTo(this._appendTo()),"disabled"===t&&e&&this.xhr&&this.xhr.abort()},_isEventTargetInWidget:function(e){var i=this.menu.element[0];return e.target===this.element[0]||e.target===i||t.contains(i,e.target)},_closeOnClickOutside:function(t){this._isEventTargetInWidget(t)||this.close()},_appendTo:function(){var e=this.options.appendTo;return e&&(e=e.jquery||e.nodeType?t(e):this.document.find(e).eq(0)),e&&e[0]||(e=this.element.closest(".ui-front, dialog")),e.length||(e=this.document[0].body),e},_initSource:function(){var e,i,s=this;t.isArray(this.options.source)?(e=this.options.source,this.source=function(i,s){s(t.ui.autocomplete.filter(e,i.term))}):"string"==typeof this.options.source?(i=this.options.source,this.source=function(e,n){s.xhr&&s.xhr.abort(),s.xhr=t.ajax({url:i,data:e,dataType:"json",success:function(t){n(t)},error:function(){n([])}})}):this.source=this.options.source},_searchTimeout:function(t){clearTimeout(this.searching),this.searching=this._delay(function(){var e=this.term===this._value(),i=this.menu.element.is(":visible"),s=t.altKey||t.ctrlKey||t.metaKey||t.shiftKey;(!e||e&&!i&&!s)&&(this.selectedItem=null,this.search(null,t))},this.options.delay)},search:function(t,e){return t=null!=t?t:this._value(),this.term=this._value(),t.length").append(t("
      ").text(i.label)).appendTo(e)},_move:function(t,e){return this.menu.element.is(":visible")?this.menu.isFirstItem()&&/^previous/.test(t)||this.menu.isLastItem()&&/^next/.test(t)?(this.isMultiLine||this._value(this.term),this.menu.blur(),void 0):(this.menu[t](e),void 0):(this.search(null,e),void 0)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(t,e){(!this.isMultiLine||this.menu.element.is(":visible"))&&(this._move(t,e),e.preventDefault())},_isContentEditable:function(t){if(!t.length)return!1;var e=t.prop("contentEditable");return"inherit"===e?this._isContentEditable(t.parent()):"true"===e}}),t.extend(t.ui.autocomplete,{escapeRegex:function(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(e,i){var s=RegExp(t.ui.autocomplete.escapeRegex(i),"i");return t.grep(e,function(t){return s.test(t.label||t.value||t)})}}),t.widget("ui.autocomplete",t.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(t){return t+(t>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(e){var i;this._superApply(arguments),this.options.disabled||this.cancelSearch||(i=e&&e.length?this.options.messages.results(e.length):this.options.messages.noResults,this.liveRegion.children().hide(),t("
      ").text(i).appendTo(this.liveRegion))}}),t.ui.autocomplete}); \ No newline at end of file diff --git a/core/docs/script-dir/jquery-ui.structure.min.css b/core/docs/script-dir/jquery-ui.structure.min.css new file mode 100644 index 0000000..e880892 --- /dev/null +++ b/core/docs/script-dir/jquery-ui.structure.min.css @@ -0,0 +1,5 @@ +/*! jQuery UI - v1.12.1 - 2018-12-06 +* http://jqueryui.com +* Copyright jQuery Foundation and other contributors; Licensed MIT */ + +.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0} \ No newline at end of file diff --git a/core/docs/script.js b/core/docs/script.js new file mode 100644 index 0000000..ccac782 --- /dev/null +++ b/core/docs/script.js @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +var moduleSearchIndex; +var packageSearchIndex; +var typeSearchIndex; +var memberSearchIndex; +var tagSearchIndex; +function loadScripts(doc, tag) { + createElem(doc, tag, 'search.js'); + + createElem(doc, tag, 'module-search-index.js'); + createElem(doc, tag, 'package-search-index.js'); + createElem(doc, tag, 'type-search-index.js'); + createElem(doc, tag, 'member-search-index.js'); + createElem(doc, tag, 'tag-search-index.js'); +} + +function createElem(doc, tag, path) { + var script = doc.createElement(tag); + var scriptElement = doc.getElementsByTagName(tag)[0]; + script.src = pathtoroot + path; + scriptElement.parentNode.insertBefore(script, scriptElement); +} + +function show(tableId, selected, columns) { + if (tableId !== selected) { + document.querySelectorAll('div.' + tableId + ':not(.' + selected + ')') + .forEach(function(elem) { + elem.style.display = 'none'; + }); + } + document.querySelectorAll('div.' + selected) + .forEach(function(elem, index) { + elem.style.display = ''; + var isEvenRow = index % (columns * 2) < columns; + elem.classList.remove(isEvenRow ? oddRowColor : evenRowColor); + elem.classList.add(isEvenRow ? evenRowColor : oddRowColor); + }); + updateTabs(tableId, selected); +} + +function updateTabs(tableId, selected) { + document.querySelector('div#' + tableId +' .summary-table') + .setAttribute('aria-labelledby', selected); + document.querySelectorAll('button[id^="' + tableId + '"]') + .forEach(function(tab, index) { + if (selected === tab.id || (tableId === selected && index === 0)) { + tab.className = activeTableTab; + tab.setAttribute('aria-selected', true); + tab.setAttribute('tabindex',0); + } else { + tab.className = tableTab; + tab.setAttribute('aria-selected', false); + tab.setAttribute('tabindex',-1); + } + }); +} + +function switchTab(e) { + var selected = document.querySelector('[aria-selected=true]'); + if (selected) { + if ((e.keyCode === 37 || e.keyCode === 38) && selected.previousSibling) { + // left or up arrow key pressed: move focus to previous tab + selected.previousSibling.click(); + selected.previousSibling.focus(); + e.preventDefault(); + } else if ((e.keyCode === 39 || e.keyCode === 40) && selected.nextSibling) { + // right or down arrow key pressed: move focus to next tab + selected.nextSibling.click(); + selected.nextSibling.focus(); + e.preventDefault(); + } + } +} + +var updateSearchResults = function() {}; + +function indexFilesLoaded() { + return moduleSearchIndex + && packageSearchIndex + && typeSearchIndex + && memberSearchIndex + && tagSearchIndex; +} + +// Workaround for scroll position not being included in browser history (8249133) +document.addEventListener("DOMContentLoaded", function(e) { + var contentDiv = document.querySelector("div.flex-content"); + window.addEventListener("popstate", function(e) { + if (e.state !== null) { + contentDiv.scrollTop = e.state; + } + }); + window.addEventListener("hashchange", function(e) { + history.replaceState(contentDiv.scrollTop, document.title); + }); + contentDiv.addEventListener("scroll", function(e) { + var timeoutID; + if (!timeoutID) { + timeoutID = setTimeout(function() { + history.replaceState(contentDiv.scrollTop, document.title); + timeoutID = null; + }, 100); + } + }); + if (!location.hash) { + history.replaceState(contentDiv.scrollTop, document.title); + } +}); diff --git a/core/docs/search.js b/core/docs/search.js new file mode 100644 index 0000000..3f826c7 --- /dev/null +++ b/core/docs/search.js @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +var noResult = {l: "No results found"}; +var loading = {l: "Loading search index..."}; +var catModules = "Modules"; +var catPackages = "Packages"; +var catTypes = "Classes and Interfaces"; +var catMembers = "Members"; +var catSearchTags = "Search Tags"; +var highlight = "$&"; +var searchPattern = ""; +var fallbackPattern = ""; +var RANKING_THRESHOLD = 2; +var NO_MATCH = 0xffff; +var MIN_RESULTS = 3; +var MAX_RESULTS = 500; +var UNNAMED = ""; +function escapeHtml(str) { + return str.replace(//g, ">"); +} +function getHighlightedText(item, matcher, fallbackMatcher) { + var escapedItem = escapeHtml(item); + var highlighted = escapedItem.replace(matcher, highlight); + if (highlighted === escapedItem) { + highlighted = escapedItem.replace(fallbackMatcher, highlight) + } + return highlighted; +} +function getURLPrefix(ui) { + var urlPrefix=""; + var slash = "/"; + if (ui.item.category === catModules) { + return ui.item.l + slash; + } else if (ui.item.category === catPackages && ui.item.m) { + return ui.item.m + slash; + } else if (ui.item.category === catTypes || ui.item.category === catMembers) { + if (ui.item.m) { + urlPrefix = ui.item.m + slash; + } else { + $.each(packageSearchIndex, function(index, item) { + if (item.m && ui.item.p === item.l) { + urlPrefix = item.m + slash; + } + }); + } + } + return urlPrefix; +} +function createSearchPattern(term) { + var pattern = ""; + var isWordToken = false; + term.replace(/,\s*/g, ", ").trim().split(/\s+/).forEach(function(w, index) { + if (index > 0) { + // whitespace between identifiers is significant + pattern += (isWordToken && /^\w/.test(w)) ? "\\s+" : "\\s*"; + } + var tokens = w.split(/(?=[A-Z,.()<>[\/])/); + for (var i = 0; i < tokens.length; i++) { + var s = tokens[i]; + if (s === "") { + continue; + } + pattern += $.ui.autocomplete.escapeRegex(s); + isWordToken = /\w$/.test(s); + if (isWordToken) { + pattern += "([a-z0-9_$<>\\[\\]]*?)"; + } + } + }); + return pattern; +} +function createMatcher(pattern, flags) { + var isCamelCase = /[A-Z]/.test(pattern); + return new RegExp(pattern, flags + (isCamelCase ? "" : "i")); +} +var watermark = 'Search'; +$(function() { + var search = $("#search-input"); + var reset = $("#reset-button"); + search.val(''); + search.prop("disabled", false); + reset.prop("disabled", false); + search.val(watermark).addClass('watermark'); + search.blur(function() { + if ($(this).val().length === 0) { + $(this).val(watermark).addClass('watermark'); + } + }); + search.on('click keydown paste', function() { + if ($(this).val() === watermark) { + $(this).val('').removeClass('watermark'); + } + }); + reset.click(function() { + search.val('').focus(); + }); + search.focus()[0].setSelectionRange(0, 0); +}); +$.widget("custom.catcomplete", $.ui.autocomplete, { + _create: function() { + this._super(); + this.widget().menu("option", "items", "> :not(.ui-autocomplete-category)"); + }, + _renderMenu: function(ul, items) { + var rMenu = this; + var currentCategory = ""; + rMenu.menu.bindings = $(); + $.each(items, function(index, item) { + var li; + if (item.category && item.category !== currentCategory) { + ul.append("
    • " + item.category + "
    • "); + currentCategory = item.category; + } + li = rMenu._renderItemData(ul, item); + if (item.category) { + li.attr("aria-label", item.category + " : " + item.l); + li.attr("class", "result-item"); + } else { + li.attr("aria-label", item.l); + li.attr("class", "result-item"); + } + }); + }, + _renderItem: function(ul, item) { + var label = ""; + var matcher = createMatcher(escapeHtml(searchPattern), "g"); + var fallbackMatcher = new RegExp(fallbackPattern, "gi") + if (item.category === catModules) { + label = getHighlightedText(item.l, matcher, fallbackMatcher); + } else if (item.category === catPackages) { + label = getHighlightedText(item.l, matcher, fallbackMatcher); + } else if (item.category === catTypes) { + label = (item.p && item.p !== UNNAMED) + ? getHighlightedText(item.p + "." + item.l, matcher, fallbackMatcher) + : getHighlightedText(item.l, matcher, fallbackMatcher); + } else if (item.category === catMembers) { + label = (item.p && item.p !== UNNAMED) + ? getHighlightedText(item.p + "." + item.c + "." + item.l, matcher, fallbackMatcher) + : getHighlightedText(item.c + "." + item.l, matcher, fallbackMatcher); + } else if (item.category === catSearchTags) { + label = getHighlightedText(item.l, matcher, fallbackMatcher); + } else { + label = item.l; + } + var li = $("
    • ").appendTo(ul); + var div = $("
      ").appendTo(li); + if (item.category === catSearchTags && item.h) { + if (item.d) { + div.html(label + " (" + item.h + ")
      " + + item.d + "
      "); + } else { + div.html(label + " (" + item.h + ")"); + } + } else { + if (item.m) { + div.html(item.m + "/" + label); + } else { + div.html(label); + } + } + return li; + } +}); +function rankMatch(match, category) { + if (!match) { + return NO_MATCH; + } + var index = match.index; + var input = match.input; + var leftBoundaryMatch = 2; + var periferalMatch = 0; + // make sure match is anchored on a left word boundary + if (index === 0 || /\W/.test(input[index - 1]) || "_" === input[index]) { + leftBoundaryMatch = 0; + } else if ("_" === input[index - 1] || (input[index] === input[index].toUpperCase() && !/^[A-Z0-9_$]+$/.test(input))) { + leftBoundaryMatch = 1; + } + var matchEnd = index + match[0].length; + var leftParen = input.indexOf("("); + var endOfName = leftParen > -1 ? leftParen : input.length; + // exclude peripheral matches + if (category !== catModules && category !== catSearchTags) { + var delim = category === catPackages ? "/" : "."; + if (leftParen > -1 && leftParen < index) { + periferalMatch += 2; + } else if (input.lastIndexOf(delim, endOfName) >= matchEnd) { + periferalMatch += 2; + } + } + var delta = match[0].length === endOfName ? 0 : 1; // rank full match higher than partial match + for (var i = 1; i < match.length; i++) { + // lower ranking if parts of the name are missing + if (match[i]) + delta += match[i].length; + } + if (category === catTypes) { + // lower ranking if a type name contains unmatched camel-case parts + if (/[A-Z]/.test(input.substring(matchEnd))) + delta += 5; + if (/[A-Z]/.test(input.substring(0, index))) + delta += 5; + } + return leftBoundaryMatch + periferalMatch + (delta / 200); + +} +function doSearch(request, response) { + var result = []; + searchPattern = createSearchPattern(request.term); + fallbackPattern = createSearchPattern(request.term.toLowerCase()); + if (searchPattern === "") { + return this.close(); + } + var camelCaseMatcher = createMatcher(searchPattern, ""); + var fallbackMatcher = new RegExp(fallbackPattern, "i"); + + function searchIndexWithMatcher(indexArray, matcher, category, nameFunc) { + if (indexArray) { + var newResults = []; + $.each(indexArray, function (i, item) { + item.category = category; + var ranking = rankMatch(matcher.exec(nameFunc(item)), category); + if (ranking < RANKING_THRESHOLD) { + newResults.push({ranking: ranking, item: item}); + } + return newResults.length <= MAX_RESULTS; + }); + return newResults.sort(function(e1, e2) { + return e1.ranking - e2.ranking; + }).map(function(e) { + return e.item; + }); + } + return []; + } + function searchIndex(indexArray, category, nameFunc) { + var primaryResults = searchIndexWithMatcher(indexArray, camelCaseMatcher, category, nameFunc); + result = result.concat(primaryResults); + if (primaryResults.length <= MIN_RESULTS && !camelCaseMatcher.ignoreCase) { + var secondaryResults = searchIndexWithMatcher(indexArray, fallbackMatcher, category, nameFunc); + result = result.concat(secondaryResults.filter(function (item) { + return primaryResults.indexOf(item) === -1; + })); + } + } + + searchIndex(moduleSearchIndex, catModules, function(item) { return item.l; }); + searchIndex(packageSearchIndex, catPackages, function(item) { + return (item.m && request.term.indexOf("/") > -1) + ? (item.m + "/" + item.l) : item.l; + }); + searchIndex(typeSearchIndex, catTypes, function(item) { + return request.term.indexOf(".") > -1 ? item.p + "." + item.l : item.l; + }); + searchIndex(memberSearchIndex, catMembers, function(item) { + return request.term.indexOf(".") > -1 + ? item.p + "." + item.c + "." + item.l : item.l; + }); + searchIndex(tagSearchIndex, catSearchTags, function(item) { return item.l; }); + + if (!indexFilesLoaded()) { + updateSearchResults = function() { + doSearch(request, response); + } + result.unshift(loading); + } else { + updateSearchResults = function() {}; + } + response(result); +} +$(function() { + $("#search-input").catcomplete({ + minLength: 1, + delay: 300, + source: doSearch, + response: function(event, ui) { + if (!ui.content.length) { + ui.content.push(noResult); + } else { + $("#search-input").empty(); + } + }, + autoFocus: true, + focus: function(event, ui) { + return false; + }, + position: { + collision: "flip" + }, + select: function(event, ui) { + if (ui.item.category) { + var url = getURLPrefix(ui); + if (ui.item.category === catModules) { + url += "module-summary.html"; + } else if (ui.item.category === catPackages) { + if (ui.item.u) { + url = ui.item.u; + } else { + url += ui.item.l.replace(/\./g, '/') + "/package-summary.html"; + } + } else if (ui.item.category === catTypes) { + if (ui.item.u) { + url = ui.item.u; + } else if (ui.item.p === UNNAMED) { + url += ui.item.l + ".html"; + } else { + url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.l + ".html"; + } + } else if (ui.item.category === catMembers) { + if (ui.item.p === UNNAMED) { + url += ui.item.c + ".html" + "#"; + } else { + url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.c + ".html" + "#"; + } + if (ui.item.u) { + url += ui.item.u; + } else { + url += ui.item.l; + } + } else if (ui.item.category === catSearchTags) { + url += ui.item.u; + } + if (top !== window) { + parent.classFrame.location = pathtoroot + url; + } else { + window.location.href = pathtoroot + url; + } + $("#search-input").focus(); + } + } + }); +}); diff --git a/core/docs/serialized-form.html b/core/docs/serialized-form.html new file mode 100644 index 0000000..df25242 --- /dev/null +++ b/core/docs/serialized-form.html @@ -0,0 +1,71 @@ + + + + +Serialized Form (core 1.0 API) + + + + + + + + + + + + + + +
      + +
      +
      +
      +

      Serialized Form

      +
      + +
      +
      +
      + + diff --git a/core/docs/stylesheet.css b/core/docs/stylesheet.css new file mode 100644 index 0000000..8133b9b --- /dev/null +++ b/core/docs/stylesheet.css @@ -0,0 +1,865 @@ +/* + * Javadoc style sheet + */ + +@import url('resources/fonts/dejavu.css'); + +/* + * Styles for individual HTML elements. + * + * These are styles that are specific to individual HTML elements. Changing them affects the style of a particular + * HTML element throughout the page. + */ + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; + padding:0; + height:100%; + width:100%; +} +iframe { + margin:0; + padding:0; + height:100%; + width:100%; + overflow-y:scroll; + border:none; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a[href]:hover, a[href]:focus { + text-decoration:none; + color:#bb7a2a; +} +a[name] { + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; +} +h4 { + font-size:15px; +} +h5 { + font-size:14px; +} +h6 { + font-size:13px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; +} +:not(h1, h2, h3, h4, h5, h6) > code, +:not(h1, h2, h3, h4, h5, h6) > tt { + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +.summary-table dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +button { + font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size: 14px; +} +/* + * Styles for HTML generated by javadoc. + * + * These are style classes that are used by the standard doclet to generate HTML documentation. + */ + +/* + * Styles for document title and copyright. + */ +.clear { + clear:both; + height:0; + overflow:hidden; +} +.about-language { + float:right; + padding:0 21px 8px 8px; + font-size:11px; + margin-top:-9px; + height:2.9em; +} +.legal-copy { + margin-left:.5em; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* + * Styles for navigation bar. + */ +@media screen { + .flex-box { + position:fixed; + display:flex; + flex-direction:column; + height: 100%; + width: 100%; + } + .flex-header { + flex: 0 0 auto; + } + .flex-content { + flex: 1 1 auto; + overflow-y: auto; + } +} +.top-nav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + min-height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.sub-nav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.sub-nav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +.sub-nav .nav-list { + padding-top:5px; +} +ul.nav-list { + display:block; + margin:0 25px 0 0; + padding:0; +} +ul.sub-nav-list { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.nav-list li { + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +.sub-nav .nav-list-search { + float:right; + margin:0 0 0 0; + padding:5px 6px; + clear:none; +} +.nav-list-search label { + position:relative; + right:-16px; +} +ul.sub-nav-list li { + list-style:none; + float:left; + padding-top:10px; +} +.top-nav a:link, .top-nav a:active, .top-nav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.top-nav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.nav-bar-cell1-rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skip-nav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* + * Hide navigation links and search box in print layout + */ +@media print { + ul.nav-list, div.sub-nav { + display:none; + } +} +/* + * Styles for page header and footer. + */ +.title { + color:#2c4557; + margin:10px 0; +} +.sub-title { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* + * Styles for headings. + */ +body.class-declaration-page .summary h2, +body.class-declaration-page .details h2, +body.class-use-page h2, +body.module-declaration-page .block-list h2 { + font-style: italic; + padding:0; + margin:15px 0; +} +body.class-declaration-page .summary h3, +body.class-declaration-page .details h3, +body.class-declaration-page .summary .inherited-list h2 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +/* + * Styles for page layout containers. + */ +main { + clear:both; + padding:10px 20px; + position:relative; +} +dl.notes > dt { + font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +dl.notes > dd { + margin:5px 10px 10px 0; + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} +dl.name-value > dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +dl.name-value > dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* + * Styles for lists. + */ +li.circle { + list-style:circle; +} +ul.horizontal li { + display:inline; + font-size:0.9em; +} +div.inheritance { + margin:0; + padding:0; +} +div.inheritance div.inheritance { + margin-left:2em; +} +ul.block-list, +ul.details-list, +ul.member-list, +ul.summary-list { + margin:10px 0 10px 0; + padding:0; +} +ul.block-list > li, +ul.details-list > li, +ul.member-list > li, +ul.summary-list > li { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +.summary-table dl, .summary-table dl dt, .summary-table dl dd { + margin-top:0; + margin-bottom:1px; +} +ul.see-list, ul.see-list-long { + padding-left: 0; + list-style: none; +} +ul.see-list li { + display: inline; +} +ul.see-list li:not(:last-child):after, +ul.see-list-long li:not(:last-child):after { + content: ", "; + white-space: pre-wrap; +} +/* + * Styles for tables. + */ +.summary-table, .details-table { + width:100%; + border-spacing:0; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; + padding:0; +} +.caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0; + padding-top:10px; + padding-left:1px; + margin:0; + white-space:pre; +} +.caption a:link, .caption a:visited { + color:#1f389c; +} +.caption a:hover, +.caption a:active { + color:#FFFFFF; +} +.caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +div.table-tabs { + padding:10px 0 0 1px; + margin:0; +} +div.table-tabs > button { + border: none; + cursor: pointer; + padding: 5px 12px 7px 12px; + font-weight: bold; + margin-right: 3px; +} +div.table-tabs > button.active-table-tab { + background: #F8981D; + color: #253441; +} +div.table-tabs > button.table-tab { + background: #4D7A97; + color: #FFFFFF; +} +.two-column-summary { + display: grid; + grid-template-columns: minmax(15%, max-content) minmax(15%, auto); +} +.three-column-summary { + display: grid; + grid-template-columns: minmax(10%, max-content) minmax(15%, max-content) minmax(15%, auto); +} +.four-column-summary { + display: grid; + grid-template-columns: minmax(10%, max-content) minmax(10%, max-content) minmax(10%, max-content) minmax(10%, auto); +} +@media screen and (max-width: 600px) { + .two-column-summary { + display: grid; + grid-template-columns: 1fr; + } +} +@media screen and (max-width: 800px) { + .three-column-summary { + display: grid; + grid-template-columns: minmax(10%, max-content) minmax(25%, auto); + } + .three-column-summary .col-last { + grid-column-end: span 2; + } +} +@media screen and (max-width: 1000px) { + .four-column-summary { + display: grid; + grid-template-columns: minmax(15%, max-content) minmax(15%, auto); + } +} +.summary-table > div, .details-table > div { + text-align:left; + padding: 8px 3px 3px 7px; +} +.col-first, .col-second, .col-last, .col-constructor-name, .col-summary-item-name { + vertical-align:top; + padding-right:0; + padding-top:8px; + padding-bottom:3px; +} +.table-header { + background:#dee3e9; + font-weight: bold; +} +.col-first, .col-first { + font-size:13px; +} +.col-second, .col-second, .col-last, .col-constructor-name, .col-summary-item-name, .col-last { + font-size:13px; +} +.col-first, .col-second, .col-constructor-name { + vertical-align:top; + overflow: auto; +} +.col-last { + white-space:normal; +} +.col-first a:link, .col-first a:visited, +.col-second a:link, .col-second a:visited, +.col-first a:link, .col-first a:visited, +.col-second a:link, .col-second a:visited, +.col-constructor-name a:link, .col-constructor-name a:visited, +.col-summary-item-name a:link, .col-summary-item-name a:visited, +.constant-values-container a:link, .constant-values-container a:visited, +.all-classes-container a:link, .all-classes-container a:visited, +.all-packages-container a:link, .all-packages-container a:visited { + font-weight:bold; +} +.table-sub-heading-color { + background-color:#EEEEFF; +} +.even-row-color, .even-row-color .table-header { + background-color:#FFFFFF; +} +.odd-row-color, .odd-row-color .table-header { + background-color:#EEEEEF; +} +/* + * Styles for contents. + */ +.deprecated-content { + margin:0; + padding:10px 0; +} +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} +.col-last div { + padding-top:0; +} +.col-last a { + padding-bottom:3px; +} +.module-signature, +.package-signature, +.type-signature, +.member-signature { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + margin:14px 0; + white-space: pre-wrap; +} +.module-signature, +.package-signature, +.type-signature { + margin-top: 0; +} +.member-signature .type-parameters-long, +.member-signature .parameters, +.member-signature .exceptions { + display: inline-block; + vertical-align: top; + white-space: pre; +} +.member-signature .type-parameters { + white-space: normal; +} +/* + * Styles for formatting effect. + */ +.source-line-no { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:0 10px 5px 0; + color:#474747; +} +.deprecated-label, .descfrm-type-label, .implementation-label, .member-name-label, .member-name-link, +.module-label-in-package, .module-label-in-type, .override-specify-label, .package-label-in-type, +.package-hierarchy-label, .type-name-label, .type-name-link, .search-tag-link, .preview-label { + font-weight:bold; +} +.deprecation-comment, .help-footnote, .preview-comment { + font-style:italic; +} +.deprecation-block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; + border-style:solid; + border-width:thin; + border-radius:10px; + padding:10px; + margin-bottom:10px; + margin-right:10px; + display:inline-block; +} +.preview-block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; + border-style:solid; + border-width:thin; + border-radius:10px; + padding:10px; + margin-bottom:10px; + margin-right:10px; + display:inline-block; +} +div.block div.deprecation-comment { + font-style:normal; +} +/* + * Styles specific to HTML5 elements. + */ +main, nav, header, footer, section { + display:block; +} +/* + * Styles for javadoc search. + */ +.ui-autocomplete-category { + font-weight:bold; + font-size:15px; + padding:7px 0 7px 3px; + background-color:#4D7A97; + color:#FFFFFF; +} +.result-item { + font-size:13px; +} +.ui-autocomplete { + max-height:85%; + max-width:65%; + overflow-y:scroll; + overflow-x:scroll; + white-space:nowrap; + box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); +} +ul.ui-autocomplete { + position:fixed; + z-index:999999; +} +ul.ui-autocomplete li { + float:left; + clear:both; + width:100%; +} +.result-highlight { + font-weight:bold; +} +#search-input { + background-image:url('resources/glass.png'); + background-size:13px; + background-repeat:no-repeat; + background-position:2px 3px; + padding-left:20px; + position:relative; + right:-18px; + width:400px; +} +#reset-button { + background-color: rgb(255,255,255); + background-image:url('resources/x.png'); + background-position:center; + background-repeat:no-repeat; + background-size:12px; + border:0 none; + width:16px; + height:16px; + position:relative; + left:-4px; + top:-4px; + font-size:0px; +} +.watermark { + color:#545454; +} +.search-tag-desc-result { + font-style:italic; + font-size:11px; +} +.search-tag-holder-result { + font-style:italic; + font-size:12px; +} +.search-tag-result:target { + background-color:yellow; +} +.module-graph span { + display:none; + position:absolute; +} +.module-graph:hover span { + display:block; + margin: -100px 0 0 100px; + z-index: 1; +} +.inherited-list { + margin: 10px 0 10px 0; +} +section.class-description { + line-height: 1.4; +} +.summary section[class$="-summary"], .details section[class$="-details"], +.class-uses .detail, .serialized-class-details { + padding: 0px 20px 5px 10px; + border: 1px solid #ededed; + background-color: #f8f8f8; +} +.inherited-list, section[class$="-details"] .detail { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +.vertical-separator { + padding: 0 5px; +} +ul.help-section-list { + margin: 0; +} +ul.help-subtoc > li { + display: inline-block; + padding-right: 5px; + font-size: smaller; +} +ul.help-subtoc > li::before { + content: "\2022" ; + padding-right:2px; +} +span.help-note { + font-style: italic; +} +/* + * Indicator icon for external links. + */ +main a[href*="://"]::after { + content:""; + display:inline-block; + background-image:url('data:image/svg+xml; utf8, \ + \ + \ + '); + background-size:100% 100%; + width:7px; + height:7px; + margin-left:2px; + margin-bottom:4px; +} +main a[href*="://"]:hover::after, +main a[href*="://"]:focus::after { + background-image:url('data:image/svg+xml; utf8, \ + \ + \ + '); +} + +/* + * Styles for user-provided tables. + * + * borderless: + * No borders, vertical margins, styled caption. + * This style is provided for use with existing doc comments. + * In general, borderless tables should not be used for layout purposes. + * + * plain: + * Plain borders around table and cells, vertical margins, styled caption. + * Best for small tables or for complex tables for tables with cells that span + * rows and columns, when the "striped" style does not work well. + * + * striped: + * Borders around the table and vertical borders between cells, striped rows, + * vertical margins, styled caption. + * Best for tables that have a header row, and a body containing a series of simple rows. + */ + +table.borderless, +table.plain, +table.striped { + margin-top: 10px; + margin-bottom: 10px; +} +table.borderless > caption, +table.plain > caption, +table.striped > caption { + font-weight: bold; + font-size: smaller; +} +table.borderless th, table.borderless td, +table.plain th, table.plain td, +table.striped th, table.striped td { + padding: 2px 5px; +} +table.borderless, +table.borderless > thead > tr > th, table.borderless > tbody > tr > th, table.borderless > tr > th, +table.borderless > thead > tr > td, table.borderless > tbody > tr > td, table.borderless > tr > td { + border: none; +} +table.borderless > thead > tr, table.borderless > tbody > tr, table.borderless > tr { + background-color: transparent; +} +table.plain { + border-collapse: collapse; + border: 1px solid black; +} +table.plain > thead > tr, table.plain > tbody tr, table.plain > tr { + background-color: transparent; +} +table.plain > thead > tr > th, table.plain > tbody > tr > th, table.plain > tr > th, +table.plain > thead > tr > td, table.plain > tbody > tr > td, table.plain > tr > td { + border: 1px solid black; +} +table.striped { + border-collapse: collapse; + border: 1px solid black; +} +table.striped > thead { + background-color: #E3E3E3; +} +table.striped > thead > tr > th, table.striped > thead > tr > td { + border: 1px solid black; +} +table.striped > tbody > tr:nth-child(even) { + background-color: #EEE +} +table.striped > tbody > tr:nth-child(odd) { + background-color: #FFF +} +table.striped > tbody > tr > th, table.striped > tbody > tr > td { + border-left: 1px solid black; + border-right: 1px solid black; +} +table.striped > tbody > tr > th { + font-weight: normal; +} +/** + * Tweak font sizes and paddings for small screens. + */ +@media screen and (max-width: 1050px) { + #search-input { + width: 300px; + } +} +@media screen and (max-width: 800px) { + #search-input { + width: 200px; + } + .top-nav, + .bottom-nav { + font-size: 11px; + padding-top: 6px; + } + .sub-nav { + font-size: 11px; + } + .about-language { + padding-right: 16px; + } + ul.nav-list li, + .sub-nav .nav-list-search { + padding: 6px; + } + ul.sub-nav-list li { + padding-top: 5px; + } + main { + padding: 10px; + } + .summary section[class$="-summary"], .details section[class$="-details"], + .class-uses .detail, .serialized-class-details { + padding: 0 8px 5px 8px; + } + body { + -webkit-text-size-adjust: none; + } +} +@media screen and (max-width: 500px) { + #search-input { + width: 150px; + } + .top-nav, + .bottom-nav { + font-size: 10px; + } + .sub-nav { + font-size: 10px; + } + .about-language { + font-size: 10px; + padding-right: 12px; + } +} diff --git a/core/docs/tag-search-index.js b/core/docs/tag-search-index.js new file mode 100644 index 0000000..bf10aaf --- /dev/null +++ b/core/docs/tag-search-index.js @@ -0,0 +1 @@ +tagSearchIndex = [{"l":"Constant Field Values","h":"","u":"constant-values.html"},{"l":"Serialized Form","h":"","u":"serialized-form.html"}];updateSearchResults(); \ No newline at end of file diff --git a/core/docs/type-search-index.js b/core/docs/type-search-index.js new file mode 100644 index 0000000..0b43dc9 --- /dev/null +++ b/core/docs/type-search-index.js @@ -0,0 +1 @@ +typeSearchIndex = [{"l":"All Classes and Interfaces","u":"allclasses-index.html"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","l":"Behaviour"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","l":"Blinky"},{"p":"edu.uoc.pacman.model.entities.characters","l":"Character"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","l":"ChaseAggressive"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","l":"ChaseAmbush"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","l":"ChaseBehaviour"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","l":"ChaseCoward"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts.chase","l":"ChasePatrol"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","l":"Clyde"},{"p":"edu.uoc.pacman.model.utils","l":"Direction"},{"p":"edu.uoc.pacman.model.entities.items","l":"Dot"},{"p":"edu.uoc.pacman.model.entities.items","l":"Energizer"},{"p":"edu.uoc.pacman.model.entities","l":"Entity"},{"p":"edu.uoc.pacman.controller","l":"Game"},{"p":"edu.uoc.pacman.view","l":"GameOverScreen"},{"p":"edu.uoc.pacman.view","l":"GameScreen"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","l":"Ghost"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","l":"GhostFactory"},{"p":"edu.uoc.pacman.model.entities.characters","l":"Hitable"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","l":"Inky"},{"p":"edu.uoc.pacman.view","l":"InterLevelsScreen"},{"p":"edu.uoc.pacman.model","l":"Level"},{"p":"edu.uoc.pacman.model.exceptions","l":"LevelException"},{"p":"edu.uoc.pacman.model.entities.items","l":"Life"},{"p":"edu.uoc.pacman.model.entities.items","l":"MapItem"},{"p":"edu.uoc.pacman.model.entities.items","l":"MapItemFactory"},{"p":"edu.uoc.pacman.model.entities.characters","l":"Movable"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","l":"Pacman"},{"p":"edu.uoc.pacman.view","l":"PacmanGame"},{"p":"edu.uoc.pacman.model.entities.items","l":"Path"},{"p":"edu.uoc.pacman.model.entities.items","l":"Pickable"},{"p":"edu.uoc.pacman.model.entities.characters.ghosts","l":"Pinky"},{"p":"edu.uoc.pacman.model.utils","l":"Position"},{"p":"edu.uoc.pacman.model.entities","l":"Scorable"},{"p":"edu.uoc.pacman.model.utils","l":"Sprite"},{"p":"edu.uoc.pacman.model.entities.characters.pacman","l":"State"},{"p":"edu.uoc.pacman.view","l":"UserInputProcessor"},{"p":"edu.uoc.pacman.model.entities.items","l":"Wall"},{"p":"edu.uoc.pacman.view","l":"WelcomeScreen"}];updateSearchResults(); \ No newline at end of file diff --git a/core/src/main/java/edu/uoc/pacman/controller/Game.java b/core/src/main/java/edu/uoc/pacman/controller/Game.java new file mode 100644 index 0000000..8c83528 --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/controller/Game.java @@ -0,0 +1,306 @@ +package edu.uoc.pacman.controller; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.characters.pacman.Pacman; +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.entities.items.MapItem; +import edu.uoc.pacman.model.exceptions.LevelException; +import edu.uoc.pacman.model.utils.Direction; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.*; +import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; + +/** + * Controller class of the game. It is the middleware (or bridge) between the model and view classes. + *
      + * This class is called from the view classes in order to access/modify the model data. + * This class controls the logic of the game. + * + * @author David García-Solórzano + * @version 1.0 + */ +public class Game { + + /** + * Number of lives which each level has when it starts. + */ + private static final int NUM_LIVES = 3; + + /** + * Name of the folder in which level files are + */ + private String fileFolder; + + /** + * Number of the current level. + */ + private int currentLevel = 0; + + /** + * Maximum amount of levels that the game has. + */ + private final int maxLevels; + + /** + * Total score of the game, i.e. the sum of the levels' scores. + */ + private int score; + + /** + * Level object that contains the information of the current level. + */ + private Level level; + + + /** + * Constructor with argument. + * + * @param fileFolder Folder name where the configuration/level files are. + * @throws IOException When there is a problem while retrieving number of levels + */ + public Game(String fileFolder) throws IOException { + int num; + + setFileFolder(fileFolder); + + //Get the number of files that are in the fileFolder, i.e. the number of levels. + URL url = getClass().getClassLoader().getResource(getFileFolder()); + + URLConnection urlConnection = Objects.requireNonNull(url).openConnection(); + + if (urlConnection instanceof JarURLConnection) { + //run in jar + String path = null; + try { + path = getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); + } catch (URISyntaxException e) { + System.out.println("ERROR: Game Constructor"); + e.printStackTrace(); + System.exit(-1); + } + + URI uri = URI.create("jar:file:" + path); + + try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { + num = (int) Files.walk(fs.getPath(getFileFolder())) + .filter(Files::isRegularFile).count(); + } + } else { + //run in ide + ClassLoader classLoader = getClass().getClassLoader(); + InputStream inputStream; + inputStream = Objects.requireNonNull(classLoader.getResourceAsStream(getFileFolder())); + + try (InputStreamReader streamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); + BufferedReader reader = new BufferedReader(streamReader)) { + num = (int) reader.lines().count(); + } + } + + setScore(0); + + maxLevels = num; + } + + /** + * Setter of the attribute {@code fileFolder}. + * + * @param fileFolder Folder name where the configuration/level files are. + */ + private void setFileFolder(String fileFolder) { + this.fileFolder = fileFolder; + } + + /** + * Gets an Iterator of the {@code itemMapList} + * @return Iterator of the {@code itemMapList} + */ + public Iterator getItemMapListIterator() { + return level.getMapItemListIterator(); + } + + + /** + * Getter of the attribute {@code fileFolder}. + * + * @return Value of the attribute {@code fileFolder}. + */ + private String getFileFolder() { + return fileFolder; + } + + + /** + * Gets the current score of the level that the player is playing. + * @return Current score of the current level. + */ + public int getLevelScore(){ + return level.getScore(); + } + + /** + * Getter of the attribute "score" (Game score). + * + * @return Value of the attribute "score" + */ + public int getScore() { + return score; + } + + /** + * Setter of the attribute "score" (Game score). + * + * @param score New value for the attribute "score" + */ + private void setScore(int score) { + this.score = score; + } + + /** + * Gests the @link Pacman} object which is present in the current level. + * + * @return Reference to the {@link Pacman} object in the current level. + */ + public Pacman getPacman() { + return level.getPacman(); + } + + /** + * Gets the list of Ghosts which are present in the level. + * + * @return List which contains all the ghosts in the current live. + */ + public List getGhosts() { + return level.getGhostList(); + } + + /** + * Returns the number of lives that the player has in the current level. + * + * @return Number of lives in the current level. + */ + public int getNumLives() { + return level.getLives(); + } + + /** + * Indicates if the game is finished ({@code true}) or not ({@code false}). + *

      The game is finished when the attribute {@code currentLevel} is equal to attribute {@code maxLevels} + 1. + *

      + * + * @return {@code true} if there are no more levels and therefore the game is finished. Otherwise, {@code false}. + */ + public boolean isFinished() { + return getCurrentLevel() == maxLevels + 1; + } + + /** + * Getter of the attribute {@code currentLevel}. + * + * @return Value of the attribute {@code currentLevel} that indicates which level the player is playing. + */ + public int getCurrentLevel() { + return currentLevel; + } + + /** + * Checks if there is a new level to play and loads it.
      + * If the game is finished, it returns {@code false}. Otherwise, it returns {@code true}.
      + * The game score must be updated when a level is finished. + * Thus, when the player is playing the first level, game's score is zero. + * + * @return {@code true} if there is a next level, and it has been loaded correctly. Otherwise, it returns {@code false}. + * @throws LevelException When there is a level exception/problem loading the new level. + */ + public boolean nextLevel() throws LevelException { + + if (!isFinished()) { + if (getCurrentLevel() == 0) { + setScore(0); + } else { + setScore(getScore() + level.getScore()); + } + currentLevel++; + loadLevel(); + return true; + } else { + setScore(getScore() + level.getScore()); + return false; + } + } + + /** + * Loads a new level by using the value of the attribute {@code currentLevel}. + *

      + * The pattern of the filename is: fileFolder+"level" + numberLevel + ".txt". + *

      + * + * @throws LevelException When there is a level exception/problem. + */ + private void loadLevel() throws LevelException { + level = new Level(getFileFolder() + "level" + currentLevel + ".txt", NUM_LIVES); + } + + /** + * Checks if the level is completed, i.e. the player has collected all the dots and energizers of the map. + * + * @return {@code true} if this level is beaten, otherwise {@code false}. + */ + public boolean isLevelCompleted() { + return level.hasWon(); + } + + /** + * Checks if the player has lost, i.e. the number of lives is zero. + * + * @return {@code true} if this the player has lost, otherwise {@code false}. + */ + public boolean hasLost() { + return level.getLives() == 0; + } + + /** + * Reloads the current level, i.e. load the level again. + * + * @throws LevelException When there is a level exception/problem. + */ + public void reload() throws LevelException { + loadLevel(); + } + + /** + * This method allows us to change Pacman's direction according to the user input (i.e. the pressed key). + * + * @param direction New direction to set to Pacman. + */ + public void setPacmanDirection(Direction direction) { + level.getPacman().setDirection(direction); + } + + /** + * Resets the game so that it starts again. + */ + public void reset(){ + setScore(0); + currentLevel = 0; + } + + /** + * Update the game, namely the level. + */ + public void update() { + level.update(); + } + +} diff --git a/core/src/main/java/edu/uoc/pacman/model/Level.java b/core/src/main/java/edu/uoc/pacman/model/Level.java new file mode 100644 index 0000000..167c9b3 --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/model/Level.java @@ -0,0 +1,448 @@ +package edu.uoc.pacman.model; + +import edu.uoc.pacman.model.entities.Scorable; +import edu.uoc.pacman.model.entities.characters.ghosts.Behaviour; +import edu.uoc.pacman.model.entities.characters.pacman.Pacman; +import edu.uoc.pacman.model.entities.characters.ghosts.Blinky; +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.entities.characters.ghosts.GhostFactory; +import edu.uoc.pacman.model.entities.characters.pacman.State; +import edu.uoc.pacman.model.entities.items.*; +import edu.uoc.pacman.model.exceptions.LevelException; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.*; + +/** + * Represents a level in the game. + * + * @author David García Solórzano + * @version 1.0 + */ +public class Level { + /** + * The minimum width that the map must have. + */ + private static final int MIN_WIDTH = 8; + /** + * The minimum height that the map must have. + */ + private static final int MIN_HEIGHT = 8; + /** + * The name of the level configuration file. + */ + private String fileName; + /** + * The width of the map/labyrinth. + */ + private int width; + /** + * The height of the map/labyrinth. + */ + private int height; + /** + * Stores the items which are part of the map/labyrinth. + */ + private List mapItemList; + + /** + * Reference to {@link Pacman} object, i.e. the player. + */ + private Pacman pacman; + + /** + * Ghosts that are part of the level. + */ + private List ghostList; + + /** + * Level's score. + */ + private int score; + + /** + * Number of lives in the level. + */ + private int lives = 3; + + /** + * Number that allows us to manage when the actions happen. An action will be performed, when tick == UPDATE_GAME. + */ + private int tick; + + /** + * It is the refresh time. In other words, it is the speed of the game. + */ + private static final int UPDATE_GAME = 30; + + /** + * Constructor with argument. + * + * @param filename Value for the attribute {@code fileName}. + * @param lives Initial number of lives in the level. + * @throws LevelException If there are any problems while parsing the level configuration file. + */ + public Level(String filename, int lives) throws LevelException { + setFileName(filename); + setLives(lives); + parse(); + } + + /** + * Setter of the attribute {@code fileName}. + * + * @param fileName New value for the attribute {@code fileName}. + */ + private void setFileName(String fileName) { + //TODO + } + + /** + * Getter of the attribute {@code fileName} + * + * @return Current value of the attribute {@code fileName} + */ + public String getFileName() { + //TODO + return null; + } + + /** + * Getter of the attribute {@code lives}. + * + * @return The value of the attribute {@code lives}. + */ + public int getLives() { + //TODO + return null; + } + + /** + * Setter of the attribute {@code lives}. + * + * @param lives Number of lives to assign to the attribute {@code lives}. + */ + private void setLives(int lives) { + if (lives > 0) { + this.lives = lives; + } + } + + /** + * Increases 1 the number of lives. + */ + public void increaseLives() { + //TODO + } + + /** + * Decreases 1 the number of lives as long as the number of lives is not zero. + */ + public void decreaseLives() { + //TODO + } + + /** + * Parses/Reads level's data from the given file.
      + * It also checks which the board's requirements are met. + * + * @throws LevelException When there is any error while parsing the file + * or some board's requirement is not satisfied. + */ + private void parse() throws LevelException { + String line; + + ClassLoader classLoader = getClass().getClassLoader(); + InputStream inputStream = Objects.requireNonNull(classLoader.getResourceAsStream(getFileName())); + + try (InputStreamReader streamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); + BufferedReader reader = new BufferedReader(streamReader)) { + + line = Objects.requireNonNull(getFirstNonEmptyLine(reader)); + + + setWidth(Integer.parseInt(line)); + + line = Objects.requireNonNull(getFirstNonEmptyLine(reader)); + + setHeight(Integer.parseInt(line)); + + mapItemList = new LinkedList<>();//getWidth() * getHeight()); + + for (int y = 0; y < getHeight(); y++) { + char[] rowChar = Objects.requireNonNull(getFirstNonEmptyLine(reader)).toCharArray(); + for (int x = 0; x < getWidth(); x++) { + addMapItem(MapItemFactory.getItemMapInstance(x, y, rowChar[x])); + } + } + + //Checks if there is one Dot or Energizer item in the board at least + if (getMapItemList().stream().noneMatch(item -> item instanceof Dot || item instanceof Energizer)) { + throw new LevelException(LevelException.PICKABLE_ERROR); + } + + //Read pacman and ghosts + line = Objects.requireNonNull(getFirstNonEmptyLine(reader)); + + String[] pacmanInfo = line.split(","); + this.pacman = new Pacman(new Position(Integer.parseInt(pacmanInfo[0]), + Integer.parseInt(pacmanInfo[1])), Direction.valueOf(pacmanInfo[2]), State.valueOf(pacmanInfo[3]), this); + + + ghostList = new ArrayList<>(); + + while ((line = getFirstNonEmptyLine(reader)) != null) { + String[] ghostInfo = line.split(","); + ghostList.add(GhostFactory.getGhostInstance(Integer.parseInt(ghostInfo[1]), + Integer.parseInt(ghostInfo[2]), ghostInfo[0], Direction.valueOf(ghostInfo[3]), edu.uoc.pacman.model.entities.characters.ghosts.Behaviour.valueOf(ghostInfo[4]), this)); + } + + if (ghostList.isEmpty()) { + throw new LevelException(LevelException.GHOSTS_ERROR); + } + + } catch (IllegalStateException | IllegalArgumentException | IOException e) { + throw new LevelException(LevelException.PARSING_LEVEL_FILE_ERROR + e.getMessage()); + } + } + + /** + * This is a helper method for {@link #parse()} which returns + * the first non-empty and non-comment line from the reader. + * + * @param br BufferedReader object to read from. + * @return First line that is a parsable line, or {@code null} there are no lines to read. + * @throws IOException if the reader fails to read a line. + */ + private String getFirstNonEmptyLine(final BufferedReader br) throws IOException { + do { + + String s = br.readLine(); + + if (s == null) { + return null; + } + if (s.isBlank() || s.startsWith(";")) { + continue; + } + + return s; + } while (true); + } + + /** + * Getter of the attribute {@code width}. + * + * @return The current value of the attribute {@code width}. + */ + public int getWidth() { + //TODO + return null; + } + + /** + * Setter of the attribute {@code width}. + * + * @param width New value for the attribute {@code width}. + * @throws LevelException When {@code width} is less than {@code MIN_WIDTH}. + */ + private void setWidth(int width) throws LevelException { + //TODO + } + + /** + * Getter of the attribute {@code height}. + * + * @return The current value of the attribute {@code height}. + */ + public int getHeight() { + //TODO + } + + /** + * Setter of the attribute {@code height}. + * + * @param height New value for the attribute {@code height}. + * @throws LevelException When {@code height} is less than {@code MIN_HEIGHT}. + */ + private void setHeight(int height) throws LevelException { + //TODO + } + + /** + * Getter of the attribute {@code mapItemList}. + * + * @return The current value of the attribute {@code mapItemList}. + */ + private List getMapItemList() { + //TODO + return null; + } + + /** + * Returns an Iterator of the attribute {@code mapItemList}. + * + * @return Iterator of the attribute {@code mapItemList}. + */ + public Iterator getMapItemListIterator() { + //TODO + return null; + } + + /** + * Returns the map/labyrinth item which is in the position (x,y). + * + * @param x Value of the position in the X axis. + * @param y Value of the position in the Y axis. + * @return If any, the item which is the position (x,y). Otherwise, {@code null}. + */ + public MapItem getMapItem(int x, int y) { + //TODO + return null; + } + + /** + * Returns the map/labyrinth item which is in {@code position}. + * + * @param position The position where the item that we want to get is. + * @return If any, the item which is {@code position}. Otherwise, {@code null}. + * @throws NullPointerException When {@code position} is {@code null}. + */ + public MapItem getMapItem(Position position) throws NullPointerException { + //TODO + return null; + } + + /** + * Adds {@code item} to the {@code mapItemList} as long as {@code item} is not {@code null}. + * + * @param item Item which we want to add. + */ + public void addMapItem(MapItem item) { + //TODO + return null; + } + + /** + * Removes {@code item} from the {@code mapItemList}. + * + * @param item Item which we want to remove. + */ + public void removeMapItem(MapItem item) { + //TODO + } + + /** + * Getter of the attribute {@code ghostList}. + * + * @return The current value of the attribute {@code ghostList}. + */ + public List getGhostList() { + //TODO + return null; + } + + /** + * Getter of the attribute {@code score}. + * + * @return The current value of the attribute {@code score}. + */ + public int getScore() { + //TODO + return 0; + } + + /** + * Add the value of {@code points} to the attribute {@code score} as long as {@code points} is greater than 0. + * + * @param points Number to add to the attribute {@code score}. + */ + public void addPoints(int points) { + //TODO + } + + /** + * Getter ot the attribute {@code pacman}. + * + * @return The current value of the attribute {@code pacman}. + */ + public Pacman getPacman() { + //TODO + return null; + } + + /** + * Gets the first {@link Blinky} object in the Ghost list of the level. + * + * @return The first {@link Blinky} object in the level, + * or {@code null} if there are not {@link Blinky} ghosts in the level. + */ + public Blinky getBlinky() { + //TODO + return null; + } + + /** + * Given a position, it indicates if such a position is pathable or not. + * + * @param position Position which must be checked. + * @return {@code true} if the position is pathable. Otherwise, {@code false}. + */ + public boolean isPathable(Position position) { + //TODO + return false; + } + + + /** + * Sets the behaviour of all the ghosts in the level to FRIGHTENED. + */ + public void setGhostsFrightened() { + //TODO + } + + /** + * Checks if the level was finished. This happens when all the objects + * that are {@link Scorable} and {@link Pickable} have been picked. + * + * @return {@code true} if the level was finished/won. Otherwise, {@code false}. + */ + public boolean hasWon() { + //TODO + return false; + } + + /** + * Refreshes/Updates the game when needed. + */ + public void update() { + + if (tick == UPDATE_GAME) { + pacman.move(); + + ghostList.forEach(ghost -> { + if (ghost.isDead()) { + ghost.reset(); + } + ghost.move(); + }); + + if (pacman.isDead()) { + pacman.reset(); + ghostList.forEach(ghost -> { + ghost.reset(); + }); + } + + tick = 0; + } + + tick++; + } +} diff --git a/core/src/main/java/edu/uoc/pacman/model/entities/characters/ghosts/GhostFactory.java b/core/src/main/java/edu/uoc/pacman/model/entities/characters/ghosts/GhostFactory.java new file mode 100644 index 0000000..9b38b36 --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/model/entities/characters/ghosts/GhostFactory.java @@ -0,0 +1,41 @@ +package edu.uoc.pacman.model.entities.characters.ghosts; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.items.*; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; + +/** + * Ghost Simple Factory class. + * + * @author David García Solórzano + * @version 1.0 + */ +public abstract class GhostFactory { + + /** + * Returns a new {@link Ghost} object. + * + * @param x Column of the coordinate/position in which the item is in the board. + * @param y Row of the coordinate/position in which the item is in the board. + * @param ghostClassName String value of the {@link MapItem} enumeration that corresponds to the item of the map. + * @param direction Direction which the ghost faces in the beginning. + * @param behaviour Current behaviour of the ghost. + * @param level Reference to the {@link Level} object. + * @return {@link MapItem} object. + * @throws IllegalStateException When a wrong symbol is used as an argument. + */ + public static Ghost getGhostInstance(int x, int y, String ghostClassName, Direction direction, Behaviour behaviour, + Level level) throws IllegalStateException { + Position position = new Position(x, y); + + return switch (ghostClassName.toLowerCase()) { + case "blinky" -> new Blinky(position, direction, behaviour, level); + case "pinky" -> new Pinky(position, direction, behaviour, level); + case "inky" -> new Inky(position, direction, behaviour, level); + case "clyde" -> new Clyde(position, direction, behaviour, level); + default -> throw new IllegalStateException("Unexpected value: " + ghostClassName.toUpperCase()); + }; + + } +} diff --git a/core/src/main/java/edu/uoc/pacman/model/entities/items/MapItemFactory.java b/core/src/main/java/edu/uoc/pacman/model/entities/items/MapItemFactory.java new file mode 100644 index 0000000..8693d69 --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/model/entities/items/MapItemFactory.java @@ -0,0 +1,35 @@ +package edu.uoc.pacman.model.entities.items; + +import edu.uoc.pacman.model.utils.Position; + +/** + * Entity Simple Factory class. + * + * @author David García Solórzano + * @version 1.0 + */ +public abstract class MapItemFactory { + + /** + * Returns a new {@link MapItem} object. + * + * @param x Column of the coordinate/position in which the item is in the board. + * @param y Row of the coordinate/position in which the item is in the board. + * @param itemMapSymbol String value of the {@link MapItem} enumeration that corresponds to the item of the map. + * @return {@link MapItem} object. + * @throws IllegalStateException When a wrong symbol is used as an argument. + */ + public static MapItem getItemMapInstance(int x, int y, char itemMapSymbol) throws IllegalStateException { + Position position = new Position(x, y); + + return switch (Character.toLowerCase(itemMapSymbol)) { + case ' ' -> new Path(position); + case '#' -> new Wall(position); + case '.' -> new Dot(position); + case 'o' -> new Energizer(position); + case 'l' -> new Life(position); + default -> throw new IllegalStateException("Unexpected value: " + Character.toLowerCase(itemMapSymbol)); + }; + + } +} diff --git a/core/src/main/java/edu/uoc/pacman/view/GameOverScreen.java b/core/src/main/java/edu/uoc/pacman/view/GameOverScreen.java new file mode 100644 index 0000000..4961b2e --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/view/GameOverScreen.java @@ -0,0 +1,76 @@ +package edu.uoc.pacman.view; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.OrthographicCamera; +import edu.uoc.pacman.model.exceptions.LevelException; + +import java.io.IOException; + +public class GameOverScreen implements Screen { + + final PacmanGame game; + + OrthographicCamera camera; + + public GameOverScreen(PacmanGame game) { + this.game = game; + game.getGameController().reset(); + } + + + @Override + public void show() { + + } + + @Override + public void render(float delta) { + //ScreenUtils.clear(0, 0, 0.2f, 1); + + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + game.batch.begin(); + game.font.getData().setScale(2.0f); + + if (Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) { + game.setScreen(new WelcomeScreen(game)); + } + game.batch.draw(PacmanGame.assetManager.get(PacmanGame.logoAsset), 0, 0, PacmanGame.WINDOW_WIDTH, PacmanGame.WINDOW_HEIGHT); + game.font.draw(game.batch, "Game Over!", (int) (PacmanGame.WINDOW_WIDTH * 0.3), PacmanGame.WINDOW_HEIGHT / 4); + game.font.draw(game.batch, game.getGameController().getScore()+" points", (int) (PacmanGame.WINDOW_WIDTH * 0.3), PacmanGame.WINDOW_HEIGHT / 4 + 30); + + game.batch.end(); + } + + @Override + public void resize(int width, int height) { + //camera.viewportWidth = width; + //camera.viewportHeight = height; + } + + @Override + public void pause() { + + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + + } + + @Override + public void dispose() { + game.batch.dispose(); + } + + +} diff --git a/core/src/main/java/edu/uoc/pacman/view/GameScreen.java b/core/src/main/java/edu/uoc/pacman/view/GameScreen.java new file mode 100644 index 0000000..e0f0a35 --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/view/GameScreen.java @@ -0,0 +1,137 @@ +package edu.uoc.pacman.view; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import edu.uoc.pacman.controller.Game; +import edu.uoc.pacman.model.entities.characters.ghosts.Behaviour; +import edu.uoc.pacman.model.entities.characters.pacman.Pacman; +import edu.uoc.pacman.model.entities.characters.pacman.State; +import edu.uoc.pacman.model.entities.items.MapItem; +import edu.uoc.pacman.model.exceptions.LevelException; + +import java.io.IOException; +import java.util.Iterator; + +public class GameScreen implements Screen { + + private final PacmanGame game; + private final Game gameController; + + boolean loaded; + + public GameScreen(PacmanGame game) throws IOException, LevelException { + this.game = game; + gameController = game.getGameController(); + loaded = true; + gameController.nextLevel(); + Gdx.input.setInputProcessor(new UserInputProcessor(gameController)); + } + + + @Override + public void show() { + + } + + @Override + public void render(float delta) { + + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + if (!gameController.isFinished() && !gameController.hasLost()) { + + if (loaded) { + gameController.update(); + + Iterator itr = gameController.getItemMapListIterator(); + game.batch.begin(); + + Color c = game.batch.getColor(); + + game.font.draw(game.batch, "Level " + gameController.getCurrentLevel(), 25, 160); + game.font.draw(game.batch, "Points " + gameController.getLevelScore(), 25, 120); + game.font.draw(game.batch, "Lives " + gameController.getNumLives(), 25, 90); + game.font.draw(game.batch, "Score " + gameController.getScore(), 25, 50); + + while (itr.hasNext()) { + MapItem item = itr.next(); + game.batch.setColor(c.r, c.g, c.b, 1f); + game.drawImage(item.getSprite(), + item.getPosition().getX(), + item.getPosition().getY() + ); + } + + Pacman pacman = gameController.getPacman(); + + + if (pacman.getState() == State.INVINCIBLE) { + game.batch.setColor(c.r, c.g, c.b, 0.3f); + } else { + game.batch.setColor(c.r, c.g, c.b, 1f); + } + + + game.drawImage(pacman.getSprite(), + pacman.getPosition().getX(), + pacman.getPosition().getY()); + + //Ghost's status in graphic mode + + gameController.getGhosts().forEach(ghost -> { + if (ghost.getBehaviour() == Behaviour.INACTIVE) { + game.batch.setColor(c.r, c.g, c.b, 0.3f); + } else if (ghost.getBehaviour() == Behaviour.FRIGHTENED) { + game.batch.setColor(Color.BLUE); //blue + } else { + game.batch.setColor(c.r, c.g, c.b, 1f); //scatter, normal + } + game.drawImage(ghost.getSprite(), + ghost.getPosition().getX(), + ghost.getPosition().getY()); + }); + + game.batch.setColor(Color.WHITE); + + game.batch.end(); + + if (gameController.isLevelCompleted()) { + game.setScreen(new InterLevelsScreen(game)); + } + } + } else { + game.setScreen(new GameOverScreen(game)); + } + + } + + @Override + public void resize(int width, int height) { + + } + + @Override + public void pause() { + + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + + } + + @Override + public void dispose() { + game.batch.dispose(); + } + + +} diff --git a/core/src/main/java/edu/uoc/pacman/view/InterLevelsScreen.java b/core/src/main/java/edu/uoc/pacman/view/InterLevelsScreen.java new file mode 100644 index 0000000..67e20d9 --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/view/InterLevelsScreen.java @@ -0,0 +1,79 @@ +package edu.uoc.pacman.view; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.OrthographicCamera; +import edu.uoc.pacman.model.exceptions.LevelException; + +import java.io.IOException; + +public class InterLevelsScreen implements Screen { + + final PacmanGame game; + + OrthographicCamera camera; + + public InterLevelsScreen(PacmanGame game) { + this.game = game; + } + + + @Override + public void show() { + + } + + @Override + public void render(float delta) { + //ScreenUtils.clear(0, 0, 0.2f, 1); + + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + game.batch.begin(); + game.font.getData().setScale(2.0f); + + if (Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) { + try { + game.setScreen(new GameScreen(game)); + } catch (LevelException | IOException e) { + e.printStackTrace(); + System.exit(0); + } + } + game.batch.draw(PacmanGame.assetManager.get(PacmanGame.logoAsset), 0, 0, PacmanGame.WINDOW_WIDTH, PacmanGame.WINDOW_HEIGHT); + game.font.draw(game.batch, "Press enter to play the next level!", (int) (PacmanGame.WINDOW_WIDTH * 0.3), PacmanGame.WINDOW_HEIGHT / 4); + + game.batch.end(); + } + + @Override + public void resize(int width, int height) { + //camera.viewportWidth = width; + //camera.viewportHeight = height; + } + + @Override + public void pause() { + + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + + } + + @Override + public void dispose() { + game.batch.dispose(); + } + + +} diff --git a/core/src/main/java/edu/uoc/pacman/view/PacmanGame.java b/core/src/main/java/edu/uoc/pacman/view/PacmanGame.java new file mode 100644 index 0000000..22c5563 --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/view/PacmanGame.java @@ -0,0 +1,124 @@ +package edu.uoc.pacman.view; + +//https://libgdx.com/wiki/app/starter-classes-and-configuration + +import com.badlogic.gdx.Game; +import com.badlogic.gdx.assets.AssetDescriptor; +import com.badlogic.gdx.assets.AssetManager; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import edu.uoc.pacman.model.utils.Sprite; + +import java.io.IOException; + +public class PacmanGame extends Game { + + public static final int WINDOW_WIDTH = 915; + public static final int WINDOW_HEIGHT = 768; + + SpriteBatch batch; + + edu.uoc.pacman.controller.Game gameController; + + public static AssetDescriptor pacmanRightAsset, + pacmanLeftAsset, pacmanUpAsset, pacmanDownAsset, + blinkyAsset, inkyAsset, pinkyAsset, clydeAsset, + dotAsset, energizerAsset, wallAsset, pathAsset, + lifeAsset, logoAsset; + + public static AssetManager assetManager; + + BitmapFont font; + + public static final int CELL_SIZE = 35; + + @Override + public void create(){ + try { + gameController = new edu.uoc.pacman.controller.Game("levels/"); + } catch (IOException e) { + throw new RuntimeException(e); + } + batch = new SpriteBatch(); + assetManager = new AssetManager(); + font = new BitmapFont(); + loadImages(); + assetManager.finishLoading(); + this.setScreen(new WelcomeScreen(this)); + } + + @Override + public void dispose() { + super.dispose(); + } + + @Override + public void render() { + super.render(); + } + + public void loadImages() { + pacmanUpAsset = new AssetDescriptor<>(Sprite.PACMAN_UP.getImageSrc(), Texture.class); + pacmanRightAsset = new AssetDescriptor<>(Sprite.PACMAN_RIGHT.getImageSrc(), Texture.class); + pacmanDownAsset = new AssetDescriptor<>(Sprite.PACMAN_DOWN.getImageSrc(), Texture.class); + pacmanLeftAsset = new AssetDescriptor<>(Sprite.PACMAN_LEFT.getImageSrc(), Texture.class); + blinkyAsset = new AssetDescriptor<>(Sprite.BLINKY.getImageSrc(), Texture.class); + pinkyAsset = new AssetDescriptor<>(Sprite.PINKY.getImageSrc(), Texture.class); + inkyAsset = new AssetDescriptor<>(Sprite.INKY.getImageSrc(), Texture.class); + clydeAsset = new AssetDescriptor<>(Sprite.CLYDE.getImageSrc(), Texture.class); + dotAsset = new AssetDescriptor<>(Sprite.DOT.getImageSrc(), Texture.class); + energizerAsset = new AssetDescriptor<>(Sprite.ENERGIZER.getImageSrc(), Texture.class); + wallAsset = new AssetDescriptor<>(Sprite.WALL.getImageSrc(), Texture.class); + pathAsset = new AssetDescriptor<>(Sprite.PATH.getImageSrc(), Texture.class); + lifeAsset = new AssetDescriptor<>(Sprite.LIFE.getImageSrc(), Texture.class); + + logoAsset = new AssetDescriptor<>("images/pacman_logo.png", Texture.class); + + assetManager.load(pacmanUpAsset); + assetManager.load(pacmanRightAsset); + assetManager.load(pacmanDownAsset); + assetManager.load(pacmanLeftAsset); + assetManager.load(blinkyAsset); + assetManager.load(inkyAsset); + assetManager.load(pinkyAsset); + assetManager.load(clydeAsset); + assetManager.load(dotAsset); + assetManager.load(energizerAsset); + assetManager.load(wallAsset); + assetManager.load(pathAsset); + assetManager.load(lifeAsset); + assetManager.load(logoAsset); + + } + + AssetDescriptor getAssertBySprite(Sprite sprite) { + return switch (sprite) { + case PACMAN_RIGHT -> pacmanRightAsset; + case PACMAN_LEFT -> pacmanLeftAsset; + case PACMAN_UP -> pacmanUpAsset; + case PACMAN_DOWN -> pacmanDownAsset; + case BLINKY -> blinkyAsset; + case PINKY -> pinkyAsset; + case INKY -> inkyAsset; + case CLYDE -> clydeAsset; + case DOT -> dotAsset; + case ENERGIZER -> energizerAsset; + case WALL -> wallAsset; + case PATH -> pathAsset; + case LIFE -> lifeAsset; + }; + } + + void drawImage(Sprite sprite, int x, int y) { + batch.draw(PacmanGame.assetManager.get(getAssertBySprite(sprite)), + x * PacmanGame.CELL_SIZE, + (WINDOW_HEIGHT - (y * PacmanGame.CELL_SIZE) - PacmanGame.CELL_SIZE), + CELL_SIZE, CELL_SIZE); + } + + public edu.uoc.pacman.controller.Game getGameController(){ + return this.gameController; + } +} diff --git a/core/src/main/java/edu/uoc/pacman/view/UserInputProcessor.java b/core/src/main/java/edu/uoc/pacman/view/UserInputProcessor.java new file mode 100644 index 0000000..ca51bc5 --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/view/UserInputProcessor.java @@ -0,0 +1,26 @@ +package edu.uoc.pacman.view; + +import com.badlogic.gdx.InputAdapter; +import edu.uoc.pacman.controller.Game; +import edu.uoc.pacman.model.utils.Direction; + +public class UserInputProcessor extends InputAdapter { + + Game gameController; + + public UserInputProcessor(Game gameController) { + this.gameController = gameController; + } + + @Override + public boolean keyDown(int keycode) { + return false; + } + + @Override + public boolean keyUp(int keycode) { + gameController.setPacmanDirection(Direction.getDirectionByKeyCode(keycode)); + return false; + } + +} diff --git a/core/src/main/java/edu/uoc/pacman/view/WelcomeScreen.java b/core/src/main/java/edu/uoc/pacman/view/WelcomeScreen.java new file mode 100644 index 0000000..188004b --- /dev/null +++ b/core/src/main/java/edu/uoc/pacman/view/WelcomeScreen.java @@ -0,0 +1,82 @@ +package edu.uoc.pacman.view; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.OrthographicCamera; +import edu.uoc.pacman.model.exceptions.LevelException; + +import java.io.IOException; + +public class WelcomeScreen implements Screen { + + final PacmanGame game; + + OrthographicCamera camera; + + public WelcomeScreen(PacmanGame game) { + this.game = game; + } + + + @Override + public void show() { + + } + + @Override + public void render(float delta) { + //ScreenUtils.clear(0, 0, 0.2f, 1); + + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + game.batch.begin(); + game.font.getData().setScale(2.0f); + + if (!PacmanGame.assetManager.isFinished()) { + game.font.draw(game.batch, "Wait... loading", PacmanGame.WINDOW_WIDTH / 2, PacmanGame.WINDOW_HEIGHT / 2); + } else { + if (Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) { + try { + game.setScreen(new GameScreen(game)); + } catch (LevelException | IOException e) { + e.printStackTrace(); + System.exit(0); + } + } + game.batch.draw(PacmanGame.assetManager.get(PacmanGame.logoAsset), 0, 0, PacmanGame.WINDOW_WIDTH, PacmanGame.WINDOW_HEIGHT); + game.font.draw(game.batch, "Press enter to play!", (int) (PacmanGame.WINDOW_WIDTH * 0.3), PacmanGame.WINDOW_HEIGHT / 4); + } + game.batch.end(); + } + + @Override + public void resize(int width, int height) { + //camera.viewportWidth = width; + //camera.viewportHeight = height; + } + + @Override + public void pause() { + + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + + } + + @Override + public void dispose() { + game.batch.dispose(); + } + + +} diff --git a/core/src/test/java/edu/uoc/pacman/model/LevelTest.java b/core/src/test/java/edu/uoc/pacman/model/LevelTest.java new file mode 100644 index 0000000..3348756 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/LevelTest.java @@ -0,0 +1,320 @@ +package edu.uoc.pacman.model; + +import edu.uoc.pacman.model.entities.characters.ghosts.Behaviour; +import edu.uoc.pacman.model.entities.characters.ghosts.Blinky; +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.entities.characters.pacman.Pacman; +import edu.uoc.pacman.model.entities.items.MapItem; +import edu.uoc.pacman.model.exceptions.LevelException; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.io.BufferedReader; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +class LevelTest { + + Level level; + + @BeforeEach + @DisplayName("Set up of LevelTest") + private void setUp() { + try { + level = new Level("levels/level1.txt", 3); + } catch (LevelException e) { + fail(); + } + } + + @Test + @Tag("basic") + void getFileName() { + assertEquals("levels/level1.txt", level.getFileName()); + } + + @Test + @Tag("basic") + void getLives() { + assertEquals(3,level.getLives()); + } + + @Test + @Tag("basic") + void increaseLives() { + level.increaseLives(); + assertEquals(4,level.getLives()); + } + + @Test + @Tag("basic") + void decreaseLives() { + level.decreaseLives(); + assertEquals(2,level.getLives()); + } + + @Test + @Tag("basic") + void getWidth() { + assertEquals(26,level.getWidth()); + } + + @Test + @Tag("basic") + void getHeight() { + assertEquals(8,level.getHeight()); + } + + + @Test + @Tag("basic") + void getMapItemXY() { + assertEquals(Sprite.WALL,level.getMapItem(0,0).getSprite()); + assertEquals(Sprite.PATH,level.getMapItem(1,1).getSprite()); + assertEquals(Sprite.ENERGIZER,level.getMapItem(1,4).getSprite()); + assertEquals(Sprite.DOT,level.getMapItem(2,4).getSprite()); + assertEquals(Sprite.LIFE,level.getMapItem(24,6).getSprite()); + } + + @Test + @Tag("basic") + void getMapItemPosition() { + assertEquals(Sprite.WALL,level.getMapItem(new Position(0,0)).getSprite()); + assertEquals(Sprite.PATH,level.getMapItem(new Position(1,1)).getSprite()); + assertEquals(Sprite.ENERGIZER,level.getMapItem(new Position(1,4)).getSprite()); + assertEquals(Sprite.DOT,level.getMapItem(new Position(2,4)).getSprite()); + assertEquals(Sprite.LIFE,level.getMapItem(new Position(24,6)).getSprite()); + } + + @Test + @Tag("basic") + void getGhostList() { + assertTrue(level.getGhostList() instanceof List); + assertEquals(4, level.getGhostList().size()); + } + + @Test + @Tag("basic") + void getScore() { + assertEquals(0, level.getScore()); + } + + @Test + @Tag("basic") + void addPoints() { + level.addPoints(3); + assertEquals(3,level.getScore()); + level.addPoints(2); + assertEquals(5,level.getScore()); + level.addPoints(-4); + assertEquals(5,level.getScore()); + level.addPoints(1); + assertEquals(6,level.getScore()); + } + + @Test + @Tag("basic") + void getPacman() { + assertTrue(level.getPacman() instanceof Pacman); + assertEquals(new Position(1,1), level.getPacman().getPosition()); + } + + @Test + @Tag("basic") + void getBlinky() { + assertTrue(level.getBlinky() instanceof Blinky); + assertEquals(new Position(6,1), level.getBlinky().getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(level.getMapItem(2,1).isPathable()); + assertTrue(level.getMapItem(6,1).isPathable()); + assertTrue(level.getMapItem(2,4).isPathable()); + assertFalse(level.getMapItem(0,0).isPathable()); + assertFalse(level.getMapItem(3,2).isPathable()); + + } + + @Test + @Tag("basic") + void setGhostsFrightened() { + level.setGhostsFrightened(); + assertTrue(level.getGhostList().stream().allMatch(g -> g.getBehaviour() == Behaviour.FRIGHTENED)); + } + + @Test + @Tag("advanced") + void hasWon() { + assertFalse(level.hasWon()); + + try { + level = new Level("levels/level2.txt",5); + assertFalse(level.hasWon()); + level.getPacman().move(); + assertTrue(level.hasWon()); + } catch (LevelException e) { + fail(e.getMessage()); + } + + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Level - Class definition") + void checkClassSanity() { + final Class ownClass = Level.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertFalse(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model",ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Level - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Level.class; + + //check attribute fields + assertEquals(12, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("MIN_WIDTH").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("MIN_WIDTH").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("MIN_HEIGHT").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("MIN_HEIGHT").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("fileName").getModifiers())); + assertEquals(String.class, ownClass.getDeclaredField("fileName").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("width").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("width").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("height").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("height").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("mapItemList").getModifiers())); + assertEquals(List.class, ownClass.getDeclaredField("mapItemList").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("pacman").getModifiers())); + assertEquals(Pacman.class, ownClass.getDeclaredField("pacman").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("ghostList").getModifiers())); + assertEquals(List.class, ownClass.getDeclaredField("ghostList").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("score").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("score").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("lives").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("lives").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("tick").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("tick").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("UPDATE_GAME").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("UPDATE_GAME").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("UPDATE_GAME").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("UPDATE_GAME").getType()); + + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Level - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Level.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(String.class, int.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Level's constructor is defined wrongly"); + } + + //Max public methods: 20 methods + assertEquals(20, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 7); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getFileName").getModifiers())); + assertEquals(String.class, ownClass.getDeclaredMethod("getFileName").getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("setFileName", String.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setFileName", String.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getLives").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getLives").getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("setLives", int.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setLives", int.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("increaseLives").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("increaseLives").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("decreaseLives").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("decreaseLives").getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("parse").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("parse").getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("getFirstNonEmptyLine", BufferedReader.class).getModifiers())); + assertEquals(String.class, ownClass.getDeclaredMethod("getFirstNonEmptyLine", BufferedReader.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getWidth").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getWidth").getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("setWidth", int.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setWidth", int.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getHeight").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getHeight").getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("setHeight", int.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setHeight", int.class).getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("getMapItemList").getModifiers())); + assertEquals(List.class, ownClass.getDeclaredMethod("getMapItemList").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getMapItemListIterator").getModifiers())); + assertEquals(Iterator.class, ownClass.getDeclaredMethod("getMapItemListIterator").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getMapItem", int.class, int.class).getModifiers())); + assertEquals(MapItem.class, ownClass.getDeclaredMethod("getMapItem", int.class, int.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getMapItem", Position.class).getModifiers())); + assertEquals(MapItem.class, ownClass.getDeclaredMethod("getMapItem", Position.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("addMapItem", MapItem.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("addMapItem", MapItem.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("removeMapItem", MapItem.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("removeMapItem", MapItem.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getGhostList").getModifiers())); + assertEquals(List.class, ownClass.getDeclaredMethod("getGhostList").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getScore").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getScore").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("addPoints", int.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("addPoints", int.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPacman").getModifiers())); + assertEquals(Pacman.class, ownClass.getDeclaredMethod("getPacman").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getBlinky").getModifiers())); + assertEquals(Blinky.class, ownClass.getDeclaredMethod("getBlinky").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("isPathable", Position.class).getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("isPathable", Position.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setGhostsFrightened").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setGhostsFrightened").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("hasWon").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("hasWon").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("update").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("update").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/EntityTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/EntityTest.java new file mode 100644 index 0000000..80cb249 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/EntityTest.java @@ -0,0 +1,101 @@ +package edu.uoc.pacman.model.entities; + +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class EntityTest { + + @Test + @Tag("sanity") + @DisplayName("Sanity Entity - Class definition") + void checkClassSanity() { + final Class ownClass = Entity.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertTrue(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities",ownClass.getPackageName()); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Entity - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Entity.class; + + //check attribute fields + assertEquals(3, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("position").getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredField("position").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("pathable").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredField("pathable").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("sprite").getModifiers())); + assertEquals(Sprite.class, ownClass.getDeclaredField("sprite").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Entity - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Entity.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, boolean.class, Sprite.class).getModifiers(); + assertTrue(Modifier.isProtected(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Entity's constructor is defined wrongly"); + } + + //Max public methods: 5 methods + assertEquals(5, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPosition").getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("getPosition").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setPosition", Position.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setPosition", Position.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("isPathable").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("isPathable").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setPathable", boolean.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setPathable", boolean.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getSprite").getModifiers())); + assertEquals(Sprite.class, ownClass.getDeclaredMethod("getSprite").getReturnType()); + assertTrue(Modifier.isProtected(ownClass.getDeclaredMethod("setSprite", Sprite.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setSprite", Sprite.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/ScorableTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/ScorableTest.java new file mode 100644 index 0000000..731bbf8 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/ScorableTest.java @@ -0,0 +1,51 @@ +package edu.uoc.pacman.model.entities; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class ScorableTest { + + @Test + @Tag("sanity") + @DisplayName("Sanity Scorable - Interface definition") + void checkInterfaceSanity() { + final Class ownClass = Scorable.class; + + assertTrue(ownClass.isInterface()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities", ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Scorable - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Scorable.class; + + //check attribute fields: 0 attributes + assertEquals(0, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Scorable - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Scorable.class; + + //Number of methods + assertEquals(1, ownClass.getDeclaredMethods().length); + + //Max public methods: + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + } +} diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/CharacterTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/CharacterTest.java new file mode 100644 index 0000000..94afe4d --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/CharacterTest.java @@ -0,0 +1,113 @@ +package edu.uoc.pacman.model.entities.characters; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.Entity; +import edu.uoc.pacman.model.entities.Scorable; +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.entities.items.Pickable; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class CharacterTest { + @Test + @Tag("sanity") + @DisplayName("Sanity Character - Class definition") + void checkClassSanity() { + final Class ownClass = Character.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertTrue(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters",ownClass.getPackageName()); + assertTrue(Entity.class.isAssignableFrom(ownClass)); + assertTrue(Movable.class.isAssignableFrom(ownClass)); + assertTrue(Hitable.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Character - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Character.class; + + //check attribute fields + assertEquals(5, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("startPosition").getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredField("startPosition").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("dead").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredField("dead").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("duration").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("duration").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("direction").getModifiers())); + assertEquals(Direction.class, ownClass.getDeclaredField("direction").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("level").getModifiers())); + assertEquals(Level.class, ownClass.getDeclaredField("level").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Entity - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Entity.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, boolean.class, Sprite.class).getModifiers(); + assertTrue(Modifier.isProtected(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Entity's constructor is defined wrongly"); + } + + //Max public methods: 5 methods + assertEquals(5, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPosition").getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("getPosition").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setPosition", Position.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setPosition", Position.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("isPathable").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("isPathable").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setPathable", boolean.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setPathable", boolean.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getSprite").getModifiers())); + assertEquals(Sprite.class, ownClass.getDeclaredMethod("getSprite").getReturnType()); + assertTrue(Modifier.isProtected(ownClass.getDeclaredMethod("setSprite", Sprite.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setSprite", Sprite.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/HitableTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/HitableTest.java new file mode 100644 index 0000000..4a3ac80 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/HitableTest.java @@ -0,0 +1,57 @@ +package edu.uoc.pacman.model.entities.characters; + +import edu.uoc.pacman.model.utils.Direction; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class HitableTest { + + private final Class ownClass = Hitable.class; + + @Test + @Tag("sanity") + @DisplayName("Sanity Hitable - Interface definition") + void checkInterfaceSanity() { + assertTrue(ownClass.isInterface()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters", ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Hitable - Fields definition") + public void checkFieldsSanity() { + + //check attribute fields: 0 attributes + assertEquals(0, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Hitable - Methods definition") + public void checkMethodsSanity() { + //Number of methods + assertEquals(1, ownClass.getDeclaredMethods().length); + + //Max public methods: + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + + try { + assertEquals(boolean.class, ownClass.getDeclaredMethod("hit").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/MovableTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/MovableTest.java new file mode 100644 index 0000000..7ad2254 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/MovableTest.java @@ -0,0 +1,58 @@ +package edu.uoc.pacman.model.entities.characters; + +import edu.uoc.pacman.model.utils.Direction; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class MovableTest { + + private final Class ownClass = Movable.class; + + @Test + @Tag("sanity") + @DisplayName("Sanity Movable - Interface definition") + void checkInterfaceSanity() { + assertTrue(ownClass.isInterface()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters", ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Movable - Fields definition") + public void checkFieldsSanity() { + + //check attribute fields: 0 attributes + assertEquals(0, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Movable - Methods definition") + public void checkMethodsSanity() { + //Number of methods + assertEquals(2, ownClass.getDeclaredMethods().length); + + //Max public methods: + assertEquals(2, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + + try { + assertEquals(void.class, ownClass.getDeclaredMethod("move").getReturnType()); + assertEquals(void.class, ownClass.getDeclaredMethod("setDirection", Direction.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/BehaviourTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/BehaviourTest.java new file mode 100644 index 0000000..8cb3a93 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/BehaviourTest.java @@ -0,0 +1,104 @@ +package edu.uoc.pacman.model.entities.characters.ghosts; + +import edu.uoc.pacman.model.entities.characters.pacman.State; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class BehaviourTest { + + @Test + @Tag("basic") + void getDuration() { + assertEquals(30,Behaviour.FRIGHTENED.getDuration()); + assertEquals(20, Behaviour.CHASE.getDuration()); + assertEquals(10,Behaviour.SCATTER.getDuration()); + assertEquals(5,Behaviour.INACTIVE.getDuration()); + } + + @Test + @Tag("basic") + void testToString() { + assertEquals("FRIGHTENED:30",Behaviour.FRIGHTENED.toString()); + assertEquals("CHASE:20", Behaviour.CHASE.toString()); + assertEquals("SCATTER:10",Behaviour.SCATTER.toString()); + assertEquals("INACTIVE:5",Behaviour.INACTIVE.toString()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Behaviour - Enum definition") + void checkEnumSanity() { + final Class ownClass = Behaviour.class; + + assertTrue(ownClass.isEnum()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertTrue(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts",ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Behaviour - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Behaviour.class; + + //check attribute fields: 1 attributes + 4 values + $VALUES + assertEquals(6, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("duration").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("duration").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Behaviour - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Behaviour.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor: the first parameter is the value itself and the second one is the ordinal. + int constructorModifiers = ownClass.getDeclaredConstructor(String.class, int.class, int.class).getModifiers(); + assertTrue(Modifier.isPrivate(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Behaviour's constructor is defined wrongly"); + } + + //Max public methods: 2 methods + values() + valueOf() + assertEquals(4, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: $values() + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 1); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getDuration").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getDuration").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("toString").getModifiers())); + assertEquals(String.class, ownClass.getDeclaredMethod("toString").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/BlinkyTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/BlinkyTest.java new file mode 100644 index 0000000..2065167 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/BlinkyTest.java @@ -0,0 +1,413 @@ +package edu.uoc.pacman.model.entities.characters.ghosts; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAggressive; +import edu.uoc.pacman.model.entities.characters.pacman.Pacman; +import edu.uoc.pacman.model.entities.characters.pacman.State; +import edu.uoc.pacman.model.exceptions.LevelException; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +class BlinkyTest { + Blinky blinky; + + + @Mock + Level level; + + @Mock + Pacman pacman; + + @BeforeEach + void setUp() { + when(level.getWidth()).thenReturn(8); + blinky = new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level); + } + + @Test + @Tag("basic") + void correctInstanceChaseBehaviour(){ + assertTrue(blinky.chaseBehaviour instanceof ChaseAggressive); + } + + @Test + @Tag("basic") + void getBehaviour() { + assertEquals(Behaviour.CHASE, blinky.getBehaviour()); + } + + @Test + @Tag("basic") + void setBehaviour() { + blinky.setBehaviour(Behaviour.FRIGHTENED); + assertEquals(Behaviour.FRIGHTENED, blinky.getBehaviour()); + } + + @Test + @Tag("basic") + void reset() { + blinky.reset(); + assertEquals(Behaviour.INACTIVE, blinky.getBehaviour()); + assertFalse(blinky.isDead()); + assertEquals(Direction.UP, blinky.getDirection()); + assertEquals(new Position(2, 3), blinky.getPosition()); + } + + @Test + @Tag("basic") + void testEqualsOK() { + assertTrue(blinky.equals(blinky)); + assertTrue(blinky.equals(new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level))); + } + + @Test + @Tag("basic") + void testEqualsKO() { + assertFalse(blinky.equals(new Blinky(new Position(3, 3), Direction.DOWN, Behaviour.CHASE, level))); + assertFalse(blinky.equals(new Blinky(new Position(2, 3), Direction.UP, Behaviour.CHASE, level))); + assertFalse(blinky.equals(new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.FRIGHTENED, level))); + blinky.kill(); + assertFalse(blinky.equals(new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level))); + } + + @Test + @Tag("basic") + void testToString() { + assertEquals("2,3,DOWN,CHASE:20", blinky.toString()); + } + + @Test + @Tag("basic") + void getScatterPosition() { + assertEquals(new Position(8, -1), blinky.getScatterPosition()); + } + + @Test + @Tag("expert") + void move() { + try { + Level level = new Level("levels/level1.txt",3); + Blinky blinky = spy(level.getBlinky()); + assertEquals(new Position(6,1), blinky.getPosition()); + blinky.move(); + assertEquals(new Position(5,1), blinky.getPosition()); + assertEquals(Direction.LEFT, blinky.getDirection()); + verify(blinky, times(1)).hit(); + + level.getPacman().setPosition(new Position(5,2)); + blinky.move(); + assertEquals(new Position(5,2), blinky.getPosition()); + assertEquals(Direction.DOWN, blinky.getDirection()); + + level.getPacman().setPosition(new Position(10,6)); + blinky.move(); + assertEquals(new Position(6,2), blinky.getPosition()); + assertEquals(Direction.RIGHT, blinky.getDirection()); + + level.getPacman().setPosition(new Position(2,2)); + blinky.move(); + assertEquals(new Position(6,1), blinky.getPosition()); + assertEquals(Direction.UP, blinky.getDirection()); + + //There is a wall between Pacman and Blinky + level.getPacman().setPosition(new Position(4,4)); + blinky.setPosition(new Position(4,6)); + blinky.move(); + assertEquals(new Position(3,6), blinky.getPosition()); + assertEquals(Direction.LEFT, blinky.getDirection()); + + blinky = spy(new Blinky(new Position(3,6),Direction.LEFT, Behaviour.INACTIVE, level)); + blinky.move(); + assertEquals(new Position(3,6), blinky.getPosition()); + assertEquals(Direction.LEFT, blinky.getDirection()); + verify(blinky, never()).hit(); + } catch (LevelException e) { + System.out.println("[ERROR] Loading level while testing move()"); + } + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is CHASE, then ghost kills Pacman (NORMAL).") + void hitGhostKillsPacman1() { + when(level.getPacman()).thenReturn(pacman); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + when(pacman.getState()).thenReturn(State.NORMAL); + assertTrue(blinky.hit()); + verify(pacman, times(1)).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is SCATTER, then ghost kills Pacman (NORMAL)") + void hitGhostKillsPacman2() { + Blinky blinky = spy(new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.SCATTER, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.NORMAL); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(blinky.hit()); + verify(pacman, times(1)).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is SCATTER and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitGhostNotKillPacman1() { + Blinky blinky = spy(new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.SCATTER, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.INVINCIBLE); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(blinky.hit()); + verify(pacman, never()).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is CHASE and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitGhostNotKillPacman2() { + Blinky blinky = spy(new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.INVINCIBLE); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(blinky.hit()); + verify(pacman, never()).kill(); + } + + + @Test + @Tag("advanced") + @DisplayName("Ghost is INACTIVE, then it does not kill Pacman") + void hitGhostInactive() { + Blinky blinky = spy(new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.INACTIVE, level)); + assertFalse(blinky.hit()); + verify(blinky,never()).kill(); + verify(pacman, never()).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is FRIGHTENED, then Pacman (by logical it is EATER) kills ghost") + void hitPacmanKillsGhost() { + Blinky blinky = spy(new Blinky(new Position(2, 3), Direction.DOWN, Behaviour.FRIGHTENED, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(blinky.hit()); + verify(blinky, times(1)).kill(); + } + + + @Test + @Tag("basic") + void kill() { + blinky.kill(); + assertTrue(blinky.isDead()); + assertEquals(Behaviour.INACTIVE, blinky.getBehaviour()); + verify(level, times(1)).addPoints(blinky.getPoints()); + } + + @Test + @Tag("basic") + void testReset() { + //Given the setUp state + //When + blinky.reset(); + //Then + assertFalse(blinky.isDead()); + assertEquals(new Position(2, 3), blinky.getPosition()); + assertEquals(Behaviour.INACTIVE, blinky.getBehaviour()); + assertEquals(Direction.UP, blinky.getDirection()); + + //Given + blinky.setPosition(new Position(4, 5)); + blinky.setBehaviour(Behaviour.FRIGHTENED); + blinky.setDirection(Direction.LEFT); + //When + blinky.reset(); + //Then + assertFalse(blinky.isDead()); + assertEquals(new Position(2, 3), blinky.getPosition()); + assertEquals(Behaviour.INACTIVE, blinky.getBehaviour()); + assertEquals(Direction.UP, blinky.getDirection()); + } + + @Test + @Tag("basic") + void getDirection() { + assertEquals(Direction.DOWN, blinky.getDirection()); + } + + @Test + @Tag("basic") + void setDirection() { + blinky.setDirection(Direction.LEFT); + assertEquals(Direction.LEFT, blinky.getDirection()); + + blinky.setDirection(Direction.RIGHT); + assertEquals(Direction.RIGHT, blinky.getDirection()); + + blinky.setDirection(Direction.UP); + assertEquals(Direction.UP, blinky.getDirection()); + } + + @Test + @Tag("basic") + void isDead() { + assertFalse(blinky.isDead()); + } + + @Test + @Tag("basic") + void alive() { + blinky.alive(); + assertFalse(blinky.isDead()); + blinky.kill(); + assertTrue(blinky.isDead()); + blinky.alive(); + assertFalse(blinky.isDead()); + } + + @Test + @Tag("basic") + void getLevel() { + assertEquals(level, blinky.getLevel()); + } + + @Test + @Tag("basic") + void setLevel() { + blinky.setLevel(null); + assertNull(blinky.getLevel()); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(2, 3), blinky.getPosition()); + } + + @Test + @Tag("basic") + void setPosition() { + blinky.setPosition(new Position(-1, 50)); + assertEquals(new Position(-1, 50), blinky.getPosition()); + + blinky.setPosition(new Position(2, 3)); + assertEquals(new Position(2, 3), blinky.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(blinky.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + blinky.setPathable(false); + assertFalse(blinky.isPathable()); + + blinky.setPathable(true); + assertTrue(blinky.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.BLINKY, blinky.getSprite()); + } + + @Test + @Tag("basic") + void getPoints() { + assertEquals(400, blinky.getPoints()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Blinky - Class definition") + void checkClassSanity() { + final Class ownClass = Blinky.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts", ownClass.getPackageName()); + assertTrue(Ghost.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Blinky - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Blinky.class; + + //check attribute fields + assertEquals(1, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("POINTS").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("POINTS").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Blinky - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Blinky.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, Direction.class, + Behaviour.class, Level.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Blinky's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPoints").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getPoints").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/ClydeTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/ClydeTest.java new file mode 100644 index 0000000..b62dab1 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/ClydeTest.java @@ -0,0 +1,418 @@ +package edu.uoc.pacman.model.entities.characters.ghosts; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseCoward; +import edu.uoc.pacman.model.entities.characters.pacman.Pacman; +import edu.uoc.pacman.model.entities.characters.pacman.State; +import edu.uoc.pacman.model.exceptions.LevelException; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@ExtendWith(MockitoExtension.class) +class ClydeTest { + + Clyde clyde; + + @Mock + Level level; + + @Mock + Pacman pacman; + + @BeforeEach + void setUp() { + when(level.getHeight()).thenReturn(8); + clyde = new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level); + } + + @Test + @Tag("basic") + void correctInstanceChaseBehaviour(){ + assertTrue(clyde.chaseBehaviour instanceof ChaseCoward); + } + + @Test + @Tag("basic") + void getBehaviour() { + assertEquals(Behaviour.CHASE, clyde.getBehaviour()); + } + + @Test + @Tag("basic") + void setBehaviour() { + clyde.setBehaviour(Behaviour.FRIGHTENED); + assertEquals(Behaviour.FRIGHTENED, clyde.getBehaviour()); + } + + @Test + @Tag("basic") + void reset() { + clyde.reset(); + assertEquals(Behaviour.INACTIVE, clyde.getBehaviour()); + assertFalse(clyde.isDead()); + assertEquals(Direction.UP, clyde.getDirection()); + assertEquals(new Position(2, 3), clyde.getPosition()); + } + + @Test + @Tag("basic") + void testEqualsOK() { + assertTrue(clyde.equals(clyde)); + assertTrue(clyde.equals(new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level))); + } + + @Test + @Tag("basic") + void testEqualsKO() { + assertFalse(clyde.equals(new Clyde(new Position(3, 3), Direction.DOWN, Behaviour.CHASE, level))); + assertFalse(clyde.equals(new Clyde(new Position(2, 3), Direction.UP, Behaviour.CHASE, level))); + assertFalse(clyde.equals(new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.FRIGHTENED, level))); + clyde.kill(); + assertFalse(clyde.equals(new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level))); + } + + @Test + @Tag("basic") + void testToString() { + assertEquals("2,3,DOWN,CHASE:20", clyde.toString()); + } + + @Test + @Tag("basic") + void getScatterPosition() { + assertEquals(new Position(-1, 8), clyde.getScatterPosition()); + } + + @Test + @Tag("expert") + void move() { + try { + Level level = new Level("levels/level1.txt",3); + + Clyde clyde = spy((Clyde) level.getGhostList().stream().filter(g -> g instanceof Clyde).findFirst().get()); + clyde.setBehaviour(Behaviour.CHASE); + + assertEquals(new Position(2,6), clyde.getPosition()); + clyde.move(); //Pacman is in (1,1), then distance is sqrt(26) --> scatterPosition (-1,8) + assertEquals(new Position(2,5), clyde.getPosition()); + assertEquals(Direction.UP, clyde.getDirection()); + verify(clyde, times(1)).hit(); + + level.getPacman().setPosition(new Position(5,2)); + clyde.move(); //ScatterPosition + assertEquals(new Position(1,5), clyde.getPosition()); + assertEquals(Direction.LEFT, clyde.getDirection()); + + level.getPacman().setPosition(new Position(10,6)); + clyde.move(); //ScatterPosition + assertEquals(new Position(1,6), clyde.getPosition()); + assertEquals(Direction.DOWN, clyde.getDirection()); + + level.getPacman().setPosition(new Position(24,1)); + clyde.move(); //Pacman's position + assertEquals(new Position(2,6), clyde.getPosition()); + assertEquals(Direction.RIGHT, clyde.getDirection()); + + //There is a wall between Pacman and Clyde + level.getPacman().setPosition(new Position(4,4)); + clyde.setPosition(new Position(4,6)); + clyde.move(); //ScatterPosition + assertEquals(new Position(5,6), clyde.getPosition()); //No (4,6) because it is the opposite direction + assertEquals(Direction.RIGHT, clyde.getDirection()); + + clyde = spy(new Clyde(new Position(5,6),Direction.DOWN, Behaviour.INACTIVE, level)); + clyde.move(); + assertEquals(new Position(5,6), clyde.getPosition()); + assertEquals(Direction.DOWN, clyde.getDirection()); + verify(clyde, never()).hit(); + + } catch (LevelException e) { + System.out.println("[ERROR] Loading level while testing move()"); + } + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is CHASE, then ghost kills Pacman (NORMAL).") + void hitGhostKillsPacman() { + when(level.getPacman()).thenReturn(pacman); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + when(pacman.getState()).thenReturn(State.NORMAL); + assertTrue(clyde.hit()); + verify(pacman, times(1)).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is SCATTER, then ghost kills Pacman (NORMAL)") + void hitPGhostKillsPacman() { + Clyde clyde = spy(new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.SCATTER, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.NORMAL); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(clyde.hit()); + verify(pacman, times(1)).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is SCATTER and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitPGhostNotKillPacman1() { + Clyde clyde = spy(new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.SCATTER, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.INVINCIBLE); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(clyde.hit()); + verify(pacman, never()).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is CHASE and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitPGhostNotKillPacman2() { + Clyde clyde = spy(new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.INVINCIBLE); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(clyde.hit()); + verify(pacman, never()).kill(); + } + + + @Test + @Tag("advanced") + @DisplayName("Ghost is INACTIVE, then it does not kill Pacman") + void hitGhostInactive() { + Clyde clyde = spy(new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.INACTIVE, level)); + assertFalse(clyde.hit()); + verify(clyde,never()).kill(); + verify(pacman, never()).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is FRIGHTENED, then Pacman (by logical it is EATER) kills ghost") + void hitPacmanKillsGhost1() { + Clyde clyde = spy(new Clyde(new Position(2, 3), Direction.DOWN, Behaviour.FRIGHTENED, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(clyde.hit()); + verify(clyde, times(1)).kill(); + } + + + @Test + @Tag("basic") + void kill() { + clyde.kill(); + assertTrue(clyde.isDead()); + assertEquals(Behaviour.INACTIVE, clyde.getBehaviour()); + verify(level, times(1)).addPoints(clyde.getPoints()); + } + + @Test + @Tag("basic") + void testReset() { + //Given the setUp state + //When + clyde.reset(); + //Then + assertFalse(clyde.isDead()); + assertEquals(new Position(2, 3), clyde.getPosition()); + assertEquals(Behaviour.INACTIVE, clyde.getBehaviour()); + assertEquals(Direction.UP, clyde.getDirection()); + + //Given + clyde.setPosition(new Position(4, 5)); + clyde.setBehaviour(Behaviour.FRIGHTENED); + clyde.setDirection(Direction.LEFT); + //When + clyde.reset(); + //Then + assertFalse(clyde.isDead()); + assertEquals(new Position(2, 3), clyde.getPosition()); + assertEquals(Behaviour.INACTIVE, clyde.getBehaviour()); + assertEquals(Direction.UP, clyde.getDirection()); + } + + @Test + @Tag("basic") + void getDirection() { + assertEquals(Direction.DOWN, clyde.getDirection()); + } + + @Test + @Tag("basic") + void setDirection() { + clyde.setDirection(Direction.LEFT); + assertEquals(Direction.LEFT, clyde.getDirection()); + + clyde.setDirection(Direction.RIGHT); + assertEquals(Direction.RIGHT, clyde.getDirection()); + + clyde.setDirection(Direction.UP); + assertEquals(Direction.UP, clyde.getDirection()); + } + + @Test + @Tag("basic") + void isDead() { + assertFalse(clyde.isDead()); + } + + @Test + @Tag("basic") + void alive() { + clyde.alive(); + assertFalse(clyde.isDead()); + clyde.kill(); + assertTrue(clyde.isDead()); + clyde.alive(); + assertFalse(clyde.isDead()); + } + + @Test + @Tag("basic") + void getLevel() { + assertEquals(level, clyde.getLevel()); + } + + @Test + @Tag("basic") + void setLevel() { + clyde.setLevel(null); + assertNull(clyde.getLevel()); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(2, 3), clyde.getPosition()); + } + + @Test + @Tag("basic") + void setPosition() { + clyde.setPosition(new Position(-1, 50)); + assertEquals(new Position(-1, 50), clyde.getPosition()); + + clyde.setPosition(new Position(2, 3)); + assertEquals(new Position(2, 3), clyde.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(clyde.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + clyde.setPathable(false); + assertFalse(clyde.isPathable()); + + clyde.setPathable(true); + assertTrue(clyde.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.CLYDE, clyde.getSprite()); + } + + @Test + @Tag("basic") + void getPoints() { + assertEquals(100, clyde.getPoints()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Clyde - Class definition") + void checkClassSanity() { + final Class ownClass = Clyde.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts", ownClass.getPackageName()); + assertTrue(Ghost.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Clyde - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Clyde.class; + + //check attribute fields + assertEquals(1, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("POINTS").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("POINTS").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Clyde - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Clyde.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, Direction.class, + Behaviour.class, Level.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Clyde's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPoints").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getPoints").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/GhostTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/GhostTest.java new file mode 100644 index 0000000..eb48f0b --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/GhostTest.java @@ -0,0 +1,120 @@ +package edu.uoc.pacman.model.entities.characters.ghosts; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.characters.Character; +import edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseBehaviour; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class GhostTest { + + @Test + @Tag("sanity") + @DisplayName("Sanity Ghost - Class definition") + void checkClassSanity() { + final Class ownClass = Ghost.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertTrue(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts", ownClass.getPackageName()); + assertTrue(Character.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Ghost - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Ghost.class; + + //check attribute fields + assertEquals(3, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("behaviour").getModifiers())); + assertEquals(Behaviour.class, ownClass.getDeclaredField("behaviour").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("scatterPosition").getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredField("scatterPosition").getType()); + assertTrue(Modifier.isProtected(ownClass.getDeclaredField("chaseBehaviour").getModifiers())); + assertEquals(ChaseBehaviour.class, ownClass.getDeclaredField("chaseBehaviour").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Ghost - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Ghost.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, Position.class, + Direction.class, Behaviour.class, Sprite.class, Level.class).getModifiers(); + assertTrue(Modifier.isProtected(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Ghost's constructor is defined wrongly"); + } + + //Max public methods: 9 methods + assertEquals(9, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 3); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getBehaviour").getModifiers())); + assertEquals(Behaviour.class, ownClass.getDeclaredMethod("getBehaviour").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setBehaviour", Behaviour.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setBehaviour", Behaviour.class).getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("nextBehaviour").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("nextBehaviour").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("reset").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("reset").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("equals", Object.class).getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("equals", Object.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("toString").getModifiers())); + assertEquals(String.class, ownClass.getDeclaredMethod("toString").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getScatterPosition").getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("getScatterPosition").getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("setScatterPosition", Position.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setScatterPosition", Position.class).getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("getTargetPosition").getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("getTargetPosition").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("move").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("move").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("hit").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("hit").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("kill").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("kill").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/InkyTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/InkyTest.java new file mode 100644 index 0000000..76b5def --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/InkyTest.java @@ -0,0 +1,423 @@ +package edu.uoc.pacman.model.entities.characters.ghosts; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol; +import edu.uoc.pacman.model.entities.characters.pacman.Pacman; +import edu.uoc.pacman.model.entities.characters.pacman.State; +import edu.uoc.pacman.model.exceptions.LevelException; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@ExtendWith(MockitoExtension.class) +class InkyTest { + + Inky inky; + + @Mock + Level level; + + @Mock + Pacman pacman; + + @BeforeEach + void setUp() { + when(level.getWidth()).thenReturn(8); + when(level.getHeight()).thenReturn(8); + inky = new Inky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level); + } + + @Test + @Tag("basic") + void correctInstanceChaseBehaviour(){ + assertTrue(inky.chaseBehaviour instanceof ChasePatrol); + } + + @Test + @Tag("basic") + void getBehaviour() { + assertEquals(Behaviour.CHASE, inky.getBehaviour()); + } + + @Test + @Tag("basic") + void setBehaviour() { + inky.setBehaviour(Behaviour.SCATTER); + assertEquals(Behaviour.SCATTER, inky.getBehaviour()); + } + + @Test + @Tag("basic") + void reset() { + inky.reset(); + assertEquals(Behaviour.INACTIVE, inky.getBehaviour()); + assertFalse(inky.isDead()); + assertEquals(Direction.UP, inky.getDirection()); + assertEquals(new Position(2, 3), inky.getPosition()); + } + + @Test + @Tag("basic") + void testEqualsOK() { + assertTrue(inky.equals(inky)); + assertTrue(inky.equals(new Inky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level))); + } + + @Test + @Tag("basic") + void testEqualsKO() { + assertFalse(inky.equals(new Inky(new Position(3, 3), Direction.DOWN, Behaviour.CHASE, level))); + assertFalse(inky.equals(new Inky(new Position(2, 3), Direction.UP, Behaviour.CHASE, level))); + assertFalse(inky.equals(new Inky(new Position(2, 3), Direction.DOWN, Behaviour.FRIGHTENED, level))); + inky.kill(); + assertFalse(inky.equals(new Inky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level))); + } + + @Test + @Tag("basic") + void testToString() { + assertEquals("2,3,DOWN,CHASE:20", inky.toString()); + } + + @Test + @Tag("basic") + void getScatterPosition() { + assertEquals(new Position(8, 8), inky.getScatterPosition()); + } + + @Test + @Tag("expert") + void move() { + try { + Level level = new Level("levels/level1.txt",3); + Inky inky = spy((Inky) level.getGhostList().stream().filter(g -> g instanceof Inky).findFirst().get()); + assertEquals(new Position(1,5), inky.getPosition()); + //targetBlinkyPosition is (3,1)--> +2 steps in X (Pacman is facing right at (1,1)) + // targetBlinkyPosition - FirstBlinkyPosition = (3,1) - (6,1) = (-3, 0) + //targetPosition = 2 * (-3,0) = (-6,0) + inky.move(); + //Inky in level1.text is facing UP + // UP(1,4): sqrt(65), DOWN(1,6): sqrt(85), RIGHT(2,5): sqrt(89), LEFT(0,5): sqrt(69) but there is a WALL. + assertEquals(new Position(1,4), inky.getPosition()); + assertEquals(Direction.UP, inky.getDirection()); + verify(inky,times(1)).hit(); + + level.getPacman().setPosition(new Position(5,2)); + level.getPacman().setDirection(Direction.DOWN); + //inky is (1,4), UP + //targetBlinkyPosition is (5,4)--> +2 steps in Y (Pacman is facing down at (5,2)) + // targetBlinkyPosition - FirstBlinkyPosition = (5,4) - (6,1) = (-1, 3) + //targetPosition = 2 * (-1,3) = (-2,6) + inky.move(); + //left(0,4): sqrt(8), but there is a wall; down(1,5): sqrt(1), but it's opposite, + // up(1,3): sqrt(18); right(2,4): sqrt(20) + assertEquals(new Position(1,3), inky.getPosition()); + assertEquals(Direction.UP, inky.getDirection()); + + level.getPacman().setPosition(new Position(8,5)); + level.getPacman().setDirection(Direction.RIGHT); + inky.setPosition(new Position(6,1)); + inky.setDirection(Direction.LEFT); + //targetBlinkyPosition is (10,5)--> +2 steps in X (Pacman is facing right at (10,5)) + // targetBlinkyPosition - FirstBlinkyPosition = (10,5) - (6,1) = (4, 4) + //targetPosition = 2 * (4,4) = (8,8) + inky.move(); + //UP(6,0): sqrt(4), but WALL , DOWN(6,2): sqrt(40), RIGHT(7,1): sqrt(50) -->opposite, LEFT(5,1): sqrt(58) + assertEquals(new Position(6,2), inky.getPosition()); + assertEquals(Direction.DOWN, inky.getDirection()); + + inky = spy(new Inky(new Position(3,6),Direction.LEFT, Behaviour.INACTIVE, level)); + inky.move(); + assertEquals(new Position(3,6), inky.getPosition()); + assertEquals(Direction.LEFT, inky.getDirection()); + verify(inky, never()).hit(); + } catch (LevelException e) { + System.out.println("[ERROR] Loading level while testing move()"); + } + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is CHASE, then ghost kills Pacman (NORMAL).") + void hitGhostKillsPacman() { + when(level.getPacman()).thenReturn(pacman); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + when(pacman.getState()).thenReturn(State.NORMAL); + assertTrue(inky.hit()); + verify(pacman, times(1)).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is SCATTER, then ghost kills Pacman (NORMAL)") + void hitPGhostKillsPacman() { + Inky inky = spy(new Inky(new Position(2, 3), Direction.DOWN, Behaviour.SCATTER, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.NORMAL); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(inky.hit()); + verify(pacman, times(1)).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is SCATTER and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitPGhostNotKillPacman1() { + Inky inky = spy(new Inky(new Position(2, 3), Direction.DOWN, Behaviour.SCATTER, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.INVINCIBLE); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(inky.hit()); + verify(pacman, never()).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is CHASE and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitPGhostNotKillPacman2() { + Inky inky = spy(new Inky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.INVINCIBLE); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(inky.hit()); + verify(pacman, never()).kill(); + } + + + @Test + @Tag("advanced") + @DisplayName("Ghost is INACTIVE, then it does not kill Pacman") + void hitGhostInactive() { + Inky inky = spy(new Inky(new Position(2, 3), Direction.DOWN, Behaviour.INACTIVE, level)); + assertFalse(inky.hit()); + verify(inky,never()).kill(); + verify(pacman, never()).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is FRIGHTENED, then Pacman (by logical it is EATER) kills ghost") + void hitPacmanKillsGhost1() { + Inky inky = spy(new Inky(new Position(2, 3), Direction.DOWN, Behaviour.FRIGHTENED, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(inky.hit()); + verify(inky, times(1)).kill(); + } + + + @Test + @Tag("basic") + void kill() { + inky.kill(); + assertTrue(inky.isDead()); + assertEquals(Behaviour.INACTIVE, inky.getBehaviour()); + verify(level, times(1)).addPoints(inky.getPoints()); + } + + @Test + @Tag("basic") + void testReset() { + //Given the setUp state + //When + inky.reset(); + //Then + assertFalse(inky.isDead()); + assertEquals(new Position(2, 3), inky.getPosition()); + assertEquals(Behaviour.INACTIVE, inky.getBehaviour()); + assertEquals(Direction.UP, inky.getDirection()); + + //Given + inky.setPosition(new Position(4, 5)); + inky.setBehaviour(Behaviour.FRIGHTENED); + inky.setDirection(Direction.LEFT); + //When + inky.reset(); + //Then + assertFalse(inky.isDead()); + assertEquals(new Position(2, 3), inky.getPosition()); + assertEquals(Behaviour.INACTIVE, inky.getBehaviour()); + assertEquals(Direction.UP, inky.getDirection()); + } + + @Test + @Tag("basic") + void getDirection() { + assertEquals(Direction.DOWN, inky.getDirection()); + } + + @Test + @Tag("basic") + void setDirection() { + inky.setDirection(Direction.LEFT); + assertEquals(Direction.LEFT, inky.getDirection()); + + inky.setDirection(Direction.RIGHT); + assertEquals(Direction.RIGHT, inky.getDirection()); + + inky.setDirection(Direction.UP); + assertEquals(Direction.UP, inky.getDirection()); + } + + @Test + @Tag("basic") + void isDead() { + assertFalse(inky.isDead()); + } + + @Test + @Tag("basic") + void alive() { + inky.alive(); + assertFalse(inky.isDead()); + inky.kill(); + assertTrue(inky.isDead()); + inky.alive(); + assertFalse(inky.isDead()); + } + + @Test + @Tag("basic") + void getLevel() { + assertEquals(level, inky.getLevel()); + } + + @Test + @Tag("basic") + void setLevel() { + inky.setLevel(null); + assertNull(inky.getLevel()); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(2, 3), inky.getPosition()); + } + + @Test + @Tag("basic") + void setPosition() { + inky.setPosition(new Position(-1, 50)); + assertEquals(new Position(-1, 50), inky.getPosition()); + + inky.setPosition(new Position(2, 3)); + assertEquals(new Position(2, 3), inky.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(inky.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + inky.setPathable(false); + assertFalse(inky.isPathable()); + + inky.setPathable(true); + assertTrue(inky.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.INKY, inky.getSprite()); + } + + + @Test + @Tag("basic") + void getPoints() { + assertEquals(200, inky.getPoints()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Inky - Class definition") + void checkClassSanity() { + final Class ownClass = Inky.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts", ownClass.getPackageName()); + assertTrue(Ghost.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Inky - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Inky.class; + + //check attribute fields + assertEquals(1, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("POINTS").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("POINTS").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Inky - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Inky.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, Direction.class, + Behaviour.class, Level.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Inky's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPoints").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getPoints").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/PinkyTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/PinkyTest.java new file mode 100644 index 0000000..4f5a983 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/PinkyTest.java @@ -0,0 +1,420 @@ +package edu.uoc.pacman.model.entities.characters.ghosts; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.characters.ghosts.chase.ChaseAmbush; +import edu.uoc.pacman.model.entities.characters.pacman.Pacman; +import edu.uoc.pacman.model.entities.characters.pacman.State; +import edu.uoc.pacman.model.exceptions.LevelException; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@ExtendWith(MockitoExtension.class) +class PinkyTest { + + Pinky pinky; + + @Mock + Level level; + + @Mock + Pacman pacman; + + @BeforeEach + void setUp() { + pinky = new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level); + } + + @Test + @Tag("basic") + void correctInstanceChaseBehaviour(){ + assertTrue(pinky.chaseBehaviour instanceof ChaseAmbush); + } + + @Test + @Tag("basic") + void getBehaviour() { + assertEquals(Behaviour.CHASE, pinky.getBehaviour()); + } + + @Test + @Tag("basic") + void setBehaviour() { + pinky.setBehaviour(Behaviour.SCATTER); + assertEquals(Behaviour.SCATTER, pinky.getBehaviour()); + } + + @Test + @Tag("basic") + void reset() { + pinky.reset(); + assertEquals(Behaviour.INACTIVE, pinky.getBehaviour()); + assertFalse(pinky.isDead()); + assertEquals(Direction.UP, pinky.getDirection()); + assertEquals(new Position(2, 3), pinky.getPosition()); + } + + @Test + @Tag("basic") + void testEqualsOK() { + assertTrue(pinky.equals(pinky)); + assertTrue(pinky.equals(new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level))); + } + + @Test + @Tag("basic") + void testEqualsKO() { + assertFalse(pinky.equals(new Pinky(new Position(3, 3), Direction.DOWN, Behaviour.CHASE, level))); + assertFalse(pinky.equals(new Pinky(new Position(2, 3), Direction.UP, Behaviour.CHASE, level))); + assertFalse(pinky.equals(new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.FRIGHTENED, level))); + pinky.kill(); + assertFalse(pinky.equals(new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level))); + } + + @Test + @Tag("basic") + void testToString() { + assertEquals("2,3,DOWN,CHASE:20", pinky.toString()); + } + + @Test + @Tag("basic") + void getScatterPosition() { + assertEquals(new Position(-1, -1), pinky.getScatterPosition()); + } + + @Test + @Tag("expert") + void move() { + try { + Level level = new Level("levels/level1.txt",3); + Pinky pinky = spy((Pinky) level.getGhostList().stream().filter(g -> g instanceof Pinky).findFirst().get()); + assertEquals(new Position(1,6), pinky.getPosition()); + pinky.move(); //targetPosition is (5,1) --> 4 steps in X (Pacman is facing right at (1,1)) + assertEquals(new Position(2,6), pinky.getPosition()); + assertEquals(Direction.RIGHT, pinky.getDirection()); + verify(pinky,times(1)).hit(); + + level.getPacman().setPosition(new Position(5,2)); + level.getPacman().setDirection(Direction.DOWN); + pinky.move(); //targetPosition is (5,6) + assertEquals(new Position(3,6), pinky.getPosition()); + assertEquals(Direction.RIGHT, pinky.getDirection()); + + level.getPacman().setPosition(new Position(1,1)); + level.getPacman().setDirection(Direction.RIGHT); + pinky.setPosition(new Position(4,1)); + pinky.setDirection(Direction.LEFT); + // P..GT Because Ghost is facing left, it cannot go back, so the shortest path is (4,2). UP is a wall. + pinky.move(); + assertEquals(new Position(4,2), pinky.getPosition()); + assertEquals(Direction.DOWN, pinky.getDirection()); + + level.getPacman().setPosition(new Position(2,2)); + level.getPacman().setDirection(Direction.LEFT); + pinky.move(); + assertEquals(new Position(4,3), pinky.getPosition()); + assertEquals(Direction.DOWN, pinky.getDirection()); + + //There is a wall between Pacman and Pinky + level.getPacman().setPosition(new Position(4,4)); + pinky.setPosition(new Position(4,6)); + pinky.move(); + assertEquals(new Position(3,6), pinky.getPosition()); + assertEquals(Direction.LEFT, pinky.getDirection()); + + pinky = spy(new Pinky(new Position(3,6),Direction.LEFT, Behaviour.INACTIVE, level)); + pinky.move(); + assertEquals(new Position(3,6), pinky.getPosition()); + assertEquals(Direction.LEFT, pinky.getDirection()); + verify(pinky, never()).hit(); + } catch (LevelException e) { + System.out.println("[ERROR] Loading level while testing move()"); + } + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is CHASE, then ghost kills Pacman (NORMAL).") + void hitGhostKillsPacman() { + when(level.getPacman()).thenReturn(pacman); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + when(pacman.getState()).thenReturn(State.NORMAL); + assertTrue(pinky.hit()); + verify(pacman, times(1)).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is SCATTER, then ghost kills Pacman (NORMAL)") + void hitPGhostKillsPacman() { + Pinky pinky = spy(new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.SCATTER, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.NORMAL); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(pinky.hit()); + verify(pacman, times(1)).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is SCATTER and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitPGhostNotKillPacman1() { + Pinky pinky = spy(new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.SCATTER, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.INVINCIBLE); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(pinky.hit()); + verify(pacman, never()).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is CHASE and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitPGhostNotKillPacman2() { + Pinky pinky = spy(new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.CHASE, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getState()).thenReturn(State.INVINCIBLE); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(pinky.hit()); + verify(pacman, never()).kill(); + } + + + @Test + @Tag("advanced") + @DisplayName("Ghost is INACTIVE, then it does not kill Pacman") + void hitGhostInactive() { + Pinky pinky = spy(new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.INACTIVE, level)); + assertFalse(pinky.hit()); + verify(pinky,never()).kill(); + verify(pacman, never()).kill(); + } + + @Test + @Tag("advanced") + @DisplayName("Ghost is FRIGHTENED, then Pacman (by logical it is EATER) kills ghost") + void hitPacmanKillsGhost1() { + Pinky pinky = spy(new Pinky(new Position(2, 3), Direction.DOWN, Behaviour.FRIGHTENED, level)); + when(level.getPacman()).thenReturn(pacman); + when(pacman.getPosition()).thenReturn(new Position(2, 3)); + assertTrue(pinky.hit()); + verify(pinky, times(1)).kill(); + } + + + @Test + @Tag("basic") + void kill() { + pinky.kill(); + assertTrue(pinky.isDead()); + assertEquals(Behaviour.INACTIVE, pinky.getBehaviour()); + verify(level, times(1)).addPoints(pinky.getPoints()); + } + + @Test + @Tag("basic") + void testReset() { + //Given the setUp state + //When + pinky.reset(); + //Then + assertFalse(pinky.isDead()); + assertEquals(new Position(2, 3), pinky.getPosition()); + assertEquals(Behaviour.INACTIVE, pinky.getBehaviour()); + assertEquals(Direction.UP, pinky.getDirection()); + + //Given + pinky.setPosition(new Position(4, 5)); + pinky.setBehaviour(Behaviour.FRIGHTENED); + pinky.setDirection(Direction.LEFT); + //When + pinky.reset(); + //Then + assertFalse(pinky.isDead()); + assertEquals(new Position(2, 3), pinky.getPosition()); + assertEquals(Behaviour.INACTIVE, pinky.getBehaviour()); + assertEquals(Direction.UP, pinky.getDirection()); + } + + @Test + @Tag("basic") + void getDirection() { + assertEquals(Direction.DOWN, pinky.getDirection()); + } + + @Test + @Tag("basic") + void setDirection() { + pinky.setDirection(Direction.LEFT); + assertEquals(Direction.LEFT, pinky.getDirection()); + + pinky.setDirection(Direction.RIGHT); + assertEquals(Direction.RIGHT, pinky.getDirection()); + + pinky.setDirection(Direction.UP); + assertEquals(Direction.UP, pinky.getDirection()); + } + + @Test + @Tag("basic") + void isDead() { + assertFalse(pinky.isDead()); + } + + @Test + @Tag("basic") + void alive() { + pinky.alive(); + assertFalse(pinky.isDead()); + pinky.kill(); + assertTrue(pinky.isDead()); + pinky.alive(); + assertFalse(pinky.isDead()); + } + + @Test + @Tag("basic") + void getLevel() { + assertEquals(level, pinky.getLevel()); + } + + @Test + @Tag("basic") + void setLevel() { + pinky.setLevel(null); + assertNull(pinky.getLevel()); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(2, 3), pinky.getPosition()); + } + + @Test + @Tag("basic") + void setPosition() { + pinky.setPosition(new Position(-1, 50)); + assertEquals(new Position(-1, 50), pinky.getPosition()); + + pinky.setPosition(new Position(2, 3)); + assertEquals(new Position(2, 3), pinky.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(pinky.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + pinky.setPathable(false); + assertFalse(pinky.isPathable()); + + pinky.setPathable(true); + assertTrue(pinky.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.PINKY, pinky.getSprite()); + } + + + @Test + @Tag("basic") + void getPoints() { + assertEquals(300, pinky.getPoints()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Pinky - Class definition") + void checkClassSanity() { + final Class ownClass = Pinky.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts", ownClass.getPackageName()); + assertTrue(Ghost.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Pinky - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Pinky.class; + + //check attribute fields + assertEquals(1, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("POINTS").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("POINTS").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Pinky - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Pinky.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, Direction.class, + Behaviour.class, Level.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Pinky's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPoints").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getPoints").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAggressiveTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAggressiveTest.java new file mode 100644 index 0000000..0ee20c4 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAggressiveTest.java @@ -0,0 +1,79 @@ +package edu.uoc.pacman.model.entities.characters.ghosts.chase; + +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.utils.Position; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class ChaseAggressiveTest { + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseAggressive - Class definition") + void checkClassSanity() { + final Class ownClass = ChaseAggressive.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertFalse(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts.chase",ownClass.getPackageName()); + assertTrue(ChaseBehaviour.class.isAssignableFrom(ownClass)); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseAggresive - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = ChaseAggressive.class; + + //check attribute fields + assertEquals(0, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseAggressive - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = ChaseAggressive.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor().getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] ChaseAggresive's constructor is defined wrongly"); + } + + //Max public methods: 6 methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count()); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAmbushTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAmbushTest.java new file mode 100644 index 0000000..4174d09 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseAmbushTest.java @@ -0,0 +1,91 @@ +package edu.uoc.pacman.model.entities.characters.ghosts.chase; + +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.utils.Position; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class ChaseAmbushTest { + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseAmbush - Class definition") + void checkClassSanity() { + final Class ownClass = ChaseAmbush.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertFalse(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts.chase",ownClass.getPackageName()); + assertTrue(ChaseBehaviour.class.isAssignableFrom(ownClass)); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChasePatrol - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = ChaseAmbush.class; + + //check attribute fields + assertEquals(1, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("TILES_OFFSET").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("TILES_OFFSET").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("TILES_OFFSET").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("TILES_OFFSET").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChasePatrol - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = ChaseAmbush.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor().getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] ChaseAmbush's constructor is defined wrongly"); + } + + //Max public methods: 6 methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count()); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseBehaviourTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseBehaviourTest.java new file mode 100644 index 0000000..0a27eff --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseBehaviourTest.java @@ -0,0 +1,57 @@ +package edu.uoc.pacman.model.entities.characters.ghosts.chase; + +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.utils.Position; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class ChaseBehaviourTest { + + private final Class ownClass = ChaseBehaviour.class; + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseBehaviour - Interface definition") + void checkInterfaceSanity() { + assertTrue(ownClass.isInterface()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts.chase", ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseBehaviour - Fields definition") + public void checkFieldsSanity() { + + //check attribute fields: 0 attributes + assertEquals(0, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseBehaviour - Methods definition") + public void checkMethodsSanity() { + //Number of methods + assertEquals(1, ownClass.getDeclaredMethods().length); + + //Max public methods: + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + + try { + assertEquals(Position.class, ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseCowardTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseCowardTest.java new file mode 100644 index 0000000..5363d27 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChaseCowardTest.java @@ -0,0 +1,90 @@ +package edu.uoc.pacman.model.entities.characters.ghosts.chase; + +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.utils.Position; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class ChaseCowardTest { + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseCoward - Class definition") + void checkClassSanity() { + final Class ownClass = ChaseCoward.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertFalse(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts.chase",ownClass.getPackageName()); + assertTrue(ChaseBehaviour.class.isAssignableFrom(ownClass)); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChaseCoward - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = ChaseCoward.class; + + //check attribute fields + assertEquals(1, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("TILES_TO_CHASE").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("TILES_TO_CHASE").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("TILES_TO_CHASE").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("TILES_TO_CHASE").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChasePatrol - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = ChaseCoward.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor().getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] ChaseCoward's constructor is defined wrongly"); + } + + //Max public methods: 6 methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count()); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChasePatrolTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChasePatrolTest.java new file mode 100644 index 0000000..0c3705e --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/ghosts/chase/ChasePatrolTest.java @@ -0,0 +1,96 @@ +package edu.uoc.pacman.model.entities.characters.ghosts.chase; + +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class ChasePatrolTest { + + @Test + @Tag("sanity") + @DisplayName("Sanity ChasePatrol - Class definition") + void checkClassSanity() { + final Class ownClass = ChasePatrol.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertFalse(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.ghosts.chase",ownClass.getPackageName()); + assertTrue(ChaseBehaviour.class.isAssignableFrom(ownClass)); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChasePatrol - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = ChasePatrol.class; + + //check attribute fields + assertEquals(2, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("TILES_OFFSET").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("TILES_OFFSET").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("TILES_OFFSET").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("TILES_OFFSET").getType()); + + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("VECTOR_INCREASE").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("VECTOR_INCREASE").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("VECTOR_INCREASE").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("VECTOR_INCREASE").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity ChasePatrol - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = ChasePatrol.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor().getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] ChasePatrol's constructor is defined wrongly"); + } + + //Max public methods: 6 methods + assertEquals(1, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count()); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("getChasePosition", Ghost.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/pacman/PacmanTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/pacman/PacmanTest.java new file mode 100644 index 0000000..8d63631 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/pacman/PacmanTest.java @@ -0,0 +1,476 @@ +package edu.uoc.pacman.model.entities.characters.pacman; + +import edu.uoc.pacman.model.Level; +import edu.uoc.pacman.model.entities.characters.Character; +import edu.uoc.pacman.model.entities.characters.ghosts.Behaviour; +import edu.uoc.pacman.model.entities.characters.ghosts.Blinky; +import edu.uoc.pacman.model.entities.items.MapItem; +import edu.uoc.pacman.model.entities.items.Path; +import edu.uoc.pacman.model.exceptions.LevelException; +import edu.uoc.pacman.model.utils.Direction; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Iterator; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static org.mockito.internal.verification.VerificationModeFactory.times; + +@ExtendWith(MockitoExtension.class) +class PacmanTest { + + Pacman pacman; + + @Mock + Level level; + + @BeforeEach + void setUp() { + pacman = new Pacman(new Position(1, 1), Direction.RIGHT, State.NORMAL, level); + + } + + @Test + @Tag("basic") + void reset() { + pacman.reset(); + assertEquals(State.INVINCIBLE, pacman.getState()); + assertFalse(pacman.isDead()); + assertEquals(Direction.UP, pacman.getDirection()); + assertEquals(new Position(1, 1), pacman.getPosition()); + + } + + @Test + @Tag("basic") + void getDirection() { + assertEquals(Direction.RIGHT, pacman.getDirection()); + } + + @Test + @Tag("basic") + void setDirection() { + pacman.setDirection(Direction.UP); + assertEquals(Direction.UP, pacman.getDirection()); + assertEquals(Sprite.PACMAN_UP, pacman.getSprite()); + + pacman.setDirection(Direction.DOWN); + assertEquals(Direction.DOWN, pacman.getDirection()); + assertEquals(Sprite.PACMAN_DOWN, pacman.getSprite()); + + pacman.setDirection(Direction.LEFT); + assertEquals(Direction.LEFT, pacman.getDirection()); + assertEquals(Sprite.PACMAN_LEFT, pacman.getSprite()); + + pacman.setDirection(Direction.RIGHT); + assertEquals(Direction.RIGHT, pacman.getDirection()); + assertEquals(Sprite.PACMAN_RIGHT, pacman.getSprite()); + } + + @Test + @Tag("basic") + void isDead() { + assertFalse(pacman.isDead()); + } + + @Test + @Tag("basic") + void kill() { + pacman.kill(); + assertTrue(pacman.isDead()); + assertEquals(State.INVINCIBLE, pacman.getState()); + verify(level, times(1)).decreaseLives(); + } + + @Test + @Tag("basic") + void alive() { + pacman.alive(); + assertFalse(pacman.isDead()); + pacman.kill(); + assertTrue(pacman.isDead()); + pacman.alive(); + assertFalse(pacman.isDead()); + + } + + @Test + @Tag("basic") + void getLevel() { + assertEquals(level, pacman.getLevel()); + } + + @Test + @Tag("basic") + void setLevel() { + pacman.setLevel(null); + assertNull(pacman.getLevel()); + } + + @Test + @Tag("basic") + void testToString() { + assertEquals("1,1,RIGHT", pacman.toString()); + } + + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(1, 1), pacman.getPosition()); + } + + @Test + @Tag("basic") + void setPosition() { + pacman.setPosition(new Position(6, 9)); + assertEquals(new Position(6, 9), pacman.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(pacman.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + pacman.setPathable(false); + assertFalse(pacman.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.PACMAN_RIGHT, pacman.getSprite()); + } + + @Test + @Tag("basic") + void getState() { + assertEquals(State.NORMAL, pacman.getState()); + } + + @Test + @Tag("basic") + void setState() { + pacman.setState(State.EATER); + assertEquals(State.EATER, pacman.getState()); + + pacman.setState(State.INVINCIBLE); + assertEquals(State.INVINCIBLE, pacman.getState()); + + pacman.setState(State.NORMAL); + assertEquals(State.NORMAL, pacman.getState()); + } + + @Test + @Tag("expert") + void moveToDot() { + try { + Level level = new Level("levels/level1.txt", 3); + MapItem dot = level.getMapItem(2,1); + Pacman pacman = spy(level.getPacman()); + pacman.move(); + assertEquals(new Position(2, 1), pacman.getPosition()); + verify(pacman, times(1)).hit(); + assertEquals(1, level.getScore()); + + Iterator itr = level.getMapItemListIterator(); + + boolean path = false; + while(itr.hasNext()){ + MapItem item = itr.next(); + if(item.equals(dot)) fail("The dot has not been removed"); + if(item instanceof Path && item.getPosition().equals(new Position(2,1))){ + path = true; + } + } + + assertTrue(path, "You have not replaced dot by path"); + + + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + @Test + @Tag("expert") + void moveToEnergizer() { + try { + Level level = new Level("levels/level1.txt", 3); + MapItem energizer = level.getMapItem(1,4); + Pacman pacman = spy(level.getPacman()); + pacman.setPosition(new Position(2,4)); + pacman.setDirection(Direction.LEFT); + pacman.move(); + assertEquals(new Position(1, 4), pacman.getPosition()); + verify(pacman, times(1)).hit(); + assertEquals(5, level.getScore()); + + assertEquals(State.EATER, pacman.getState()); + //All ghosts are frightened + assertTrue(level.getGhostList().stream().allMatch(g -> g.getBehaviour() == Behaviour.FRIGHTENED)); + + Iterator itr = level.getMapItemListIterator(); + boolean path = false; + while(itr.hasNext()){ + MapItem item = itr.next(); + if(item.equals(energizer)) fail("The energizer has not been removed"); + if(item instanceof Path && item.getPosition().equals(new Position(1,4))){ + path = true; + } + } + + assertTrue(path, "You have not replaced energizer by path"); + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + @Test + @Tag("expert") + void moveToLife() { + try { + Level level = new Level("levels/level1.txt", 3); + + MapItem life = level.getMapItem(24,6); + Pacman pacman = spy(level.getPacman()); + pacman.setPosition(new Position(23,6)); //RIGHT + pacman.move(); + assertEquals(new Position(24, 6), pacman.getPosition()); + verify(pacman, times(1)).hit(); + assertEquals(0, level.getScore()); + assertEquals(4, level.getLives()); + + Iterator itr = level.getMapItemListIterator(); + + boolean path = false; + while(itr.hasNext()){ + MapItem item = itr.next(); + if(item.equals(life)) fail("The life has not been removed"); + if(item instanceof Path && item.getPosition().equals(new Position(24,6))){ + path = true; + } + } + + assertTrue(path, "You have not replaced life by path"); + + + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + + @Test + @Tag("expert") + @DisplayName("Ghost is CHASE, then ghost kills Pacman (NORMAL).") + void hitGhostKillsPacman1() { + try { + Level level = new Level("levels/level1.txt", 3); + level.getPacman().setPosition(new Position(6, 1)); //Blinky's position + Pacman pacman = spy(level.getPacman()); + assertTrue(pacman.hit()); + verify(pacman, times(1)).kill(); + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + @Test + @Tag("expert") + @DisplayName("Ghost is SCATTER, then ghost kills Pacman (NORMAL)") + void hitGhostKillsPacman2() { + try { + Level level = new Level("levels/level1.txt", 3); + level.getBlinky().setBehaviour(Behaviour.SCATTER); + level.getPacman().setPosition(new Position(6, 1)); //Blinky's position + Pacman pacman = spy(level.getPacman()); + assertTrue(pacman.hit()); + verify(pacman, times(1)).kill(); + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + @Test + @Tag("expert") + @DisplayName("Ghost is SCATTER and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitGhostNotKillPacman1() { + try { + Level level = new Level("levels/level1.txt", 3); + level.getBlinky().setBehaviour(Behaviour.SCATTER); + level.getPacman().setState(State.INVINCIBLE); + level.getPacman().setPosition(new Position(6, 1)); //Blinky's position + Pacman pacman = spy(level.getPacman()); + assertFalse(pacman.hit()); + verify(pacman, never()).kill(); + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + @Test + @Tag("expert") + @DisplayName("Ghost is CHASE and Pacman is INVINCIBLE, then ghost does not kills Pacman") + void hitGhostNotKillPacman2() { + try { + Level level = new Level("levels/level1.txt", 3); + level.getPacman().setState(State.INVINCIBLE); + level.getPacman().setPosition(new Position(6, 1)); //Blinky's position + Pacman pacman = spy(level.getPacman()); + assertFalse(pacman.hit()); + verify(pacman, never()).kill(); + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + + @Test + @Tag("expert") + @DisplayName("Ghost is INACTIVE, then it does not kill Pacman (NORMAL) and it is not killed") + void hitGhostInactive() { + try { + Level level = new Level("levels/level1.txt", 3); + level.getBlinky().setBehaviour(Behaviour.INACTIVE); + level.getPacman().setPosition(new Position(6, 1)); //Blinky's position + Pacman pacman = spy(level.getPacman()); + Blinky blinky = spy(level.getBlinky()); + assertFalse(pacman.hit()); + verify(pacman, never()).kill(); + verify(blinky, never()).kill(); + + pacman.setState(State.EATER); + assertFalse(pacman.hit()); + verify(pacman, never()).kill(); + verify(blinky, never()).kill(); + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + @Test + @Tag("expert") + @DisplayName("Ghost is FRIGHTENED, then Pacman (by logical it is EATER) kills ghost") + void hitPacmanKillsGhost() { + try { + Level level = new Level("levels/level1.txt", 3); + level.getBlinky().setBehaviour(Behaviour.FRIGHTENED); + level.getPacman().setPosition(new Position(6, 1)); //Blinky's position + Pacman pacman = spy(level.getPacman()); + Blinky blinky = level.getBlinky(); + pacman.hit(); + verify(pacman, never()).kill(); + assertEquals(400, level.getScore()); + assertTrue(blinky.isDead()); + assertEquals(Behaviour.INACTIVE, blinky.getBehaviour()); + } catch (LevelException e) { + throw new RuntimeException(e); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Pacman - Class definition") + void checkClassSanity() { + final Class ownClass = Pacman.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.pacman", ownClass.getPackageName()); + assertTrue(Character.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Pacman - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Pacman.class; + + //check attribute fields + assertEquals(1, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("state").getModifiers())); + assertFalse(Modifier.isStatic(ownClass.getDeclaredField("state").getModifiers())); + assertFalse(Modifier.isFinal(ownClass.getDeclaredField("state").getModifiers())); + assertEquals(State.class, ownClass.getDeclaredField("state").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Pacman - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Pacman.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, Direction.class, + State.class, Level.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Pacman's constructor is defined wrongly"); + } + + //Max public methods: 7 methods + assertEquals(7, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 2 methods + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count() >= 2); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getState").getModifiers())); + assertEquals(State.class, ownClass.getDeclaredMethod("getState").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setState", State.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setState", State.class).getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("nextState").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("nextState").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("reset").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("reset").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("move").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("move").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setDirection", Direction.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setDirection", Direction.class).getReturnType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredMethod("eat").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("eat").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("hit").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("hit").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("kill").getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("kill").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/characters/pacman/StateTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/characters/pacman/StateTest.java new file mode 100644 index 0000000..ff56272 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/characters/pacman/StateTest.java @@ -0,0 +1,101 @@ +package edu.uoc.pacman.model.entities.characters.pacman; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class StateTest { + + @Test + @Tag("basic") + void getDuration() { + assertEquals(Integer.MAX_VALUE,State.NORMAL.getDuration()); + assertEquals(30,State.EATER.getDuration()); + assertEquals(5,State.INVINCIBLE.getDuration()); + } + + @Test + @Tag("basic") + void testToString() { + assertEquals("NORMAL:"+Integer.MAX_VALUE,State.NORMAL.toString()); + assertEquals("EATER:30",State.EATER.toString()); + assertEquals("INVINCIBLE:5",State.INVINCIBLE.toString()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity State - Enum definition") + void checkEnumSanity() { + final Class ownClass = State.class; + + assertTrue(ownClass.isEnum()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertTrue(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.characters.pacman",ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity State - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = State.class; + + //check attribute fields: 1 attributes + 3 values + $VALUES + assertEquals(5, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("duration").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("duration").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity State - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = State.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor: the first parameter is the value itself and the second one is the ordinal. + int constructorModifiers = ownClass.getDeclaredConstructor(String.class, int.class, int.class).getModifiers(); + assertTrue(Modifier.isPrivate(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] State's constructor is defined wrongly"); + } + + //Max public methods: 2 methods + values() + valueOf() + assertEquals(4, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: $values() + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 1); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getDuration").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getDuration").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("toString").getModifiers())); + assertEquals(String.class, ownClass.getDeclaredMethod("toString").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/items/DotTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/items/DotTest.java new file mode 100644 index 0000000..729c835 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/items/DotTest.java @@ -0,0 +1,167 @@ +package edu.uoc.pacman.model.entities.items; + +import edu.uoc.pacman.model.entities.Scorable; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class DotTest { + + Dot dot; + + @BeforeEach + private void setUp() { + dot = new Dot(new Position(-4, 6)); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(-4, 6), dot.getPosition()); + } + + + @Test + @Tag("basic") + void setPosition() { + dot.setPosition(new Position(-10, 50)); + assertEquals(new Position(-10, 50), dot.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(dot.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + dot.setPathable(false); + assertFalse(dot.isPathable()); + + dot.setPathable(true); + assertTrue(dot.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.DOT, dot.getSprite()); + } + + + + @Test + @Tag("basic") + void isPicked() { + assertFalse(dot.isPicked()); + } + + @Test + @Tag("basic") + void setPicked() { + dot.setPicked(true); + assertTrue(dot.isPicked()); + + dot.setPicked(false); + assertFalse(dot.isPicked()); + } + + @Test + @Tag("basic") + void getPoints() { + assertEquals(1, dot.getPoints()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Dot - Class definition") + void checkClassSanity() { + final Class ownClass = Dot.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.items", ownClass.getPackageName()); + assertTrue(MapItem.class.isAssignableFrom(ownClass)); + assertTrue(Pickable.class.isAssignableFrom(ownClass)); + assertTrue(Scorable.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Dot - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Dot.class; + + //check attribute fields + assertEquals(2, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("picked").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredField("picked").getType()); + + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("POINTS").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("POINTS").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Dot - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Dot.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Dot's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(3, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("isPicked").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("isPicked").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setPicked", boolean.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setPicked", boolean.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPoints").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getPoints").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/items/EnergizerTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/items/EnergizerTest.java new file mode 100644 index 0000000..0be5c96 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/items/EnergizerTest.java @@ -0,0 +1,168 @@ +package edu.uoc.pacman.model.entities.items; + +import edu.uoc.pacman.model.entities.Scorable; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class EnergizerTest { + + + Energizer energizer; + + @BeforeEach + private void setUp() { + energizer = new Energizer(new Position(2, 16)); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(2, 16), energizer.getPosition()); + } + + + @Test + @Tag("basic") + void setPosition() { + energizer.setPosition(new Position(100, 50)); + assertEquals(new Position(100, 50), energizer.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(energizer.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + energizer.setPathable(false); + assertFalse(energizer.isPathable()); + + energizer.setPathable(true); + assertTrue(energizer.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.ENERGIZER, energizer.getSprite()); + } + + + + @Test + @Tag("basic") + void isPicked() { + assertFalse(energizer.isPicked()); + } + + @Test + @Tag("basic") + void setPicked() { + energizer.setPicked(true); + assertTrue(energizer.isPicked()); + + energizer.setPicked(false); + assertFalse(energizer.isPicked()); + } + + @Test + @Tag("basic") + void getPoints() { + assertEquals(5, energizer.getPoints()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Energizer - Class definition") + void checkClassSanity() { + final Class ownClass = Energizer.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.items", ownClass.getPackageName()); + assertTrue(MapItem.class.isAssignableFrom(ownClass)); + assertTrue(Pickable.class.isAssignableFrom(ownClass)); + assertTrue(Scorable.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Energizer - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Energizer.class; + + //check attribute fields + assertEquals(2, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("picked").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredField("picked").getType()); + + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredField("POINTS").getModifiers())); + assertTrue(Modifier.isFinal(ownClass.getDeclaredField("POINTS").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("POINTS").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Energizer - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Energizer.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Dot's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(3, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("isPicked").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("isPicked").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setPicked", boolean.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setPicked", boolean.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getPoints").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getPoints").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/items/LifeTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/items/LifeTest.java new file mode 100644 index 0000000..66a6a32 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/items/LifeTest.java @@ -0,0 +1,149 @@ +package edu.uoc.pacman.model.entities.items; + +import edu.uoc.pacman.model.entities.Scorable; +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.*; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class LifeTest { + + Life life; + + @BeforeEach + private void setUp() { + life = new Life(new Position(14, -23)); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(14, -23), life.getPosition()); + } + + @Test + @Tag("basic") + void setPosition() { + life.setPosition(new Position(-10, 20)); + assertEquals(new Position(-10, 20), life.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(life.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + life.setPathable(false); + assertFalse(life.isPathable()); + + life.setPathable(true); + assertTrue(life.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.LIFE, life.getSprite()); + } + + + @Test + @Tag("basic") + void isPicked() { + assertFalse(life.isPicked()); + } + + @Test + @Tag("basic") + void setPicked() { + life.setPicked(true); + assertTrue(life.isPicked()); + + life.setPicked(false); + assertFalse(life.isPicked()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Life - Class definition") + void checkClassSanity() { + final Class ownClass = Life.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.items", ownClass.getPackageName()); + assertTrue(MapItem.class.isAssignableFrom(ownClass)); + assertTrue(Pickable.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Life - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Life.class; + + //check attribute fields + assertEquals(1, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("picked").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredField("picked").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Life - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Life.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Life's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(2, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("isPicked").getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("isPicked").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setPicked", boolean.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setPicked", boolean.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/items/MapItemTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/items/MapItemTest.java new file mode 100644 index 0000000..2c047c5 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/items/MapItemTest.java @@ -0,0 +1,75 @@ +package edu.uoc.pacman.model.entities.items; + +import edu.uoc.pacman.model.entities.Entity; +import edu.uoc.pacman.model.entities.characters.ghosts.Ghost; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class MapItemTest { + + @Test + @Tag("sanity") + @DisplayName("Sanity MapItem - Class definition") + void checkClassSanity() { + final Class ownClass = MapItem.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + assertTrue(Modifier.isAbstract(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.items",ownClass.getPackageName()); + assertTrue(Entity.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity MapItem - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = MapItem.class; + + //check attribute fields + assertEquals(0, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity MapItem - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = MapItem.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class, boolean.class, Sprite.class).getModifiers(); + assertTrue(Modifier.isProtected(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] MapItem's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + } + +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/items/PathTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/items/PathTest.java new file mode 100644 index 0000000..7e3c9e9 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/items/PathTest.java @@ -0,0 +1,113 @@ +package edu.uoc.pacman.model.entities.items; + +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class PathTest { + Path path; + + @BeforeEach + private void setUp(){ + path = new Path(new Position(4,3)); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(4,3), path.getPosition()); + } + + @Test + @Tag("basic") + void setPosition() { + path.setPosition(new Position(-10,-20)); + assertEquals(new Position(-10,-20), path.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertTrue(path.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + path.setPathable(false); + assertFalse(path.isPathable()); + + path.setPathable(true); + assertTrue(path.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.PATH, path.getSprite()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Path - Class definition") + void checkClassSanity() { + final Class ownClass = Path.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.items",ownClass.getPackageName()); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Path - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Path.class; + + //check attribute fields + assertEquals(0, ownClass.getDeclaredFields().length); + assertTrue(MapItem.class.isAssignableFrom(ownClass)); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Path - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Path.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Path's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/items/PickableTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/items/PickableTest.java new file mode 100644 index 0000000..77cab5f --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/items/PickableTest.java @@ -0,0 +1,57 @@ +package edu.uoc.pacman.model.entities.items; + +import edu.uoc.pacman.model.utils.Direction; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class PickableTest { + + private final Class ownClass = Pickable.class; + + @Test + @Tag("sanity") + @DisplayName("Sanity Pickable - Interface definition") + void checkInterfaceSanity() { + assertTrue(ownClass.isInterface()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.items", ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Pickable - Fields definition") + public void checkFieldsSanity() { + + //check attribute fields: 0 attributes + assertEquals(0, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Pickable - Methods definition") + public void checkMethodsSanity() { + //Number of methods + assertEquals(2, ownClass.getDeclaredMethods().length); + + //Max public methods: + assertEquals(2, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + + try { + assertEquals(boolean.class, ownClass.getDeclaredMethod("isPicked").getReturnType()); + assertEquals(void.class, ownClass.getDeclaredMethod("setPicked", boolean.class).getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/entities/items/WallTest.java b/core/src/test/java/edu/uoc/pacman/model/entities/items/WallTest.java new file mode 100644 index 0000000..924233e --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/entities/items/WallTest.java @@ -0,0 +1,115 @@ +package edu.uoc.pacman.model.entities.items; + +import edu.uoc.pacman.model.entities.Entity; +import edu.uoc.pacman.model.utils.Position; +import edu.uoc.pacman.model.utils.Sprite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class WallTest { + + Wall wall; + + @BeforeEach + private void setUp(){ + wall = new Wall(new Position(3,4)); + } + + @Test + @Tag("basic") + void getPosition() { + assertEquals(new Position(3,4), wall.getPosition()); + } + + @Test + @Tag("basic") + void setPosition() { + wall.setPosition(new Position(-1,20)); + assertEquals(new Position(-1,20), wall.getPosition()); + } + + @Test + @Tag("basic") + void isPathable() { + assertEquals(false, wall.isPathable()); + } + + @Test + @Tag("basic") + void setPathable() { + wall.setPathable(true); + assertEquals(true, wall.isPathable()); + + wall.setPathable(false); + assertEquals(false, wall.isPathable()); + } + + @Test + @Tag("basic") + void getSprite() { + assertEquals(Sprite.WALL, wall.getSprite()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Wall - Class definition") + void checkClassSanity() { + final Class ownClass = Wall.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.entities.items",ownClass.getPackageName()); + assertTrue(MapItem.class.isAssignableFrom(ownClass)); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Wall - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Wall.class; + + //check attribute fields + assertEquals(0, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Wall - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Wall.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(Position.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Wall's constructor is defined wrongly"); + } + + //Max public methods: 0 methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/exceptions/LevelExceptionTest.java b/core/src/test/java/edu/uoc/pacman/model/exceptions/LevelExceptionTest.java new file mode 100644 index 0000000..1a12fda --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/exceptions/LevelExceptionTest.java @@ -0,0 +1,71 @@ +package edu.uoc.pacman.model.exceptions; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class LevelExceptionTest { + + private final Class ownClass = LevelException.class; + + @Test + @Tag("sanity") + @DisplayName("Sanity LevelException - Class definition") + void checkClassSanity() { + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.exceptions",ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity LevelException - Fields definition") + void checkFieldsSanity() { + //All fields must meet these requirements + assertTrue(Arrays.stream(ownClass.getDeclaredFields()).allMatch(p -> { + return p.getType().getSimpleName().equals("String") + && Modifier.isPublic(p.getModifiers()) + && Modifier.isStatic(p.getModifiers()) + && Modifier.isFinal(p.getModifiers()); + })); + + //Max 4 fields + assertEquals(4, ownClass.getDeclaredFields().length); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity LevelException - Methods and Constructor definition") + void checkMethodsSanity() { + //Max 0 public methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max 0 protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max 0 package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + + //Max 1 constructor + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(String.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + + } catch (NoSuchMethodException e) { + fail("LevelException's constructor is defined wrongly"); + } + } + +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/utils/DirectionTest.java b/core/src/test/java/edu/uoc/pacman/model/utils/DirectionTest.java new file mode 100644 index 0000000..6d47a5a --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/utils/DirectionTest.java @@ -0,0 +1,142 @@ +package edu.uoc.pacman.model.utils; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class DirectionTest { + + @Test + @Tag("basic") + void getX() { + assertEquals(0,Direction.UP.getX()); + assertEquals(0,Direction.DOWN.getX()); + assertEquals(1,Direction.RIGHT.getX()); + assertEquals(-1,Direction.LEFT.getX()); + } + + @Test + @Tag("basic") + void getY() { + assertEquals(-1,Direction.UP.getY()); + assertEquals(1,Direction.DOWN.getY()); + assertEquals(0,Direction.RIGHT.getY()); + assertEquals(0,Direction.LEFT.getY()); + } + + @Test + @Tag("basic") + void getKeyCode() { + assertEquals(19,Direction.UP.getKeyCode()); + assertEquals(20,Direction.DOWN.getKeyCode()); + assertEquals(22,Direction.RIGHT.getKeyCode()); + assertEquals(21,Direction.LEFT.getKeyCode()); + } + + @Test + @Tag("basic") + void getDirectionByKeyCode() { + assertEquals(19,Direction.UP.getKeyCode()); + assertEquals(20,Direction.DOWN.getKeyCode()); + assertEquals(22,Direction.RIGHT.getKeyCode()); + assertEquals(21,Direction.LEFT.getKeyCode()); + } + + @Test + @Tag("basic") + void opposite() { + assertEquals(Direction.DOWN,Direction.UP.opposite()); + assertEquals(Direction.UP,Direction.DOWN.opposite()); + assertEquals(Direction.LEFT,Direction.RIGHT.opposite()); + assertEquals(Direction.RIGHT,Direction.LEFT.opposite()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Direction - Enum definition") + void checkEnumSanity() { + final Class ownClass = Direction.class; + + assertTrue(ownClass.isEnum()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertTrue(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.utils",ownClass.getPackageName()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Direction - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Direction.class; + + //check attribute fields: 3 attributes + 4 values + $VALUES + assertEquals(8, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("x").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("x").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("y").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("y").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("keyCode").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("keyCode").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Direction - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Direction.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor: the first parameter is the value itself and the second one is the ordinal. + int constructorModifiers = ownClass.getDeclaredConstructor(String.class, int.class, int.class, int.class, int.class).getModifiers(); + assertTrue(Modifier.isPrivate(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Direction's constructor is defined wrongly"); + } + + //Max public methods: 5 methods + values() + valueOf() + assertEquals(7, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: $values() + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 1); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getX").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getX").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getY").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getY").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getKeyCode").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getKeyCode").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getDirectionByKeyCode", int.class).getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredMethod("getDirectionByKeyCode", int.class).getModifiers())); + assertEquals(Direction.class, ownClass.getDeclaredMethod("getDirectionByKeyCode", int.class).getReturnType()); + assertEquals(int.class, ownClass.getDeclaredMethod("getKeyCode").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("opposite").getModifiers())); + assertEquals(Direction.class, ownClass.getDeclaredMethod("opposite").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/utils/PositionTest.java b/core/src/test/java/edu/uoc/pacman/model/utils/PositionTest.java new file mode 100644 index 0000000..e482191 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/utils/PositionTest.java @@ -0,0 +1,211 @@ +package edu.uoc.pacman.model.utils; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class PositionTest { + + Position position; + + @BeforeEach + @DisplayName("Set up of PositionTest") + private void setUp() { + position = new Position(0, 0); + } + + @Test + @Tag("basic") + void getX() { + assertEquals(0, position.getX()); + } + + @Test + @Tag("basic") + void setX() { + position.setX(5); + assertEquals(5, position.getX()); + + position.setX(-53); + assertEquals(-53, position.getX()); + + position.setX(0); + assertEquals(0, position.getX()); + } + + @Test + @Tag("basic") + void getY() { + assertEquals(0, position.getY()); + } + + @Test + @Tag("basic") + void setY() { + position.setY(8); + assertEquals(8, position.getY()); + + position.setY(-18); + assertEquals(-18, position.getY()); + + position.setY(0); + assertEquals(0, position.getY()); + } + + @Test + @Tag("basic") + void distance() { + assertEquals(Math.sqrt(34),position.distance(new Position(5,3))); + assertEquals(Math.sqrt(37),(new Position(-1,-4)).distance(new Position(0,2))); + assertEquals(Math.sqrt(13),(new Position(3,5)).distance(new Position(1,2))); + assertEquals(Math.sqrt(2),(new Position(3,2)).distance(new Position(4,1))); + assertEquals(Math.sqrt(40),(new Position(0,4)).distance(new Position(6,2))); + } + + @Test + @Tag("basic") + void add() { + assertEquals(new Position(2,3), Position.add(position, new Position(2,3))); + assertEquals(new Position(5,6), Position.add(new Position(3,3), new Position(2,3))); + assertEquals(new Position(-5,6), Position.add(new Position(-5,6), position)); + assertEquals(new Position(-5,6), Position.add(new Position(10,36), new Position(-15, -30))); + assertEquals(new Position(15,-3), Position.add(new Position(-10,7), new Position(25, -10))); + } + + @Test + @Tag("basic") + @DisplayName("Test of equals when returning true") + void testEqualsTrue() { + assertTrue(position.equals(position)); + + Position p1 = new Position(0,0); + assertTrue(position.equals(p1)); + } + + @Test + @Tag("basic") + @DisplayName("Test of equals when returning false") + void testEqualsFalse() { + Position p1 = new Position(0,1); + assertFalse(position.equals(p1)); + + p1 = new Position(1,0); + assertFalse(position.equals(p1)); + + p1 = new Position(1,-10); + assertFalse(position.equals(p1)); + } + + @Test + @Tag("basic") + @DisplayName("Test of hashCode when returning true") + void testHashCodeTrue() { + Position p1 = new Position(0,0); + assertEquals(position.hashCode(), p1.hashCode()); + } + + @Test + @Tag("basic") + @DisplayName("Test of hashCode when returning false") + void testHashCodeFalse() { + Position p1 = new Position(0,1); + assertNotEquals(position.hashCode(), p1.hashCode()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Position - Class definition") + void checkClassSanity() { + final Class ownClass = Position.class; + + //Class declaration + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertFalse(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.utils",ownClass.getPackageName()); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Position - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Position.class; + + //check attribute fields + assertEquals(2, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("x").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("x").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("y").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredField("y").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Position - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Position.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + try { + //Constructor + int constructorModifiers = ownClass.getDeclaredConstructor(int.class, int.class).getModifiers(); + assertTrue(Modifier.isPublic(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Position's constructor is defined wrongly"); + } + + //Max public methods: 9 methods + assertEquals(9, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: 0 + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 0); + + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getX").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getX").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setX", int.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setX", int.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getY").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("getY").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("setY", int.class).getModifiers())); + assertEquals(void.class, ownClass.getDeclaredMethod("setY", int.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("distance", Position.class).getModifiers())); + assertEquals(double.class, ownClass.getDeclaredMethod("distance", Position.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("add", Position.class, Position.class).getModifiers())); + assertTrue(Modifier.isStatic(ownClass.getDeclaredMethod("add", Position.class, Position.class).getModifiers())); + assertEquals(Position.class, ownClass.getDeclaredMethod("add", Position.class, Position.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("equals", Object.class).getModifiers())); + assertEquals(boolean.class, ownClass.getDeclaredMethod("equals", Object.class).getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("hashCode").getModifiers())); + assertEquals(int.class, ownClass.getDeclaredMethod("hashCode").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("toString").getModifiers())); + assertEquals(String.class, ownClass.getDeclaredMethod("toString").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/edu/uoc/pacman/model/utils/SpriteTest.java b/core/src/test/java/edu/uoc/pacman/model/utils/SpriteTest.java new file mode 100644 index 0000000..5848828 --- /dev/null +++ b/core/src/test/java/edu/uoc/pacman/model/utils/SpriteTest.java @@ -0,0 +1,126 @@ +package edu.uoc.pacman.model.utils; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Modifier; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class SpriteTest { + + @Test + @Tag("basic") + void getSymbol() { + assertEquals('B', Sprite.BLINKY.getSymbol()); + assertEquals('P', Sprite.PINKY.getSymbol()); + assertEquals('I', Sprite.INKY.getSymbol()); + assertEquals('C', Sprite.CLYDE.getSymbol()); + assertEquals('.', Sprite.DOT.getSymbol()); + assertEquals('0', Sprite.ENERGIZER.getSymbol()); + assertEquals('#', Sprite.WALL.getSymbol()); + assertEquals(' ', Sprite.PATH.getSymbol()); + assertEquals('L', Sprite.LIFE.getSymbol()); + assertEquals('V', Sprite.PACMAN_DOWN.getSymbol()); + assertEquals('^', Sprite.PACMAN_UP.getSymbol()); + assertEquals('<', Sprite.PACMAN_RIGHT.getSymbol()); + assertEquals('>', Sprite.PACMAN_LEFT.getSymbol()); + } + + @Test + @Tag("basic") + void getImageSrc() { + assertEquals("images/blinky.png", Sprite.BLINKY.getImageSrc()); + assertEquals("images/pinky.png", Sprite.PINKY.getImageSrc()); + assertEquals("images/inky.png", Sprite.INKY.getImageSrc()); + assertEquals("images/clyde.png", Sprite.CLYDE.getImageSrc()); + assertEquals("images/dot.png", Sprite.DOT.getImageSrc()); + assertEquals("images/energizer.png", Sprite.ENERGIZER.getImageSrc()); + assertEquals("images/wall.png", Sprite.WALL.getImageSrc()); + assertEquals("images/path.png", Sprite.PATH.getImageSrc()); + assertEquals("images/life.png", Sprite.LIFE.getImageSrc()); + assertEquals("images/pac_down.png", Sprite.PACMAN_DOWN.getImageSrc()); + assertEquals("images/pac_up.png", Sprite.PACMAN_UP.getImageSrc()); + assertEquals("images/pac_right.png", Sprite.PACMAN_RIGHT.getImageSrc()); + assertEquals("images/pac_left.png", Sprite.PACMAN_LEFT.getImageSrc()); + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Sprite - Enum definition") + void checkEnumSanity() { + final Class ownClass = Sprite.class; + + assertTrue(ownClass.isEnum()); + int modifiers = ownClass.getModifiers(); + assertTrue(Modifier.isPublic(modifiers)); + assertFalse(Modifier.isStatic(modifiers)); + assertTrue(Modifier.isFinal(modifiers)); + + assertEquals("edu.uoc.pacman.model.utils", ownClass.getPackageName()); + } + + + @Test + @Tag("sanity") + @DisplayName("Sanity Sprite - Fields definition") + public void checkFieldsSanity() { + final Class ownClass = Sprite.class; + + //check attribute fields: 2 attributes + 13 values + $VALUES + assertEquals(16, ownClass.getDeclaredFields().length); + + try { + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("symbol").getModifiers())); + assertEquals(char.class, ownClass.getDeclaredField("symbol").getType()); + assertTrue(Modifier.isPrivate(ownClass.getDeclaredField("imageSrc").getModifiers())); + assertEquals(String.class, ownClass.getDeclaredField("imageSrc").getType()); + } catch (NoSuchFieldException e) { + fail("[ERROR] There is some problem with the definition of the attributes"); + e.printStackTrace(); + } + } + + @Test + @Tag("sanity") + @DisplayName("Sanity Sprite - Methods definition") + public void checkMethodsSanity() { + final Class ownClass = Sprite.class; + + //check constructors + assertEquals(1, ownClass.getDeclaredConstructors().length); + + Arrays.stream(ownClass.getDeclaredConstructors()).forEach(i -> System.out.println(i)); + + try { + //Constructor: the first parameter is the value itself and the second one is the ordinal. + int constructorModifiers = ownClass.getDeclaredConstructor(String.class, int.class, char.class, String.class).getModifiers(); + assertTrue(Modifier.isPrivate(constructorModifiers)); + assertFalse(Modifier.isStatic(constructorModifiers)); + assertFalse(Modifier.isFinal(constructorModifiers)); + } catch (NoSuchMethodException e) { + fail("[ERROR] Sprite's constructor is defined wrongly"); + } + + //Max public methods: 2 methods + values() + valueOf() + assertEquals(4, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPublic(p.getModifiers())).count()); + //Max protected methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isProtected(p.getModifiers())).count()); + //Max package-private methods + assertEquals(0, Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isNative(p.getModifiers())).count()); + //Min private methods: $values() + assertTrue(Arrays.stream(ownClass.getDeclaredMethods()).filter(p -> Modifier.isPrivate(p.getModifiers())).count() >= 1); + + try { + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getSymbol").getModifiers())); + assertEquals(char.class, ownClass.getDeclaredMethod("getSymbol").getReturnType()); + assertTrue(Modifier.isPublic(ownClass.getDeclaredMethod("getImageSrc").getModifiers())); + assertEquals(String.class, ownClass.getDeclaredMethod("getImageSrc").getReturnType()); + } catch (NoSuchMethodException e) { + fail("[ERROR] There is some problem with the definition of methods"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/core/src/test/resources/levels/level1.txt b/core/src/test/resources/levels/level1.txt new file mode 100644 index 0000000..0bd70ad --- /dev/null +++ b/core/src/test/resources/levels/level1.txt @@ -0,0 +1,20 @@ +;width +26 +;height +8 +;board +########################## +# .......................# +#..#...#..######..#####..# +#..#...#..# #..#..o...# +#o.#...#.o# #..#......# +#..#####..######..#####..# +#.......................L# +########################## +;pacman +1,1,RIGHT,NORMAL +;ghosts +blinky,6,1,LEFT,CHASE +inky,1,5,UP,CHASE +pinky,1,6,DOWN,CHASE +clyde,2,6,RIGHT,SCATTER \ No newline at end of file diff --git a/core/src/test/resources/levels/level2.txt b/core/src/test/resources/levels/level2.txt new file mode 100644 index 0000000..aefbd5f --- /dev/null +++ b/core/src/test/resources/levels/level2.txt @@ -0,0 +1,17 @@ +;width +8 +;height +8 +;board +######## +# . L# +# # +# # +# # +# # +# # +######## +;pacman +1,1,RIGHT,NORMAL +;ghosts +clyde,2,2,LEFT,SCATTER \ No newline at end of file diff --git a/desktop/build.gradle b/desktop/build.gradle new file mode 100644 index 0000000..017d33f --- /dev/null +++ b/desktop/build.gradle @@ -0,0 +1,47 @@ +sourceCompatibility = 17 +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "edu.uoc.pacman.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + main = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + main = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/desktop/src/edu/uoc/pacman/DesktopLauncher.java b/desktop/src/edu/uoc/pacman/DesktopLauncher.java new file mode 100644 index 0000000..5ac4166 --- /dev/null +++ b/desktop/src/edu/uoc/pacman/DesktopLauncher.java @@ -0,0 +1,18 @@ +package edu.uoc.pacman; + +import com.badlogic.gdx.Graphics; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import edu.uoc.pacman.view.PacmanGame; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + config.setForegroundFPS(60); + config.setTitle("PACMAN Game"); + config.setResizable(false); + config.setWindowedMode(PacmanGame.WINDOW_WIDTH, PacmanGame.WINDOW_HEIGHT);; + new Lwjgl3Application(new PacmanGame(), config); + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..a69d9cb --- /dev/null +++ b/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..74fc652 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include 'desktop', 'core' \ No newline at end of file