GetCommandCondition.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. ** Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  3. **
  4. ** File: GetCommandCondition.cpp
  5. **
  6. ** Author:
  7. **
  8. ** Description:
  9. ** Implementation of the training library "GetCommandCondition" interface.
  10. **
  11. ** History:
  12. */
  13. #include "pch.h"
  14. #include "GetCommandCondition.h"
  15. #include "TypeIDTarget.h"
  16. namespace Training
  17. {
  18. //------------------------------------------------------------------------------
  19. // class methods
  20. //------------------------------------------------------------------------------
  21. /* void */ GetCommandCondition::GetCommandCondition (IshipIGC* pShip, CommandID command) :
  22. m_pShip (new TypeIDTarget (OT_ship, pShip->GetObjectID ())),
  23. m_command (command)
  24. {
  25. }
  26. //------------------------------------------------------------------------------
  27. /* void */ GetCommandCondition::GetCommandCondition (ObjectID shipID, CommandID command) :
  28. m_pShip (new TypeIDTarget (OT_ship, shipID)),
  29. m_command (command)
  30. {
  31. }
  32. //------------------------------------------------------------------------------
  33. /* void */ GetCommandCondition::~GetCommandCondition (void)
  34. {
  35. delete m_pShip;
  36. }
  37. //------------------------------------------------------------------------------
  38. bool GetCommandCondition::Evaluate (void)
  39. {
  40. IshipIGC* pShip = static_cast<IshipIGC*> (static_cast<ImodelIGC*> (*m_pShip));
  41. // check that the ship is present
  42. if (pShip)
  43. {
  44. // the ship is there, so we return true if it has a command like the one we
  45. // are checking for.
  46. return ((pShip->GetCommandID (c_cmdAccepted) == m_command) or (pShip->GetCommandID (c_cmdCurrent) == m_command)) ? true : false;
  47. }
  48. // the ship wasn't there for some reason, so we assume that this condition is true
  49. return true;
  50. }
  51. //------------------------------------------------------------------------------
  52. }