public void StealDisplay() { HeightGen printHeight = new HeightGen(); if (VarStorage.Globals.changeType == 1) { VarStorage.Globals.textLine1 = VarStorage.Globals.mainName + " steals " + VarStorage.Globals.percentDelta + "% (" + printHeight.totalHeight(Convert.ToInt32(12 * VarStorage.Globals.changeDelta)) + ") from " + VarStorage.Globals.otherName + " causing them to swell up to " + printHeight.totalHeight(Convert.ToInt32(12 * VarStorage.Globals.mainFinalSize)) + "."; } else { VarStorage.Globals.textLine1 = VarStorage.Globals.mainName + " steals " + printHeight.totalHeight(Convert.ToInt32(12 * VarStorage.Globals.changeDelta)) + " from " + VarStorage.Globals.otherName + " causing them to swell up to " + printHeight.totalHeight(Convert.ToInt32(12 * VarStorage.Globals.mainFinalSize)) + "."; } VarStorage.Globals.textLine2 = VarStorage.Globals.mainName + " now appears " + printHeight.totalHeight(Convert.ToInt32(VarStorage.Globals.mainCompSize)) + " to the " + printHeight.totalHeight(Convert.ToInt32(12 * VarStorage.Globals.otherFinalSize)) + " tall " + VarStorage.Globals.otherName; VarStorage.Globals.textLine3 = VarStorage.Globals.otherName + " looks to be " + printHeight.totalHeight(Convert.ToInt32(VarStorage.Globals.otherCompSize)) + " tall to " + VarStorage.Globals.mainName + "."; }
public void ChangeSize() { //Create a random number gen and height gen CryptoRandom rnd = new CryptoRandom(); HeightGen conv = new HeightGen(); //set values on the first turn only. if (firstTurn == true) { VarStorage.Globals.player1Height = Convert.ToDouble(txtStartP1.Text); VarStorage.Globals.player2Height = Convert.ToDouble(txtStartP2.Text); firstTurn = false; } //Checks who's turn it is, then sets global variables. if (p1Turn == true) { VarStorage.Globals.mainName = txtP1Name.Text; VarStorage.Globals.otherName = txtP2Name.Text; VarStorage.Globals.mainSize = VarStorage.Globals.player1Height; VarStorage.Globals.otherSize = VarStorage.Globals.player2Height; } else { VarStorage.Globals.mainName = txtP2Name.Text; VarStorage.Globals.otherName = txtP1Name.Text; VarStorage.Globals.mainSize = VarStorage.Globals.player2Height; VarStorage.Globals.otherSize = VarStorage.Globals.player1Height; } //Rolls to see which change to make, then executes said change. int rNumber = rnd.Next(100) + 1; ChangeHandler theChange = new ChangeHandler(); if (rNumber >= 1 && rNumber <= 10) { VarStorage.Globals.rollType = 1; theChange.Changing(); } else if (rNumber >= 11 && rNumber <= 50) { VarStorage.Globals.rollType = 2; theChange.Changing(); } else if (rNumber >=51 && rNumber <= 60) { VarStorage.Globals.rollType = 3; theChange.Changing(); } else { VarStorage.Globals.rollType = 4; theChange.Changing(); } //Checks the turn and then sets the main height variables. if (p1Turn == true) { VarStorage.Globals.player1Height = VarStorage.Globals.mainFinalSize; VarStorage.Globals.player2Height = VarStorage.Globals.otherFinalSize; } else { VarStorage.Globals.player1Height = VarStorage.Globals.otherFinalSize; VarStorage.Globals.player2Height = VarStorage.Globals.mainFinalSize; } //Creates the text that is displayed in the main textbox. txtDisplay.Text += VarStorage.Globals.textLine1; txtDisplay.Text += Environment.NewLine; txtDisplay.Text += Environment.NewLine; //Finds closest object sizes. List<int> objects = new List<int> { 304800, 762000, 1828800, 7493000}; int relativeSize = Convert.ToInt32(VarStorage.Globals.mainFinalSize); string compObject = ""; /* if (VarStorage.Globals.player1Height >= VarStorage.Globals.player2Height) { relativeSize = Convert.ToInt32(VarStorage.Globals.player1Height * 12); } else { relativeSize = Convert.ToInt32(VarStorage.Globals.player2Height * 12); } */ double closest = objects.Aggregate((x, y) => Math.Abs(x - relativeSize) < Math.Abs(y - relativeSize) ? x : y); if (closest == 304800) { compObject = "Rabbit"; } else if (closest == 762000) { compObject = "Wolf"; } else if (closest == 1828800) { compObject = "SUV"; } //Creates text for the comparison textbox. VarStorage.Globals.textLine2 = VarStorage.Globals.mainName + " now appears " + conv.totalHeight(Convert.ToInt32(VarStorage.Globals.mainCompSize)) + " to the " + conv.totalHeight(Convert.ToInt32((VarStorage.Globals.otherFinalSize))) + " tall " + VarStorage.Globals.otherName; VarStorage.Globals.textLine3 = VarStorage.Globals.otherName + " looks to be " + conv.totalHeight(Convert.ToInt32(VarStorage.Globals.otherCompSize)) + " tall to " + VarStorage.Globals.mainName + "."; txtRecap.Text = VarStorage.Globals.textLine2; txtRecap.Text += Environment.NewLine; txtRecap.Text += VarStorage.Globals.textLine3; txtRecap.Text += Environment.NewLine; txtRecap.Text += "To " + VarStorage.Globals.mainName + ", the " + compObject + " looks to be " + conv.totalHeight(Convert.ToInt32((closest * 1828800) / Convert.ToInt32(VarStorage.Globals.mainFinalSize))); //Creates the VMS link. double p1in = VarStorage.Globals.player1Height; string p1HeightRounded = p1in.ToString("0"); double p2in = VarStorage.Globals.player2Height; string p2HeightRounded = p2in.ToString("0"); txtBFLink.Text = "http://vms.bigfurs.com/?chars=" + compObject + "+" + txtP1Name.Text + "[" + p1HeightRounded+ "um]+" + txtP2Name.Text + "[" + p2HeightRounded + "um]"; txtDisplay.SelectionStart = txtDisplay.Text.Length; //Set the current caret position at the end txtDisplay.ScrollToCaret(); //Now scroll it automatically //Set the Height text fields. txtSize1.Text = conv.totalHeight(Convert.ToInt32(VarStorage.Globals.player1Height)); txtSize2.Text = conv.totalHeight(Convert.ToInt32(VarStorage.Globals.player2Height)); }
public void Reader(string filePath) { var lineCount = 0; CryptoRandom rng = new CryptoRandom(); HeightGen format = new HeightGen(); using (var reader = File.OpenText(filePath)) { while (reader.ReadLine() != null) { lineCount++; } } int phrase = rng.Next(lineCount); string[] values = File.ReadAllText(filePath).Split(new string[] { Environment.NewLine }, StringSplitOptions.None); string outputString = values[phrase]; if (VarStorage.Globals.percentDelta != "") { outputString = outputString.Replace("mainName", VarStorage.Globals.mainName).Replace("otherName", VarStorage.Globals.otherName).Replace("mainSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.mainSize))).Replace("otherSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.otherSize))).Replace("mainFinalSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.mainFinalSize))).Replace("otherFinalSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.otherFinalSize))).Replace("changeDelta", format.totalHeight(Convert.ToInt32(VarStorage.Globals.changeDelta))).Replace("percentDelta", Convert.ToString(VarStorage.Globals.percentDelta) + "%").Replace("mainCompSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.mainCompSize))).Replace("otherCompSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.otherCompSize))); } else { outputString = outputString.Replace("mainName", VarStorage.Globals.mainName).Replace("otherName", VarStorage.Globals.otherName).Replace("mainSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.mainSize))).Replace("otherSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.otherSize))).Replace("mainFinalSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.mainFinalSize))).Replace("otherFinalSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.otherFinalSize))).Replace("(changeDelta)", format.totalHeight(Convert.ToInt32(VarStorage.Globals.changeDelta))).Replace("percentDelta", "").Replace("mainCompSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.mainCompSize))).Replace("otherCompSize", format.totalHeight(Convert.ToInt32(VarStorage.Globals.otherCompSize))); } VarStorage.Globals.textLine1 = outputString; }