169 lines
5.4 KiB
C++
169 lines
5.4 KiB
C++
#include <string>
|
|
#include <vector>
|
|
#include <format>
|
|
#include "HtmxShItemList.hpp"
|
|
#include "HtmxShAttributeList.hpp"
|
|
#include "HtmxShCondition.hpp"
|
|
#include "ShadowrunCharacterForm.hpp"
|
|
|
|
using namespace std;
|
|
|
|
static const vector<string> cCharacterInfo = {
|
|
"Name",
|
|
"Metatype",
|
|
"Age",
|
|
"Sex",
|
|
"Nuyen",
|
|
"Lifestyle",
|
|
"Total Karma",
|
|
"C. Karma",
|
|
"Street Cred",
|
|
"Notoriety",
|
|
"Fame"
|
|
};
|
|
|
|
static const vector<string> cAttributes = {
|
|
"Body",
|
|
"Agility",
|
|
"Reaction",
|
|
"Strength",
|
|
"Charisma",
|
|
"Intuition",
|
|
"Logic",
|
|
"Willpower",
|
|
"Edge",
|
|
"Essence",
|
|
"Initiative"
|
|
};
|
|
|
|
static const vector<string> cSkillParameters = {
|
|
"Name",
|
|
"RTG.",
|
|
"ATT.",
|
|
};
|
|
|
|
static const vector<string> cContactsParameters = {
|
|
"Name",
|
|
"Loyalty",
|
|
};
|
|
|
|
static const vector<string> cRangedWeaponsParameters = {
|
|
"Weapon",
|
|
"Damage",
|
|
"AP",
|
|
"Mode",
|
|
"RC",
|
|
"Ammo"
|
|
};
|
|
|
|
static const vector<string> cImplantParameters = {
|
|
"Implant",
|
|
"Rating",
|
|
"Essence",
|
|
"Notes",
|
|
};
|
|
|
|
static const vector<string> cMeleeWeaponParameters = {
|
|
"Weapon",
|
|
"Reach",
|
|
"Damage",
|
|
"AP",
|
|
};
|
|
|
|
static const vector<string> cArmorParamters = {
|
|
"Armor",
|
|
"Ballistic",
|
|
"Impact",
|
|
"Notes",
|
|
};
|
|
|
|
static const vector<string> genCheckboxIds(){
|
|
vector<string> vec;
|
|
HtmxShCondition::genIds(vec, "Physical Condition", 18);
|
|
HtmxShCondition::genIds(vec, "Stun Condition", 12);
|
|
return vec;
|
|
}
|
|
|
|
static const vector<string> genFormIds(){
|
|
vector<string> vec;
|
|
vec.reserve(200);
|
|
|
|
// OBS make sure to update both here and in ShadowrunCharacterForm()
|
|
HtmxShAttributeList::genIds(vec, "Character Info", cCharacterInfo);
|
|
HtmxShAttributeList::genIds(vec, "Attributes", cAttributes);
|
|
HtmxShItemList::genIds(vec, "Active Skills", cSkillParameters, 8);
|
|
HtmxShItemList::genIds(vec, "Knowledge Skills", cSkillParameters, 8);
|
|
vec.push_back("positive_qualities");
|
|
vec.push_back("negative_qualities");
|
|
vec.push_back("datapack_notes");
|
|
|
|
auto v = genCheckboxIds();
|
|
vec.insert(vec.end(), v.begin(), v.end());
|
|
|
|
HtmxShCondition::genIds(vec, "Physical Condition", 18);
|
|
HtmxShCondition::genIds(vec, "Stun Condition", 12);
|
|
HtmxShItemList::genIds(vec, "Contacts", cContactsParameters, 6);
|
|
HtmxShItemList::genIds(vec, "Ranged Weapons", cRangedWeaponsParameters, 7);
|
|
HtmxShItemList::genIds(vec, "Cyberware and Bioware", cImplantParameters, 18);
|
|
HtmxShItemList::genIds(vec, "Melee Weapons", cMeleeWeaponParameters, 7);
|
|
HtmxShItemList::genIds(vec, "Armor", cArmorParamters , 3);
|
|
vec.push_back("notes");
|
|
|
|
return vec;
|
|
}
|
|
|
|
const std::vector<std::string> ShadowrunCharacterForm::m_formIds = genFormIds();
|
|
const std::vector<std::string> ShadowrunCharacterForm::m_checkboxIds = genCheckboxIds();
|
|
|
|
ShadowrunCharacterForm::ShadowrunCharacterForm(std::map<std::string, std::string>& data) {
|
|
html.reserve(30000);
|
|
html += "<form hx-post='/api/shadowrun/submit-character' hx-target='#form-response' hx-swap='innerHTML'>";
|
|
html += "<div style='display: grid; grid-template-columns: 1fr 1fr; gap: 2em;'>";
|
|
|
|
html += HtmxShAttributeList("Character Info", cCharacterInfo, data).htmx();
|
|
html += HtmxShAttributeList("Attributes", cAttributes, data).htmx();
|
|
html += HtmxShItemList("Active Skills", cSkillParameters, 8, data).htmx();
|
|
html += HtmxShItemList("Knowledge Skills", cSkillParameters, 8, data).htmx();
|
|
|
|
auto valuePos = data.contains("positive_qualities") ? data["positive_qualities"] : "";
|
|
auto valueNeg = data.contains("negative_qualities") ? data["negative_qualities"] : "";
|
|
|
|
// add Qualities
|
|
html += format("<div class='section'>"
|
|
"<h2>Qualities</h2>"
|
|
"<label>Positive Qualities:"
|
|
"<textarea name='positive_qualities' rows='4'>{}</textarea>"
|
|
"</label>"
|
|
"<label>Negative Qualities:"
|
|
"<textarea name='negative_qualities' rows='4'>{}</textarea>"
|
|
"</label>"
|
|
"</div>", valuePos, valueNeg);
|
|
|
|
auto valueNotes = data.contains("datapack_notes") ? data["datapack_notes"] : "";
|
|
// add datapack notes
|
|
html += format("<div class='section'>"
|
|
"<h2>Datajack / Commlink / Cyberdeck / Notes</h2>"
|
|
"<label>Notes:"
|
|
"<textarea name='datapack_notes' rows='6'>{}</textarea>"
|
|
"</label>"
|
|
"</div>", valueNotes);
|
|
|
|
html += HtmxShCondition("Physical Condition", 18, data).htmx();
|
|
html += HtmxShCondition("Stun Condition", 12, data).htmx();
|
|
html += HtmxShItemList("Contacts", cContactsParameters, 6, data).htmx();
|
|
html += HtmxShItemList("Ranged Weapons", cRangedWeaponsParameters, 7, data).htmx();
|
|
html += HtmxShItemList("Cyberware and Bioware", cImplantParameters, 18, data).htmx();
|
|
html += HtmxShItemList("Melee Weapons", cMeleeWeaponParameters, 7, data).htmx();
|
|
html += HtmxShItemList("Armor", cArmorParamters , 3, data).htmx();
|
|
html += "</div>";
|
|
|
|
valueNotes = data.contains("notes") ? data["notes"] : "";
|
|
html += format("<div style='margin-top: 1em;'><label for='notes'>Notes:</label>"
|
|
"<textarea id='notes' name='notes' rows='100' style='width:100%; resize:vertical; overflow:auto;'>{}</textarea></div>", valueNotes);
|
|
|
|
|
|
html += "<div style='text-align:center'>"
|
|
"<button type='submit'>Submit</button>"
|
|
"</div>"
|
|
"</form>";
|
|
} |