-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Added Game & RandomGenerator Classes (#8)
* 🚀 Added game class * 🚀 Added RandomGenerator class * 📝 Commented line causing build error * 📝 Changed Visual Studio filters * ⚡ Changed Game class data members * 🐛 fixed a typo * 🎨 improved consistency of lab code * 📝 Updated Range struct --------- Co-authored-by: HelanaNady <helananady7@gmail.com>
- Loading branch information
1 parent
c9c7b6e
commit 51cb821
Showing
12 changed files
with
223 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,103 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Containers"> | ||
<Filter Include="Army Classes"> | ||
<UniqueIdentifier>{8a245181-84c7-4cb6-9cc0-a558bcaf50e4}</UniqueIdentifier> | ||
</Filter> | ||
<Filter Include="Game Class"> | ||
<UniqueIdentifier>{e00b24d1-c45b-4cf0-a79c-f081f0669982}</UniqueIdentifier> | ||
</Filter> | ||
<Filter Include="Containers Classes"> | ||
<UniqueIdentifier>{30a4ef19-f6b1-4dde-9639-08137b5a96c3}</UniqueIdentifier> | ||
</Filter> | ||
<Filter Include="UnitsClasses"> | ||
<UniqueIdentifier>{d6265d0d-9e06-4a0b-9c88-39e5e3415fa3}</UniqueIdentifier> | ||
<Filter Include="RandomGenerator Class"> | ||
<UniqueIdentifier>{b46dd307-1a63-43e4-9442-65d606a3ceb0}</UniqueIdentifier> | ||
</Filter> | ||
<Filter Include="ArmyClasses"> | ||
<UniqueIdentifier>{8a245181-84c7-4cb6-9cc0-a558bcaf50e4}</UniqueIdentifier> | ||
<Filter Include="Unit Classes"> | ||
<UniqueIdentifier>{d6265d0d-9e06-4a0b-9c88-39e5e3415fa3}</UniqueIdentifier> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="Containers\PriorityQueue.h"> | ||
<Filter>Containers</Filter> | ||
<Filter>Containers Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Containers\PriorityNode.h"> | ||
<Filter>Containers</Filter> | ||
<Filter>Containers Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Containers\Deque.h"> | ||
<Filter>Containers</Filter> | ||
<Filter>Containers Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Containers\LinkedQueue.h"> | ||
<Filter>Containers</Filter> | ||
<Filter>Containers Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Containers\Node.h"> | ||
<Filter>Containers</Filter> | ||
<Filter>Containers Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Containers\QueueADT.h"> | ||
<Filter>Containers</Filter> | ||
<Filter>Containers Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Containers\StackADT.h"> | ||
<Filter>Containers</Filter> | ||
<Filter>Containers Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Containers\ArrayStack.h"> | ||
<Filter>Containers</Filter> | ||
<Filter>Containers Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="UnitClasses\AlienDrone.h"> | ||
<Filter>UnitsClasses</Filter> | ||
<Filter>Unit Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="UnitClasses\AlienMonster.h"> | ||
<Filter>UnitsClasses</Filter> | ||
<Filter>Unit Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="UnitClasses\AlienSoldier.h"> | ||
<Filter>UnitsClasses</Filter> | ||
<Filter>Unit Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="UnitClasses\EarthGunnery.h"> | ||
<Filter>UnitsClasses</Filter> | ||
<Filter>Unit Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="UnitClasses\EarthSoldier.h"> | ||
<Filter>UnitsClasses</Filter> | ||
<Filter>Unit Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="UnitClasses\EarthTank.h"> | ||
<Filter>UnitsClasses</Filter> | ||
<Filter>Unit Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="UnitClasses\Unit.h"> | ||
<Filter>UnitsClasses</Filter> | ||
<Filter>Unit Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="RandomGenerator\RandomGenerator.h"> | ||
<Filter>RandomGenerator Class</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Game.h"> | ||
<Filter>Game Class</Filter> | ||
</ClInclude> | ||
<ClInclude Include="DEFS.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="ArmyClasses\AlienArmy.h"> | ||
<Filter>ArmyClasses</Filter> | ||
<Filter>Army Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ArmyClasses\Army.h"> | ||
<Filter>ArmyClasses</Filter> | ||
<Filter>Army Classes</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ArmyClasses\EarthArmy.h"> | ||
<Filter>ArmyClasses</Filter> | ||
<Filter>Army Classes</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="main.cpp" /> | ||
<ClCompile Include="UnitClasses\Unit.cpp"> | ||
<Filter>UnitsClasses</Filter> | ||
<Filter>Unit Classes</Filter> | ||
</ClCompile> | ||
<ClCompile Include="RandomGenerator\RandomGenerator.cpp"> | ||
<Filter>RandomGenerator Class</Filter> | ||
</ClCompile> | ||
<ClCompile Include="ArmyClasses\AlienArmy.cpp"> | ||
<Filter>Army Classes</Filter> | ||
</ClCompile> | ||
<ClCompile Include="ArmyClasses\EarthArmy.cpp"> | ||
<Filter>Army Classes</Filter> | ||
</ClCompile> | ||
<ClCompile Include="Game.cpp"> | ||
<Filter>Game Class</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "AlienArmy.h" | ||
|
||
void AlienArmy::addUnit() | ||
{ | ||
} | ||
|
||
void AlienArmy::removeUnit() | ||
{ | ||
} | ||
|
||
void AlienArmy::print() const | ||
{ | ||
} | ||
|
||
void AlienArmy::attack() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "EarthArmy.h" | ||
|
||
void EarthArmy::addUnit() | ||
{ | ||
} | ||
|
||
void EarthArmy::removeUnit() | ||
{ | ||
} | ||
|
||
void EarthArmy::print() const | ||
{ | ||
} | ||
|
||
void EarthArmy::attack() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef DEFS_H | ||
#define DEFS_H | ||
|
||
struct Range { | ||
int min; | ||
int max; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "Game.h" | ||
|
||
Game::Game(): gameMode(GameMode::INTERACTIVE), currentTimestep(0) | ||
{ | ||
} | ||
|
||
Game::~Game() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef GAME_H | ||
#define GAME_H | ||
|
||
#include "ArmyClasses/EarthArmy.h" | ||
#include "ArmyClasses/AlienArmy.h" | ||
#include "RandomGenerator/RandomGenerator.h" | ||
|
||
enum GameMode | ||
{ | ||
INTERACTIVE, | ||
SILENT, | ||
}; | ||
|
||
class Game | ||
{ | ||
private: | ||
GameMode gameMode; | ||
int currentTimestep; | ||
|
||
EarthArmy earthArmy; | ||
AlienArmy alienArmy; | ||
// RandomGenerator randomGenerator; // We need to pass the parameters to the constructor | ||
|
||
public: | ||
Game(); | ||
|
||
void run(GameMode); | ||
void incrementTimestep(); | ||
void changeGameMode(GameMode); | ||
|
||
~Game(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "RandomGenerator.h" | ||
|
||
RandomGenerator::RandomGenerator(int N, int ESPercentage, int ETPercentage, int EGPercentage, int ASPercentage, int AMPercentage, int ADPercentage, int prob, Range earthPowerRange, Range earthHealthRange, Range earthAttackCapacityRange, Range alienPowerRange, Range alienHealthRange, Range alienAttackCapacityRange) | ||
{ | ||
this->N = N; | ||
|
||
this->ESPercentage = ESPercentage; | ||
this->ETPercentage = ETPercentage; | ||
this->EGPercentage = EGPercentage; | ||
|
||
this->ASPercentage = ASPercentage; | ||
this->AMPercentage = AMPercentage; | ||
this->ADPercentage = ADPercentage; | ||
|
||
this->prob = prob; | ||
|
||
this->earthPowerRange = earthPowerRange; | ||
this->earthHealthRange = earthHealthRange; | ||
this->earthAttackCapacityRange = earthAttackCapacityRange; | ||
|
||
this->alienPowerRange = alienPowerRange; | ||
this->alienHealthRange = alienHealthRange; | ||
this->alienAttackCapacityRange = alienAttackCapacityRange; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef RANDOM_GENERATOR_H | ||
#define RANDOM_GENERATOR_H | ||
|
||
#include "../DEFS.h" | ||
#include "../UnitClasses/Unit.h" | ||
|
||
class RandomGenerator | ||
{ | ||
private: | ||
int N; | ||
int ESPercentage; | ||
int ETPercentage; | ||
int EGPercentage; | ||
int ASPercentage; | ||
int AMPercentage; | ||
int ADPercentage; | ||
int prob; | ||
Range earthPowerRange; | ||
Range earthHealthRange; | ||
Range earthAttackCapacityRange; | ||
Range alienPowerRange; | ||
Range alienHealthRange; | ||
Range alienAttackCapacityRange; | ||
|
||
public: | ||
RandomGenerator(int, int, int, int, int, int, int, int, Range, Range, Range, Range, Range, Range); | ||
|
||
Unit* generateUnit(); | ||
int getRandomNumber(int min, int max); | ||
}; | ||
|
||
#endif |