public GameForm(Mission mission) { InitializeComponent(); this.mission = mission; RefreshTitle(); this.missionNote.Text = mission.data.note; string content = FileReadWrite.ReadFile(mission.data.name); if (content != null) { this.codeText.Text = content; } else { this.codeText.Text = mission.data.code; } solutions = mission.data.solutions; viewer.SetMission(mission.data.number); viewer.GiveInputs(mission.data.inputs); renderArea.Paint += new PaintEventHandler(Painter); }
public static void SearchInEnabledMissions(string missionPassed) { if (!enabledMissions.Contains(missionPassed)) { FileReadWrite.AddToLoginFile(missionPassed); enabledMissions.Add(missionPassed); } }
private void run_Click(object sender, System.EventArgs e) { RefreshMission(); string content = this.codeText.Text.ToUpper(); string file = FileReadWrite.WriteFile(content, mission.data.name); CallInterpreter(file, mission.data.inputs); int[] outputs = interpreter.TakeOutputs(); debugOutputs = interpreter.TakeDebugOutputs(); if (UiManager.debugForm != null) { UiManager.debugForm.GetDebugOutputs(debugOutputs); } viewer.GiveOutputs(outputs); bool success = true; for (int i = 0; i < outputs.Length; i++) { if (outputs.Length != solutions.Length) { success = false; break; } if (outputs[i] != solutions[i]) { success = false; break; } } viewer.SetSuccess(success); viewer.Refresh(); if (success) { MissionForm.SearchInEnabledMissions(mission.data.number.ToString()); RefreshTitle(); } }
private void save_Click(object sender, System.EventArgs e) { string content = this.codeText.Text.ToUpper(); FileReadWrite.WriteFile(content, mission.data.name); }
private void start_Click(object sender, EventArgs e) { string id = idBox.Text.ToString(); string pw = pwBox.Text.ToString(); if (id.Length < 5) { MessageBox.Show("ID is too short", "ID Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (pw.Length < 5) { MessageBox.Show("PW is too short", "PW Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var condition = FileReadWrite.CheckLoginFile(id, pw); if (condition == FileReadWrite.FileCondition.DirectoryNotExist) { if (MessageBox.Show("Account could not find. " + "\nDo you want to create now?? " + "\nYour ID: " + id + " and your PW: " + pw, "No User Account", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { FileReadWrite.WriteLoginFile(new List <string> { id, pw, "0" }); } } else if (condition == FileReadWrite.FileCondition.FileNotExist) { if (MessageBox.Show("File could not find. Please check your save file. " + "\nOr Do you want to register?" + "\nYour ID: " + id + " and your PW: " + pw, "No User File", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { FileReadWrite.WriteLoginFile(new List <string> { id, pw, "0" }); } } else if (condition == FileReadWrite.FileCondition.FileExist) { List <string> read = FileReadWrite.ReadLoginFile(); if (HashGenerator.VerifyHash(read[0], id) && HashGenerator.VerifyHash(read[1], pw)) { MissionForm.enabledMissions = HashGenerator.TakeValues(read.GetRange(2, read.Count - 2)); UiManager.CreateMissionForm(); this.idBox.Text = ""; this.pwBox.Text = ""; } else { MessageBox.Show("Your password is wrong!!", "WRONG PASSWORD", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Something gone wrong.", "Unkown Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }