private void btnLoadRoleSet_Click(object sender, EventArgs e) { if (!saved) { if (MessageBox.Show("Do you want to save your progress before loading a new file?", "Save?", MessageBoxButtons.YesNo) == DialogResult.Yes) { SaveRoleSet(); } } // Show the dialog and get result. DialogResult result = openFileDialog.ShowDialog(); if (result == DialogResult.OK) // Test result. { string file = openFileDialog.FileName; try { RolePMSet temp = JsonConvert.DeserializeObject <RolePMSet>(File.ReadAllText(file)); resetRoleList(temp); } catch (JsonSerializationException error) { Console.WriteLine(error); MessageBox.Show("This isn't valid JSON!"); return; } saved = true; } }
private void resetRoleList(RolePMSet rolepmset) { dataRoles.Rows.Clear(); dataTeams.Rows.Clear(); rolepms = rolepmset; for (int i = 0; i < rolepms.Teams.Count(); i++) { dataTeams.Rows.Add(rolepms.Teams[i].Name, rolepms.Teams[i].WinCon, rolepms.Teams[i].Color, rolepms.Teams[i].Share, 0); } DataGridViewComboBoxColumn comboboxColumn = (DataGridViewComboBoxColumn)dataRoles.Columns[0]; DataGridViewComboBoxColumn roleColumn = (DataGridViewComboBoxColumn)dataRoles.Columns[1]; DataGridViewComboBoxColumn subRoleColumn = (DataGridViewComboBoxColumn)dataRoles.Columns[2]; comboboxColumn.DataSource = rolepms.Teams; comboboxColumn.DisplayMember = "Name"; comboboxColumn.ValueMember = "Self"; for (int i = 0; i < rolepms.Teams.Count; i++) { for (int j = 0; j < rolepms.Teams[i].Members.Count; j++) { if (!roleColumn.Items.Contains(rolepms.Teams[i].Members[j].Role) && rolepms.Teams[i].Members[j].Role.Length > 0) { roleColumn.Items.Add(rolepms.Teams[i].Members[j].Role); } if (!subRoleColumn.Items.Contains(rolepms.Teams[i].Members[j].SubRole) && rolepms.Teams[i].Members[j].SubRole.Length > 0) { subRoleColumn.Items.Add(rolepms.Teams[i].Members[j].SubRole); } dataRoles.Rows.Add(rolepms.Teams[i], rolepms.Teams[i].Members[j].Role, rolepms.Teams[i].Members[j].SubRole, rolepms.Teams[i].Members[j].Color, rolepms.Teams[i].Members[j].ExtraFlavor, rolepms.Teams[i].Members[j].Redacted, rolepms.Teams[i].Members[j].n0, "", rolepms.Teams[i].Members[j].Count); } } txtRoleSetName.Text = rolepms.Name; dataRoles_CellValueChanged(null, null); }
private void btnLoadRoleSetGame_Click(object sender, EventArgs e) { DialogResult result = openFileDialog.ShowDialog(); if (result == DialogResult.OK) // Test result. { string file = openFileDialog.FileName; List <String> rolestxt = new List <string>(); try { gamepms = JsonConvert.DeserializeObject <RolePMSet>(File.ReadAllText(file)); } catch (JsonSerializationException error) { Console.WriteLine(error); MessageBox.Show("This isn't valid JSON!"); return; } int playerCount = 0; txtRoleList.Text = ""; for (int i = 0; i < gamepms.Teams.Count; i++) { for (int j = 0; j < gamepms.Teams[i].Members.Count; j++) { string subrole = gamepms.Teams[i].Members[j].SubRole; if (gamepms.Teams[i].Members[j].SubRole != "") { subrole = gamepms.Teams[i].Members[j].SubRole + " "; } string team = gamepms.Teams[i].Name; if (gamepms.Teams[i].Name != "") { team = gamepms.Teams[i].Name + " "; } txtRoleList.Text += gamepms.Teams[i].Members[j].Count + "X " + team + subrole + gamepms.Teams[i].Members[j].Role + " with " + gamepms.Teams[i].Members[j].n0 + Environment.NewLine; playerCount += gamepms.Teams[i].Members[j].Count; } } for (int i = 0; i < gamepms.Teams.Count; i++) { Console.WriteLine(gamepms.Teams[i].Name + gamepms.Teams[i].Share); } txtRoleCount.Text = Convert.ToString(playerCount); if (Convert.ToInt16(txtRoleCount.Text) > 0 && roster.Count > 0 && roster.Count == Convert.ToInt16(txtRoleCount.Text)) { btnDoIt.Enabled = true; btnTest.Enabled = true; } else { btnDoIt.Enabled = false; btnTest.Enabled = false; } } }
private void boxRoleSetSelect_SelectedIndexChanged(object sender, EventArgs e) { ComboBox roleset = (ComboBox)sender; gamepms = JsonConvert.DeserializeObject <RolePMSet>(rolepms.DefaultRoleSets[roleset.Text]); int playerCount = 0; txtRoleList.Text = ""; for (int i = 0; i < gamepms.Teams.Count; i++) { for (int j = 0; j < gamepms.Teams[i].Members.Count; j++) { string subrole = gamepms.Teams[i].Members[j].SubRole; if (gamepms.Teams[i].Members[j].SubRole != "") { subrole = gamepms.Teams[i].Members[j].SubRole + " "; } string team = gamepms.Teams[i].Name; if (gamepms.Teams[i].Name != "") { team = gamepms.Teams[i].Name + " "; } txtRoleList.Text += gamepms.Teams[i].Members[j].Count + "X " + team + subrole + gamepms.Teams[i].Members[j].Role + " with " + gamepms.Teams[i].Members[j].n0 + Environment.NewLine; playerCount += gamepms.Teams[i].Members[j].Count; } } txtRoleCount.Text = Convert.ToString(playerCount); if (Convert.ToInt16(txtRoleCount.Text) > 0 && roster.Count > 0 && roster.Count == Convert.ToInt16(txtRoleCount.Text)) { btnDoIt.Enabled = true; btnTest.Enabled = true; } else { btnDoIt.Enabled = false; btnTest.Enabled = false; } }
public string FullPM(string gameURL, RolePMSet gamepms, Team team, string playername) { string peek = ""; string peektype = ""; if (n0 == "a random villager peek") { List <string> villagers = new List <string>(); for (int k = 0; k < gamepms.Teams.Count; k++) { for (int l = 0; l < gamepms.Teams[k].Members.Count; l++) { if (gamepms.Teams[k].Name == "Villager") { villagers.AddRange(gamepms.Teams[k].Members[l].Players); } } } villagers.Remove(playername); Random random = new Random(); int index = random.Next(villagers.Count); peek = villagers[index]; peektype = "villager"; } else if (n0 == "a random peek across entire playerlist") { Random random = new Random(); List <string> roster = new List <string>(); for (int k = 0; k < gamepms.Teams.Count; k++) { for (int l = 0; l < gamepms.Teams[k].Members.Count; l++) { roster.AddRange(gamepms.Teams[k].Members[l].Players); } } roster.Remove(playername); int index = random.Next(roster.Count); peek = roster[index]; peektype = "ERROR"; for (int k = 0; k < gamepms.Teams.Count; k++) { for (int l = 0; l < gamepms.Teams[k].Members.Count; l++) { for (int m = 0; m < gamepms.Teams[k].Members[l].Players.Count; m++) { if (gamepms.Teams[k].Members[l].Players[m] == peek) { peektype = gamepms.Teams[k].Name; } } } } } if (peek != "") { peek = String.Format("Your n0 random peek is {0}, {1}", peek, peektype); } string teammates = ""; if (team.Share == true) { teammates += "Your Team is:" + Environment.NewLine; for (int i = 0; i < team.Members.Count; i++) { for (int j = 0; j < team.Members[i].Count; j++) { teammates += team.Members[i].Players[j] + Environment.NewLine; } } } Console.WriteLine(teammates); string subrole = ""; if (SubRole != "") { subrole = SubRole + " "; } string role = ""; if (Role != "") { role = Role; } string teamname = ""; if (team.Name != "") { teamname = team.Name + " "; } string extraflavor = ""; if (ExtraFlavor != "") { extraflavor = ExtraFlavor + " "; } return(String.Format(@"************************************************* You are {0}on the {1} team. Your role is: {2}{3}! You win by {4}. You have {5}. {6}{7} The game thread is here: {8} Good luck! *************************************************", extraflavor, team.Name, subrole, role, team.WinCon, n0, teammates, peek, gameURL)); }