Start working on powders translation
taking a pause to clean up load code
This commit is contained in:
parent
ed60e2ac6d
commit
caa4c87662
8 changed files with 75 additions and 7 deletions
|
@ -3,13 +3,15 @@ CXXFLAGS=-sENVIRONMENT=web -sSINGLE_FILE -sMODULARIZE -sWASM_ASYNC_COMPILATION=0
|
||||||
|
|
||||||
all: utils.js powders.js
|
all: utils.js powders.js
|
||||||
|
|
||||||
%.js:
|
%.js: %.js.out
|
||||||
$(CXX) $(CXXFLAGS) -sEXPORT_NAME=create_$* -o $@.out $^
|
|
||||||
cat $@.out $@.in > ../$@
|
cat $@.out $@.in > ../$@
|
||||||
|
|
||||||
powders.js: powders.cpp
|
%.js.out:
|
||||||
|
$(CXX) $(CXXFLAGS) -sEXPORT_NAME=create_$* -o $@ $^
|
||||||
|
|
||||||
utils.js: utils.cpp utils/math_utils.cpp utils/base64.cpp utils/bitvector.cpp
|
powders.js.out: powders.cpp definitions.cpp
|
||||||
|
|
||||||
|
utils.js.out: utils.cpp utils/math_utils.cpp utils/base64.cpp utils/bitvector.cpp
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|
1
js/c++/definitions.cpp
Normal file
1
js/c++/definitions.cpp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "definitions.h"
|
7
js/c++/definitions.h
Normal file
7
js/c++/definitions.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
static const std::vector<std::string> skp_order { "str", "dex", "int", "def", "agi" };
|
||||||
|
static const std::vector<std::string> skp_elements {"e","t","w","f","a"};
|
|
@ -4,7 +4,44 @@ using namespace emscripten;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "powders.h"
|
#include "powders.h"
|
||||||
|
#include "definitions.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
const std::map<std::string, int> powderIDs = []{
|
||||||
|
std::map<std::string, int> m;
|
||||||
|
int powder_id = 0;
|
||||||
|
for (const auto& x : skp_elements) {
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
m[x + std::to_string(i)] = i;
|
||||||
|
m[(char)toupper(x[0]) + std::to_string(i)] = i;
|
||||||
|
powder_id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m;
|
||||||
|
}();
|
||||||
|
|
||||||
|
const std::map<int, std::string> powderNames = []{
|
||||||
|
std::map<int, std::string> m;
|
||||||
|
for (const auto& kv : powderIDs) {
|
||||||
|
m[kv.second] = kv.first;
|
||||||
|
}
|
||||||
|
return m;
|
||||||
|
}();
|
||||||
|
|
||||||
|
Powder::Powder(int min, int max, int conv, int defPlus, int defMinus) :
|
||||||
|
min(min), max(max), convert(conv), defPlus(defPlus), defMinus(defMinus) {}
|
||||||
|
|
||||||
|
const std::vector<Powder> powderStats = []{
|
||||||
|
auto _p = [](int a, int b, int c, int d, int e){ return Powder(a,b,c,d,e); };
|
||||||
|
return std::vector<Powder> {
|
||||||
|
_p(3,6,17,2,1), _p(5,8,21,4,2), _p(6,10,25,8,3), _p(7,10,31,14,5), _p(9,11,38,22,9), _p(11,13,46,30,13),
|
||||||
|
_p(1,8,9,3,1), _p(1,12,11,5,1), _p(2,15,13,9,2), _p(3,15,17,14,4), _p(4,17,22,20,7), _p(5,20,28,28,10),
|
||||||
|
_p(3,4,13,3,1), _p(4,6,15,6,1), _p(5,8,17,11,2), _p(6,8,21,18,4), _p(7,10,26,28,7), _p(9,11,32,40,10),
|
||||||
|
_p(2,5,14,3,1), _p(4,8,16,5,2), _p(5,9,19,9,3), _p(6,9,24,16,5), _p(8,10,30,25,9), _p(10,12,37,36,13),
|
||||||
|
_p(2,6,11,3,1), _p(3,10,14,6,2), _p(4,11,17,10,3), _p(5,11,22,16,5), _p(7,12,28,24,9), _p(8,14,35,34,13)
|
||||||
|
};
|
||||||
|
}();
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
EMSCRIPTEN_BINDINGS(powders) {
|
EMSCRIPTEN_BINDINGS(powders) {
|
||||||
|
|
|
@ -1 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
extern const std::map<std::string, int> powderIDs;
|
||||||
|
extern const std::map<int, std::string> powderNames;
|
||||||
|
|
||||||
|
struct Powder {
|
||||||
|
int min;
|
||||||
|
int max;
|
||||||
|
int convert;
|
||||||
|
int defPlus;
|
||||||
|
int defMinus;
|
||||||
|
|
||||||
|
Powder(int min, int max, int conv, int defPlus, int defMinus);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const std::vector<Powder> powderStats;
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Base64 {
|
||||||
// v v v v v v v v v
|
// v v v v v v v v v
|
||||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+-";
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+-";
|
||||||
|
|
||||||
const std::map<char, size_t> digitsMap = []{
|
static const std::map<char, size_t> digitsMap = []{
|
||||||
std::map<char, size_t> m;
|
std::map<char, size_t> m;
|
||||||
for (size_t i = 0; i < digits.length(); ++i) {
|
for (size_t i = 0; i < digits.length(); ++i) {
|
||||||
m[digits[i]] = i;
|
m[digits[i]] = i;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
BitVector::BitVector() {};
|
||||||
|
BitVector::BitVector(const BitVector& other) : data(other.data), length(other.length) {};
|
||||||
|
|
||||||
BitVector::BitVector(const std::string b64_data) {
|
BitVector::BitVector(const std::string b64_data) {
|
||||||
length = b64_data.length() * 6;
|
length = b64_data.length() * 6;
|
||||||
data.reserve(length/bitvec_data_s + 1);
|
data.reserve(length/bitvec_data_s + 1);
|
||||||
|
|
|
@ -23,8 +23,8 @@ public:
|
||||||
*
|
*
|
||||||
* The structure of the Uint32Array should be [[last, ..., first], ..., [last, ..., first], [empty space, last, ..., first]]
|
* The structure of the Uint32Array should be [[last, ..., first], ..., [last, ..., first], [empty space, last, ..., first]]
|
||||||
*/
|
*/
|
||||||
BitVector() {};
|
BitVector();
|
||||||
BitVector(const BitVector& other) : data(other.data), length(other.length) {};
|
BitVector(const BitVector& other);
|
||||||
BitVector(const std::string b64_data);
|
BitVector(const std::string b64_data);
|
||||||
BitVector(bitvec_data_t num, size_t length);
|
BitVector(bitvec_data_t num, size_t length);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue