//--------------------------------------------------------------------------------------- public void ComputerIntellSellDealAction(int index, int val) { int cost; if (MayCompSellAction(index, val)) { if (val <= 22) { cost = stock[val - 1].Price + 400; DialogResult result = MessageBox.Show("Эту акцию могу продать за " + cost + " АС. Вы согласны?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (player[data.ActivePlayer].Money >= cost) { player[index].DeleteStock(val); stock[val - 1].Owner = (byte)(data.ActivePlayer + 1); stock[val - 1].Buildings = 0; player[data.ActivePlayer].Money -= cost; player[data.ActivePlayer].AddStock(stock[val - 1]); player[index].Money += cost; StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } else { MessageBox.Show("У вас недостаточно средств", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else if (val >= 23 && val <= 26) { cost = companie[val - 23].Price + 350; DialogResult result = MessageBox.Show("Эту акцию могу продать за " + cost + " АС. Вы согласны?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (player[data.ActivePlayer].Money >= cost) { player[index].DeleteStock(val); companie[val - 23].Owner = (byte)(data.ActivePlayer + 1); player[data.ActivePlayer].AddStock(companie[val - 23]); player[data.ActivePlayer].Money -= cost; player[index].Money += cost; StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } else { MessageBox.Show("У вас недостаточно средств", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { cost = tVRadioComp[val - 27].Price + 280; DialogResult result = MessageBox.Show("Эту акцию могу продать за " + cost + " АС. Вы согласны?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (player[data.ActivePlayer].Money >= cost) { player[index].DeleteStock(val); tVRadioComp[val - 27].Owner = (byte)(data.ActivePlayer + 1); player[data.ActivePlayer].Money -= cost; player[index].Money += cost; player[data.ActivePlayer].AddStock(tVRadioComp[val - 27]); StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } else { MessageBox.Show("У вас недостаточно средств", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } else { MessageBox.Show("Извините, но я не продам эту акцию не за какие деньги.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void BayButton_Click(object sender, EventArgs e) { string s = StockListBox.SelectedItem.ToString(); int value; int.TryParse(string.Join("", s.Where(c => char.IsDigit(c))), out value); if (PlayerListBox.SelectedIndex == 0) { if (!player[indexone].CompORUser) { ComputerIntellSellDealAction(indexone, value); } else { if (BayTextBox.Text != "") { DialogResult result = MessageBox.Show("Вы действительно собираетесь купить акцию за " + BayTextBox.Text + "\n У игрока: " + player[indexone].Name, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (player[data.ActivePlayer].Money >= int.Parse(BayTextBox.Text)) { if (value <= 22) { player[indexone].DeleteStock(value); stock[value - 1].Owner = (byte)(data.ActivePlayer + 1); stock[value - 1].Buildings = 0; player[data.ActivePlayer].Money -= int.Parse(BayTextBox.Text); player[data.ActivePlayer].AddStock(stock[value - 1]); player[indexone].Money += int.Parse(BayTextBox.Text); StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } else if (value >= 23 && value <= 26) { player[indexone].DeleteStock(value); companie[value - 23].Owner = (byte)(data.ActivePlayer + 1); player[data.ActivePlayer].AddStock(companie[value - 23]); player[data.ActivePlayer].Money -= int.Parse(BayTextBox.Text); player[indexone].Money += int.Parse(BayTextBox.Text); StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } else { player[indexone].DeleteStock(value); tVRadioComp[value - 27].Owner = (byte)(data.ActivePlayer + 1); player[data.ActivePlayer].Money -= int.Parse(BayTextBox.Text); player[indexone].Money += int.Parse(BayTextBox.Text); player[data.ActivePlayer].AddStock(tVRadioComp[value - 27]); StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } } else { MessageBox.Show("У игрока не достаточно средств для покупки", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("Укажите пожалуйста сумму за которую вы хотите продать акцию", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { if (!player[indextwo].CompORUser) { ComputerIntellSellDealAction(indexone, value); } else { if (BayTextBox.Text != "") { DialogResult result = MessageBox.Show("Вы действительно собираетесь купить акцию за " + BayTextBox.Text + "\n У игрока: " + player[indextwo].Name, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (player[data.ActivePlayer].Money >= int.Parse(BayTextBox.Text)) { if (value <= 22) { player[indextwo].DeleteStock(value); stock[value - 1].Owner = (byte)(data.ActivePlayer + 1); stock[value - 1].Buildings = 0; player[data.ActivePlayer].Money -= int.Parse(BayTextBox.Text); player[data.ActivePlayer].AddStock(stock[value - 1]); player[indextwo].Money += int.Parse(BayTextBox.Text); StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } else if (value >= 23 && value <= 26) { player[indextwo].DeleteStock(value); companie[value - 23].Owner = (byte)(data.ActivePlayer + 1); player[data.ActivePlayer].AddStock(companie[value - 23]); player[data.ActivePlayer].Money -= int.Parse(BayTextBox.Text); player[indextwo].Money += int.Parse(BayTextBox.Text); StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } else { player[indextwo].DeleteStock(value); tVRadioComp[value - 27].Owner = (byte)(data.ActivePlayer + 1); player[data.ActivePlayer].Money -= int.Parse(BayTextBox.Text); player[indextwo].Money += int.Parse(BayTextBox.Text); player[data.ActivePlayer].AddStock(tVRadioComp[value - 27]); StockListBox.Items.RemoveAt(StockListBox.SelectedIndex); StockListBox.SelectedIndex = -1; StockListBox.Update(); } } else { MessageBox.Show("У вас не достаточно средств для покупки", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("Укажите пожалуйста сумму за которую вы хотите продать акцию", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } StocksListBoxAct.Items.Clear(); for (int i = 0; i < player[data.ActivePlayer].Stocks.Length; i++) { for (int j = 0; j < stock.Length; j++) { if (stock[j].StockNumber == player[data.ActivePlayer].Stocks[i].StockNumber) { StocksListBoxAct.Items.Add(stock[j].Name + " " + stock[j].StockNumber.ToString()); } ; } } for (int i = 0; i < player[data.ActivePlayer].companies.Length; i++) { for (int k = 0; k < companie.Length; k++) { if (companie[k].StockNumber == player[data.ActivePlayer].companies[i].StockNumber) { StocksListBoxAct.Items.Add(companie[k].Name + " " + companie[k].StockNumber.ToString()); } } } for (int i = 0; i < player[data.ActivePlayer].tVRadioComps.Length; i++) { for (int z = 0; z < tVRadioComp.Length; z++) { if (tVRadioComp[z].StockNumber == player[data.ActivePlayer].tVRadioComps[i].StockNumber) { StocksListBoxAct.Items.Add(tVRadioComp[z].Name + " " + tVRadioComp[z].StockNumber.ToString()); } } } }