Development
Each player plays when it is its turn.
Here is the UML diagram of the program:
This part contains a brief description of all project classes.
This class contains the main functions:
- main : main function that calls all the following functions.
- playerCreation : function that create the 2 players.
- part_1 : function that runs game part 1.
- part_2 : function that runs game part 2.
This class contains all useful functions to save the game story in a file. We chose to put them in a class in order not to overload the Main class.
We created a Player class that keeps all information about each player. That is to say that a player contains a spacecraft and its animal. It is from this class that we can access all information at any time and everywhere in our code.
We created 1 class for each part of the game. It is from these 2 classes that each part is run. They both implements the executionInterface interface.
This interface has only one function: run(). We decided to create this interface in order to create a name convention for the function which runs each part of the game. By doing this, the Main class won’t change, it will always call the run() function of each class even if each class change.
It is composed by 2 CubeEnvironments created thanks to the 2 Players. It has 3 main functions :
- run() : main function from the interface, it runs all game part 1.
- loop() : it runs the main loop while no spacecraft has been found, each player select a location en try to guess spacecraft postition.
- selectLocation(): it return the position selected by a player.
It is composed by 2 Animals created thanks to the 2 Players and a list of special actions. It has 4 main functions :
- run() : main function from the interface, it runs all game part 2.
- loop() : it runs the main loop while no dead animal has been found, each player select an action to do.
- selectAttack(): it allows a player to select an action for its animal to do.
- solveRound(): this function manage special actions.
We thought the space environment in a particular way. Indeed, we assimilate it to 2 cubes, 1 for each player. That’s why the Space class is composed of 2 CubeEnvironment. Each cube is composed of a spacecraft and 3 meteorites. They can be located to 8 different positions that correspond to each corner of the cube.
During the 1st part of the game, each player try to find the location of the other one’s spacecraft. Of course he has to avoid meteorites that decrease the life. Once one player find the other one, part 2 of the game is started.
It is an abstract class. It was created in order to manage position of both meteorites en spacecrafts. That’s why Meteorite class and Spacecraft class both extends UFO abstract class.
To manage location, an UFO has an attribute location. We also created function which make us be able to manage location. Constructor was overloaded in order to create a UFO default position (000) or take the position in parameter.
This enumeration enumerates all available positions in a cube. These positions match each corner of the cube. They are coordinates.
There are 3 meteorites in each cube. A Meteorite has size which can be one from the MeteoriteSize enumeration. The size impact the amount of life to withdraw to an animal if a player collides a meteorite.
This enumeration enumerates all existing meteorite size.
There is one spacecraft in each cube. Spacecraft class has a color and an Animal. The spacecraft can be damaged by a meteorite. A damaged spacecraft means its animal life decreases.
It is an abstract class.
It is an abstract class which extends animal class. It overrides attack() function to caracterize it by the way the animal attack (with paws or with wings).
It is an abstract class which extends animal class. It overrides attack() function to caracterize it by the way the animal attack (with paws or with wings).
Bear is an animal with paws. That’s why it extends WithPaws abstract class. It overrides attack(), specialAction() and scream() functions. Since Bear is a fierce animal, it implements BeFierce interface and overrides beFierce() function.
Chicken is an animal with paws. That’s why it extends WithWings abstract class. It overrides attack(), specialAction() and scream() functions. Since Chicken is a fierce animal, it implements BeFierce interface and overrides beFierce() function.
Duck is an animal with paws. That’s why it extends WithWings abstract class. It overrides attack(), specialAction() and scream() functions.
Pig is an animal with paws. That’s why it extends WithPaws abstract class. It overrides attack(), specialAction() and scream() functions.
Tiger is an animal with paws. That’s why it extends WithPaws abstract class. It overrides attack(), specialAction() and scream() functions. Since Tiger is a fierce animal, it implements BeFierce interface and overrides beFierce() function.
This interface was created to caracterize scream of some animals that are said to be fierce. It contains 1 function, beFierce() function.
Each animal has an offensive stuff which gives it a force bonus. Offensif class is here to do that. It has force bonus value and constants that defines existing offensive stuff.
Each animal has an defensive stuff which gives it a force bonus. Defensif class is here to do that. It has force bonus value and constants that defines existing defensive stuff.
- set Player class for each player.
- set Space class with 2 CubeEnvironment (1 for each player). Each CubeEnvironment is set with 3 meteorites and 1 spacecraft.
- set FightArea class with 2 pigs. Each pig is initialized with stuff selected by the player.