Fixed up building enemies and items using componentsin the JSON.

This commit is contained in:
Zed A. Shaw 2025-01-09 14:01:40 -05:00
parent 9ce4fbd552
commit 222b39c403
13 changed files with 76 additions and 60 deletions

13
dbc.cpp
View file

@ -2,17 +2,19 @@
#include <iostream>
void dbc::log(const string &message) {
fmt::print("{}\n", message);
std::cerr << message << std::endl;
}
void dbc::sentinel(const string &message) {
string err = fmt::format("[SENTINEL!] {}\n", message);
string err = fmt::format("[SENTINEL!] {}", message);
dbc::log(err);
throw dbc::SentinelError{err};
}
void dbc::pre(const string &message, bool test) {
if(!test) {
string err = fmt::format("[PRE!] {}\n", message);
string err = fmt::format("[PRE!] {}", message);
dbc::log(err);
throw dbc::PreCondError{err};
}
}
@ -23,7 +25,8 @@ void dbc::pre(const string &message, std::function<bool()> tester) {
void dbc::post(const string &message, bool test) {
if(!test) {
string err = fmt::format("[POST!] {}\n", message);
string err = fmt::format("[POST!] {}", message);
dbc::log(err);
throw dbc::PostCondError{err};
}
}
@ -35,7 +38,7 @@ void dbc::post(const string &message, std::function<bool()> tester) {
void dbc::check(bool test, const string &message) {
if(!test) {
string err = fmt::format("[CHECK!] {}\n", message);
fmt::println("{}", err);
dbc::log(err);
throw dbc::CheckError{err};
}
}