Skip to content

A simplified version of the game final-fantasy applying OOP concepts and design patterns.

License

Notifications You must be signed in to change notification settings

lukasvaz/CC3002-final-reality-java

Repository files navigation

Final Reality

http://creativecommons.org/licenses/by/4.0/

This work is licensed under a Creative Commons Attribution 4.0 International License

Context

This project's goal is to create a (simplified) clone of Final Fantasy's combat, a game developed by Square Enix Broadly speaking for the combat the player has a group of characters to control and a group of enemies controlled by the computer.


Run Instructions

This project has two testing files:TimerExample.java and Main.java.TimerExample will test the functionality of the turn system, crating an instance of each class and printing them in the right order.Main.java will test the functionality of every method of each class (i.e. getters ,setters,to string etc).Run both files for testing.


Changes

Some features have been modified to guarante a proper design of the software.Here is a quick summary of the main changes:

T1

  1. A new Abstract Class called AbstractMage class was added to implement the behaviours of WhiteMages and BlackMages. Now the proyect is open to get new features of Mages.The proyect also got the interface PlayerMage (extending of Playercharacter ) wich guarantees that methods related to Mages must be implemented in the AbstractMage class.

  2. waitTurn() was impemented for each Enemy and AbstractPlayerCharacter classes.The purpouse of this is follow the encapsulation principle where each class handles its funcionalities acording to their weights or Weapon´s weights.

  3. A new class TurnsQueue was added following the "single responsability" principle , this class will handle the functionalities related to the turns.

  4. Enemy got the method toString, now it can be compared consistently with the other classes

T2

  1. A new weapon interface was added,which is implemented by each weapon classes.
  2. Tests were implemented.It was added a unit test for each player class and weapon class.
  3. New exceptions were added. NullWeaponException to guarantee the assignment of a weapon to a character before it get push to the queue.And also InvalidWeaponAssignentException which throws an error if the assignment doesn't follow the weapon´s assignment conditions.
  4. Weapon assignment restrictions were implemented.To do this the Weapon interface got the method equipedby() and PlayerCharacter interface got the methods equipSword(),equipAxe() ,equipKnife(), equipStaff() and equipBow().
    Following the double dispatch design pattern,the method equip() in AbstractPlayerCharacter calls the method equipedby() in Weapon (first dispatch) in order to disambiguate the weapon.Then the method equippedby() calls the respective method to equip the weapon in the differents characters classes (double dispatch).

T3

  1. A new set of factories were implemented in order to instanciate characters and unified their stats
  2. It as implemented 2 methods to get attack's points , getAttack which returns the Dmg of weapon assigned to the character and getMagicAttack which return the magicDmg of the weapon (just for Staff cases) or the Dmgs points of the weapon ( in this case returns Dmg/2), if the character corresponds an Enemy getAttack() and getMagicAttack() returns Dmg
  3. In order to implement the Effects associated to Magic attacks. Enemies were given of notifyEffects() method which send a meessage to every Effect Class.
  4. Every time a character gets damaged the character notifies (notifyDmg()) the controller, to check if its dead. If the character currentHp is equal to zero, the controller extracts the chracter from the queue and Arrays.
  5. Every step of the game was implemented following the State Design Pattern.When the game is setted up the user have to choose characters and their inventary(selectCharacters), then Enemies are created (createEnemy).Both of this States in this Primitive version of the Game were given of defaults behaviours.Then a Character is pull from the queue at the begining of the turn (init Turn).When a character is selected states goes to EnemyTurn (if it's an Enemy) or selectEnemy(if it's not an Enemy , i this state the Palyer should select an Enemy target to Attack).In enemyTurn the Active Enemy updates its effects select a random character from the Characters array and attack it.If there are not any remain character goes to End state.In other way,inside the selectEnemy State (character playing) the character is free to move using inputs to selectWeapon (equips a Weapon) select Magic (select a Megic to Use) or back to select an Enemy target.The purpose of this design is to simulate a Graphic Interface, where buttons are pressed in Asynchronus way.If the character wants to attack or use Magic, the user have to input "MagicAttack" or "Attack" from every state ( error handling takes care of the anomalous behaviours).To make the decissions according the user inputs, it was implemented a Input ListenerClass ( acts as an observer) which updates the Game State.
  6. To simulate inputs from the command line it was implemented a PlayerClass which can behave as a Scripted player.

About

A simplified version of the game final-fantasy applying OOP concepts and design patterns.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages