Skip to content

Commit

Permalink
modify: sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
AppOfficer committed Dec 1, 2024
1 parent 6182d76 commit b9f1cad
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 60 deletions.
66 changes: 7 additions & 59 deletions drafts/GameEngine.draft.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,17 @@
* for LocalGen.
*/

#ifndef LGEN_MODULE_GAMEENGINE
#define LGEN_MODULE_GAMEENGINE 1
#ifndef LGEN_MODULE_GAMEENGINE_DRAFT
#define LGEN_MODULE_GAMEENGINE_DRAFT 1

#include <cstdint>

#include "coord.h"
#include "coord.h" // lib coord

typedef int64_t army_t;
#include "player.h" // players

/// Tile types.
/// Defined as enum for they're all constants.
enum tile_type_e {
/// Normal tile types.
TILE_SPAWN = 0,
TILE_BLANK = 1,
TILE_MOUNTAIN = 2,
TILE_CITY = 3,
TILE_SWAMP = 4,
TILE_DESERT = 5,
TILE_LOOKOUT = 6,
TILE_OBSERVATORY = 7,
#include "tile.h" // tiles

/// Mountains, cities, lookouts, observatories will appear as 'obstacles' if not visible.
/// Give it a specific type number. It may appear as tile type return values.
TILE_OBSTACLE = -1,
};
#include "board.h"

// Some tiles have some properties. Some tiles have aliases. Make them macros.
#define TILE_GENERAL TILE_SPAWN
#define TILE_PLAIN TILE_BLANK
#define TILE_NEUTRAL TILE_BLANK

/// Information of a single tile.
struct Tile {
tile_type_e type;
army_t army;
// Light is a tile attribute, not a tile type.
bool light;
};

#include <cassert>
#include <vector>

class Player {}; // todo))

class Board {
private:
pos_t row, col;
std::vector<std::vector<Tile>> tiles;
public:
Board() :
row(0), col(0) {}
Board(pos_t _row, pos_t _col) :
row(_row), col(_col) {
// board index starts at 1.
// give 1 space at borders for safety and convenience issues.
tiles.resize(row + 2, std::vector<Tile>(col + 2));
}
Tile getTile(pos_t x, pos_t y, Player* pplayer) {
// test tile existance
assert(x >= 1 && x <= row && y >= 1 && y <= col);
// todo))
}
};

#endif // LGEN_MODULE_GAMEENGINE
#endif // LGEN_MODULE_GAMEENGINE_DRAFT
38 changes: 38 additions & 0 deletions drafts/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @file board.h
*
* LocalGen Module: GameEngine
*
* Map Boards
*
* Container of maps.
*/

#include <cassert>
#include <vector>

#include "coord.h"

#include "player.h"
#include "tile.h"

/// Game map board. Zoomable.
class Board {
private:
pos_t row, col;
std::vector<std::vector<Tile>> tiles;
public:
Board() :
row(0), col(0) {}
Board(pos_t _row, pos_t _col) :
row(_row), col(_col) {
// board index starts at 1.
// give 1 space at borders for safety and convenience issues.
tiles.resize(row + 2, std::vector<Tile>(col + 2));
}
Tile getTile(pos_t x, pos_t y, Player* pplayer) {
// test tile existance
assert(x >= 1 && x <= row && y >= 1 && y <= col);
// todo))
}
};
2 changes: 1 addition & 1 deletion drafts/coord.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <cstdint>

typedef int32_t pos_t;
using pos_t = int32_t;

/// @brief Struct for Coordinates, %Coord.
///
Expand Down
23 changes: 23 additions & 0 deletions drafts/player.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @file player.h
*
* LocalGen Module: GameEngine
*
* Players
*
* Players are basic participants of games.
*/

#ifndef LGEN_MODULE_GE_PLAYER
#define LGEN_MODULE_GE_PLAYER 1

#include <string>

/// Base struct for players.
class Player {
private:
std::string name;
public:
}; // todo))

#endif // LGEN_MODULE_GE_PLAYER
52 changes: 52 additions & 0 deletions drafts/tile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @file tile.h
*
* LocalGen Module: GameEngine
*
* Tiles
*
* Tiles are basic elements of map boards.
*/

#ifndef LGEN_MODULE_GE_TILE
#define LGEN_MODULE_GE_TILE 1

#include <cstdint>

#include "player.h"

using army_t = int64_t;

/// Tile types.
/// Defined as enum for they're all constants.
enum tile_type_e {
/// Normal tile types.
TILE_SPAWN = 0,
TILE_BLANK = 1,
TILE_MOUNTAIN = 2,
TILE_CITY = 3,
TILE_SWAMP = 4,
TILE_DESERT = 5,
TILE_LOOKOUT = 6,
TILE_OBSERVATORY = 7,

/// Mountains, cities, lookouts, observatories will appear as 'obstacles' if not visible.
/// Give it a specific type number. It may appear as tile type return values.
TILE_OBSTACLE = -1,
};

// Some tiles have some properties. Some tiles have aliases. Make them macros.
#define TILE_GENERAL TILE_SPAWN
#define TILE_PLAIN TILE_BLANK
#define TILE_NEUTRAL TILE_BLANK

/// Information of a single tile.
struct Tile {
Player* occupier;
tile_type_e type;
army_t army;
// Light is a tile attribute, not a tile type.
bool light;
};

#endif // LGEN_MODULE_GE_TILE

0 comments on commit b9f1cad

Please sign in to comment.