forked from rtpHarry/Sokoban
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SokobanActiveLevel.h
115 lines (90 loc) · 2.63 KB
/
SokobanActiveLevel.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#pragma once
#include <vector> // stl vector class
#include <string>
#include <iostream>
#include <fstream>
using namespace std; // expose std namespace used in stl
#include "Vector2.h" // my vector2int class
#include "MoveList.h" // for MoveEvent
#include "EncodedLevel.h"
#define SYMBOL_PLAYER '@'
#define SYMBOL_PLAYER_ON_TARGET '+'
#define SYMBOL_CRATE '$'
#define SYMBOL_CRATE_ON_TARGET '*'
#define SYMBOL_TARGET '.'
#define SYMBOL_FLOOR ' '
#define SYMBOL_WALL '#'
#define SYMBOL_VOID 'X'
//////////////////////////////////////////////////////////////////////////
//
class LevelItem
{
public:
LevelItem(void) {}
LevelItem(char Type, Vector2 Loc) { ItemType = Type; ItemLocation = Loc; }
~LevelItem(void) {}
public:
char ItemType;
Vector2 ItemLocation;
bool operator==(const LevelItem rhs)
{
// compare
if(ItemType == rhs.ItemType && ItemLocation == rhs.ItemLocation)
{
// equal
return true;
}
// something didnt match
return false;
}
};
//////////////////////////////////////////////////////////////////////////
//
typedef vector<LevelItem> LevelItemList;
typedef vector<string> LevelWallData;
//////////////////////////////////////////////////////////////////////////
//
class SokobanActiveLevel
{
public:
LevelWallData m_WallData;
LevelItemList m_ItemList;
LevelItem m_Player;
Vector2 m_LevelDimensions;
int m_TargetQuota;
int m_TargetsTagged;
string m_RenderTheme;
private:
MoveList m_MoveList;
public:
SokobanActiveLevel(void);
~SokobanActiveLevel(void);
// reset all values to defaults
void Reset(void);
// extract a filtered LevelItemList from the current level dataset
LevelItemList GetMatchingItems(char ItemType);
LevelItemList GetItemsAtLocation(Vector2 SourceItemLocation);
// update a LevelItem in the current level dataset
void ChangeItem(LevelItem ItemToMatch, LevelItem NewItemValues);
// Perform the operation in MoveEvent on the gameboard in Level
void ExecuteMoveEvent(const MoveEvent Event);
// Undo the operation in MoveEvent on the gameboard in Level
void ReverseMoveEvent(const MoveEvent Event);
public:
// MoveList Related
// Get the number of moves the player has made this level
int GetMoveCount(void) const
{
return m_MoveList.GetMoveCount();
}
// Remove a move event from the stack (UNDO)
MoveEvent RemoveMoveEvent(void)
{
// remove and return (error checking already done in MoveEvent class)
return m_MoveList.RemoveEvent();
}
// Replace all data with a new level and reset move list
void Reset(SokobanActiveLevel NewLevel);
// extract information from an encoded level
void _ExtractLevelItems(EncodedLevel NewLevel);
};