Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to working version #29

Merged
merged 2 commits into from
Nov 18, 2022
Merged
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
26 changes: 14 additions & 12 deletions JSON_Converter/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ let convertVehicle = async(team, mapName) => {
// Attempt to Map the SDK name to a map. If the name/displayname is invalid throw an error.
let conVehicleName = vehicleMap[`${vehicle.rawType}_Name`]
if(conVehicleName === undefined) {
throw(`${vehicle.rawType} is not in the Map file... (Name Invalid or Non Existant) Team: ${team.faction} | MapName: ${mapName}`)
throw(`${vehicle.rawType} vehicle is not in the Map file... (Name Invalid or Non Existant) Team: ${team.faction} | MapName: ${mapName}`)
}
log2(`------${conVehicleName}`)

let conVehicleDisplayName = vehicleMap[`${vehicle.rawType}_DisplayName`]
if(conVehicleDisplayName === undefined) {
throw(`${vehicle.rawType} is not in the Map file... (Display Name Invalid or Non Existant) Team: ${team.faction} | MapName: ${mapName}`)
throw(`${vehicle.rawType} vehicle is not in the Map file... (Display Name Invalid or Non Existant) Team: ${team.faction} | MapName: ${mapName}`)
}
log2(`--------${conVehicleDisplayName}`)

Expand Down Expand Up @@ -128,7 +128,7 @@ const main = async() => {
conMaps.Maps = []
log('Preparing to loop through each Setup....')

console.log(inputJson.Setups)

await asyncForEach(inputJson.Setups, async (setup) => {
let blacklisted = false
await asyncForEach(setupBlacklist.blacklist, async (black) => {
Expand All @@ -138,7 +138,7 @@ const main = async() => {
if(blacklisted) return

let confactionSetup = factionMap[setup.faction]
if(confactionSetup === undefined) throw(`${setup.faction} is not in the map file (${setup.setup_Name})`)
if(confactionSetup === undefined) throw(`${setup.faction} setup is not in the map file (${setup.setup_Name})`)

let setupObject = {}
conVeh = await convertVehicle(setup,setup.setup_Name)
Expand Down Expand Up @@ -173,7 +173,7 @@ const main = async() => {
let conteam2Veh = []
if(confaction1 === undefined) {
if(layer.team1.allowedAlliances === undefined) {
throw(`${layer.team1.faction} is not in the Map file... (${layer.Name})`)
throw(`${layer.team1.faction} team is not in the Map file... (${layer.Name})`)
}
else {
confaction1 = layer.team1.allowedAlliances.join(" or ")
Expand Down Expand Up @@ -208,14 +208,15 @@ const main = async() => {
}
else {
// Vehicle Conversion
conteam1Veh = await convertVehicle(layer.team1, layer.Name)
if (layer.team1.vehicles == undefined) conteam1Veh = ""
else conteam1Veh = await convertVehicle(layer.team1, layer.Name)
}
log2(`---${confaction1}`)


if(confaction2 === undefined) {
if(layer.team2.allowedAlliances === undefined) {
throw(`${layer.team2.faction} is not in the Map file... (${layer.Name})`)
throw(`${layer.team2.faction} team is not in the Map file... (${layer.Name})`)
}
else {
confaction2 = layer.team2.allowedAlliances.join(" or ")
Expand Down Expand Up @@ -250,7 +251,8 @@ const main = async() => {
}
else {
// Vehicle Conversion
conteam2Veh = await convertVehicle(layer.team2,layer.Name)
if (layer.team2.vehicles == undefined) conteam2Veh = ""
else conteam2Veh = await convertVehicle(layer.team2, layer.Name)
}
log2(`---${confaction2}`)

Expand Down Expand Up @@ -282,18 +284,18 @@ const main = async() => {
fs.writeFileSync(`./files/output/debug/ConvertedJson_${mainconfig.version}.json`, JSON.stringify(conMaps, null, 4))

await asyncForEach(conMaps.Maps, async(layer) => {
let combteam1Veh = await combinevehicles(layer.team1)
if (layer.team1.vehicles == undefined || layer.team1.vehicles == "") combteam1Veh = ""
else combteam1Veh = await combinevehicles(layer.team1)

let combteam2Veh = await combinevehicles(layer.team2)
if (layer.team2.vehicles == undefined || layer.team1.vehicles == "") combteam2Veh = ""
else combteam2Veh = await combinevehicles(layer.team2)

conMaps.Maps[conMaps.Maps.indexOf(layer)].team1.vehicles = combteam1Veh
conMaps.Maps[conMaps.Maps.indexOf(layer)].team2.vehicles = combteam2Veh
})

fs.writeFileSync('./files/output/ConvertedJsonCombined.json', JSON.stringify(conMaps, null, 4))
fs.writeFileSync('./files/temp/ConvertedJsonCombined.json', JSON.stringify(conMaps, null, 4))
console.log(numOfVeh)
console.log(numOfVehComb)
}

main()
132 changes: 132 additions & 0 deletions JSON_Converter/toSpreadsheet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
const inputJson = require('../files/temp/finished.json')
const async = require(`async`)
const gamemodes = require('../files/config/gamemodes.json')

const fs = require("fs");
require.extensions['.txt'] = function (module, filename) {
module.exports = fs.readFileSync(filename, 'utf8');
};

async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}

let loop = async() => {
let string = ""
let string2 = ""
let currentMap = ""
await asyncForEach(inputJson.Maps, async(layer) => {

let gamemodeinfo = await findGamemode(layer.Name)


let mapPage = layer.mapName
let layerVersion = layer.Name.substring(gamemodeinfo.location + gamemodeinfo.gamemode.length + 1)
let randomFactions = false
if(currentMap !== mapPage){
string += `\n`
currentMap = mapPage
}
else {
mapPage = ""
}
if(layer.team1.faction == ""){
randomFactions = true
if(layer.team1.factionSetups == undefined) layer.team1.factionSetups = [""]
layer.team1.faction = `(${layer.team1.factionSetups.join("|")}) ${layer.team1.allowedAlliances.join(" ")}`
}
if(layer.team2.faction == ""){
randomFactions = true
if(layer.team2.factionSetups == undefined) layer.team2.factionSetups = [""]
layer.team2.faction = `(${layer.team2.factionSetups.join("|")}) ${layer.team2.allowedAlliances.join(" ")}`
}
string += `${mapPage},${gamemodeinfo.gamemode} ${layerVersion}, ${layer.rawName}, ${layer.mapSize}, ${layer.lighting}, ${layer.team1.commander}, ${layer.capturePoints}, ${layer.type}, ${randomFactions}, ${layer.team1.faction}, ${layer.team2.faction}, ${layer.team1.tickets}, ${layer.team2.tickets}, \n`


let currentGamemode = ""
let currentFaction = ""
let temp = currentMap
if(layer.team1.vehicles == undefined){
string2 += `${mapPage}, ${gamemodeinfo.gamemode} ${layerVersion}, ${layer.team1.faction}\n`
}
else {
await asyncForEach(layer.team1.vehicles, async(vehicle) =>{
combined = `${gamemodeinfo.gamemode} ${layerVersion}`
if(currentGamemode !== combined){
string2 += `\n`
currentGamemode = combined
}
else {
combined = ""
}

if(currentFaction !== layer.team1.faction){
currentFaction = layer.team1.faction
}
else {
layer.team1.faction = ""
}
string2 += ` ${temp}, ${combined}, ${layer.team1.faction}, ${vehicle.type}, ${vehicle.count}, ${vehicle.delay}, ${vehicle.respawnTime}\n`
temp = ""
return
})
}
if(layer.team2.vehicles == undefined){
string2 += `${mapPage}, ${gamemodeinfo.gamemode} ${layerVersion}, ${layer.team2.faction}\n`
}
else {
let combined = ""
await asyncForEach(layer.team2.vehicles, async(vehicle) =>{
combined = `${gamemodeinfo.gamemode} ${layerVersion}`
if(currentGamemode !== combined){
string2 += `\n`
currentGamemode = combined
}
else {
combined = ""
}

if(currentFaction !== layer.team2.faction){
currentFaction = layer.team2.faction
}
else {
layer.team2.faction = ""
}
string2 += ` ${temp}, ${combined}, ${layer.team2.faction}, ${vehicle.type}, ${vehicle.count}, ${vehicle.delay}, ${vehicle.respawnTime}\n`
return
})

}

return
});

console.log(string)
fs.writeFileSync('.files/output/LayerSheet.csv',string)
fs.writeFileSync('.files/output/Vehicles.csv',string2)
}


const findGamemode = async(text) => {
let location = -1

let i = 0
// Try to find the location of the gamemode in the map name string. Looping through each gamemode to search for each one.

for(i = 0; i < gamemodes.Gamemodes.length; i++){
location = text.indexOf(gamemodes.Gamemodes[i])
if (location != -1) break;
}

// If we couldn't find the gamemode throw and error and stop here.
if(location == -1) throw("Couldn't find a gamemode for: " + text);

return {
location: location,
gamemode: gamemodes.Gamemodes[i]
}
}

loop()
Binary file modified SDK/MapGrabAssets.uasset
Binary file not shown.
2 changes: 1 addition & 1 deletion files/config/main.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.15",
"version": "3.0",
"caf": false
}
Loading