Esempio n. 1
0
        //-----------------------------------------------------------------

        public void CopmIntellBuyDealAction(int index, int val)
        {
            if (player[index].Money >= (int.Parse(ActivePriceBox.Text) + 200))
            {
                if (val <= 22)
                {
                    if ((stock[val - 1].Price + 300) < int.Parse(ActivePriceBox.Text))
                    {
                        MessageBox.Show("Нет, я вынужден отклонить ваше предложенние. Предложите лучшее условие!",
                                        "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        player[data.ActivePlayer].DeleteStock(val);
                        stock[val - 1].Owner             = (byte)(index + 1);
                        stock[val - 1].Buildings         = 0;
                        player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);
                        player[index].AddStock(stock[val - 1]);
                        player[index].Money -= int.Parse(ActivePriceBox.Text);
                        StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                        StocksListBoxAct.SelectedIndex = -1;
                        StocksListBoxAct.Update();
                        log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + stock[val - 1].Name + " игроку " +
                                   "" + player[index].Name + " за " + ActivePriceBox.Text + " АС");
                    }
                }
                else if (val >= 23 && val <= 26)
                {
                    if ((companie[val - 23].Price + 300) < int.Parse(ActivePriceBox.Text))
                    {
                        MessageBox.Show("Нет, я вынужден отклонить ваше предложенние. Предложите лучшее условие!",
                                        "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        player[data.ActivePlayer].DeleteStock(val);
                        companie[val - 23].Owner = (byte)(index + 1);
                        player[index].AddStock(companie[val - 23]);
                        player[index].Money -= int.Parse(ActivePriceBox.Text);

                        player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);

                        StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                        StocksListBoxAct.SelectedIndex = -1;
                        StocksListBoxAct.Update();
                        log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + companie[val - 23].Name + " игроку " +
                                   "" + player[index].Name + " за " + ActivePriceBox.Text + " АС");
                    }
                }
                else
                {
                    if ((tVRadioComp[val - 27].Price + 300) < int.Parse(ActivePriceBox.Text))
                    {
                        MessageBox.Show("Нет, я вынужден отклонить ваше предложенние. Предложите лучшее условие!",
                                        "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        player[data.ActivePlayer].DeleteStock(val);
                        tVRadioComp[val - 27].Owner      = (byte)(index + 1);
                        player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);
                        player[index].Money             -= int.Parse(ActivePriceBox.Text);
                        player[index].AddStock(tVRadioComp[val - 27]);

                        StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                        StocksListBoxAct.SelectedIndex = -1;
                        StocksListBoxAct.Update();
                        log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + tVRadioComp[val - 27].Name + " игроку " +
                                   "" + player[index].Name + " за " + ActivePriceBox.Text + " АС");
                    }
                }
            }
            else
            {
                MessageBox.Show("Нет, я вынужден отклонить ваше предложенние. Предложите лучшее условие!",
                                "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
        private void SellButton_Click(object sender, EventArgs e)
        {
            string s = StocksListBoxAct.SelectedItem.ToString();

            int value;

            int.TryParse(string.Join("", s.Where(c => char.IsDigit(c))), out value);

            if (ActivePriceBox.Text != "")
            {
                if (PlayerListBox.SelectedIndex == 0)
                {
                    DialogResult result = MessageBox.Show("Вы действительно собираетесь продать акцию за " + ActivePriceBox.Text
                                                          + "\n Игроку: " + player[indexone].Name, "Question",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);


                    if (result == DialogResult.Yes)
                    {
                        if (!player[indexone].CompORUser)
                        {
                            CopmIntellBuyDealAction(indexone, value);
                        }
                        else
                        {
                            if (player[indexone].Money >= int.Parse(ActivePriceBox.Text))
                            {
                                if (value <= 22)
                                {
                                    player[data.ActivePlayer].DeleteStock(value);
                                    stock[value - 1].Owner           = (byte)(indexone + 1);
                                    stock[value - 1].Buildings       = 0;
                                    player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);
                                    player[indexone].AddStock(stock[value - 1]);
                                    player[indexone].Money -= int.Parse(ActivePriceBox.Text);
                                    StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                                    StocksListBoxAct.SelectedIndex = -1;
                                    StocksListBoxAct.Update();
                                    log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + stock[value - 1].Name + " игроку " +
                                               "" + player[indexone].Name + " за " + ActivePriceBox.Text + " АС");
                                }
                                else if (value >= 23 && value <= 26)
                                {
                                    player[data.ActivePlayer].DeleteStock(value);
                                    companie[value - 23].Owner = (byte)(indexone + 1);
                                    player[indexone].AddStock(companie[value - 23]);
                                    player[indexone].Money -= int.Parse(ActivePriceBox.Text);

                                    player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);

                                    StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                                    StocksListBoxAct.SelectedIndex = -1;
                                    StocksListBoxAct.Update();
                                    log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + companie[value - 23].Name + " игроку " +
                                               "" + player[indexone].Name + " за " + ActivePriceBox.Text + " АС");
                                }
                                else
                                {
                                    player[data.ActivePlayer].DeleteStock(value);
                                    tVRadioComp[value - 27].Owner    = (byte)(indexone + 1);
                                    player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);
                                    player[indexone].Money          -= int.Parse(ActivePriceBox.Text);
                                    player[indexone].AddStock(tVRadioComp[value - 27]);

                                    StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                                    StocksListBoxAct.SelectedIndex = -1;
                                    StocksListBoxAct.Update();
                                    log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + tVRadioComp[value - 27].Name + " игроку " +
                                               "" + player[indexone].Name + " за " + ActivePriceBox.Text + " АС");
                                }
                            }
                            else
                            {
                                MessageBox.Show("У игрока не достаточно средств для покупки", "Information",
                                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
                else
                {
                    DialogResult result = MessageBox.Show("Вы действительно собираетесь продать акцию за " + ActivePriceBox.Text
                                                          + "\n Игроку: " + player[indextwo].Name, "Question",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (!player[indextwo].CompORUser)
                    {
                        CopmIntellBuyDealAction(indextwo, value);
                    }
                    else
                    {
                        if (result == DialogResult.Yes)
                        {
                            if (player[indextwo].Money >= int.Parse(ActivePriceBox.Text))
                            {
                                if (value <= 22)
                                {
                                    player[data.ActivePlayer].DeleteStock(value);
                                    stock[value - 1].Owner           = (byte)(indextwo + 1);
                                    stock[value - 1].Buildings       = 0;
                                    player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);
                                    player[indextwo].AddStock(stock[value - 1]);
                                    player[indextwo].Money -= int.Parse(ActivePriceBox.Text);
                                    StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                                    StocksListBoxAct.SelectedIndex = -1;
                                    StocksListBoxAct.Update();
                                    log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + stock[value - 1].Name + " игроку " +
                                               "" + player[indextwo].Name + " за " + ActivePriceBox.Text + " АС");
                                }
                                else if (value >= 23 && value <= 26)
                                {
                                    player[data.ActivePlayer].DeleteStock(value);
                                    companie[value - 23].Owner = (byte)(indextwo + 1);
                                    player[indextwo].AddStock(companie[value - 23]);
                                    player[indextwo].Money -= int.Parse(ActivePriceBox.Text);

                                    player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);

                                    StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                                    StocksListBoxAct.SelectedIndex = -1;
                                    StocksListBoxAct.Update();
                                    log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + companie[value - 23].Name + " игроку " +
                                               "" + player[indextwo].Name + " за " + ActivePriceBox.Text + " АС");
                                }
                                else
                                {
                                    player[data.ActivePlayer].DeleteStock(value);
                                    tVRadioComp[value - 27].Owner    = (byte)(indextwo + 1);
                                    player[data.ActivePlayer].Money += int.Parse(ActivePriceBox.Text);
                                    player[indextwo].Money          -= int.Parse(ActivePriceBox.Text);
                                    player[indextwo].AddStock(tVRadioComp[value - 27]);

                                    StocksListBoxAct.Items.RemoveAt(StocksListBoxAct.SelectedIndex);
                                    StocksListBoxAct.SelectedIndex = -1;
                                    StocksListBoxAct.Update();
                                    log.AddLog("Сделка:", player[data.ActivePlayer].Name + " продал " + tVRadioComp[value - 27].Name + " игроку " +
                                               "" + player[indextwo].Name + " за " + ActivePriceBox.Text + " АС");
                                }
                            }
                            else
                            {
                                MessageBox.Show("У игрока не достаточно средств для покупки", "Information",
                                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
                if (PlayerListBox.SelectedIndex == 0)
                {
                    StockListUpdate(indexone);
                }
                else
                {
                    StockListUpdate(indextwo);
                }
            }
            else
            {
                MessageBox.Show("Укажите пожалуйста сумму за которую вы хотите продать акцию", "Information",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }