forked from ahmedibrahim404/Snakes_Ladders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.h
41 lines (29 loc) · 1.66 KB
/
Card.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include "GameObject.h"
#include "Player.h"
// Base Class of All Types of Cards (CardOne, CardTwo, CardThree, ...etc.)
// Note: We will make each type of Card in a separate class because:
// it may have additional data members and functions like: Apply(), ...etc. which have different implementation depending on Card Number
class Card : public GameObject
{
static int CardsCount; // A static member to get the created cards count
protected:
int cardNumber; // an integer representing the card number
const CellPosition *cellPosition;
public:
Card(const CellPosition & pos); // A Constructor for card that takes the cell position of it
void SetCardNumber(int cnum); // The setter of card number
int GetCardNumber(); // The getter of card number
void Draw(Output* pOut) const; // Draws the card number in the cell position of the card
// It has the same implementation for all Card Types (Non-Virtual)
virtual void ReadCardParameters(Grid * pGrid); // It reads the parameters specific for each Card Type
// It is a virtual function (implementation depends on Card Type)
virtual void Apply(Grid* pGrid, Player* pPlayer); // It applies the effect of the Card Type on the passed player
// It is a virtual function (implementation depends on Card Type)
virtual bool IsOverlapping(GameObject* newObj);
virtual Card* GetCopy(CellPosition&) = 0;
static int getCardsCount();
virtual void Save(ofstream& OutFile) = 0;
virtual void Load(ifstream& Infile, Grid* pGrid) = 0;
virtual ~Card(); // A Virtual Destructor
};