Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

LevelCountDown Class Reference

Collaboration diagram for LevelCountDown:

Collaboration graph
[legend]

Detailed Description

Countdowns finished or wrong state.

Definition at line 13 of file LevelCountDown.h.

Public Member Functions

 LevelCountDown (const RoomAccess *access)
 Prepare countdown.
void fillStatus (LevelStatus *status)
void reset ()
 Resets counter.
bool countDown (const CountAdvisor *advisor)
 Countdown to zero.
bool isFinishedEnough () const
bool isWrongEnough () const
void saveSolution ()
 Write best solution to the file.
GameStatecreateNextState ()
 Creates next state or returns NULL.


Constructor & Destructor Documentation

LevelCountDown::LevelCountDown const RoomAccess access  ) 
 

Prepare countdown.

Definition at line 22 of file LevelCountDown.cpp.

00023 {
00024     m_countdown = -1;
00025     m_access = access;
00026     m_levelStatus = NULL;
00027 }


Member Function Documentation

bool LevelCountDown::countDown const CountAdvisor advisor  ) 
 

Countdown to zero.

Parameters:
advisor advisor which known usable coundown values
Returns:
true when counter is at zero

Definition at line 49 of file LevelCountDown.cpp.

00050 {
00051     bool result = false;
00052     if (m_countdown < 0) {
00053         setCountDown(advisor);
00054     }
00055     else if (m_countdown > 0) {
00056         m_countdown--;
00057     }
00058     else {
00059         result = true;
00060     }
00061     return result;
00062 }

GameState * LevelCountDown::createNextState  ) 
 

Creates next state or returns NULL.

Returns:
returns NULL when only quitState() is needed

Definition at line 109 of file LevelCountDown.cpp.

00110 {
00111     return m_levelStatus->createPoster();
00112 }

void LevelCountDown::fillStatus LevelStatus status  )  [inline]
 

Definition at line 22 of file LevelCountDown.h.

00022 { m_levelStatus = status; }

bool LevelCountDown::isFinishedEnough  )  const
 

Definition at line 79 of file LevelCountDown.cpp.

00080 {
00081     return m_countdown == 0 && m_access->const_room()->isSolved();
00082 }

bool LevelCountDown::isWrongEnough  )  const
 

Definition at line 85 of file LevelCountDown.cpp.

00086 {
00087     return m_countdown == 0 && m_access->const_room()->cannotMove() &&
00088         !m_access->const_room()->isSolved();
00089 }

void LevelCountDown::reset  ) 
 

Resets counter.

Exceptions:
LogicException when levelStatus is not filled

Definition at line 34 of file LevelCountDown.cpp.

00035 {
00036     if (NULL == m_levelStatus) {
00037         throw LogicException(ExInfo("level status is NULL"));
00038     }
00039     m_levelStatus->setRunning(true);
00040     m_countdown = -1;
00041 }

void LevelCountDown::saveSolution  ) 
 

Write best solution to the file.

Save moves and models state.

Definition at line 96 of file LevelCountDown.cpp.

00097 {
00098     m_levelStatus->setComplete();
00099     std::string current_moves =
00100         m_access->const_room()->stepCounter()->getMoves();
00101     m_levelStatus->writeSolvedMoves(current_moves);
00102 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:55:38 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2