home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / scase.zip / SCASE.Z / TTTCONT.CC < prev    next >
C/C++ Source or Header  |  1994-10-17  |  4KB  |  118 lines

  1. /******************************************************************************
  2. *                         ** Company Confidential **
  3. *                  ** Copyright 1994, All rights Reserved **
  4. * %Z%%M% version %I% date:%G%
  5. ******************************************************************************/
  6.  
  7. // -MQBeg- [Module_Includes] [tttcont_cc] <00000017.00000000> Retained!
  8. #include "stdio.h"
  9. #include "ttteng.h"
  10. #include "tttdisp.h"
  11. #include "tttcont.h"
  12. // -MQEnd- [Module_Includes] [tttcont_cc] <00000017.00000000> 
  13.  
  14. // -MQBeg- [Module_Declarations_1] [tttcont_cc] <00000017.00000000> Retained!
  15. // -MQEnd- [Module_Declarations_1] [tttcont_cc] <00000017.00000000> 
  16.  
  17. // -MQBeg- [Class_Body] [TTT_Controller] <00000000.00000003> 
  18. /******************************************************************************
  19.                                 TTT_Controller
  20. ******************************************************************************/
  21.  
  22. TTT_Controller::TTT_Controller(TTT_Engine *Engine, TTT_Display *Disp)
  23. // -MQBeg- [Op_Init] [TTT_Controller::TTT_Controller] <0000002D.00000040> Retained!
  24. // -MQEnd- [Op_Init] [TTT_Controller::TTT_Controller] <0000002D.00000040> 
  25. {
  26. // -MQBeg- [Op_Body] [TTT_Controller::TTT_Controller] <0000002D.00000040> Retained!
  27.   theEngine  = Engine;
  28.   theDisplay = Disp;
  29. // -MQEnd- [Op_Body] [TTT_Controller::TTT_Controller] <0000002D.00000040> 
  30. }
  31.  
  32. TTT_Controller::~TTT_Controller()
  33. {
  34. // -MQBeg- [Op_Body] [TTT_Controller::~TTT_Controller] <0000002D.00000041> Retained!
  35.   delete theEngine;
  36.   delete theDisplay;
  37. // -MQEnd- [Op_Body] [TTT_Controller::~TTT_Controller] <0000002D.00000041> 
  38. }
  39.  
  40. void
  41. TTT_Controller::Start()
  42. {
  43. // -MQBeg- [Op_Body] [TTT_Controller::Start] <0000002D.00000042> Retained!
  44.   theDisplay->DisplayWelcomeMsg();
  45.   Reset();
  46. // -MQEnd- [Op_Body] [TTT_Controller::Start] <0000002D.00000042> 
  47. }
  48.  
  49. void
  50. TTT_Controller::HandleEvent(int Event, int Cell )
  51. {
  52. // -MQBeg- [Op_Body] [TTT_Controller::HandleEvent] <0000002D.00000043> Retained!
  53.   switch(Event)
  54.   {
  55.   case MOVE:
  56.     Move(Cell);
  57.     break;
  58.   case UPDATE:
  59.     Update();
  60.     break;
  61.   case RESET:
  62.     Reset();
  63.     break;
  64.   }
  65. // -MQEnd- [Op_Body] [TTT_Controller::HandleEvent] <0000002D.00000043> 
  66. }
  67.  
  68. void
  69. TTT_Controller::Move(int CellNum)
  70. {
  71. // -MQBeg- [Op_Body] [TTT_Controller::Move] <0000002D.00000044> Retained!
  72.   int MoveResult = theEngine->MoveRequest(CellNum);
  73.   this->Update();
  74.   switch (MoveResult)
  75.   {
  76.   case TTT_Engine::LEGAL:
  77.     break;
  78.   case TTT_Engine::ILLEGAL:
  79.     theDisplay->DisplayIllegalMove();
  80.     break;
  81.   case TTT_Engine::YOUWIN:
  82.     theDisplay->DisplayYouWin();
  83.     Reset();
  84.     break;
  85.   case TTT_Engine::YOULOSE:
  86.     theDisplay->DisplayYouLose();
  87.     Reset();
  88.     break;
  89.   case TTT_Engine::DRAW:
  90.     theDisplay->DisplayDraw();
  91.     Reset();
  92.     break;
  93.   }
  94. // -MQEnd- [Op_Body] [TTT_Controller::Move] <0000002D.00000044> 
  95. }
  96.  
  97. void
  98. TTT_Controller::Update()
  99. {
  100. // -MQBeg- [Op_Body] [TTT_Controller::Update] <0000002D.00000045> Retained!
  101.    theDisplay->Update();
  102. // -MQEnd- [Op_Body] [TTT_Controller::Update] <0000002D.00000045> 
  103. }
  104.  
  105. void
  106. TTT_Controller::Reset()
  107. {
  108. // -MQBeg- [Op_Body] [TTT_Controller::Reset] <0000002D.00000046> Retained!
  109.   theEngine->Reset();
  110.   theDisplay->Update();
  111. // -MQEnd- [Op_Body] [TTT_Controller::Reset] <0000002D.00000046> 
  112. }
  113.  
  114. // -MQEnd- [Class_Body] [TTT_Controller] <00000000.00000003> 
  115.  
  116. // -MQBeg- [Module_Declarations_2] [tttcont_cc] <00000017.00000000> Retained!
  117. // -MQEnd- [Module_Declarations_2] [tttcont_cc] <00000017.00000000> 
  118.