#include <iostream>
#include <string>
#include <typeinfo>
#include <cxxabi.h>
#include <algorithm>
using namespace std;
class AbsDictionaryDB {
public:
virtual std::string save(const std::string& key, const std::string& value) {
// Returns action string (override me)
return "";
}
virtual std::string load(const std::string& key) {
return "null";
}
virtual ~AbsDictionaryDB() = default; // Virtual destructor for proper cleanup
};
class Mutatable {
public:
bool algKillSwitch = false;
virtual std::string action(const std::string& ear, const std::string& skin, const std::string& eye) {
return "";
}
virtual bool completed() {
// Has finished?
return false;
}
std::string myName() {
// Returns the class name
int status;
char* demangledName = abi::__cxa_demangle(typeid(*this).name(), 0, 0, &status);
std::string result(demangledName);
free(demangledName);
return result;
}
virtual ~Mutatable() = default; // Virtual destructor for proper cleanup
};
class APSay : public Mutatable {
private:
int at;
std::string param;
public:
APSay(int at, const std::string& param) : Mutatable() {
if (at > 10) {
at = 10;
}
this->at = at;
this->param = param;
}
std::string action(const std::string& ear, const std::string& skin, const std::string& eye) {
std::string axnStr = "";
if (this->at > 0) {
std::string earLower = ear;
std::transform(earLower.begin(), earLower.end(), earLower.begin(), ::tolower);
std::string paramLower = this->param;
std::transform(paramLower.begin(), paramLower.end(), paramLower.begin(), ::tolower);
if (earLower != paramLower) {
axnStr = this->param;
this->at -= 1;
}
}
return axnStr;
}
bool completed() const {
return this->at < 1;
}
};