private void button1_Click(object sender, EventArgs e) { Random rnd = new Random(); kosti = rnd.Next(2, 13); renta = TVRadioComp.GetRenta(tmp, kosti); if (data.TVCompServise == true) { renta *= 2; } button1.Text = kosti.ToString(); MessageBox.Show(player[data.ActivePlayer].Name + "! Вам необходимо заплатить ренту игроку " + player[indexOw].Name + " в " + "размере " + renta + " АС"); player[indexOw].Money += renta; player[data.ActivePlayer].Money -= renta; Close(); }
public TvCompForm(TVRadioComp tVRadioComp, Player[] player, TVRadioComp[] tVRadioComps, int index, LogForm logForm) { InitializeComponent(); TVRadio = tVRadioComp; TVRadios = tVRadioComps; players = player; log = logForm; indexComp = index; if (!players[data.ActivePlayer].CompORUser) { ComputerIntellTVRadioLocation(); } else { CloseButton.Enabled = false; if (tVRadioComp.Owner == 4) { TvCompBox.Image = GetImage(TVRadio.ImageIndex + 30); } else { TvCompBox.Image = GetImage(TVRadio.ImageIndex); } if (TVRadio.Owner == 0) { tmpstring = "Владельца нет"; } else if (TVRadio.Owner == 4) { tmpstring = "Заложенно"; } else { tmpstring = players[TVRadio.Owner - 1].Name; } UserNameLabel.Text = tmpstring; if (TVRadio.Owner == 0) { tmpstring = "Владельца нет"; BuyLayButton.Enabled = true; CanselSaleButton.Enabled = true; } else if (TVRadio.Owner == 4) { BuyLayButton.Enabled = false; CanselSaleButton.Enabled = true; } else { BuyLayButton.Enabled = false; CanselSaleButton.Enabled = false; switch (TVRadio.Owner) { case 1: if (data.ActivePlayer != TVRadio.Owner - 1) { if (index == 0) { if (tVRadioComps[1].Owner == 1) { TvCompanyPay companyPay = new TvCompanyPay(players, true, 0); companyPay.ShowDialog(); CloseButton.Enabled = true; } else { TvCompanyPay companyPay = new TvCompanyPay(players, false, 0); companyPay.ShowDialog(); CloseButton.Enabled = true; } } else { if (tVRadioComps[0].Owner == 1) { TvCompanyPay companyPay = new TvCompanyPay(players, true, 0); companyPay.ShowDialog(); CloseButton.Enabled = true; } else { TvCompanyPay companyPay = new TvCompanyPay(players, false, 0); companyPay.ShowDialog(); CloseButton.Enabled = true; } } } else { MessageBox.Show("Это ваша компания", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); CloseButton.Enabled = true; } break; case 2: if (data.ActivePlayer != TVRadio.Owner - 1) { if (index == 0) { if (tVRadioComps[1].Owner == 2) { TvCompanyPay companyPay = new TvCompanyPay(players, true, 1); companyPay.ShowDialog(); CloseButton.Enabled = true; } else { TvCompanyPay companyPay = new TvCompanyPay(players, false, 1); companyPay.ShowDialog(); CloseButton.Enabled = true; } } else { if (tVRadioComps[0].Owner == 2) { TvCompanyPay companyPay = new TvCompanyPay(players, true, 1); companyPay.ShowDialog(); CloseButton.Enabled = true; } else { TvCompanyPay companyPay = new TvCompanyPay(players, false, 1); companyPay.ShowDialog(); CloseButton.Enabled = true; } } } else { MessageBox.Show("Это ваша компания", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); CloseButton.Enabled = true; } break; case 3: if (data.ActivePlayer != TVRadio.Owner - 1) { if (index == 0) { if (tVRadioComps[1].Owner == 3) { TvCompanyPay companyPay = new TvCompanyPay(players, true, 2); companyPay.ShowDialog(); CloseButton.Enabled = true; } else { TvCompanyPay companyPay = new TvCompanyPay(players, false, 2); companyPay.ShowDialog(); CloseButton.Enabled = true; } } else { if (tVRadioComps[0].Owner == 3) { TvCompanyPay companyPay = new TvCompanyPay(players, true, 2); companyPay.ShowDialog(); CloseButton.Enabled = true; } else { TvCompanyPay companyPay = new TvCompanyPay(players, false, 2); companyPay.ShowDialog(); CloseButton.Enabled = true; } } } else { MessageBox.Show("Это ваша компания", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); CloseButton.Enabled = true; } break; } } ShowDialog(); } }
public void PayRent() { int kosti; int renta; Random rnd = new Random(); kosti = rnd.Next(2, 13); switch (TVRadio.Owner) { case 1: if (indexComp == 0) { if (TVRadios[1].Owner == 1) { renta = TVRadioComp.GetRenta(true, kosti); if (data.TVCompServise == true) { renta *= 2; } players[0].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[0].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } else { renta = TVRadioComp.GetRenta(false, kosti); if (data.TVCompServise == true) { renta *= 2; } players[0].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[0].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } } else { if (TVRadios[0].Owner == 1) { renta = TVRadioComp.GetRenta(true, kosti); if (data.TVCompServise == true) { renta *= 2; } players[0].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[0].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } else { renta = TVRadioComp.GetRenta(false, kosti); if (data.TVCompServise == true) { renta *= 2; } players[0].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[0].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } } break; case 2: if (indexComp == 0) { if (TVRadios[1].Owner == 2) { renta = TVRadioComp.GetRenta(true, kosti); if (data.TVCompServise == true) { renta *= 2; } players[1].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[1].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } else { renta = TVRadioComp.GetRenta(false, kosti); if (data.TVCompServise == true) { renta *= 2; } players[1].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[1].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } } else { if (TVRadios[0].Owner == 2) { renta = TVRadioComp.GetRenta(true, kosti); if (data.TVCompServise == true) { renta *= 2; } players[1].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[1].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } else { renta = TVRadioComp.GetRenta(false, kosti); if (data.TVCompServise == true) { renta *= 2; } players[1].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[1].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } } break; case 3: if (indexComp == 0) { if (TVRadios[1].Owner == 3) { renta = TVRadioComp.GetRenta(true, kosti); if (data.TVCompServise == true) { renta *= 2; } players[2].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[2].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } else { renta = TVRadioComp.GetRenta(false, kosti); if (data.TVCompServise == true) { renta *= 2; } players[2].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[2].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } } else { if (TVRadios[0].Owner == 3) { renta = TVRadioComp.GetRenta(true, kosti); if (data.TVCompServise == true) { renta *= 2; } players[2].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[2].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } else { renta = TVRadioComp.GetRenta(false, kosti); if (data.TVCompServise == true) { renta *= 2; } players[2].Money += renta; players[data.ActivePlayer].Money -= renta; log.AddLog(players[data.ActivePlayer], "Платит аренду " + players[2].Name + " за " + "посещение " + TVRadio.Name + " сумму в размере " + renta + " АС"); } } break; } }