public StatsCompiler(Vote[] votes) { //sanatize votes for(int i = 0;i<votes.Length;i++) { Vote v=null; if (votes[i] != null) v = votes[i]; if (v == null || v.getPlayers() == null || v.getKilledVictims() == null || v.getSavedVictims() == null) //we got a bad vote { votes[i] = new Vote(new List<Victim>(), new List<Victim>(), -1, new PlayerClass[0]); } } //should be ok with abstains now.... Debug.Log ("number of votes received by the StatsCompiler is "+votes.Where (x => x != null).Count()); //Gender female = new Characteristic("female", "gender"); male = new Characteristic("male", "gender"); gender = new Characteristic[] { female, male }; //Animal cat = new Characteristic("cat", "animal"); dog = new Characteristic("dog", "animal"); chupacabra = new Characteristic("chupacabra", "animal"); deer = new Characteristic("deer", "animal"); spacecat = new Characteristic("space cat", "animal"); animal = new Characteristic[] { cat, dog, chupacabra, deer, spacecat }; //Race latinohispanic = new Characteristic ("latino/hispanic", "race"); chinese = new Characteristic ("chinese", "race"); filipino = new Characteristic("filipino", "race"); indian = new Characteristic("indian", "race"); vietnamese = new Characteristic("vietnamese", "race"); korean = new Characteristic("korean", "race"); japanese = new Characteristic("japanese" , "race"); arab = new Characteristic("arab", "race"); black = new Characteristic("black", "race"); white = new Characteristic("white", "race"); nativeamerican = new Characteristic("native american", "race"); race = new Characteristic[] { latinohispanic, chinese, filipino, indian, vietnamese, korean, japanese, arab, black, white, nativeamerican }; //Occupation author = new Characteristic("author", "occupation"); actor = new Characteristic("actor", "occupation"); arsonist = new Characteristic("arsonist", "occupation"); barista = new Characteristic("barista", "occupation"); commoncriminal = new Characteristic("common criminal", "occupation"); crazycathoarder = new Characteristic("crazy cat-hoarder", "occupation"); cattamer = new Characteristic("cat tamer", "occupation"); doctor = new Characteristic("doctor", "occupation"); dj = new Characteristic("DJ", "occupation"); debtcollector = new Characteristic("debt collector", "occupation"); faithhealer = new Characteristic("faith healer", "occupation"); fosterparent = new Characteristic("foster parent", "occupation"); gardener = new Characteristic("gardener", "occupation"); murder = new Characteristic("murderer", "occupation"); miner = new Characteristic("miner", "occupation"); musician = new Characteristic("musician", "occupation"); refugee = new Characteristic("refugee", "occupation"); roofer = new Characteristic("roofer", "occupation"); plumber = new Characteristic("plumber", "occupation"); pediatrician = new Characteristic("pediatrician", "occupation"); politician = new Characteristic("politician", "occupation"); pedophile = new Characteristic("pedophile", "occupation"); professor = new Characteristic("professor", "occupation"); policeofficer = new Characteristic("police officer", "occupation"); playboybunny = new Characteristic("playboy bunny", "occupation"); pimp = new Characteristic("pimp", "occupation"); prostitute = new Characteristic("prostitute", "occupation"); scientist = new Characteristic("scientist", "occupation"); stuntman = new Characteristic("stuntman", "occupation"); salesperson = new Characteristic("salesperson", "occupation"); stalker = new Characteristic("stalker", "occupation"); teacher = new Characteristic("teacher", "occupation"); trolleydriver = new Characteristic("trolley driver", "occupation"); tailor = new Characteristic("tailor", "occupation"); taxevader = new Characteristic("taxevader", "occupation"); preciousbaby = new Characteristic("precious baby", "occupation"); child = new Characteristic("child", "occupation"); angstyteenager = new Characteristic("angsty teenager", "occupation"); occupation = new Characteristic[] {author, actor, arsonist, barista, commoncriminal, crazycathoarder, cattamer, doctor, dj, debtcollector, faithhealer, fosterparent, gardener, murder, miner, musician, refugee, roofer, plumber, pediatrician, politician, pedophile, professor, policeofficer,playboybunny, pimp, prostitute, scientist, stuntman, stalker, teacher, trolleydriver, tailor, taxevader, preciousbaby, child, angstyteenager }; //Age zero = new Characteristic("0-9", "age"); ten = new Characteristic("10-19", "age"); twenty = new Characteristic("20-29", "age"); thirty = new Characteristic("30-39", "age"); fourty = new Characteristic("40-49", "age"); fifty = new Characteristic("50-59", "age"); sixty = new Characteristic("60-69", "age"); seventy = new Characteristic("70-79", "age"); eighty = new Characteristic("80-89", "age"); ninety = new Characteristic("90-100", "age"); age = new Characteristic[] { zero, ten, twenty, thirty, fourty, fifty, sixty, seventy, eighty, ninety }; //Affiliation PETA = new Characteristic("PETA", "affiliation"); AARP = new Characteristic("AARP", "affiliation"); NAACP = new Characteristic("NAACP", "affiliation"); ALG = new Characteristic("ALG", "affiliation"); CI = new Characteristic("CI", "affiliation"); EA = new Characteristic("EA", "affiliation"); NAS = new Characteristic("NAS", "affiliation"); FRAC = new Characteristic("FRAC", "affiliation"); NAMBLA = new Characteristic("NAMBLA", "affiliation"); affiliation = new Characteristic[] { PETA, AARP, NAACP, ALG, CI, EA, NAS, FRAC, NAMBLA }; update = new List<Characteristic>(); for (int i = 0; i < votes.Length; i++) { if (votes[i]!=null&&votes[i].getKilledVictims() != null && votes[i].getSavedVictims() != null) { killedVictims = votes[i].getKilledVictims().ToArray(); savedVictims = votes[i].getSavedVictims().ToArray(); //Since killedVictims and savedVictims are the same size //will go through them simultanously to save time for (int j = 0; j < killedVictims.Length; j++) { //Gender for (int k = 0; k < gender.Length; k++) { if (killedVictims[j].getGender() == gender[k].getType()) { gender[k].setKilled(); } if (savedVictims[k].getGender() == gender[k].getType()) { gender[k].setSaved(); } } //Age if (savedVictims[j].getIntAge() < 10) { zero.setSaved(); } else if (savedVictims[j].getIntAge() < 20) { ten.setSaved(); } else if (savedVictims[j].getIntAge() < 30) { twenty.setSaved(); } else if (savedVictims[j].getIntAge() < 40) { thirty.setSaved(); } else if (savedVictims[j].getIntAge() < 50) { fourty.setSaved(); } else if (savedVictims[j].getIntAge() < 60) { fifty.setSaved(); } else if (savedVictims[j].getIntAge() < 70) { sixty.setSaved(); } else if (savedVictims[j].getIntAge() < 80) { seventy.setSaved(); } else if (savedVictims[j].getIntAge() < 90) { eighty.setSaved(); } else { ninety.setSaved(); } if (killedVictims[j].getIntAge() < 10) { zero.setKilled(); } else if (killedVictims[j].getIntAge() < 20) { ten.setKilled(); } else if (killedVictims[j].getIntAge() < 30) { twenty.setKilled(); } else if (killedVictims[j].getIntAge() < 40) { thirty.setKilled(); } else if (killedVictims[j].getIntAge() < 50) { fourty.setKilled(); } else if (killedVictims[j].getIntAge() < 60) { fifty.setKilled(); } else if (killedVictims[j].getIntAge() < 70) { sixty.setKilled(); } else if (killedVictims[j].getIntAge() < 80) { seventy.setKilled(); } else if (killedVictims[j].getIntAge() < 90) { eighty.setKilled(); } else { ninety.setKilled(); } //Killed Animal if (!killedVictims[j].isPerson()) { for (int k = 0; k < animal.Length; k++) { if (killedVictims[j].getSpecies() == animal[k].getType()) { animal[k].setKilled(); } } } else { //Killed Race for (int k = 0; k < race.Length; k++) { if (killedVictims[j].getRace() == race[k].getType()) { race[k].setKilled(); } } //Killed Occupation for (int k = 0; k < occupation.Length; k++) { if (killedVictims[j].getOccupation() == occupation[k].getType()) { occupation[k].setKilled(); } } } //Saved Animal if (!savedVictims[j].isPerson()) { for (int k = 0; k < animal.Length; k++) { if (savedVictims[j].getSpecies() == animal[k].getType()) { animal[k].setSaved(); } } } else { //Saved Race for (int k = 0; k < race.Length; k++) { if (savedVictims[j].getRace() == race[k].getType()) { race[k].setSaved(); } } //Saved Occupation for (int k = 0; k < occupation.Length; k++) { if (savedVictims[j].getOccupation() == occupation[k].getType()) { occupation[k].setSaved(); } } } } } } for (int i =0; i<votes[0].getPlayers().Length; i++) { Debug.Log ("outer loop: "+i+" "+votes[0].ToString()+" "+votes[0].getPlayers().ToString()+" "+votes[0].getPlayers().Length); for (int j =0; j < affiliation.Length; j++) { Debug.Log ("inner loop: "+j+" "+affiliation[j].getType()+" "+votes[0].getPlayers()[i].ToString()+" "+votes[0].getPlayers()[i].getAffiliation()); if(votes[0].getPlayers()[i].getAffiliation() == affiliation[j].getType()) { for (int k =0; k < votes[0].getPlayers()[i].getVotesForAffiliation().Length; k++) { if (votes[0].getPlayers()[i].getVotesForAffiliation()[k] == 0) { affiliation[j].setSaved(); } else { affiliation[j].setKilled(); } } } } } for(int i =0; i < age.Length; i++) { if (age[i].getChanged()) { update.Add(age[i]); } } for (int i = 0; i < animal.Length; i++) { if (animal[i].getChanged()) { update.Add(animal[i]); } } for (int i = 0; i < gender.Length; i++) { if (gender[i].getChanged()) { update.Add(gender[i]); } } for (int i = 0; i < occupation.Length; i++) { if (occupation[i].getChanged()) { update.Add(occupation[i]); } } for (int i = 0; i < affiliation.Length; i++) { if (affiliation[i].getChanged()) { update.Add(affiliation[i]); } } for (int i = 0; i < race.Length; i++) { if (race[i].getChanged()) { update.Add(race[i]); } } }