private void SortBuildsButton_Click(object sender, EventArgs e) { Excel excel = OpenFileAt(11); int totalBuilds = excel.ReadCellInt(1, 15); //amount of builds num string[,] planets = new string[totalBuilds, 8]; Console.WriteLine(planets.GetLength(0) + " " + planets.GetLength(1)); for (int i = 1; i <= planets.GetLength(0); i++) //establish the array { bool tempBools = false; //Console.WriteLine(i); planets[i - 1, 0] = excel.ReadCellString(i, 2); planets[i - 1, 1] = excel.ReadCellString(i, 3); planets[i - 1, 2] = excel.ReadCellString(i, 4); tempBools = excel.ReadCellBool(i, 5); planets[i - 1, 3] = tempBools.ToString(); tempBools = excel.ReadCellBool(i, 6); planets[i - 1, 4] = tempBools.ToString(); tempBools = excel.ReadCellBool(i, 7); planets[i - 1, 5] = tempBools.ToString(); tempBools = excel.ReadCellBool(i, 8); planets[i - 1, 6] = tempBools.ToString(); int tempInt = excel.ReadCellInt(i, 9); planets[i - 1, 7] = tempInt.ToString(); } //Clearer.ClearBuildList(excel); Coordinates origin; origin = Algorithms.GetCoordinates("(0,0)"); ColonyInfo[] colInfo = Algorithms.SortPlanetsByXAndY(planets, origin, Algorithms.GetCoordinates(planets[totalBuilds - 1, 0])); //get the sorted array Clearer.ClearBuildList(excel); Console.WriteLine("This algorithm is bad its making tons of duplicates"); /* * for (int i = 0; i < planets.GetLength(0); i++) * { * for (int j = 0; j < planets.GetLength(0); j++) * { * Coordinates oldList = Algorithms.GetCoordinates(planets[j, 0]); * if ((colInfo[i].coords.x == oldList.x) && (colInfo[i].coords.y == oldList.y)) * { * //Console.WriteLine(planets[i, 0] + " "); * Adder.AddToBuilds(excel, planets[j, 0], planets[j, 1], planets[j, 2], planets[j, 3], planets[j, 4], planets[j, 5], planets[j, 6], planets[j, 7]); * } * } * } */ excel.Close(); MessageBox.Show("Build List Sorted by System", "Completed"); }
/// <summary> /// OBSOLETE USE REPLACER.REPLACEPLANET /// </summary> /// <param name="sheet"></param> /// <param name="planetName"></param> public static void AddPlanet(int sheet, string planetName) { Excel excel = OpenFileAt(sheet); int planet = excel.ReadCellInt(1, 8); //read p Tally int temp = planet + 1; //get it ot the next row excel.WriteToCell(temp, 1, temp.ToString()); //updates the number next to the cell excel.WriteToCell(temp, 2, planetName); //put the planet in the box if (excel.ReadCellInt(1, 8) < temp) { excel.WriteToCell(1, 8, temp.ToString()); //updates the planet number } //MessageBox.Show(planetName + " added to row " + temp + " sheet " + sheet, "Completed"); excel.Close(); }
public static void AddToZounds(string colony, Excel excel) { int zoundsCount = excel.ReadCellInt(2, 8); zoundsCount++; //if it's 0 don't put it in the 0 slot excel.WriteToCell(zoundsCount, 4, zoundsCount.ToString()); // this is the 1 2 3 4 excel.WriteToCell(zoundsCount, 5, colony); //put colony in here // int temp = zoundsCount + 1; Console.WriteLine(colony + " added to Zounds to cell [F," + temp + "]"); excel.WriteToCell(2, 8, zoundsCount.ToString());// changes the total zounds }
private void LowMetalButton_Click(object sender, EventArgs e) { for (int j = 2; j <= 10; j++) // goes through each sheet { Excel excel = OpenFileAt(j); int planet = (int)excel.ReadCellDouble(1, 8); for (int i = 1; i <= planet; i++) // goes through the planet list { if (excel.ReadCellInt(i, 26) <= 5000) { } } } }
public static void AddToBuilds(Excel excel, string coordinates, string planetName, string colonyName, string zoundsable, string medium, string questionable, string deconstruct, string research) { int totalBuilds = excel.ReadCellInt(1, 15); totalBuilds += 1; excel.WriteToCell(1, 15, totalBuilds.ToString()); excel.WriteToCell(totalBuilds, 1, totalBuilds.ToString()); excel.WriteToCell(totalBuilds, 2, coordinates); excel.WriteToCell(totalBuilds, 3, planetName); excel.WriteToCell(totalBuilds, 4, colonyName); excel.WriteToCell(totalBuilds, 5, zoundsable); excel.WriteToCell(totalBuilds, 6, medium); excel.WriteToCell(totalBuilds, 7, questionable); excel.WriteToCell(totalBuilds, 8, deconstruct); excel.WriteToCell(totalBuilds, 9, research); }
public static string BuildZoundsDestroy(string colonyInfo, bool resources, bool defended) { Excel excel = OpenFileAt(11); // build list StringReader reader = new StringReader(colonyInfo); string line; string planetType = null; string coordinates = null; // C string planetName = null; // D string colonyName = null; // E string discoveries = null; // K int research = -1; // J bool[] buildableHolder = new bool[4]; bool zoundsable = false; bool medium = false; bool questionable = false; bool deconstruct = false;// F , G, H, I buildableHolder[0] = zoundsable; buildableHolder[1] = medium; buildableHolder[2] = questionable; buildableHolder[3] = deconstruct; for (int i = 0; i < colonyInfo.Length; i++) { line = reader.ReadLine(); if (line != null) { if (i == 0) { colonyName = line; Console.WriteLine(line); } else if (i == 3) { string[] temp = line.Split(':'); planetType = temp[1]; planetType = RemoveSpaces(planetType); } else if (i == 4) { string[] temp = line.Split(':'); temp = temp[1].Split('('); planetName = temp[0]; coordinates = temp[1]; coordinates = "(" + coordinates; } else if (i == 40) { string[] temp = line.Split('/'); temp[0] = RemoveLetters(temp[0]); temp[0] = RemoveParenthesisColonComma(temp[0]); research = int.Parse(temp[0]); } else if (i >= 41) { discoveries = discoveries + '\n' + line; } } } bool noDuplicate = true; for (int i = 1; i <= excel.ReadCellInt(1, 15); i++) { if (planetName.Equals(excel.ReadCellString(i, 3))) { noDuplicate = false; excel.Close(); return("Duplicate Found"); } } if (research >= 1 && noDuplicate) { buildableHolder = Checkers.Buildable(discoveries, planetType); zoundsable = buildableHolder[0]; medium = buildableHolder[1]; questionable = buildableHolder[2]; deconstruct = buildableHolder[3]; int totalBuilds = excel.ReadCellInt(1, 15); totalBuilds += 1; Console.WriteLine(totalBuilds); //excel.WriteToCell(1, 15, totalBuilds.ToString()); //excel.WriteToCell(totalBuilds, 1, totalBuilds.ToString()); excel.WriteToCell(totalBuilds, 2, coordinates); excel.WriteToCell(totalBuilds, 3, planetName); excel.WriteToCell(totalBuilds, 4, colonyName); excel.WriteToCell(totalBuilds, 5, zoundsable.ToString()); excel.WriteToCell(totalBuilds, 6, medium.ToString()); excel.WriteToCell(totalBuilds, 7, questionable.ToString()); excel.WriteToCell(totalBuilds, 8, deconstruct.ToString()); excel.WriteToCell(totalBuilds, 9, research.ToString()); excel.WriteToCell(totalBuilds, 10, resources.ToString()); excel.WriteToCell(totalBuilds, 11, defended.ToString()); excel.Close(); return("build added"); } else { Console.WriteLine(colonyName + " is Not Finished Researching."); excel.Close(); return(colonyName + " is Not Finished Researching."); } }