forked from NTUT-FUCK-PTSD/Fuck-PTSD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change the function name that upperline and bottomline in throw.h
- Loading branch information
Showing
7 changed files
with
162 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// Created by adven on 2024/4/28. | ||
// | ||
|
||
#ifndef FUCK_PTSD_CONFIG_H | ||
#define FUCK_PTSD_CONFIG_H | ||
|
||
#endif // FUCK_PTSD_CONFIG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Created by adven on 2024/4/28. | ||
// | ||
|
||
#ifndef FUCK_PTSD_IEQUIP_HPP | ||
#define FUCK_PTSD_IEQUIP_HPP | ||
|
||
#include <GameElement.h> | ||
|
||
class IEquip : public GameElement { | ||
public: | ||
enum Pos { COL = 0, ROW }; | ||
|
||
virtual std::string GetName() const = 0; | ||
|
||
virtual std::string GetType() const = 0; | ||
}; | ||
|
||
#endif // FUCK_PTSD_IEQUIP_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Created by adven on 2024/4/28. | ||
// | ||
|
||
#ifndef FUCK_PTSD_TOOLSYSTEM_HPP | ||
#define FUCK_PTSD_TOOLSYSTEM_HPP | ||
|
||
#include <map> | ||
#include "Player/Equipment/IEquip.h" | ||
#include "ToolFactory.h" | ||
class Tool final { | ||
public: | ||
explicit Tool() { | ||
m_ToolFactory = std::make_shared<Players::Items::ToolFactory>(); | ||
m_GameElement = std::make_shared<GameElement>(); | ||
m_GameElement->SetVisible(false); | ||
|
||
for (const auto& elem : m_BaseTool) { | ||
const auto& obj = m_ToolFactory->MakeTool(elem.first, elem.second); | ||
|
||
m_ToolList.push_back(obj); | ||
m_GameElement->AddChild(obj); | ||
} | ||
}; | ||
|
||
void AddTool(const std::shared_ptr<IEquip>& ge) { | ||
m_ToolList.push_back(ge); | ||
m_GameElement->AddChild(ge); | ||
}; | ||
|
||
std::shared_ptr<Util::GameObject> GetGameObject() { | ||
return static_cast<std::shared_ptr<Util::GameObject>>(m_GameElement); | ||
} | ||
|
||
private: | ||
const std::map<std::string, std::string> m_BaseTool = { | ||
{"BOMB", "1"}, | ||
{"SHOVEL", "Shovel"}, | ||
{"WEAPON", "Dagger"}}; | ||
|
||
std::vector<std::shared_ptr<IEquip>> m_ToolList; | ||
|
||
std::shared_ptr<Players::Items::ToolFactory> m_ToolFactory; | ||
|
||
std::shared_ptr<GameElement> m_GameElement; | ||
}; | ||
|
||
#endif // FUCK_PTSD_TOOLSYSTEM_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Created by adven on 2024/4/28. | ||
// | ||
|
||
#ifndef FUCK_PTSD_TOOLFACTORY_H | ||
#define FUCK_PTSD_TOOLFACTORY_H | ||
|
||
#include "Player/Equipment/IEquip.h" | ||
#include "Settings/Hash.h" | ||
|
||
using namespace Settings::Hash; | ||
|
||
namespace Players::Items { | ||
class ToolFactory { | ||
public: | ||
explicit ToolFactory() = default; | ||
|
||
std::shared_ptr<IEquip> MakeTool( | ||
const std::string& name, | ||
const std::string& type | ||
) { | ||
switch (Settings::Hash::HashConvert(name)) { | ||
case "BOMB"_hash: GenBomb(); break; | ||
case "SHOVEL"_hash: GenShovel(); break; | ||
case "WEAPON"_hash: GenWeapon(); break; | ||
default: throw std::runtime_error("Tool type is not available"); break; | ||
} | ||
|
||
return m_Result; | ||
}; | ||
|
||
private: | ||
void GenBomb(); | ||
void GenShovel(); | ||
void GenWeapon(); | ||
|
||
std::shared_ptr<IEquip> m_Result; | ||
}; | ||
} // namespace Players::Items | ||
|
||
#endif // FUCK_PTSD_TOOLFACTORY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Created by adven on 2024/4/29. | ||
// | ||
|
||
#ifndef FUCK_PTSD_HASH_H | ||
#define FUCK_PTSD_HASH_H | ||
|
||
#include <iostream> | ||
|
||
namespace Settings { | ||
namespace Hash { | ||
typedef std::size_t ht; | ||
|
||
constexpr ht prime = 0x100000001B3ull; | ||
constexpr ht basis = 0xCBF29CE484222325ull; | ||
|
||
static ht HashConvert(const std::string& str) { | ||
ht ret = basis; | ||
|
||
for (std::size_t i = 0; i < str.size(); ++i) { | ||
ret ^= static_cast<std::size_t>(str[i]); | ||
ret *= prime; | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
constexpr ht hash_compile_time(const char* str, ht last_value = basis) { | ||
return *str ? hash_compile_time(str + 1, (*str ^ last_value) * prime) | ||
: last_value; | ||
} | ||
|
||
static constexpr unsigned long long operator"" _hash(const char* str, size_t) { | ||
return hash_compile_time(str); | ||
} | ||
|
||
} // namespace Hash | ||
} // namespace Settings | ||
|
||
#endif // FUCK_PTSD_HASH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters