From f0453375c465379c43b5a1e87077670261be3365 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Thu, 15 May 2014 23:59:24 +1000 Subject: [PATCH] Stating to implement the combat system --- server/character_data.hpp | 2 ++ server/combat_instance.hpp | 37 ++++++++++++++++++++++ server/combat_management.cpp | 24 ++++++++++++++ server/enemy_data.hpp | 50 ++++++++++++++++++++++++++++++ server/enemy_factory_generic.cpp | 34 ++++++++++++++++++++ server/enemy_factory_generic.hpp | 42 +++++++++++++++++++++++++ server/enemy_factory_interface.hpp | 40 ++++++++++++++++++++++++ server/server_application.hpp | 1 + todo.txt | 37 +++++++++++----------- 9 files changed, 249 insertions(+), 18 deletions(-) create mode 100644 server/combat_instance.hpp create mode 100644 server/combat_management.cpp create mode 100644 server/enemy_data.hpp create mode 100644 server/enemy_factory_generic.cpp create mode 100644 server/enemy_factory_generic.hpp create mode 100644 server/enemy_factory_interface.hpp diff --git a/server/character_data.hpp b/server/character_data.hpp index 0442483..df7aaf9 100644 --- a/server/character_data.hpp +++ b/server/character_data.hpp @@ -54,6 +54,8 @@ struct CharacterData { float accuracy = 0.0; float evasion = 0.0; float luck = 0.0; + + //TODO: equipment and items }; #endif diff --git a/server/combat_instance.hpp b/server/combat_instance.hpp new file mode 100644 index 0000000..78ba16c --- /dev/null +++ b/server/combat_instance.hpp @@ -0,0 +1,37 @@ +/* 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 COMBATINSTANCE_HPP_ +#define COMBATINSTACNE_HPP_ + +#include "character_data.hpp" +#include "enemy_data.hpp" + +#include + +struct CombatInstance { + std::list characterList; + std::list enemyList; + + //TODO: more? +}; + +#endif diff --git a/server/combat_management.cpp b/server/combat_management.cpp new file mode 100644 index 0000000..2c822a0 --- /dev/null +++ b/server/combat_management.cpp @@ -0,0 +1,24 @@ +/* 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 "server_application.hpp" + +//TODO: method definitions \ No newline at end of file diff --git a/server/enemy_data.hpp b/server/enemy_data.hpp new file mode 100644 index 0000000..1e90d68 --- /dev/null +++ b/server/enemy_data.hpp @@ -0,0 +1,50 @@ +/* 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 ENEMYDATA_HPP_ +#define ENEMYDATA_HPP_ + +#include + +struct EnemyData { + //metadata + std::string handle; + std::string avatar; + + //TODO: attached lua scripts + + //statistics + int level = 0; + int exp = 0; + int maxHP = 0; + int health = 0; + int maxMP = 0; + int mana = 0; + int attack = 0; + int defence = 0; + int intelligence = 0; + int resistance = 0; + float accuracy = 0.0; + float evasion = 0.0; + float luck = 0.0; +}; + +#endif diff --git a/server/enemy_factory_generic.cpp b/server/enemy_factory_generic.cpp new file mode 100644 index 0000000..4c83281 --- /dev/null +++ b/server/enemy_factory_generic.cpp @@ -0,0 +1,34 @@ +/* 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 "enemy_factory_generic.hpp" + +EnemyFactoryGeneric::EnemyFactoryGeneric() : EnemyFactoryInterface() { + // +} + +EnemyFactoryGeneric::~EnemyFactoryGeneric() noexcept { + // +} + +void EnemyFactoryGeneric::Generate(std::list* container) { + //TODO: fill out +} \ No newline at end of file diff --git a/server/enemy_factory_generic.hpp b/server/enemy_factory_generic.hpp new file mode 100644 index 0000000..5a63078 --- /dev/null +++ b/server/enemy_factory_generic.hpp @@ -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. +*/ +#ifndef ENEMYFACTORYGENERIC_HPP_ +#define ENEMYFACTORYGENERIC_HPP_ + +#include "enemy_factory_interface.hpp" + +#include "enemy_data.hpp" + +#include + +//DOCS: Not really intended for use, but rather for copying and tweaking +class EnemyFactoryGeneric : public EnemyFactoryInterface { +public: + EnemyFactoryGeneric(); + ~EnemyFactoryGeneric() noexcept override; + + void Generate(std::list* container) override; +private: + //TODO: hold the parameters specified by the room +}; + +#endif diff --git a/server/enemy_factory_interface.hpp b/server/enemy_factory_interface.hpp new file mode 100644 index 0000000..6582145 --- /dev/null +++ b/server/enemy_factory_interface.hpp @@ -0,0 +1,40 @@ +/* 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 ENEMYFACTORYINTERFACE_HPP_ +#define ENEMYFACTORYINTERFACE_HPP_ + +#include "enemy_data.hpp" + +#include + +//NOTE: Based on biome, world difficulty, etc. +class EnemyFactoryInterface { +public: + EnemyFactoryInterface() = default; + virtual ~EnemyFactoryInterface() = default; + + virtual void Generate(std::list* container) = 0; +private: + //TODO: hold the parameters here? +}; + +#endif diff --git a/server/server_application.hpp b/server/server_application.hpp index 0b93372..3953a30 100644 --- a/server/server_application.hpp +++ b/server/server_application.hpp @@ -51,6 +51,7 @@ #include //The main application class +//TODO: modulate this god class class ServerApplication { public: //standard functions diff --git a/todo.txt b/todo.txt index c37d3e4..a3d260d 100644 --- a/todo.txt +++ b/todo.txt @@ -16,24 +16,25 @@ I may also need to rewrite some variable names. --ServerApplication's methods-- -These interact with the database file, making the server a persistent system. - -* CreateUserAccount -* LoadUserAccount -* SaveUserAccount -* UnloadUserAccount -* DeleteUserAccount - -* CreateCharacter -* LoadCharacter -* SaveCharacter -* UnloadCharacter -* DeleteCharacter +//NOTE: I honestly don't know what I'm doing +CreateCombatInstance(roomIndex) +PushCharacterToCombat(charIndex, combatIndex) +UpdateCombatInstances() //handles all combat --Battle System-- -CombatPortal: - x, y - list - list - //... \ No newline at end of file +CharacterData: + --stats + +EnemyData + --stats + +CombatInstance + list + list + +Room: + RegionPager pager + EnemyFactory enemyFactory --this takes information on the room's data early in the room's construction + list +