Skip to content

Commit

Permalink
Refactoring Verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
davemoore22 committed Sep 16, 2024
1 parent 0000030 commit 9471e8b
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 92 deletions.
2 changes: 1 addition & 1 deletion inc/gui/menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Menu: public sf::Transformable, public sf::Drawable {
// Private Methods
auto virtual draw(sf::RenderTarget &target, sf::RenderStates states) const -> void;
auto _add_item(const int index, const MIT itemtype, const MIM code, std::string key, const bool enabled,
const ConfigOption option, const std::string &hint) -> void;
const CFG option, const std::string &hint) -> void;
auto _add_item(int index, const MIT itemtype, const MIM code, std::string key) -> void;
auto _add_item_disabled(int index, const MIT itemtype, const MIM code, std::string key) -> void;
auto _add_item(int index, const MIT itemtype, const MIM code, std::string key, unsigned int idx) -> void;
Expand Down
2 changes: 1 addition & 1 deletion inc/resources/itemstore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ItemStore {

// Overload operators
auto operator[](ItemTypeID item_type_id) const -> ItemType;
auto operator()(ItemCategory category) const -> std::vector<ItemType>;
auto operator()(ITC category) const -> std::vector<ItemType>;
auto operator[](std::string name) const -> ItemType;

// Public methods
Expand Down
2 changes: 1 addition & 1 deletion inc/resources/monsterstore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MonsterStore {

// Overload operators
auto operator[](MonsterTypeID monster_type_id) const -> MonsterType;
// auto operator()(ItemCategory category) const -> std::vector<ItemType>;
// auto operator()(ITC category) const -> std::vector<ItemType>;
auto operator[](std::string name) const -> MonsterType;

// Public methods
Expand Down
2 changes: 1 addition & 1 deletion inc/resources/spellstore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Spellstore {

// Overload operators
auto operator[](SPI spell_id) const -> Spell;
auto operator()(ItemCategory category) const -> std::vector<Spell>;
auto operator()(ITC category) const -> std::vector<Spell>;
auto operator[](std::string name) const -> Spell;

// Public methods
Expand Down
4 changes: 2 additions & 2 deletions inc/types/enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ namespace Enums::Items {
};
}

using ConfigOption = Enums::Config::Options;
using ItemCategory = Enums::Items::Category;
using CFG = Enums::Config::Options;
using ITC = Enums::Items::Category;
using ItemDef = Enums::Items::Effects::Defensive;
using ItemOff = Enums::Items::Effects::Offensive;
using ItemInv = Enums::Items::Effects::Invoke;
Expand Down
8 changes: 4 additions & 4 deletions inc/types/inventory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Inventory {
auto items() const -> std::vector<Item>;
auto has_unidentified_items() const -> bool;
auto has_cursed_items() const -> bool;
auto has_cursed_equipped_item_category(const ItemCategory category) const -> bool;
auto has_cursed_equipped_item_category(const ITC category) const -> bool;
auto equip_item(const unsigned int slot) -> bool;
auto drop_item(const unsigned int slot) -> bool;
auto discard_item(const unsigned int slot) -> bool;
Expand All @@ -83,9 +83,9 @@ class Inventory {
private:

// Private Methods
auto _has_equipped_item_category(const ItemCategory category) const -> bool;
auto _has_cursed_equipped_item_category(const ItemCategory category) const -> bool;
auto _unequip_item_category(const ItemCategory category) -> bool;
auto _has_equipped_item_category(const ITC category) const -> bool;
auto _has_cursed_equipped_item_category(const ITC category) const -> bool;
auto _unequip_item_category(const ITC category) -> bool;

// Private Members
std::vector<Item> _items;
Expand Down
18 changes: 9 additions & 9 deletions inc/types/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Item {

// Public Methods
auto get_type_id() const -> ItemTypeID;
auto get_category() const -> ItemCategory;
auto get_category() const -> ITC;
auto get_known() const -> bool;
auto get_equipped() const -> bool;
auto get_cursed() const -> bool;
Expand All @@ -73,14 +73,14 @@ class Item {
private:

// Private Members
ItemTypeID _type; // Type
ItemCategory _category; // Category
bool _known; // Is known
bool _equipped; // Is currently equipped
bool _cursed; // Is currently cursed
bool _marked; // Marked as undroppable or unsellable
bool _usable; // Is usable
std::string _name; // Individual Name (or if not set, the ItemTypeID Name)
ItemTypeID _type; // Type
ITC _category; // Category
bool _known; // Is known
bool _equipped; // Is currently equipped
bool _cursed; // Is currently cursed
bool _marked; // Marked as undroppable or unsellable
bool _usable; // Is usable
std::string _name; // Individual Name (or if not set, the ItemTypeID Name)
std::string _uname;

long _id;
Expand Down
6 changes: 3 additions & 3 deletions inc/types/itemtype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ItemType {
auto get_known_name() const -> std::string;
auto get_display_name() const -> std::string;
auto get_unknown_name() const -> std::string;
auto get_category() const -> ItemCategory;
auto get_category() const -> ITC;
auto get_cursed() const -> bool;
auto get_value() const -> unsigned int;
auto get_sellable() const -> bool;
Expand Down Expand Up @@ -84,7 +84,7 @@ class ItemType {
auto set_damage(const std::string value) -> void;
auto set_display_name(const std::string value) -> void;
auto set_unknown_name(const std::string value) -> void;
auto set_category(const ItemCategory value) -> void;
auto set_category(const ITC value) -> void;
auto set_cursed(const bool value) -> void;
auto set_value(const unsigned int value) -> void;
auto set_sellable(const bool value) -> void;
Expand Down Expand Up @@ -119,7 +119,7 @@ class ItemType {
std::string _known_name; // Friendly name once identified
std::string _display_name; // Short display name once identified (max 16 characters)
std::string _unknown_name; // Unknown name if not identified
ItemCategory _category; // e.g, WEAPON, ARMOUR etc
ITC _category; // e.g, WEAPON, ARMOUR etc
bool _cursed; // Is a cursed item
unsigned int _value; // Price to buy in shop (Sell/Identify Price is half this)
bool _sellable; // Can be sold
Expand Down
17 changes: 8 additions & 9 deletions src/frontend/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,28 @@ auto Sorcery::Options::start() -> int {
} else if (_system->input->check(CIN::CONFIRM, event)) {
if (selected) {
if ((*_menu->selected).type == MIT::ENTRY) {
const ConfigOption config_to_toggle{(*_menu->selected).config};
if (config_to_toggle == ConfigOption::STRICT_MODE &&
!(*_system->config)[ConfigOption::STRICT_MODE]) {
const CFG config_to_toggle{(*_menu->selected).config};
if (config_to_toggle == CFG::STRICT_MODE && !(*_system->config)[CFG::STRICT_MODE]) {

// Ask for confirmation of Strict Mode
_display->set_input_mode(WIM::CONFIRM_STRICT_MODE);
} else if (config_to_toggle == ConfigOption::RECOMMENDED_MODE &&
!(*_system->config)[ConfigOption::RECOMMENDED_MODE]) {
} else if (config_to_toggle == CFG::RECOMMENDED_MODE &&
!(*_system->config)[CFG::RECOMMENDED_MODE]) {

// Handle Recommended Toggling
_system->config->set_rec_mode();
(*_system->config)[ConfigOption::RECOMMENDED_MODE] = true;
(*_system->config)[CFG::RECOMMENDED_MODE] = true;

} else {

(*_system->config)[config_to_toggle] = !(*_system->config)[config_to_toggle];

// And toggling off strict mode
if (!_system->config->is_strict_mode())
(*_system->config)[ConfigOption::STRICT_MODE] = false;
(*_system->config)[CFG::STRICT_MODE] = false;

if (!_system->config->is_rec_mode())
(*_system->config)[ConfigOption::RECOMMENDED_MODE] = false;
(*_system->config)[CFG::RECOMMENDED_MODE] = false;
}
} else if ((*_menu->selected).type == MIT::SAVE) {

Expand Down Expand Up @@ -187,7 +186,7 @@ auto Sorcery::Options::start() -> int {
return EXIT_MODULE;
} else if (dialog_input.value() == WDB::YES) {
_system->config->set_strict_mode();
(*_system->config)[ConfigOption::STRICT_MODE] = true;
(*_system->config)[CFG::STRICT_MODE] = true;
_display->set_input_mode(WIM::GAME_OPTIONS);
} else if (dialog_input.value() == WDB::NO) {
_display->set_input_mode(WIM::GAME_OPTIONS);
Expand Down
Loading

0 comments on commit 9471e8b

Please sign in to comment.