NerfUS mobile node that manages a target for the Nerf gun firing range
Dependencies: LedController mbed-rtos mbed NerfUSXbee Servomotor TargetManager
Fork of NerfUS by
Diff: source/TargetManager.cpp
- Revision:
- 39:a98413395b20
- Parent:
- 38:70a1c8bd2877
- Child:
- 43:b8cda61584a8
diff -r 70a1c8bd2877 -r a98413395b20 source/TargetManager.cpp --- a/source/TargetManager.cpp Sun Apr 09 13:12:22 2017 -0400 +++ b/source/TargetManager.cpp Sun Apr 09 19:49:07 2017 +0000 @@ -1,4 +1,5 @@ #include "TargetManager.hpp" +#include <cassert> TargetManager::TargetManager(std::vector<TargetInterface*>& targets, std::vector<NerfusTickerInterface*>& nerfus_tickers) : @@ -13,15 +14,20 @@ void TargetManager::execute(const TargetInfo& target_info) { + assert(0 <= target_info.id && target_info.id < targets.size() && "ID is out of range"); TargetInterface& target = *(targets[target_info.id]); if(target_info.type == TARGET_TYPE_ALLY) { target.ally_command(); } + else if(target_info.type == TARGET_TYPE_ENEMY) + { + target.enemy_command(); + } else { - target.enemy_command(); + assert(false && "Target type invalid"); } is_active_target[target_info.id] = true;