Example #1
0
        private void AgeOfMythologyForm_Load(object sender, EventArgs e)
        {
            this.Location = new Point(0, 0);
            player        = new Player(playerBoardChoice);

            ai1 = new Player();
            ai2 = new Player();

            players = new Player[3] {
                player, ai1, ai2
            };

            generatePieces();

            this.iForm = new InitiationForm(resourcePieces);
            iForm.Show();
            displayBoard(players[currentPlayer]);
            endTurnbutton.Enabled   = false;
            startTurnButton.Enabled = false;

            //debug purposes only
            //ActionCardForm aCForm2 = new ActionCardForm(players[currentPlayer].age, players[currentPlayer].culture, actionCards);
            //aCForm2.Show();
        }
Example #2
0
        //dont forget to add favor costs
        public void performAction(int indexToPerform)
        {
            if (CPL == 0)
            {
                #region ATTACK
                if (indexToPerform == 1)
                {
                    //attack hasn't been implemented yet
                }
                #endregion

                //done ?
                #region BUILD
                else if (Math.Abs(indexToPerform) == 2)
                {
                    if (indexToPerform >= 0)
                    {
                        bForm = new BuildForm(ref player, cMasterList);
                        bForm.Show();
                    }
                    else if (player.resourceCubes[0] >= 1)
                    {
                        bForm = new BuildForm(ref player, cMasterList, true, ref pArray);
                        bForm.Show();
                        player.resourceCubes[0]--;
                    }
                }
                #endregion

                //done ?
                #region EXPLORE / INITIATION
                else if (Math.Abs(indexToPerform) == 3)
                {
                    if (indexToPerform >= 0)
                    {
                        iForm = new InitiationForm(ref player, CPL, ref rMasterList);
                        iForm.Show();
                    }
                    else if (player.resourceCubes[0] >= 1)
                    {
                        iForm = new InitiationForm(ref player, CPL, ref rMasterList, true);
                        iForm.Show();
                        player.resourceCubes[0]--;
                    }
                    ; //god card
                }
                #endregion

                //done ?
                #region GATHER
                else if (Math.Abs(indexToPerform) == 4)
                {
                    if (indexToPerform >= 0)
                    {
                        GatherForm gForm = new GatherForm(ref player.resourceCubes, player.resourcePiecesList);
                        gForm.Show();
                    }
                    else if (player.resourceCubes[0] >= 1)
                    {
                        GatherForm gForm = new GatherForm(ref player.resourceCubes, player.resourcePiecesList, true, currentPlayerCulture);
                        gForm.Show();
                        player.resourceCubes[0]--;
                    }//done ?
                }
                #endregion

                //done ?
                #region NEXT AGE
                else if (Math.Abs(indexToPerform) == 5)
                {
                    if (indexToPerform >= 0)
                    {
                        NextAgeForm nAForm = new NextAgeForm(ref player, ref player.resourceCubes);
                        nAForm.Show();
                    }
                    else if (player.resourceCubes[0] >= 1)
                    {
                        if (player.culture == 'n')
                        {
                            totalMoves++;
                        }

                        NextAgeForm nAForm = new NextAgeForm(ref player, ref player.resourceCubes, true, ref pArray);
                        nAForm.Show();
                        player.resourceCubes[0]--;
                    }
                    ;
                }
                #endregion

                // done ?
                #region RECRUIT
                else if (Math.Abs(indexToPerform) == 6)
                {
                    if (indexToPerform >= 0)
                    {
                        RecruitForm rForm = new RecruitForm(ref player, battleUnitMasterList);
                        rForm.Show();
                    }
                    else if (player.resourceCubes[0] >= 1)
                    {
                        RecruitForm rForm = new RecruitForm(ref player, battleUnitMasterList, true);
                        rForm.Show();
                    }
                    ;
                    player.resourceCubes[0]--;
                }
                #endregion

                //done ?
                #region TRADE
                else if (Math.Abs(indexToPerform) == 7)
                {
                    if (indexToPerform >= 0)
                    {
                        TradeForm tForm = new TradeForm(ref player);
                        tForm.Show();
                    }
                    else if (player.resourceCubes[0] >= 1)
                    {
                        TradeForm tForm = new TradeForm(ref player, true);
                        tForm.Show();
                        player.resourceCubes[0]--;
                    }
                    ;  // done ?
                }
                #endregion
            }
            else
            {
                #region ATTACK
                if (indexToPerform == 1)
                {
                    //attack hasn't been implemented yet
                }
                #endregion

                //done ?
                #region BUILD
                else if (Math.Abs(indexToPerform) == 2)
                {
                    bForm = new BuildForm(ref player, cMasterList);
                    List <String> aiBuildings = bForm.getPossibleBuildings(player.resourceCubes);
                    if (aiBuildings.Count() > 0)
                    {
                        bForm.comboBox1.Text = aiBuildings[0];
                        bForm.build();
                        bForm.Close();
                    }
                    MessageBox.Show("AI" + CPL + " completed build action.");
                }
                #endregion

                //done ?
                #region EXPLORE / INITIATION
                else if (Math.Abs(indexToPerform) == 3)
                {
                    //do nothing
                    MessageBox.Show("AI" + CPL + " completed explore action.");
                }
                #endregion

                //done ?
                #region GATHER
                else if (Math.Abs(indexToPerform) == 4)
                {
                    GatherForm gForm = new GatherForm(ref player.resourceCubes, player.resourcePiecesList);
                    gForm.getPossible();
                    if (gForm.resourceGatherPossibilities.Count() > 0)
                    {
                        gForm.comboBox1.SelectedText = gForm.resourceGatherPossibilities[0];
                    }
                    gForm.Close();
                    MessageBox.Show("AI" + CPL + " completed gather action.");
                }
                #endregion

                //done ?
                #region NEXT AGE
                else if (Math.Abs(indexToPerform) == 5)
                {
                    NextAgeForm nAForm = new NextAgeForm(ref player, ref player.resourceCubes);
                    if (player.resourceCubes[0] >= 4 && player.resourceCubes[1] >= 4 && player.resourceCubes[2] >= 4 && player.resourceCubes[3] >= 4)
                    {
                        player.age++;
                    }
                    nAForm.Close();
                    MessageBox.Show("AI" + CPL + " completed next age action.");
                }
                #endregion

                // done ?
                #region RECRUIT
                else if (Math.Abs(indexToPerform) == 6)
                {
                    RecruitForm rForm = new RecruitForm(ref player, battleUnitMasterList);
                    for (int i = 0; i < rForm.recruitButtons.Length; i++)
                    {
                        if (rForm.recruitButtons[i].Enabled)
                        {
                            rForm.subtractCost(i);
                            break;
                        }
                    }
                    rForm.Close();
                    MessageBox.Show("AI" + CPL + " completed recruit action.");
                }
                #endregion

                //done ?
                #region TRADE
                else if (Math.Abs(indexToPerform) == 7)
                {
                    int tradeAmount = 0;

                    while (tradeAmount < 3)
                    {
                        if (player.resourceCubes[0] > 1)
                        {
                            player.resourceCubes[0]--;
                            tradeAmount++;
                        }
                        else if (player.resourceCubes[1] > 1)
                        {
                            player.resourceCubes[1]--;
                            tradeAmount++;
                        }
                        else if (player.resourceCubes[2] > 1)
                        {
                            player.resourceCubes[2]--;
                            tradeAmount++;
                        }
                        else if (player.resourceCubes[3] > 1)
                        {
                            player.resourceCubes[3]--;
                            tradeAmount++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    player.resourceCubes[3]++;
                    MessageBox.Show("AI" + CPL + " completed trade action.");
                }
                #endregion

                else
                {
                    MessageBox.Show("AI" + CPL + " passed.");
                }
            }
        }