You can now craft a single ritual from the blanket.
This commit is contained in:
parent
292711f91f
commit
c8a8d2b1af
6 changed files with 27 additions and 7 deletions
|
@ -4,7 +4,7 @@ namespace Events {
|
||||||
enum GUI {
|
enum GUI {
|
||||||
START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP,
|
START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP,
|
||||||
COMBAT_START, NO_NEIGHBORS, HP_STATUS,
|
COMBAT_START, NO_NEIGHBORS, HP_STATUS,
|
||||||
ATTACK, BLOCK, EVADE,
|
ATTACK, BLOCK, EVADE, NEW_RITUAL,
|
||||||
UPDATE_SPRITE, ENEMY_SPAWN, NOOP
|
UPDATE_SPRITE, ENEMY_SPAWN, NOOP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -395,9 +395,12 @@ namespace gui {
|
||||||
// std::string(item.data["name"])));
|
// std::string(item.data["name"])));
|
||||||
$status_ui.log(L"You picked up an item.");
|
$status_ui.log(L"You picked up an item.");
|
||||||
} break;
|
} break;
|
||||||
case eGUI::HP_STATUS: {
|
case eGUI::HP_STATUS:
|
||||||
System::player_status($level);
|
System::player_status($level);
|
||||||
} break;
|
break;
|
||||||
|
case eGUI::NEW_RITUAL:
|
||||||
|
$combat_ui.init();
|
||||||
|
break;
|
||||||
case eGUI::EVADE:
|
case eGUI::EVADE:
|
||||||
case eGUI::BLOCK:
|
case eGUI::BLOCK:
|
||||||
dbc::log("YOU NEED TO IMPLEMENT THIS!!!!!");
|
dbc::log("YOU NEED TO IMPLEMENT THIS!!!!!");
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "rand.hpp"
|
#include "rand.hpp"
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
#include "rand.hpp"
|
#include "rand.hpp"
|
||||||
|
#include "sound.hpp"
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
using namespace guecs;
|
using namespace guecs;
|
||||||
|
@ -90,7 +91,7 @@ namespace gui {
|
||||||
bs.sprite->setPosition({float(x), float(y)});
|
bs.sprite->setPosition({float(x), float(y)});
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is where we add the junk to the engine
|
$engine.set_state($blanket, "has_magick", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RitualUI::reset_inv_positions() {
|
void RitualUI::reset_inv_positions() {
|
||||||
|
@ -115,7 +116,19 @@ namespace gui {
|
||||||
animation::rotate(*bs.sprite, 20.0);
|
animation::rotate(*bs.sprite, 20.0);
|
||||||
|
|
||||||
// finalize here ritual here
|
// finalize here ritual here
|
||||||
// add it to the belt
|
$engine.plan($blanket);
|
||||||
|
|
||||||
|
if($blanket.is_combined()) {
|
||||||
|
// add it to the belt
|
||||||
|
auto ritual = $engine.finalize($blanket);
|
||||||
|
auto& the_belt = $level.world->get<combat::RitualBelt>($level.player);
|
||||||
|
the_belt.equip(0, ritual);
|
||||||
|
$level.world->send<Events::GUI>(Events::GUI::NEW_RITUAL, $level.player, {});
|
||||||
|
reset_inv_positions();
|
||||||
|
} else {
|
||||||
|
fmt::println("Failed to combine!");
|
||||||
|
sound::play("ui_click");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RitualUI::mouse(float x, float y, bool hover) {
|
bool RitualUI::mouse(float x, float y, bool hover) {
|
||||||
|
@ -128,6 +141,7 @@ namespace gui {
|
||||||
if($ritual_state == OPEN) {
|
if($ritual_state == OPEN) {
|
||||||
$ritual_state = CLOSING;
|
$ritual_state = CLOSING;
|
||||||
} else if($ritual_state == CLOSED) {
|
} else if($ritual_state == CLOSED) {
|
||||||
|
$blanket = $engine.start();
|
||||||
$ritual_state = OPENING;
|
$ritual_state = OPENING;
|
||||||
$ritual_anim.play();
|
$ritual_anim.play();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include "textures.hpp"
|
#include "textures.hpp"
|
||||||
#include "guecs.hpp"
|
#include "guecs.hpp"
|
||||||
|
#include "rituals.hpp"
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
enum class RitualUIState {
|
enum class RitualUIState {
|
||||||
|
@ -17,6 +18,8 @@ namespace gui {
|
||||||
public:
|
public:
|
||||||
sf::IntRect $ritual_closed_rect{{0,0},{380,720}};
|
sf::IntRect $ritual_closed_rect{{0,0},{380,720}};
|
||||||
sf::IntRect $ritual_open_rect{{380 * 2,0},{380,720}};
|
sf::IntRect $ritual_open_rect{{380 * 2,0},{380,720}};
|
||||||
|
combat::RitualEngine $engine;
|
||||||
|
combat::RitualBlanket $blanket;
|
||||||
RitualUIState $ritual_state = RitualUIState::CLOSED;
|
RitualUIState $ritual_state = RitualUIState::CLOSED;
|
||||||
textures::SpriteTexture $ritual_ui;
|
textures::SpriteTexture $ritual_ui;
|
||||||
components::Animation $ritual_anim;
|
components::Animation $ritual_anim;
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace combat {
|
||||||
std::unordered_map<std::string, ai::State> $states;
|
std::unordered_map<std::string, ai::State> $states;
|
||||||
std::unordered_map<std::string, std::vector<ai::Action>> $scripts;
|
std::unordered_map<std::string, std::vector<ai::Action>> $scripts;
|
||||||
|
|
||||||
RitualEngine(std::string config_path);
|
RitualEngine(std::string config_path="assets/rituals.json");
|
||||||
|
|
||||||
ai::State load_state(std::string name);
|
ai::State load_state(std::string name);
|
||||||
ai::Action load_action(std::string name);
|
ai::Action load_action(std::string name);
|
||||||
|
|
|
@ -72,7 +72,7 @@ TEST_CASE("blanket can be finalized for the end result", "[rituals]") {
|
||||||
|
|
||||||
TEST_CASE("the ritual belt works", "[rituals-belt]") {
|
TEST_CASE("the ritual belt works", "[rituals-belt]") {
|
||||||
RitualBelt the_belt;
|
RitualBelt the_belt;
|
||||||
RitualEngine re("assets/rituals.json");
|
RitualEngine re;
|
||||||
auto blanket = re.start();
|
auto blanket = re.start();
|
||||||
|
|
||||||
re.set_state(blanket, "has_magick", true);
|
re.set_state(blanket, "has_magick", true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue