Pygame-RPG 13.3 Preparation for BattleManager class
This PR is the final preparatory PRs. This PR mostly includes the tests for all of the entity classes that have been created so far.
Unlike with the manager classes, all of the Entity classes tests are in a single python file called Entities_test.py. This is because the entities in the Entity package are meant to interact with each other and so it would be difficult to test one without creating another entity to see if their functions work in conjunction.
The Entities_test.py file is split into different sections, testing each individual type of Entity. It first uses an Enemy object (loaded from the JSON/Enemies/dummy.json file) to test the methods in the Entity class and then goes on to test the Enemy class methods and finally the Knight class methods. During testing, it was decided that Enemy Inventory attribute will also be a dictionary object. As a result, a change to Scripts.py needed to be made. Once that change was made, the enemy JSON files needed to be reloaded.
Another large part of this PR is adjusting the manager classes pytests. As a result of turning some of the dictionary information into JSON, the manager packages tests were outdated and needed to be adjusted. This consisted of making mock JSON variables for object constructors.
As a consequence of using JSON, the tuple type is converted to the array type when loading the information back (despite the fact that you can't have arrays in dictionaries in python). As such, I needed to ensure type equality for some of the automated tests. As a result, the SaveManager.py files' tuplefy() function needed some changing for use in the automated tests.
As a result of all of these changes, most files in this PR had only light changes with nothing too major changing. So far, the only thing of note is the fact that the Entity classes attack() function is still empty and is the only function in the Entity Packages lacking a test aside from the EntityFactory class. At this time I'm not too concerned in making a test for the class since it's extremely simple and I've confirmed that it works.
Another change is the addition of the Enemy classes take_attack() function. This function is meant to be a combination of Entity classes take_damage() and the Enemy classes die() function. It just simply calls die if the status of the object is "Dead" after taking damage.
PR checklist
[x] All Pytests pass
[x] All changes are documented somewhere in the commit
[x] Rpg2.py is tested and works even with the changes
Pygame-RPG 13.3 Preparation for BattleManager class
This PR is the final preparatory PRs. This PR mostly includes the tests for all of the entity classes that have been created so far.
Unlike with the manager classes, all of the Entity classes tests are in a single python file called
Entities_test.py
. This is because the entities in the Entity package are meant to interact with each other and so it would be difficult to test one without creating another entity to see if their functions work in conjunction.The
Entities_test.py
file is split into different sections, testing each individual type ofEntity
. It first uses anEnemy
object (loaded from theJSON/Enemies/dummy.json
file) to test the methods in theEntity
class and then goes on to test theEnemy
class methods and finally theKnight
class methods. During testing, it was decided that Enemy Inventory attribute will also be a dictionary object. As a result, a change to Scripts.py needed to be made. Once that change was made, the enemy JSON files needed to be reloaded.Another large part of this PR is adjusting the manager classes pytests. As a result of turning some of the dictionary information into JSON, the manager packages tests were outdated and needed to be adjusted. This consisted of making mock JSON variables for object constructors.
As a consequence of using JSON, the tuple type is converted to the array type when loading the information back (despite the fact that you can't have arrays in dictionaries in python). As such, I needed to ensure type equality for some of the automated tests. As a result, the
SaveManager.py
files'tuplefy()
function needed some changing for use in the automated tests.As a result of all of these changes, most files in this PR had only light changes with nothing too major changing. So far, the only thing of note is the fact that the
Entity
classesattack()
function is still empty and is the only function in the Entity Packages lacking a test aside from theEntityFactory
class. At this time I'm not too concerned in making a test for the class since it's extremely simple and I've confirmed that it works.Another change is the addition of the
Enemy
classestake_attack()
function. This function is meant to be a combination ofEntity
classestake_damage()
and theEnemy
classesdie()
function. It just simply calls die if the status of the object is "Dead" after taking damage.PR checklist