NerfUS game coordinator for the Nerf gun firing range
Dependencies: HardwareInterface mbed-rtos mbed
Fork of NerfUS by
include/PlayableGame.hpp
- Committer:
- Ismael Balafrej
- Date:
- 2017-03-17
- Branch:
- PlayableGame
- Revision:
- 17:48474266a361
- Child:
- 18:469c8b2a9af9
File content as of revision 17:48474266a361:
#pragma once #include <vector> #include "Target.hpp" #include "RandomNumberGenerator.hpp" struct GameStats { int timeTaken; //ms int numberOfHits; int numberOfMiss; int accuracy; //4 digits percentage to avoid a float int averageTimePerTarget; //ms }; //Abstract class, must be implemented as a GameMode class PlayableGame { public: PlayableGame(std::vector<TargetInfo> *targets, RandomNumberGenerator& random_number_generator); ~PlayableGame(); virtual bool IsWeaponValid(int weaponId); //Default to any Weapons virtual int GetPoints(); virtual GameStats GetStats(); virtual TargetInfo GetNextTarget() = 0; void Start(); //Create a thread that will call GetNextTarget at set speed void Stop(); //Stop the thread void TargetMsgReceived(int ) protected: int points; GameStats stats; TargetInfo GetRandomTarget(int timeout_ms ); virtual void OnTargetHit(int timeTaken) = 0; virtual void OnTargetMiss() = 0; private: RandomNumberGenerator& random_number_generator; };