Advertisement
Guest User

Untitled

a guest
Sep 15th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.52 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6.  
  7.  
  8. struct Structures
  9.     {
  10.         int farms;
  11.         int subterraneanFarms;
  12.         int mines;
  13.         int forges;
  14.         int naturePreserves;
  15.         int stables;
  16.         int unicornPens;
  17.         int fisheries;
  18.         int fortresses;
  19.         int towns;
  20.         int graveyards;
  21.         int towers;
  22.     };
  23. struct Stocks
  24.     {
  25.         int food;
  26.         int wood;
  27.         int horses;
  28.         int coal;
  29.         int sulfur;
  30.         int ironOre;
  31.         int ironBars;
  32.         int ironWeapons;
  33.         int ironArmor;
  34.         int steelBars;
  35.         int steelWeapons;
  36.         int SteelArmor;
  37.         int rawMithril;
  38.         int mithrilBars;
  39.         int mithrilWeapons;
  40.         int mithrilArmor;
  41.         int unicorns;
  42.         int humanPopulation;
  43.         int elfPopulation;
  44.         int dwarfPopulation;
  45.         int koboldPopulation;
  46.         int hobbitPopulation;
  47.     };
  48. struct Technologies
  49. {
  50.     bool mining;
  51.     bool mithrilMining;
  52.     bool blastingCharges;
  53.     bool fieldAgriculture;
  54.     bool subterraneanFarming;
  55.     bool horseDomestication;
  56.     bool unicornDomestication;
  57.     bool preservation;
  58.     bool fishDomestication;
  59.     bool woodcutting;
  60.     bool smelting;
  61.     bool steelsmelting;
  62.     bool armoring;
  63.     bool weaponSmithing;
  64.     bool mithrilSmelting;
  65.     bool mithrilSmithing;
  66.     bool charcoalBurning;
  67.     bool theft;
  68.     bool masterTheft;
  69.     bool stealthManeuvering;
  70.     bool fortress;
  71.     bool wallConstruction;
  72.     bool sailing;
  73.     int researchPoints;
  74. };
  75. struct Population
  76. {
  77.     int population;
  78. };
  79. class Holdings
  80. {
  81. public:
  82.     Structures EmpireStructures;
  83.     Stocks EmpireStocks;
  84.     Technologies EmpireTechnologies;
  85.     Population EmpirePopulation;
  86.  
  87.     //takes data from EmpireHoldings.dat and assigns it to variables
  88.     int getHoldings(string strStartRead, string strEndRead)
  89.     {
  90.         int x;
  91.         ifstream fin("EmpireHoldings.dat");
  92.  
  93.         fin >> x;
  94.         EmpireStructures.farms = x; //updates structures with information from file
  95.         fin >> x;
  96.         EmpireStructures.fisheries = x;
  97.         fin >> x;
  98.         EmpireStructures.forges = x;
  99.         fin >> x;
  100.         EmpireStructures.fortresses = x;
  101.         fin >> x;
  102.         EmpireStructures.graveyards = x;
  103.         fin >> x;
  104.         EmpireStructures.mines = x;
  105.         fin >> x;
  106.         EmpireStructures.naturePreserves = x;
  107.         fin >> x;
  108.         EmpireStructures.stables = x;
  109.         fin >> x;
  110.         EmpireStructures.subterraneanFarms = x;
  111.         fin >> x;
  112.         EmpireStructures.towers = x;
  113.         fin >> x;
  114.         EmpireStructures.towns = x;
  115.         fin >> x;
  116.         EmpireStructures.unicornPens = x;
  117.         fin >> x;
  118.  
  119.         EmpireStocks.food = x; //updates stocks with information from file
  120.         fin >> x;
  121.         EmpireStocks.coal = x;
  122.         fin >> x;
  123.         EmpireStocks.ironArmor = x;
  124.         fin >> x;
  125.         EmpireStocks.ironBars = x;
  126.         fin >> x;
  127.         EmpireStocks.ironOre = x;
  128.         fin >> x;
  129.         EmpireStocks.ironWeapons = x;
  130.         fin >> x;
  131.         EmpireStocks.mithrilArmor = x;
  132.         fin >> x;
  133.         EmpireStocks.mithrilBars = x;
  134.         fin >> x;
  135.         EmpireStocks.mithrilWeapons = x;
  136.         fin >> x;
  137.         EmpireStocks.rawMithril = x;
  138.         fin >> x;
  139.         EmpireStocks.SteelArmor = x;
  140.         fin >> x;
  141.         EmpireStocks.steelBars = x;
  142.         fin >> x;
  143.         EmpireStocks.steelWeapons = x;
  144.         fin >> x;
  145.         EmpireStocks.sulfur = x;
  146.         fin >> x;
  147.         EmpireStocks.unicorns = x;
  148.         fin >> x;
  149.         EmpireStocks.wood = x;
  150.         fin >> x;
  151.         EmpireStocks.humanPopulation = x;
  152.         fin >> x;
  153.         EmpireStocks.elfPopulation = x;
  154.         fin >> x;
  155.         EmpireStocks.dwarfPopulation = x;
  156.         fin >> x;
  157.         EmpireStocks.hobbitPopulation = x;
  158.         fin >> x;
  159.         EmpireStocks.koboldPopulation = x;
  160.         // needs to save current position in the file
  161.  
  162.         string strY;
  163.         do
  164.         {
  165.             // needs to return to beginning of the file, then stop at strStartRead and end at EndRead
  166.             fin >> strY;
  167.             if (!strcmp (strY, "armoring"))
  168.                 EmpireTechnologies.armoring = 1;
  169.             if (strY == "blasting charges")
  170.                 EmpireTechnologies.blastingCharges = 1;
  171.             if (strY == "charcoal burning")
  172.                 EmpireTechnologies.charcoalBurning = 1;
  173.             if (strY == "field agriculture")
  174.                 EmpireTechnologies.fieldAgriculture = 1;
  175.             if (strY == "fish domestication")
  176.                 EmpireTechnologies.fishDomestication = 1;
  177.             if (strY == "fortress")
  178.                 EmpireTechnologies.fortress = 1;
  179.             if (strY == "horse domestication")
  180.                 EmpireTechnologies.horseDomestication = 1;
  181.             if (strY == "master theft")
  182.                 EmpireTechnologies.masterTheft = 1;
  183.             if (strY == "mining")
  184.                 EmpireTechnologies.mining = 1;
  185.             if (strY == "mithril mining")
  186.                 EmpireTechnologies.mithrilMining = 1;
  187.             if (strY == "mithril smelting")
  188.                 EmpireTechnologies.mithrilSmelting = 1;
  189.             if (strY == "mithril smithing")
  190.                 EmpireTechnologies.mithrilSmithing = 1;
  191.             if (strY == "preservation")
  192.                 EmpireTechnologies.preservation = 1;
  193.             if (strY == "sailing")
  194.                 EmpireTechnologies.sailing = 1;
  195.             if (strY == "smelting")
  196.                 EmpireTechnologies.smelting = 1;
  197.             if (strY == "stealth maneuvering")
  198.                 EmpireTechnologies.stealthManeuvering = 1;
  199.             if (strY == "steel smelting")
  200.                 EmpireTechnologies.steelsmelting = 1;
  201.             if (strY == "subterranean farming")
  202.                 EmpireTechnologies.subterraneanFarming = 1;
  203.             if (strY == "theft")
  204.                 EmpireTechnologies.theft = 1;
  205.             if (strY == "unicorn domestication")
  206.                 EmpireTechnologies.unicornDomestication = 1;
  207.             if (strY == "wall construction")
  208.                 EmpireTechnologies.wallConstruction = 1;
  209.             if (strY == "weapon smithing")
  210.                 EmpireTechnologies.weaponSmithing = 1;
  211.             if (strY == "woodcutting")
  212.                 EmpireTechnologies.woodcutting = 1;
  213.         }while (strY != strEndRead);
  214.  
  215.         //needs to return to saved position
  216.         fin >> x;
  217.         EmpireTechnologies.researchPoints = x;
  218.  
  219.         fin >> x;
  220.         EmpirePopulation.population = x;
  221.  
  222.         return 0;
  223.     }
  224.     //changes variables based on HFC Input.dat
  225.     int getInputs()
  226.     {
  227.         return 0;
  228.     }
  229.     //prints up-to-date data to EmpireHoldings.dat
  230.     int printHoldings()
  231.     {
  232.     return 0;
  233.     }
  234.  
  235. };
  236. int main()
  237. {
  238.     Holdings HumanHoldings("HumanEmpire", "endHuman");
  239.     Holdings KoboldHoldings ("KoboldEmpire", "endKobold");
  240.     Holdings DwarvenHoldings ("DwarvenEmpire", "endDwarven");
  241.     Holdings HobbitHoldings ("HobbitEmpire", "endHobbit");
  242.     Holdings ElvenHoldings ("ElvenEmpire", "endElven");
  243.     return 0;
  244. }
  245.  
  246. int printEverything(Structures structx, Stocks stocksx, Technologies technox, int populx)
  247. {
  248.     printStructures(structx);
  249.     printStocks(stocksx);
  250.     printTechnologies(technox);
  251.  
  252.     outf << "Population: " << populx << endl << endl;
  253.     return 0;
  254. }
  255. int printStructures(Structures x)
  256. {
  257.     outf << "Structures:" << endl;
  258.  
  259.         outf << "farms: " << x.farms << endl;
  260.         outf << "fisheries: " << x.fisheries << endl;
  261.         outf << "forges: " << x.forges << endl;
  262.         outf << "fortresses: " << x.fortresses << endl;
  263.         outf << "graveyards: " << x.graveyards << endl;
  264.         outf << "mines: " <<  x.mines << endl;
  265.         outf << "nature preserves: " << x.naturePreserves << endl;
  266.         outf << "stables: " << x.stables << endl;
  267.         outf << "subterranean farms: " <<  x.subterraneanFarms << endl;
  268.         outf << "towers: " << x.towers << endl;
  269.         outf << "towns: " << x.towns << endl;
  270.         outf << "unicorn pens: " << x.unicornPens << endl;
  271.  
  272.     outf << endl;
  273.  
  274.     return 0;
  275. }
  276. int printStocks(Stocks x)
  277. {
  278.     outf << "Stocks:" << endl;
  279.  
  280.         outf << "coal: " << x.coal << endl;
  281.         outf << "food: " << x.food << endl;
  282.         outf << "horses: " << x.horses << endl;
  283.         outf << "ironArmor: " << x.ironArmor << endl;
  284.         outf << "ironBars: " << x.ironBars << endl;
  285.         outf << "ironOre: " << x.ironOre << endl;
  286.         outf << "ironWeapons: " << x.ironWeapons << endl;
  287.         outf << "mithrilArmor: " << x.mithrilArmor << endl;
  288.         outf << "mithrilBars: " << x.mithrilBars << endl;
  289.         outf << "mithrilWeapons: " << x.mithrilWeapons << endl;
  290.         outf << "rawMithril: " << x.rawMithril << endl;
  291.         outf << "SteelArmor: " << x.SteelArmor << endl;
  292.         outf << "steelBars: " << x.steelBars << endl;
  293.         outf << "steelWeapons: " << x.steelWeapons << endl;
  294.         outf << "sulfur: " << x.sulfur << endl;
  295.         outf << "unicorns: " << x.unicorns << endl;
  296.         outf << "wood: " << x.wood << endl;
  297.         outf << "humans: " << x.humanPopulation << endl;
  298.         outf << "elves: " << x.elfPopulation << endl;
  299.         outf << "dwarves: " << x.dwarfPopulation << endl;
  300.         outf << "hobbits: " << x.hobbitPopulation << endl;
  301.         outf << "kobolds: " << x.koboldPopulation << endl;
  302.     outf << endl;
  303.     return 0;
  304. }
  305. int printTechnologies(Technologies x)
  306. {
  307.     outf << "Technologies:" << endl;
  308.  
  309.     if (x.armoring == 1)
  310.         outf << "armoring" << endl;
  311.     if (x.blastingCharges == 1)
  312.         outf << "blasting charges" << endl;
  313.     if (x.charcoalBurning == 1)
  314.         outf << "charcoal burning" << endl;
  315.     if (x.fieldAgriculture == 1)
  316.         outf << "field agriculture" << endl;
  317.     if (x.fishDomestication == 1)
  318.         outf << "fish domestication" << endl;
  319.     if (x.fortress == 1)
  320.         outf << "fortress" << endl;
  321.     if (x.horseDomestication == 1)
  322.         outf << "horse domestication" << endl;
  323.     if (x.masterTheft == 1)
  324.         outf << "master theft" << endl;
  325.     if (x.mining == 1)
  326.         outf << "mining" << endl;
  327.     if (x.mithrilMining == 1)
  328.         outf << "mithril mining" << endl;
  329.     if (x.mithrilSmelting == 1)
  330.         outf << "mithril smelting" << endl;
  331.     if (x.mithrilSmithing == 1)
  332.         outf << "mithril smithing" << endl;
  333.     if (x.preservation == 1)
  334.         outf << "preservation" << endl;
  335.     if (x.sailing == 1)
  336.         outf << "sailing" << endl;
  337.     if (x.smelting == 1)
  338.         outf << "smelting" << endl;
  339.     if (x.stealthManeuvering == 1)
  340.         outf << "stealth maneuvering" << endl;
  341.     if (x.steelsmelting == 1)
  342.         outf << "steel smelting" << endl;
  343.     if (x.subterraneanFarming == 1)
  344.         outf << "subterranean farming" << endl;
  345.     if (x.theft == 1)
  346.         outf << "theft" << endl;
  347.     if (x.unicornDomestication == 1)
  348.         outf << "unicorn domestication" << endl;
  349.     if (x.wallConstruction == 1)
  350.         outf << "wall construction" << endl;
  351.     if (x.weaponSmithing == 1)
  352.         outf << "weapon smithing" << endl;
  353.     if (x.woodcutting == 1)
  354.         outf << "woodcutting" << endl;
  355.     outf << "research points: " << x.researchPoints << endl;
  356.     outf << endl;
  357.     return 0;
  358. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement