home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
scase.zip
/
SCASE.Z
/
TTTCONT.CC
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-17
|
4KB
|
118 lines
/******************************************************************************
* ** Company Confidential **
* ** Copyright 1994, All rights Reserved **
* %Z%%M% version %I% date:%G%
******************************************************************************/
// -MQBeg- [Module_Includes] [tttcont_cc] <00000017.00000000> Retained!
#include "stdio.h"
#include "ttteng.h"
#include "tttdisp.h"
#include "tttcont.h"
// -MQEnd- [Module_Includes] [tttcont_cc] <00000017.00000000>
// -MQBeg- [Module_Declarations_1] [tttcont_cc] <00000017.00000000> Retained!
// -MQEnd- [Module_Declarations_1] [tttcont_cc] <00000017.00000000>
// -MQBeg- [Class_Body] [TTT_Controller] <00000000.00000003>
/******************************************************************************
TTT_Controller
******************************************************************************/
TTT_Controller::TTT_Controller(TTT_Engine *Engine, TTT_Display *Disp)
// -MQBeg- [Op_Init] [TTT_Controller::TTT_Controller] <0000002D.00000040> Retained!
// -MQEnd- [Op_Init] [TTT_Controller::TTT_Controller] <0000002D.00000040>
{
// -MQBeg- [Op_Body] [TTT_Controller::TTT_Controller] <0000002D.00000040> Retained!
theEngine = Engine;
theDisplay = Disp;
// -MQEnd- [Op_Body] [TTT_Controller::TTT_Controller] <0000002D.00000040>
}
TTT_Controller::~TTT_Controller()
{
// -MQBeg- [Op_Body] [TTT_Controller::~TTT_Controller] <0000002D.00000041> Retained!
delete theEngine;
delete theDisplay;
// -MQEnd- [Op_Body] [TTT_Controller::~TTT_Controller] <0000002D.00000041>
}
void
TTT_Controller::Start()
{
// -MQBeg- [Op_Body] [TTT_Controller::Start] <0000002D.00000042> Retained!
theDisplay->DisplayWelcomeMsg();
Reset();
// -MQEnd- [Op_Body] [TTT_Controller::Start] <0000002D.00000042>
}
void
TTT_Controller::HandleEvent(int Event, int Cell )
{
// -MQBeg- [Op_Body] [TTT_Controller::HandleEvent] <0000002D.00000043> Retained!
switch(Event)
{
case MOVE:
Move(Cell);
break;
case UPDATE:
Update();
break;
case RESET:
Reset();
break;
}
// -MQEnd- [Op_Body] [TTT_Controller::HandleEvent] <0000002D.00000043>
}
void
TTT_Controller::Move(int CellNum)
{
// -MQBeg- [Op_Body] [TTT_Controller::Move] <0000002D.00000044> Retained!
int MoveResult = theEngine->MoveRequest(CellNum);
this->Update();
switch (MoveResult)
{
case TTT_Engine::LEGAL:
break;
case TTT_Engine::ILLEGAL:
theDisplay->DisplayIllegalMove();
break;
case TTT_Engine::YOUWIN:
theDisplay->DisplayYouWin();
Reset();
break;
case TTT_Engine::YOULOSE:
theDisplay->DisplayYouLose();
Reset();
break;
case TTT_Engine::DRAW:
theDisplay->DisplayDraw();
Reset();
break;
}
// -MQEnd- [Op_Body] [TTT_Controller::Move] <0000002D.00000044>
}
void
TTT_Controller::Update()
{
// -MQBeg- [Op_Body] [TTT_Controller::Update] <0000002D.00000045> Retained!
theDisplay->Update();
// -MQEnd- [Op_Body] [TTT_Controller::Update] <0000002D.00000045>
}
void
TTT_Controller::Reset()
{
// -MQBeg- [Op_Body] [TTT_Controller::Reset] <0000002D.00000046> Retained!
theEngine->Reset();
theDisplay->Update();
// -MQEnd- [Op_Body] [TTT_Controller::Reset] <0000002D.00000046>
}
// -MQEnd- [Class_Body] [TTT_Controller] <00000000.00000003>
// -MQBeg- [Module_Declarations_2] [tttcont_cc] <00000017.00000000> Retained!
// -MQEnd- [Module_Declarations_2] [tttcont_cc] <00000017.00000000>