2011-05-10 01:20:47 +03:00
|
|
|
#pragma once
|
2012-04-23 22:56:37 +03:00
|
|
|
#include "BattleHex.h"
|
|
|
|
|
|
|
|
struct CObstacleInfo;
|
2011-05-10 01:20:47 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
struct DLL_LINKAGE CObstacleInstance
|
2011-05-10 01:20:47 +03:00
|
|
|
{
|
2012-05-18 23:50:16 +03:00
|
|
|
BattleHex pos; //position on battlefield, typically left bottom corner
|
|
|
|
ui8 obstacleType; //if true, then position is meaningless
|
2012-04-23 22:56:37 +03:00
|
|
|
si32 uniqueID;
|
|
|
|
si32 ID; //ID of obstacle (defines type of it)
|
|
|
|
|
2012-05-05 00:16:39 +03:00
|
|
|
enum EObstacleType
|
|
|
|
{
|
2012-07-19 21:52:44 +03:00
|
|
|
//ABSOLUTE needs an underscore because it's a Win
|
2012-05-18 23:50:16 +03:00
|
|
|
USUAL, ABSOLUTE_OBSTACLE, QUICKSAND, LAND_MINE, FORCE_FIELD, FIRE_WALL, MOAT
|
2012-05-05 00:16:39 +03:00
|
|
|
};
|
2012-04-23 22:56:37 +03:00
|
|
|
|
|
|
|
|
2012-05-18 23:50:16 +03:00
|
|
|
//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)
|
2012-07-19 21:52:44 +03:00
|
|
|
|
2012-05-18 23:50:16 +03:00
|
|
|
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
|
|
|
|
{
|
2012-05-05 00:16:39 +03:00
|
|
|
si8 turnsRemaining;
|
2012-05-18 23:50:16 +03:00
|
|
|
si8 casterSpellPower;
|
2012-05-05 00:16:39 +03:00
|
|
|
si8 spellLevel;
|
|
|
|
si8 casterSide; //0 - obstacle created by attacker; 1 - by defender
|
|
|
|
si8 visibleForAnotherSide;
|
2012-07-19 21:52:44 +03:00
|
|
|
|
2012-05-18 23:50:16 +03:00
|
|
|
SpellCreatedObstacle();
|
2012-05-05 00:16:39 +03:00
|
|
|
|
2012-05-18 23:50:16 +03:00
|
|
|
virtual std::vector<BattleHex> getAffectedTiles() const OVERRIDE; //for special effects (not blocking)
|
|
|
|
virtual bool visibleForSide(ui8 side, bool hasNativeStack) const OVERRIDE; //0 attacker
|
2012-07-19 21:52:44 +03:00
|
|
|
|
2012-05-18 23:50:16 +03:00
|
|
|
virtual void battleTurnPassed() OVERRIDE;
|
2012-04-23 22:56:37 +03:00
|
|
|
|
2011-05-10 01:20:47 +03:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2012-05-18 23:50:16 +03:00
|
|
|
h & static_cast<CObstacleInstance&>(*this);
|
|
|
|
h & turnsRemaining & casterSpellPower & spellLevel & casterSide & visibleForAnotherSide;
|
2011-05-10 01:20:47 +03:00
|
|
|
}
|
2012-05-18 23:50:16 +03:00
|
|
|
};
|