Created the monster system
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#config
|
||||
INCLUDES+=. ../entities ../server_utilities ../../common/gameplay ../../common/utilities
|
||||
LIBS+=
|
||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||
|
||||
#source
|
||||
CXXSRC=$(wildcard *.cpp)
|
||||
|
||||
#objects
|
||||
OBJDIR=obj
|
||||
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||
|
||||
#output
|
||||
OUTDIR=..
|
||||
OUT=$(addprefix $(OUTDIR)/,server.a)
|
||||
|
||||
#targets
|
||||
all: $(OBJ) $(OUT)
|
||||
ar -crs $(OUT) $(OBJ)
|
||||
|
||||
$(OBJ): | $(OBJDIR)
|
||||
|
||||
$(OUT): | $(OUTDIR)
|
||||
|
||||
$(OBJDIR):
|
||||
mkdir $(OBJDIR)
|
||||
|
||||
$(OUTDIR):
|
||||
mkdir $(OUTDIR)
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
$(RM) *.o *.a *.exe
|
||||
|
||||
rebuild: clean all
|
||||
@@ -0,0 +1,42 @@
|
||||
/* Copyright: (c) Kayne Ruse 2014
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
#include "monster_data.hpp"
|
||||
|
||||
Statistics* MonsterData::GetBaseStats() {
|
||||
return &baseStats;
|
||||
}
|
||||
|
||||
std::string MonsterData::SetAvatar(std::string s) {
|
||||
return avatar = s;
|
||||
}
|
||||
|
||||
int MonsterData::SetScriptReference(int i) {
|
||||
return scriptRef = i;
|
||||
}
|
||||
|
||||
std::string MonsterData::GetAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
int MonsterData::GetScriptReference() {
|
||||
return scriptRef;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/* Copyright: (c) Kayne Ruse 2014
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
#ifndef MONSTERDATA_HPP_
|
||||
#define MONSTERDATA_HPP_
|
||||
|
||||
#include "entity.hpp"
|
||||
#include "statistics.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
class MonsterData: Entity {
|
||||
public:
|
||||
MonsterData() = default;
|
||||
~MonsterData() = default;
|
||||
|
||||
Statistics* GetBaseStats();
|
||||
|
||||
std::string SetAvatar(std::string);
|
||||
int SetScriptReference(int);
|
||||
|
||||
std::string GetAvatar();
|
||||
int GetScriptReference();
|
||||
|
||||
private:
|
||||
friend class MonsterManager;
|
||||
|
||||
Statistics baseStats;
|
||||
std::string avatar;
|
||||
int scriptRef;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/* Copyright: (c) Kayne Ruse 2014
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
#include "monster_manager.hpp"
|
||||
|
||||
//TODO: monster_manager.cpp
|
||||
|
||||
int MonsterManager::Create(std::string) {
|
||||
//
|
||||
}
|
||||
|
||||
int MonsterManager::Load(std::string) {
|
||||
//
|
||||
}
|
||||
|
||||
int MonsterManager::Save(int uid) {
|
||||
//
|
||||
}
|
||||
|
||||
void MonsterManager::Unload(int uid) {
|
||||
//
|
||||
}
|
||||
|
||||
void MonsterManager::Delete(int uid) {
|
||||
//
|
||||
}
|
||||
|
||||
void MonsterManager::UnloadAll() {
|
||||
//
|
||||
}
|
||||
|
||||
void MonsterManager::UnloadIf(std::function<bool(std::pair<const int, MonsterData>)> fn) {
|
||||
//
|
||||
}
|
||||
|
||||
MonsterData* MonsterManager::Get(int uid) {
|
||||
//
|
||||
}
|
||||
|
||||
int MonsterManager::GetLoadedCount() {
|
||||
//
|
||||
}
|
||||
|
||||
int MonsterManager::GetTotalCount() {
|
||||
//
|
||||
}
|
||||
|
||||
std::map<int, MonsterData>* MonsterManager::GetContainer() {
|
||||
//
|
||||
}
|
||||
|
||||
sqlite3* MonsterManager::SetDatabase(sqlite3* db) {
|
||||
//
|
||||
}
|
||||
|
||||
sqlite3* MonsterManager::GetDatabase() {
|
||||
//
|
||||
}
|
||||
|
||||
lua_State* MonsterManager::SetLuaState(lua_State* L) {
|
||||
//
|
||||
}
|
||||
|
||||
lua_State* MonsterManager::GetLuaState() {
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/* Copyright: (c) Kayne Ruse 2014
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
#ifndef MONSTERMANAGER_HPP_
|
||||
#define MONSTERMANAGER_HPP_
|
||||
|
||||
#include "manager_interface.hpp"
|
||||
#include "monster_data.hpp"
|
||||
#include "singleton.hpp"
|
||||
|
||||
#ifdef __unix__
|
||||
#include "lua.hpp"
|
||||
#include "sqlite3.h"
|
||||
#else
|
||||
#include "lua/lua.hpp"
|
||||
#include "sqlite3/sqlite3.h"
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class MonsterManager:
|
||||
Singleton<MonsterManager>,
|
||||
ManagerInterface<MonsterData, std::string>
|
||||
{
|
||||
public:
|
||||
//common public methods
|
||||
int Create(std::string);
|
||||
int Load(std::string);
|
||||
int Save(int uid);
|
||||
void Unload(int uid);
|
||||
void Delete(int uid);
|
||||
|
||||
void UnloadAll();
|
||||
void UnloadIf(std::function<bool(std::pair<const int, MonsterData>)> fn);
|
||||
|
||||
//accessors & mutators
|
||||
MonsterData* Get(int uid);
|
||||
int GetLoadedCount();
|
||||
int GetTotalCount();
|
||||
std::map<int, MonsterData>* GetContainer();
|
||||
|
||||
//hooks
|
||||
sqlite3* SetDatabase(sqlite3* db);
|
||||
sqlite3* GetDatabase();
|
||||
lua_State* SetLuaState(lua_State* L);
|
||||
lua_State* GetLuaState();
|
||||
|
||||
private:
|
||||
friend Singleton<MonsterManager>;
|
||||
|
||||
MonsterManager() = default;
|
||||
~MonsterManager() = default;
|
||||
|
||||
sqlite3* database = nullptr;
|
||||
lua_State* lua = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
TODO: Get the rooms working, even if only via hotkeys
|
||||
TODO: I need a better way to handle the statistics
|
||||
TODO: SerialPacketType::CHARACTER_LOCATION, CHARACTER_MOVE, CHARACTER_TELEPORT, ROOM_CHANGE, etc.
|
||||
TODO: Fix shoddy movement
|
||||
TODO: Handle statistics server-side
|
||||
|
||||
Reference in New Issue
Block a user