NerfUS game coordinator for the Nerf gun firing range
Dependencies: HardwareInterface mbed-rtos mbed
Fork of NerfUS by
Diff: include/PlayableGame.hpp
- Branch:
- PlayableGame
- Revision:
- 17:48474266a361
- Child:
- 18:469c8b2a9af9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/PlayableGame.hpp Fri Mar 17 17:19:42 2017 -0400 @@ -0,0 +1,43 @@ +#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; +}; \ No newline at end of file