Commit 470c8ae9 authored by sirjorj's avatar sirjorj

add hyperspace info

parent af546f5f
Subproject commit 09364404edfa6a38ad7b60159f380b8a802c4bf1
Subproject commit 7821204f6b2c5a3d868890663257e006982ac17e
......@@ -91,6 +91,12 @@ void pilot2(struct kreq *req) {
khtml_attr(&r, KELEM_TD, KATTR__MAX); khtml_puts(&r, std::to_string(pilot.GetNatCost()).c_str()); khtml_closeelem(&r, 1);
khtml_closeelem(&r, 1);
}
{ // hyperspace legal
khtml_elem(&r, KELEM_TR);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::Key().c_str(), KATTR__MAX); khtml_puts(&r, "Hyperspace"); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX); khtml_puts(&r, pilot.GetHyperspace() ? "Yes" : "No"); khtml_closeelem(&r, 1);
khtml_closeelem(&r, 1);
}
{ // initiative
khtml_elem(&r, KELEM_TR);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::Key().c_str(), KATTR__MAX); khtml_puts(&r, "Initiative"); khtml_closeelem(&r, 1);
......
......@@ -5,8 +5,10 @@ using namespace libxwing2;
void pilots2(struct kreq *req) {
std::string format="";
std::string restriction="";
for(int i=0; i<req->fieldsz; i++) {
if(strcmp(req->fields[i].key, "format") == 0) { format = req->fields[i].val; }
if(strcmp(req->fields[i].key, "format") == 0) { format = req->fields[i].val; }
if(strcmp(req->fields[i].key, "restriction") == 0) { restriction = req->fields[i].val; }
}
if(format == "") {
......@@ -29,6 +31,11 @@ void pilots2(struct kreq *req) {
// gather data
std::map<Fac, std::map<Shp,std::vector<Pilot>>> data;
for(const Pilot &p : Pilot::GetAllPilots()) {
if(restriction == "hyperspace") {
if(p.GetHyperspace() == 0) {
continue;
}
}
data[p.GetFac()][p.GetShp()].push_back(p);
}
......@@ -64,18 +71,41 @@ void pilots2(struct kreq *req) {
{ // alt formats
khtml_elem(&r, KELEM_BR);
std::string pUrl = std::string(req->pname)+"/pilots2?format=json";
khtml_elem(&r, KELEM_TABLE);
khtml_elem(&r, KELEM_TR);
khtml_elem(&r, KELEM_TD);
khtml_puts(&r, "[");
khtml_attr(&r, KELEM_A, KATTR_HREF, pUrl.c_str(), KATTR__MAX);
khtml_puts(&r, "json");
khtml_closeelem(&r, 1); // a
khtml_puts(&r, "]");
khtml_closeelem(&r, 1); // rd
khtml_closeelem(&r, 2); // tr, table
{ // all
khtml_elem(&r, KELEM_TR);
khtml_elem(&r, KELEM_TD);
std::string pUrl = std::string(req->pname)+"/pilots2";
khtml_puts(&r, "[");
khtml_attr(&r, KELEM_A, KATTR_HREF, pUrl.c_str(), KATTR__MAX);
khtml_puts(&r, "all");
khtml_closeelem(&r, 1); // a
khtml_puts(&r, "]");
khtml_closeelem(&r, 2); // td tr
}
{ // hyperspace
khtml_elem(&r, KELEM_TR);
khtml_elem(&r, KELEM_TD);
std::string pUrl = std::string(req->pname)+"/pilots2?restriction=hyperspace";
khtml_puts(&r, "[");
khtml_attr(&r, KELEM_A, KATTR_HREF, pUrl.c_str(), KATTR__MAX);
khtml_puts(&r, "hyperspace");
khtml_closeelem(&r, 1); // a
khtml_puts(&r, "]");
khtml_closeelem(&r, 2); // td tr
}
{ // json
khtml_elem(&r, KELEM_TR);
khtml_elem(&r, KELEM_TD);
std::string pUrl = std::string(req->pname)+"/pilots2?format=json";
khtml_puts(&r, "[");
khtml_attr(&r, KELEM_A, KATTR_HREF, pUrl.c_str(), KATTR__MAX);
khtml_puts(&r, "json");
khtml_closeelem(&r, 1); // a
khtml_puts(&r, "]");
khtml_closeelem(&r, 2); // td tr
}
khtml_closeelem(&r, 1); // table
}
khtml_closeelem(&r, 2); // div body
......@@ -114,6 +144,7 @@ void pilots2(struct kreq *req) {
pilots[pc]["ship"] = p.GetShip().GetName();
pilots[pc]["basesize"] = p.GetShip().GetBaseSize().GetName();
pilots[pc]["cost"] = p.GetNatCost();
pilots[pc]["hyperspace"] = p.GetHyperspace() ? "Yes" : "No";
pilots[pc]["initiative"] = p.GetNatInitiative();
{
int ac=0;
......
......@@ -93,6 +93,12 @@ void upgrade2(struct kreq *req) {
khtml_puts(&r, costStr.c_str());
khtml_closeelem(&r, 2); // td tr
}
{ // hyperspace legal
khtml_elem(&r, KELEM_TR);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::Key().c_str(), KATTR__MAX); khtml_puts(&r, "Hyperspace"); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX); khtml_puts(&r, upgrade.GetHyperspace() ? "Yes" : "No"); khtml_closeelem(&r, 1);
khtml_closeelem(&r, 1);
}
{ // attack & range
if(upgrade.GetAttackStats()) {
khtml_elem(&r, KELEM_TR);
......
......@@ -9,8 +9,10 @@ std::string cssUpgHeader() { return "font-size:60px; text-align:center; padding-
void upgrades2(struct kreq *req) {
std::string format="";
std::string restriction="";
for(int i=0; i<req->fieldsz; i++) {
if(strcmp(req->fields[i].key, "format") == 0) { format = req->fields[i].val; }
if(strcmp(req->fields[i].key, "format") == 0) { format = req->fields[i].val; }
if(strcmp(req->fields[i].key, "restriction") == 0) { restriction = req->fields[i].val; }
}
if(format == "") {
......@@ -34,6 +36,11 @@ void upgrades2(struct kreq *req) {
std::vector<UpgradeType> upTypes;
std::map<UpT, uint16_t> uptc;
for(const Upgrade &h : Upgrade::GetAllUpgrades()) {
if(restriction=="hyperspace") {
if(h.GetHyperspace() == 0) {
continue;
}
}
uptc[h.GetUpT()]++;
}
std::vector<std::pair<UpT,uint16_t>> uptcv;
......@@ -66,6 +73,12 @@ void upgrades2(struct kreq *req) {
}
for(const Upgrade& u : Upgrade::GetAllUpgrades()) {
if(restriction=="hyperspace") {
if(u.GetHyperspace() == 0) {
continue;
}
}
if(u.GetUpT() == ut.GetUpT()) {
// upgrade name
std::string xu;
......@@ -117,16 +130,41 @@ void upgrades2(struct kreq *req) {
{ // alt formats
khtml_elem(&r, KELEM_BR);
std::string pUrl = std::string(req->pname)+"/upgrades2?format=json";
khtml_elem(&r, KELEM_TABLE);
khtml_elem(&r, KELEM_TR);
khtml_elem(&r, KELEM_TD);
khtml_puts(&r, "[");
khtml_attr(&r, KELEM_A, KATTR_HREF, pUrl.c_str(), KATTR__MAX);
khtml_puts(&r, "json");
khtml_closeelem(&r, 1); // a
khtml_puts(&r, "]");
khtml_closeelem(&r, 3); // td, tr, table
{ // all
khtml_elem(&r, KELEM_TR);
khtml_elem(&r, KELEM_TD);
std::string pUrl = std::string(req->pname)+"/upgrades2";
khtml_puts(&r, "[");
khtml_attr(&r, KELEM_A, KATTR_HREF, pUrl.c_str(), KATTR__MAX);
khtml_puts(&r, "all");
khtml_closeelem(&r, 1); // a
khtml_puts(&r, "]");
khtml_closeelem(&r, 2); // td, tr
}
{ // hyperspace
khtml_elem(&r, KELEM_TR);
khtml_elem(&r, KELEM_TD);
std::string pUrl = std::string(req->pname)+"/upgrades2?restriction=hyperspace";
khtml_puts(&r, "[");
khtml_attr(&r, KELEM_A, KATTR_HREF, pUrl.c_str(), KATTR__MAX);
khtml_puts(&r, "hyperspace");
khtml_closeelem(&r, 1); // a
khtml_puts(&r, "]");
khtml_closeelem(&r, 2); // td, tr
}
{ // json
khtml_elem(&r, KELEM_TR);
khtml_elem(&r, KELEM_TD);
std::string pUrl = std::string(req->pname)+"/upgrades2?format=json";
khtml_puts(&r, "[");
khtml_attr(&r, KELEM_A, KATTR_HREF, pUrl.c_str(), KATTR__MAX);
khtml_puts(&r, "json");
khtml_closeelem(&r, 1); // a
khtml_puts(&r, "]");
khtml_closeelem(&r, 2); // td, tr
}
khtml_closeelem(&r, 1); // table
}
khtml_closeelem(&r, 1); // body
......@@ -335,6 +373,7 @@ void upgrades2(struct kreq *req) {
break;
}
}
upgrades[uc]["hyperspace"] = u.GetHyperspace() ? "Yes" : "No";
int sides = u.IsDualSided() ? 2 : 1;
for(int i=0; i<sides; i++) {
upgrades[uc]["side"][i]["title"] = u.GetTitle();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment