Exemple #1
0
        public void TakeTurn(Piece piece)
        {
            Square oldLoc = piece.getLocation();

            diceValue = rollDice();
            Square newLoc = board.getSquare(piece.getLocation(), diceValue);

            piece.setLocation(newLoc);
            if (newLoc.sell < oldLoc.sell)
            {
                PassedGo();
            }
            if (newLoc.sell == 4)
            {
                Spend(400m); return;
            }
            if (newLoc.sell == 38)
            {
                Spend(100m); return;
            }
            if (newLoc.sell == 30)
            {
                GoToJail(piece);
                return;
            }
            if (newLoc.sell == 10 || newLoc.sell == 20 || newLoc.sell == 0)
            {
                return;
            }
            if (newLoc.sell == 2 || newLoc.sell == 7 || newLoc.sell == 17 || newLoc.sell == 22 || newLoc.sell == 33 || newLoc.sell == 36)
            {
                TakeAChance(); return;
            }
            if (!own.Contains(newLoc.sell))
            {
                if (board.owned.Contains(newLoc.sell))
                {
                    Spend(newLoc.rent); GivenMoney = newLoc.rent; return;
                }
                if (!board.owned.Contains(newLoc.sell))
                {
                    if (AbleToSpend(newLoc.Cost))
                    {
                        own.Add(newLoc.sell); Spend(newLoc.Cost); board.owned.Add(newLoc.sell); added = newLoc.name;
                        PlayersStreets.Enqueue(newLoc);
                        if (newLoc.color != null)
                        {
                            if (districts.ContainsKey(newLoc.color))
                            {
                                districts[newLoc.color] += 1;
                            }
                            else
                            {
                                districts.Add(newLoc.color, 1);
                            }
                        }
                    }
                    return;
                }
                if (newLoc.color != null)
                {
                    if (newLoc.company == false && newLoc.amountOfFileals < 4 && ((districts[newLoc.color] == 2 && (newLoc.color == "brown") || (newLoc.color == "dark blue")) || (districts[newLoc.color] == 3 && (newLoc.color != "brown" || newLoc.color != "dark blue"))))
                    {
                        newLoc = new Filial(newLoc);
                        newLoc.amountOfFileals++;
                    }
                    else
                    {
                        if (newLoc.company == false && (districts[newLoc.color] == 2 && (newLoc.color == "brown") || (newLoc.color == "dark blue")) || (districts[newLoc.color] == 3 && (newLoc.color != "brown" || newLoc.color != "dark blue")))
                        {
                            newLoc                 = new Company(newLoc);
                            newLoc.company         = true;
                            newLoc.amountOfFileals = 0;
                        }
                    }
                }
                return;
            }

            return;
        }
Exemple #2
0
        public void BuySomething(Label balance_capital, List <PictureBox> cells, List <Panel> firms_owners, List <Label> firms_costs, ListBox list_box, Button current_button, Button next_button, Form1 main_form)
        {
            string s = "";

            foreach (var item in firms_owners)
            {
                s = item.Name;
                s = s.Remove(s.LastIndexOf('_'));
                if (this.NameOfCurrentCard == s)
                {
                    int k = 0;
                    foreach (var i in list_box.Items)
                    {
                        if ("- " + s + " x1" == i.ToString())
                        {
                            k = 1;
                            break;
                        }
                        else if ("- " + s + " x2" == i.ToString())
                        {
                            k = 2;
                            break;
                        }
                        else if ("- " + s + " x3" == i.ToString())
                        {
                            k = 3;
                            break;
                        }
                        else if ("- " + s + " x4" == i.ToString())
                        {
                            k = 4;
                            break;
                        }
                        else if ("- " + s + " x5" == i.ToString())
                        {
                            return;
                        }
                    }
                    if (this.Balance >= Game.CostOfFirms[this.NameOfCurrentCard][k])
                    {
                        if (k == 0)
                        {
                            Firm firm = new Firm(s);
                            item.Visible = true;
                            if (this is Person)
                            {
                                item.BackColor = Color.Red;
                            }
                            if (this is Artificial_Intelligence)
                            {
                                item.BackColor = Color.Blue;
                            }
                            this.OwnedFirms.Add(firm);
                            list_box.Items.Add("- " + firm.Name + " x" + (k + 1).ToString());
                        }
                        else if (k == 1 || k == 2 || k == 3)
                        {
                            Filial filial = new Filial(new Firm(s));
                            this.OwnedFilials.Add(filial);
                            list_box.Items.Remove("- " + filial.Name + " x" + (k).ToString());
                            list_box.Items.Add("- " + filial.Name + " x" + (k + 1).ToString());
                        }
                        else if (k == 4)
                        {
                            Company company = new Company(new Firm(s));
                            this.OwnedCompany.Add(company);
                            list_box.Items.Remove("- " + company.Name + " x" + (k).ToString());
                            list_box.Items.Add("- " + company.Name + " x" + (k + 1).ToString());
                        }
                        this.Balance        -= Game.CostOfFirms[s][k];
                        this.CurrentProfit  += Game.CostOfFirms[s][k] * 0.1;
                        balance_capital.Text = this.Balance.ToString() + " | " + this.Capital.ToString() + " | " + this.CurrentProfit.ToString();
                        string s0 = s + "_cost";
                        foreach (var firm_cost in firms_costs)
                        {
                            if (firm_cost.Name == s0)
                            {
                                if (k <= 3)
                                {
                                    firm_cost.Text = Game.CostOfFirms[s][k + 1].ToString();
                                }
                                break;
                            }
                        }
                        s0 = this.CurrentPosition.ToString() + "N";
                        foreach (var cell in cells)
                        {
                            if (cell.Tag.ToString() == s0)
                            {
                                if (this is Person)
                                {
                                    cell.Tag = this.CurrentPosition.ToString() + "R";
                                }
                                if (this is Artificial_Intelligence)
                                {
                                    cell.Tag = this.CurrentPosition.ToString() + "B";
                                }
                                break;
                            }
                        }
                    }
                    break;
                }
            }
            if (this is Person)
            {
                current_button.Enabled   = false;
                current_button.BackColor = Color.Gray;
                next_button.Enabled      = true;
                next_button.BackColor    = Color.LimeGreen;
            }
        }