Ejemplo n.º 1
0
void Cell::Reset()
{
    m_Type = 0;
    m_Symbol = "   ";
    m_Empty = true;
    SetVisibility(false);
    SetDiscovered(false);
    SetDescription("An empty space");
    m_MyObject=NULL;
}
Ejemplo n.º 2
0
int BOARD::Scan( char Row, char Col )
{
	char i, j, Count = 0;
	CONT PlaceCont;
	
	if( !Row || !Col || Row >= (Rows - 1) || Col >= (Columns - 1))
		return -1;
	if( GetContents( Row, Col ) == SHIP ){
		SetDiscovered( Row, Col, (char)(ShipNumber + 10) );
		return ShipNumber + 10;
		// this number will not be reached otherwise
	}
	// left
	for( i = Row, j = (char)(Col-1); !(PlaceCont = GetContents( i, j )); j-- );
	if( PlaceCont == SHIP ) Count++;
	// left-top
	for( i = (char)(Row+1), j = (char)(Col-1); !(PlaceCont = GetContents( i, j )); i++, j-- );
	if( PlaceCont == SHIP ) Count++;
	// top
	for( i = (char)(Row+1), j = Col; !(PlaceCont = GetContents( i, j )); i++ );
	if( PlaceCont == SHIP ) Count++;
	// top-right
	for( i = (char)(Row+1), j = (char)(Col+1); !(PlaceCont = GetContents( i, j )); i++, j++ );
	if( PlaceCont == SHIP ) Count++;
	// right
	for( i = Row, j = (char)(Col+1); !(PlaceCont = GetContents( i, j )); j++ );
	if( PlaceCont == SHIP ) Count++;
	// right-bottom
	for( i = (char)(Row-1), j = (char)(Col+1); !(PlaceCont = GetContents( i, j )); i--, j++ );
	if( PlaceCont == SHIP ) Count++;
	// bottom
	for( i = Row-1, j = Col; !(PlaceCont = GetContents( i, j )); i-- );
	if( PlaceCont == SHIP ) Count++;
	// bottom-left
	for( i = Row-1, j = Col-1; !(PlaceCont = GetContents( i, j )); i--, j-- );
	if( PlaceCont == SHIP ) Count++;
	SetDiscovered( Row, Col, Count );
	MoveCount++;		// if a ship is found, the move is not counted
	return Count;
}
Ejemplo n.º 3
0
VOID GRAPHBOARD::DrawPMPlace( const HPS hps, const char Row,
										const char Col, INT Value,
										const BOOL fSwap )
{
    POINTL Point;
    ULONG Bitmap;
    HBITMAP hbm;

    Point.x = LowerLeftPlace.x + (Col - 1)*dist - dist/3;
    Point.y = LowerLeftPlace.y + (Row - 1)*dist - dist/3;
    if( !fSwap ){
	if( Value >= 50 ) Value -= 50;
	else if(Value <= 4 ) Value += 50;
    }
				// fSwap indicates if a number
				// will be swapped into a circle or vice versa
    if ( Value >= 50 ) {	// a number has already been found and will be
				// replaced by a circle now
	Bitmap = BMP_FCIRCLE;
	SetDiscovered( Row, Col, (SHORT)(Value - 50) );
    } else {
	switch( Value ){
	case 0: Bitmap = BMP_F0; break;
	case 1: Bitmap = BMP_F1; break;
	case 2: Bitmap = BMP_F2; break;
	case 3: Bitmap = BMP_F3; break;
	case 4: Bitmap = BMP_F4; break;
	default: Bitmap = BMP_SHIP;
	}
	if( Value != GetShipNumber() + 10 )
	    SetDiscovered( Row, Col, (SHORT)(Value + 50) );
    }
    hbm = GpiLoadBitmap( hps, (HMODULE)NULL, Bitmap, dist*2/3, dist*2/3);
//	if( hbm == NULLHANDLE ) DosBeep( 500, 150 );
//	if( !(WinDrawBitmap( hps, hbm, NULL, &Point, 0, 0, DBM_NORMAL ) ))
//		DosBeep( 1000, 150 );
    WinDrawBitmap(hps, hbm, NULL, &Point, 0, 0, DBM_NORMAL);
    GpiDeleteBitmap( hbm );		// releases the bitmap-handle
}
Ejemplo n.º 4
0
Cell::Cell(int type, string description, GameObject * object):m_Type(type), m_Description(description),m_MyObject(object)
{
    vector<int>Rand;
    for(int i =0; i<5; i++)
    {
        Rand.push_back(i);
    }
    random_shuffle(Rand.begin(),Rand.end());
    switch(m_Type)
    {
    case 0:
        m_Symbol = "   "; //Blank
        m_Empty = true;
        m_isVisible = false;
        SetDiscovered(false);
        break;
    case 1:				//OUTSIDE
        m_Symbol = "|"; //Wall
        m_Empty = false;
        m_isVisible = true;
        SetDiscovered(true);
        SetDescription("a wall, don't think you'll do much here.");
        break;
    case 2:
        m_Symbol = "---"; //Top/Bottom
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        SetDescription("a wall, don't think you'll do much here.");
        break;
    case 3:
        m_Symbol = " | "; //Inside Wall
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        SetDescription("a wall, don't think you'll do much here.");
        break;
    case 4:	//Player the symbol is taken from the Player class
        m_Empty = false;
        m_isVisible = true;
        break;
    case 5:	//Enemy the symbol is taken from the Enemy class
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        break;
    case 6:
        m_Symbol = "---"; //Top/Bottom for the outside
        m_Empty = false;
        m_isVisible = true;
        SetDiscovered(true);
        SetDescription("a wall, don't think you'll do much here.");
        break;
    case 7:		//Item for the player----Matches
        m_Symbol = " * ";
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        SetDescription(description);
        break;
    case 8:		//Item for the Player-----Armour
        m_Symbol = " * ";
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        SetDescription(description);
        break;
    case 9:		//Item for the Player-----MedKit
        m_Symbol = " * ";
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        SetDescription(description);
        break;
    case 10:	//Game Event
        m_Symbol = " ! ";
        m_Empty = false;
        m_isVisible = true;
        SetDiscovered(true);
        SetDescription(description);
        break;
    case 11:	//Eye Candy
        m_Symbol = " x ";
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        switch(Rand.front())
        {
        case 0:
            description ="A Table";
            break;
        case 1:
            description ="A Chair";
            break;
        case 2:
            description ="A Computer Parts";
            break;
        case 3:
            description ="Stack of boxes";
            break;
        case 4:
            description ="A Desk";
            break;
        }
        SetDescription(description);
        break;
    case 12:	//Weapon
        m_Symbol = " * ";
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        SetDescription(description);
        break;
    case 13:	//Exit
        m_Symbol = "{ }";
        m_Empty = false;
        m_isVisible = false;
        SetDiscovered(false);
        SetDescription("An exit. Were you planning on leaving?");
        break;
    };
}