1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
vcmi/lib/CObstacleInstance.h
Ivan Savenko e4c88d5088 - moved ParseBonus to JsonNode.cpp (linkage errors)
- fixes to CMakeLists - vcmi can be compiled and started with cmake
- gcc\clang warnings fixes
2012-07-19 18:52:44 +00:00

73 lines
2.3 KiB
C++

#pragma once
#include "BattleHex.h"
struct CObstacleInfo;
struct DLL_LINKAGE CObstacleInstance
{
BattleHex pos; //position on battlefield, typically left bottom corner
ui8 obstacleType; //if true, then position is meaningless
si32 uniqueID;
si32 ID; //ID of obstacle (defines type of it)
enum EObstacleType
{
//ABSOLUTE needs an underscore because it's a Win
USUAL, ABSOLUTE_OBSTACLE, QUICKSAND, LAND_MINE, FORCE_FIELD, FIRE_WALL, MOAT
};
//used only for spell-created obstacles
CObstacleInstance();
virtual ~CObstacleInstance();
//bool spellGenerated() const;
const CObstacleInfo &getInfo() const; //allowed only when not generated by spell (usual or absolute)
std::vector<BattleHex> getBlockedTiles() const;
std::vector<BattleHex> getStoppingTile() const; //hexes that will stop stack move
//The two functions below describe how the obstacle affects affected tiles
//additional effects (like hurting stack or disappearing) are hardcoded for appropriate obstacleTypes
bool blocksTiles() const;
bool stopsMovement() const; //if unit stepping onto obstacle, can't continue movement (in general, doesn't checks for the side)
virtual std::vector<BattleHex> getAffectedTiles() const;
virtual bool visibleForSide(ui8 side, bool hasNativeStack) const; //0 attacker
virtual void battleTurnPassed(){};
template <typename Handler> void serialize(Handler &h, const int version)
{
h & ID & pos & obstacleType & uniqueID;
}
};
struct DLL_LINKAGE MoatObstacle : CObstacleInstance
{
virtual std::vector<BattleHex> getAffectedTiles() const OVERRIDE; //for special effects (not blocking)
};
struct DLL_LINKAGE SpellCreatedObstacle : CObstacleInstance
{
si8 turnsRemaining;
si8 casterSpellPower;
si8 spellLevel;
si8 casterSide; //0 - obstacle created by attacker; 1 - by defender
si8 visibleForAnotherSide;
SpellCreatedObstacle();
virtual std::vector<BattleHex> getAffectedTiles() const OVERRIDE; //for special effects (not blocking)
virtual bool visibleForSide(ui8 side, bool hasNativeStack) const OVERRIDE; //0 attacker
virtual void battleTurnPassed() OVERRIDE;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CObstacleInstance&>(*this);
h & turnsRemaining & casterSpellPower & spellLevel & casterSide & visibleForAnotherSide;
}
};