private static bool ConfirmData(string Name, Race race, Stats stats) { string Ans; while (true) { Console.WriteLine("Name: {0}", Name); Console.WriteLine("Race: {0}", StringModify.FirstToUpper(race.race)); Console.WriteLine("Strength: {0}", stats.Strength); Console.WriteLine("Ability: {0}", stats.Ability); Console.WriteLine("Resistance: {0}", stats.Resistance); Console.WriteLine("Armor: {0}", stats.Armor); Console.WriteLine("Firepower: {0}\n", stats.Firepower); Console.WriteLine("Done?"); Console.WriteLine("1. Yes"); Console.WriteLine("2. No"); Ans = Console.ReadLine(); Ans = YesNoInput.Parse(Ans); if (Ans.Equals("yes")) { return(true); } else if (Ans.Equals("no")) { return(false); } else { Console.Clear(); Console.WriteLine("Invalid command\n"); } } }
//答案區 private void Guess_btu_Click(object sender, EventArgs e) { if (textBox4.Text == "") { return; } if (listBox1.SelectedIndex < 0) { if (Ans.Equals(textBox4.Text)) { user_scro += this.progressBar1.Value / 10; Send("M" + Netname + ": Hit"); Send("S" + Netname + ":" + user_scro + "分"); textBox4.Enabled = false; Guess_btu.Enabled = false; SoundPlayer sound = new SoundPlayer { SoundLocation = Application.StartupPath + @"//Ans.wav" }; sound.Play(); } else { Send("M" + Netname + ":" + textBox4.Text); } } textBox4.Text = ""; }
//聊天室chat private void Chat_btu_Click(object sender, EventArgs e) { if (textBox3.Text == "") { return; } if (listBox1.SelectedIndex < 0) { if (Ans.Equals(textBox3.Text)) { Send("D" + " 系統 : 禁止傳解答!!"); } else { Send("D" + Netname + ":" + textBox3.Text); } } else { string[] str = listBox1.Text.Split(':'); Send("3" + "來自" + Netname + ": " + textBox3.Text + "|" + str[0]); textBox1.Text += "私密" + str[0] + ": " + textBox3.Text + "\r\n"; } textBox3.Text = ""; //清除發言框 }
//答案區 private void MetroButton2_Click(object sender, EventArgs e) { if (TextBox8.Text == "") { return; } if (listBox1.SelectedIndex < 0) { if (Ans.Equals(TextBox8.Text)) { Send("M" + User + ": Hit"); user_scro += this.metroProgressBar1.Value / 3; Send("S" + User + ":" + user_scro); } else { Send("M" + User + ":" + TextBox8.Text); } } TextBox8.Text = ""; }
//聊天室 private void MetroButton1_Click(object sender, EventArgs e) { if (TextBox6.Text == "") { return; } if (listBox1.SelectedIndex < 0) { if (Ans.Equals(TextBox6.Text)) { Send("D" + " 系統 : 禁止傳解答!!"); } else { Send("D" + User + ":" + TextBox6.Text); } } else { Send("3" + "來自" + User + ": " + TextBox6.Text + "|" + listBox1.SelectedItem); TextBox5.Text += "私密" + listBox1.SelectedItem + ": " + TextBox6.Text + "\r\n"; } TextBox6.Text = ""; //清除發言框 }
public static Stats ChooseStats() { int MaxPoints = 7; int RemainingPoints = MaxPoints; int Step = 0; string State = "", CurTop; string Num, Ans; int Strength = 0, Ability = 0, Resistance = 0, Armor = 0, Firepower = 0; Console.Clear(); CurTop = "It is now time for you to determine the numbers of your characteristics.\nYou have a total of 7 points to spend on 5 different characteristics.\n\n"; CurTop += Descriptor.Strength; while (true) { Console.Clear(); CharacterCreator.PrintState(State, CurTop, RemainingPoints); if (Step == 0) { Console.Write("Strength: "); Num = Console.ReadLine(); if (Num.Equals("") || !CharacterCreator.IsNum(Num) || Int32.Parse(Num) > RemainingPoints) { Console.Clear(); CurTop = "Invalid value"; } else { int Value = Int32.Parse(Num); Step++; State += "Strength: " + Num + "\n"; Strength = Value; RemainingPoints -= Value; CurTop = Descriptor.Ability; } } else if (Step == 1) { Console.Write("Ability: "); Num = Console.ReadLine(); if (Num.Equals("") || !CharacterCreator.IsNum(Num) || Int32.Parse(Num) > RemainingPoints) { Console.Clear(); CurTop = "Invalid value"; } else { int Value = Int32.Parse(Num); Step++; State += "Ability: " + Num + "\n"; Ability = Value; RemainingPoints -= Value; CurTop = Descriptor.Resistance; } } else if (Step == 2) { Console.Write("Resistance: "); Num = Console.ReadLine(); if (Num.Equals("") || !CharacterCreator.IsNum(Num) || Int32.Parse(Num) > RemainingPoints) { Console.Clear(); CurTop = "Invalid value"; } else { int Value = Int32.Parse(Num); Step++; State += "Resistance: " + Num + "\n"; Resistance = Value; RemainingPoints -= Value; CurTop = Descriptor.Armor; } } else if (Step == 3) { Console.Write("Armor: "); Num = Console.ReadLine(); if (Num.Equals("") || !CharacterCreator.IsNum(Num) || Int32.Parse(Num) > RemainingPoints) { Console.Clear(); CurTop = "Invalid value"; } else { int Value = Int32.Parse(Num); Step++; State += "Armor: " + Num + "\n"; Armor = Value; RemainingPoints -= Value; CurTop = Descriptor.Firepower; } } else if (Step == 4) { Console.Write("Firepower: "); Num = Console.ReadLine(); if (Num.Equals("") || !CharacterCreator.IsNum(Num) || Int32.Parse(Num) > RemainingPoints) { Console.Clear(); CurTop = "Invalid value"; } else { int Value = Int32.Parse(Num); Step++; State += "Firepower: " + Num + "\n"; Firepower = Value; RemainingPoints -= Value; } } else if (Step == 5) { if (RemainingPoints > 0) { Console.WriteLine("\nYou still have {0} unspent point{1}", RemainingPoints, (RemainingPoints > 1 ? "s" : "")); while (true) { Console.WriteLine("Do you wish to reset your points?"); Console.WriteLine("1. Yes"); Console.WriteLine("2. No"); Ans = Console.ReadLine(); Ans = YesNoInput.Parse(Ans); if (Ans.Equals("yes")) { RemainingPoints = MaxPoints; Step = 0; State = ""; break; } else if (Ans.Equals("no")) { return(new Stats(Strength, Firepower, Resistance, Armor, Ability)); } else { Console.WriteLine("Invalid command\n"); } } } else { return(new Stats(Strength, Firepower, Resistance, Armor, Ability)); } } } }
public int SetSaveSlot() { string Num; int Value = 0; string Data = ""; Console.Clear(); while (true) { Console.WriteLine("Which slot do you want to save in? (Type ENTER on empty slot to return)"); for (int i = 1; i <= this.SlotsNum; i++) { string SlotFile = String.Join("", "./GameData/Save/slot", i, ".sav"); Console.Write("> {0}", i); if (!File.Exists(SlotFile)) { Console.Write(" - Empty\n"); } else { if (LoadSlotData(i, ref Data)) { Console.Write(" - {0}\n", Data); } else { Console.Write(" - Empty\n"); } } } Num = Console.ReadLine(); if (Num.Equals("")) { return(-1); } try { Value = Int32.Parse(Num); } catch (FormatException) { Console.Clear(); Console.WriteLine("Invalid slot number\n"); continue; } if (Value < 1 || Value > 20) { Console.Clear(); Console.WriteLine("Invalid slot number\n"); continue; } if (this.SlotState[Value].Equals("empty")) { this.SlotState[Value] = "full"; this.CurrentSlot = Value; return(Value); } else { Console.Clear(); string Ans; while (true) { Console.WriteLine("This slot is already full"); Console.WriteLine("Do you wish to overwrite it?"); Console.WriteLine("1. Yes"); Console.WriteLine("2. No"); Ans = Console.ReadLine(); Ans = YesNoInput.Parse(Ans); if (Ans.Equals("yes")) { this.SlotState[Value] = "full"; this.CurrentSlot = Value; return(Value); } else if (Ans.Equals("no")) { Console.Clear(); break; } else { Console.Clear(); Console.WriteLine("Invalid command\n"); } } } } }