You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.1 KiB

#pragma once
#define ILLEGAL_IDX -1
#define NOTHING 0
#define BEAN 1
#define GOLDBEAN 2
#define WALL 3
#include <string>
#include <fstream>
using namespace std;
class Map
{
private:
int* data; // 行列式
int row;
int column;
public:
int GetData(int x, int y)const
{
if (x < 0 || x >= row || y < 0 || y >= column)
return ILLEGAL_IDX;
int k = x * column + y;
return data[k];
}
bool SetData(int x, int y, int d)
{
if (x < 0 || x >= row || y < 0 || y >= column)
return false;
if (d < 0 || d > 3)
return false;
int k = x * column + y;
data[k] = d;
return true;
}
bool SetRow(int r)
{
if (r < 0)
return false;
row = r;
return true;
}
bool SetColumn(int c)
{
if (c < 0)
return false;
column = c;
return true;
}
int GetColumn() const { return column; }
int GetRow() const { return row; }
bool Empty()const
{
int k = 0;
for (int i = 0; i < row; i++)
{
for (int j = 0; j < column; j++)
{
if (data[k] == BEAN || data[k] == GOLDBEAN)
return false;
k++;
}
}
return true;
}
// 使用一个配置文件 初始化
void Init(string filepath)
{
}
};