コード例 #1
0
 public static bool canPlayerTradeWithHarbor(Harbor hb, Player pl)
 {
     foreach (Board.ResourceType rt in Enum.GetValues(typeof(Board.ResourceType)))
     {
         //Get the player's current resource counts.
         int count = pl.getResourceCount(rt);
         if (count >= hb.getRequiredResourceCount())
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
        /*
         *  Allow the player to trade with the chosen harbor.
         */
        public void loadHarborTrade(Harbor hb, Player pl)
        {
            //Auto selects resources from other party (some trades allows the player to choose the resource)
            //Build the window based on the harbor.
            initiatingPlayer = pl;
            createResourceSelectors(false, false);
            minimumPlayerInput       = hb.getRequiredResourceCount();
            lblTradeName.Text        = "Harbor";
            lblPlayerTitle.Text      = pl.getName();
            lblPlayerTitle.BackColor = pl.getColor();
            foreach (ResourceSelector sel in playerResourceSelectors)
            {
                sel.Click += lockedTradePlayerClickPlayerResource;
            }

            if (hb.getTradeOutputResource() == Board.ResourceType.Desert)
            {
                //The player may choose any resource to trade for.
                foreach (ResourceSelector select in otherResourceSelectors)
                {
                    select.Click += playerClickOtherResource;
                }
            }
            else
            {
                //The player is only allowed to choose the one resource.
                canClearOther = false;
                foreach (ResourceSelector select in otherResourceSelectors)
                {
                    if (select.type == hb.getTradeOutputResource())
                    {
                        select.setSelected(true);
                    }
                    else
                    {
                        select.Hide();
                    }
                }
            }
        }