1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00
vcmi/scripting/lua/api/netpacks/BattleStackMoved.cpp

85 lines
1.9 KiB
C++
Raw Normal View History

/*
* api/netpacks/BattleStackMoved.cpp, 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
*
*/
#include "StdInc.h"
#include "BattleStackMoved.h"
#include "../../LuaStack.h"
#include "../Registry.h"
namespace scripting
{
namespace api
{
namespace netpacks
{
VCMI_REGISTER_SCRIPT_API(BattleStackMovedProxy, "netpacks.BattleStackMoved");
const std::vector<BattleStackMovedProxy::CustomRegType> BattleStackMovedProxy::REGISTER_CUSTOM =
{
2021-02-16 16:07:30 +02:00
{"new", &Wrapper::constructor, true},
{"addTileToMove", &BattleStackMovedProxy::addTileToMove, false},
{"setUnitId", &BattleStackMovedProxy::setUnitId, false},
{"setDistance", &BattleStackMovedProxy::setDistance, false},
{"setTeleporting", &BattleStackMovedProxy::setTeleporting, false},
{"toNetpackLight", &PackForClientProxy<BattleStackMovedProxy>::toNetpackLight, false}
};
2021-02-16 16:07:30 +02:00
int BattleStackMovedProxy::addTileToMove(lua_State * L)
{
LuaStack S(L);
2021-02-16 16:07:30 +02:00
std::shared_ptr<BattleStackMoved> object;
if(!S.tryGet(1, object))
return S.retVoid();
lua_Integer hex = 0;
2021-02-16 16:07:30 +02:00
if(!S.tryGetInteger(2, hex))
return S.retVoid();
object->tilesToMove.emplace_back(hex);
return S.retVoid();
}
2021-02-16 16:07:30 +02:00
int BattleStackMovedProxy::setUnitId(lua_State * L)
{
LuaStack S(L);
2021-02-16 16:07:30 +02:00
std::shared_ptr<BattleStackMoved> object;
if(!S.tryGet(1, object))
return S.retVoid();
S.tryGet(2, object->stack);
return S.retVoid();
}
2021-02-16 16:07:30 +02:00
int BattleStackMovedProxy::setDistance(lua_State * L)
{
LuaStack S(L);
2021-02-16 16:07:30 +02:00
std::shared_ptr<BattleStackMoved> object;
if(!S.tryGet(1, object))
return S.retVoid();
S.tryGet(2, object->distance);
return S.retVoid();
}
2021-02-16 16:07:30 +02:00
int BattleStackMovedProxy::setTeleporting(lua_State * L)
{
LuaStack S(L);
2021-02-16 16:07:30 +02:00
std::shared_ptr<BattleStackMoved> object;
if(!S.tryGet(1, object))
return S.retVoid();
S.tryGet(2, object->teleporting);
return S.retVoid();
}
}
}
}