Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
files/
*.json
3 changes: 0 additions & 3 deletions .gitignore/.gitignore

This file was deleted.

2,048 changes: 2,048 additions & 0 deletions These files are for the local mod/Yellow Machine.46ccee.lua

Large diffs are not rendered by default.

273 changes: 273 additions & 0 deletions These files are for the local mod/Yellow Storage.43ecc1.xml

Large diffs are not rendered by default.

93 changes: 5 additions & 88 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const file = new statik.Server('./site'),
pos += data[i].length;
} ;

if (postURL.pathname === "/format_and_store_army" || postURL.pathname === "/getFormattedArmy") {
if (postURL.pathname === "/getFormattedArmy") {
try {
let zip = new AdmZip(buf),
zipEntries = zip.getEntries();
Expand All @@ -121,31 +121,6 @@ const file = new statik.Server('./site'),
fs.writeFile("output.json", JSON.stringify(result.roster.forces, null, 4), () =>{})
//parseRos(result.roster.forces);
let armyDataObj = Roster.parse(result.roster.forces);

if (postURL.pathname === "/format_and_store_army") {
armyDataObj.uiHeight = postURL.searchParams.get('uiHeight');
armyDataObj.uiWidth = postURL.searchParams.get('uiWidth');
armyDataObj.baseScript = buildScript(postURL.searchParams.get("modules").split(","));

fs.writeFile(`${PATH_PREFIX}${uuid}.json`,
JSON.stringify(armyDataObj, replacer)
.replace(" & ", " and "),
(err) => {
let content,status;

if (!err) {
content = `{ "id": "${uuid}" }`;
status = 200;
}
else {
content = `{ "err": "${ERRORS.fileWrite}" }`;
status = 500
}

sendHTTPResponse(res, content, status);
});
}
else
sendHTTPResponse(res, JSON.stringify(armyDataObj, replacer), 200);
});
}
Expand Down Expand Up @@ -175,32 +150,7 @@ const file = new statik.Server('./site'),
postURL.searchParams.get('decorativeNames'),
buildScript(postURL.searchParams.get("modules").split(",")));

/* if (postURL.pathname === "/format_and_store_army") {
armyDataObj.uiHeight = postURL.searchParams.get('uiHeight');
armyDataObj.uiWidth = postURL.searchParams.get('uiWidth');
armyDataObj.baseScript = buildScript(postURL.searchParams.get("modules").split(","))

fs.writeFile(`${PATH_PREFIX}${uuid}.json`,
JSON.stringify(armyDataObj, replacer)
.replace(" & ", " and "),
(err) => {
let content,status;

if (!err) {
content = `{ "id": "${uuid}" }`;
status = 200;
}
else {
content = `{ "err": "${ERRORS.fileWrite}" }`;
status = 500
}

sendHTTPResponse(res, content, status);
});
}

else
sendHTTPResponse(res, JSON.stringify(armyDataObj, replacer).replace(" & ", " and "), 200); */
}
catch (err) {
sendHTTPResponse(res, `{ "err": "${ERRORS.unknown}" }`, 500);
Expand Down Expand Up @@ -282,8 +232,7 @@ setInterval(() => {
}
});

//let stats = fs.statSync("/dir/file.txt");
//let mtime = stats.mtime;

}, ONE_MINUTE);


Expand Down Expand Up @@ -368,12 +317,6 @@ function formatAndStoreXML(id, order, armyData, uiHeight, uiWidth, decorativeNam
.ele("VerticalLayout", { class: "unitContainer", childForceExpandHeight: "false", preferredHeight: unitData.height, spacing: "20" })
.import(unitData.fragment)

/* <VerticalLayout class="transparent" childForceExpandHeight="false">
<Text class="unitName">${unitName}</Text>
<VerticalLayout class="unitContainer" childForceExpandHeight="false" preferredHeight="${height}" spacing="20">
${unitData}
</VerticalLayout>
</VerticalLayout> */
}

