From a769f7b0200e723add7514393609cbf6ee97d175 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 3 Mar 2025 16:33:43 +0100 Subject: [PATCH] seuphorica:: initial commit --- rogueviz/seuphorica.cpp | 293 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 rogueviz/seuphorica.cpp diff --git a/rogueviz/seuphorica.cpp b/rogueviz/seuphorica.cpp new file mode 100644 index 00000000..8fcefe72 --- /dev/null +++ b/rogueviz/seuphorica.cpp @@ -0,0 +1,293 @@ +// Seuphorica frontend +// Copyright (C) 2025 Zeno Rogue, see 'hyper.cpp' for details +// the Seuphorica repo (seuphorica.cpp and dictionary files) needs to be placed in the 'seuphorica' subdirectory + +#include "rogueviz.h" +#include + +namespace hr { + +namespace seuphorica { +void read_dictionary(struct language& l); +void read_naughty_dictionary(language& l); +using std::stringstream; +using std::to_string; +using std::ostream; +} + +#define NONJS +#include "seuphorica/seuphorica.cpp" + +namespace seuphorica { + +void compute_score(); +void draw_board() { compute_score(); } + +void read_dictionary(language& l) { + fhstream f(find_file("rogueviz/seuphorica/" + l.fname), "rt"); + if(!f.f) { l.state = language_state::fetch_fail; compute_score(); return; } + string s; + while(scan(f, s)) + l.dictionary[utf8_length(s)].insert(s); + l.dictionary[utf8_length(l.gamename)].insert(l.gamename); + l.state = language_state::fetch_success; + compute_score(); + } + +void read_naughty_dictionary(language& l) { + fhstream f(find_file("rogueviz/seuphorica/naughty-" + l.fname), "rt"); + if(!f.f) { l.state = language_state::fetch_fail; compute_score(); return; } + string s; + while(scan(f, s)) + l.naughty.insert(s); + l.state = language_state::fetch_success; + compute_score(); + } + +coord from(cell *c) { + auto co = euc2_coordinates(c); + return coord(-co.first+7, -co.second+7); + } + +string fix(string s) { + auto rep = [&] (string a, string b) { + while(true) { + auto pos = s.find(a); + if(pos == string::npos) return; + s.replace(pos, a.size(), b); + } + }; + rep("", ""); + rep("", ""); + rep("", ""); + rep("🪙", "$"); + rep("", ""); + rep("", ""); + rep("
", "\n"); + rep("
  • ", " * "); + rep("
  • ", "* "); + rep("
  • ", "\n"); + rep("", ""); + rep("