2023-10-23 12:59:15 +02:00
|
|
|
/*
|
|
|
|
* BattleChanges.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2024-02-11 23:09:01 +02:00
|
|
|
#include "../json/JsonNode.h"
|
2023-10-23 12:59:15 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class BattleChanges
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class EOperation : si8
|
|
|
|
{
|
|
|
|
ADD,
|
|
|
|
RESET_STATE,
|
|
|
|
UPDATE,
|
|
|
|
REMOVE,
|
|
|
|
};
|
|
|
|
|
|
|
|
JsonNode data;
|
|
|
|
EOperation operation = EOperation::RESET_STATE;
|
|
|
|
|
|
|
|
BattleChanges() = default;
|
|
|
|
explicit BattleChanges(EOperation operation_)
|
|
|
|
: operation(operation_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class UnitChanges : public BattleChanges
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
uint32_t id = 0;
|
|
|
|
int64_t healthDelta = 0;
|
|
|
|
|
|
|
|
UnitChanges() = default;
|
|
|
|
UnitChanges(uint32_t id_, EOperation operation_)
|
|
|
|
: BattleChanges(operation_)
|
|
|
|
, id(id_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-10-23 12:59:15 +02:00
|
|
|
{
|
|
|
|
h & id;
|
|
|
|
h & healthDelta;
|
|
|
|
h & data;
|
|
|
|
h & operation;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ObstacleChanges : public BattleChanges
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
uint32_t id = 0;
|
|
|
|
|
|
|
|
ObstacleChanges() = default;
|
|
|
|
|
|
|
|
ObstacleChanges(uint32_t id_, EOperation operation_)
|
|
|
|
: BattleChanges(operation_),
|
|
|
|
id(id_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-10-23 12:59:15 +02:00
|
|
|
{
|
|
|
|
h & id;
|
|
|
|
h & data;
|
|
|
|
h & operation;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|