storeFormattedXML(id, xml.end({ prettyPrint: false }).slice(27, -7), totalHeight, armyData, uiHeight, uiWidth, baseScript);
Expand All @@ -392,16 +335,7 @@ function getUnitXMLData(unit) {

return { fragment, height: maxHeight };

/* <HorizontalLayout class="groupingContainer">
<VerticalLayout preferredWidth="500" childForceExpandHeight="false" class="modelContainer" id="${unitID}|${modelID}" preferredHeight="${height}">
<Text class="modelDataName">${numberString}${modelName}</Text>
${weapons}
${abilities}
</VerticalLayout>
.
.
.
</HorizontalLayout>*/

}

function getModelXMLData(model, modelID, unit) {
Expand Down Expand Up @@ -435,19 +369,7 @@ function getModelXMLData(model, modelID, unit) {
container.att("preferredHeight", height);

return { fragment, height };
/* <VerticalLayout preferredWidth="500" childForceExpandHeight="false" class="modelContainer" id="${unitID}|${modelID}" preferredHeight="${height}">
<Text class="modelDataName">${numberString}${modelName}</Text>
<VerticalLayout childForceExpandHeight="false" childForceExpandWidth="false">
<Text height="15"><!-- spacer --></Text>
<Text class="modelDataTitle">${weapons?}</Text>
<Text class="modelData" preferredHeight="${height}">${data}</Text>
</VerticalLayout>
<VerticalLayout childForceExpandHeight="false" childForceExpandWidth="false">
<Text height="15"><!-- spacer --></Text>
<Text class="modelDataTitle">${abilities?}</Text>
<Text class="modelData" preferredHeight="${height}">${data}</Text>
</VerticalLayout>
</VerticalLayout> */

}

function getModelSectionData (name, dataList) {
Expand All @@ -462,12 +384,7 @@ function getModelSectionData (name, dataList) {

return { fragment, height };

/* <VerticalLayout childForceExpandHeight="false" childForceExpandWidth="false">
<Text height="15"><!-- spacer --></Text>
<Text class="modelDataTitle">${title}</Text>
<Text class="modelData" preferredHeight="${height}">${data}</Text>
</VerticalLayout>
*/

}

function combineAndSortWeapons(model, characteristicProfiles) {
Expand Down
14 changes: 10 additions & 4 deletions bin/Roster.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ module.exports.parse = (data) => {

return false;
});

for (let unitData of armyUnitData) {
let unit = new Unit(unitData.$.name, unitData.$.customName, unitData.$.type === "model");


if (data[0].force[0].rules) {
let forceRules = data[0].force[0].rules[0].rule;
for (let forceRule of forceRules) {
unit.addFormattedRule(forceRule);
};
}

unit.handleSelectionDataRecursive(unitData, null, true);

units.set(unit.uuid, unit.update());
}
}
Expand All @@ -30,6 +36,6 @@ module.exports.parse = (data) => {

for (const uuid of units.keys())
order.push(uuid);

return { units, order }
}
19 changes: 17 additions & 2 deletions bin/Unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = class Unit {
weapons = {};
//weapons = [];
rules = [];
formattedrules = {};
uuid = crypto.randomBytes(4).toString("hex");
unassignedWeapons = [];
pl = 0;
Expand Down Expand Up @@ -71,6 +72,16 @@ module.exports = class Unit {
desc: profileData.characteristics[0].characteristic[0]._.replace(/[\[\]"]/g, m => dangerousReplace[m])
};
}
addFormattedRule (rule) {
const trimmedName = rule.$.name.match(abilityTrimRegex).groups.ability,
dangerousReplace = { "[": "(", "]": ")", '"': '\\"' };

if (!this.formattedrules[trimmedName])
this.formattedrules[trimmedName] = {
name: trimmedName.replace(/[\[\]"]/g, m => dangerousReplace[m]),
desc: rule.description[0].replace(/[\[\]"]/g, m => dangerousReplace[m])
};
}

/**
* Adds the given data as an ability to the unit.
Expand All @@ -87,6 +98,8 @@ module.exports = class Unit {
};
}



addRule (ruleData) {
let trimmedName = ruleData.$.name.match(abilityTrimRegex).groups.ability;

Expand Down Expand Up @@ -352,8 +365,10 @@ module.exports = class Unit {
}

if (selectionData.rules && selectionData.rules[0] !== "")
for (const rule of selectionData.rules[0].rule)
this.addRule(rule);
for (const rule of selectionData.rules[0].rule){
this.addRule(rule)
this.addFormattedRule(rule)
};

if (selectionData.selections && selectionData.selections[0] !== "")
for (const selection of selectionData.selections[0].selection)
Expand Down
4 changes: 4 additions & 0 deletions lua_modules/DataCard_Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ local uiTemplates = {
<Cell><Text class="ym-resizingSmallBold">${name}</Text></Cell>
<Cell><Text class="ym-resizingText">${desc}</Text></Cell>
</Row>]],
formattedrules = [[<Row class="${rowParity}" preferredHeight="80">
<Cell><Text class="ym-resizingSmallBold">${name}</Text></Cell>
<Cell><Text class="ym-resizingText">${desc}</Text></Cell>
</Row>]],
models = [[ <Row class="${rowParity}" preferredHeight="60">
<Cell><Text class="ym-resizingSmallBold">${name}</Text></Cell>
<Cell><Text class="ym-smallText">${m}</Text></Cell>
Expand Down
4 changes: 2 additions & 2 deletions lua_modules/MatchedPlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ function onScriptingButtonDown(index, playerColor)
if isHoveringValidTarget then scriptingFunctions[index](playerColor, hoveredObject, player) end
end


function onObjectDrop(playerColor, droppedObject)
if not self.hasTag("leaderModel") then return end -- prevents firing on objects we don't want firing
if isCurrentlyCheckingCoherency and
Expand Down Expand Up @@ -423,7 +422,8 @@ function buildUI()
buildXMLForSection("abilities")
buildXMLForSection("models")
buildXMLForSection("weapons")

buildXMLForSection("formattedrules")

if unitData.psykerProfiles ~= nil then
buildXMLForSection("powersKnown")
buildXMLForSection("psykerProfiles")
Expand Down
4 changes: 4 additions & 0 deletions lua_modules/MatchedPlay_Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ local uiTemplates = {
<Cell><Text resizeTextForBestFit="true" resizeTextMinSize="6" resizeTextMaxSize="20" preferredHeight="20" fontStyle="Bold" alignment="MiddleCenter">${name}</Text></Cell>
<Cell><Text fontStyle="Normal" resizeTextForBestFit="true" resizeTextMinSize="6" resizeTextMaxSize="20" alignment="MiddleCenter">${desc}</Text></Cell>
</Row>]],
formattedrules = [[<Row color="${rowParity}" dontUseTableRowBackground="true" preferredHeight="250">
<Cell><Text resizeTextForBestFit="true" resizeTextMinSize="6" resizeTextMaxSize="20" preferredHeight="20" fontStyle="Bold" alignment="MiddleCenter">${name}</Text></Cell>
<Cell><Text fontStyle="Normal" fontSize="14" alignment="UpperLeft">${desc}</Text></Cell>
</Row>]],
models = [[ <Row color="${rowParity}" dontUseTableRowBackground="true" preferredHeight="60">
<Cell><Text resizeTextForBestFit="true" resizeTextMinSize="6" resizeTextMaxSize="20" preferredHeight="20" fontStyle="Bold" alignment="MiddleCenter">${name}</Text></Cell>
<Cell><Text fontStyle="Normal" fontSize="18" alignment="MiddleCenter">${m}</Text></Cell>
Expand Down
Loading