*/
Stuck? Need help? Ask questions on our forums.
*/

View Battleship\inc\User.h

GPL'ed Battleship clone Win32/Linux 1.2.1

Submitted By: i_like_cpp
Rating: (Not rated) (Rate It)


/*
Free Battleship clone for Win32/Linux Console.
Copyright (C) 2005  Dennis Gertitschke

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef USER_H_
#define USER_H_

#include "../inc/Player.h"

class User:public Player{
public:
        typedef void(*F)(void*,char,int);
        User();
        ~User();
        void deployFleet();
        void shoot();
        void validateCompShot(char cX,int iY,bool& bRefHit,int& iRefHitCount);
        static void validateCompShotCallback(void *pObj,char cX,int iY,bool& bRefHit,int& iRefHitCount);
        void reset();
        void registerCallback(void *pObj,F pFunc);
private:
        bool m_barrValidEnd[100];
        char m_cStartX,m_cEndX;
        int  m_iStartY,m_iEndY;
        char m_cDirection;
        void *m_pObj;
        F m_pFunc;
       
        bool validateDirection(char cDirection);
        void transformToUserScreen(char& cRefX,int& iRefY);
                                                                                                    
        void placeShip(Ship* pShip);
        bool readValidStartEnd(Ship *pShip);
        void resetEndpoints();
        bool checkStartEnd(char cStartX,int iStartY,int iLength,int iDirection);
};

#endif/*USER_H_*/

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.