Ejemplo n.º 1
0
        private void on_DeckDealerFlip_clicked(System.Object obj, EventArgs e)
        {
            cardsFlipped++;

            if (Game.GetInstance().JustShuffledResourceCards)
            Game.GetInstance().JustShuffledResourceCards = false;
            else
            Game.GetInstance().NextResourceCard();

            ResourceCard card = Game.GetInstance().CurrentResourceCard;
            if (card.isResource() && targetIsResource())
            {
            Console.WriteLine("Both Are Resources: " + card.Good.Name + " and " + targetResource.Name);
            if (card.Good.Name == targetResource.Name)
            {
                Console.WriteLine("Found Target Resource");
                finished = true;
                DeckDealerFlip.Sensitive = false;
                DeckDealerStatus.Text = "Charging " + cardsFlipped*costPerCard;

                /* Purchase this card */
                Orig_ChargeMoney cmd3 = new Orig_ChargeMoney(cardsFlipped*costPerCard, Game.GetInstance().State.CurrentPlayer);
                Game.GetInstance().State.Execute(cmd3);
                cardsFlipped = 0; // don't make them double-pay

                DeckDealerFlip.Sensitive = false; // stop their clicking manias

                /* Add this card to the player's hand, marked unopened */
                card.Active = false;
                Orig_AddResourceCard cmd4 = new Orig_AddResourceCard(card, Game.GetInstance().State.CurrentPlayer);
                Game.GetInstance().State.Execute(cmd4);
            }
            } else if (!card.isResource() && !targetIsResource()) {
            Console.WriteLine("Both Are Units");
            if (card.Knowledge.Name == targetUnit.Name)
            {
                Unit nu = targetUnit.Clone(Game.GetInstance().State.CurrentPlayer); // copy that, rogue two.

                finished = true;
                Console.WriteLine("Found Target Unit");
                DeckDealerStatus.Text = "Charging " + cardsFlipped*costPerCard;
                /* Set available */
                Game.GetInstance().State.CurrentPlayer.makeUnitAvailable(nu);

                /* Make an immediate purchase */
                Orig_PurchaseUnit cmd = new Orig_PurchaseUnit(nu, Game.GetInstance().State.CurrentPlayer);
                Game.GetInstance().State.Execute(cmd);
                Orig_BuildUnit cmd2 = new Orig_BuildUnit(nu, null, Game.GetInstance().State.CurrentPlayer);
                Game.GetInstance().State.Execute(cmd2);

                /* Pay for flipped cards */
                Orig_ChargeMoney cmd3 = new Orig_ChargeMoney(cardsFlipped*costPerCard, Game.GetInstance().State.CurrentPlayer);
                Game.GetInstance().State.Execute(cmd3);
                cardsFlipped = 0; // don't make them double-pay

                DeckDealerFlip.Sensitive = false; // stop their clicking manias
            }
            }

            on_DeckDealer_exposed(null,null); // evil! Update screen
            updateStatusBoxes();
            //DeckDealer.SendExpose(null); // less evil, but crashes
        }
Ejemplo n.º 2
0
        private void doProspectForResources()
        {
            if (spinalCord.myPlayer.Money < DeckDealer.GetInstance().CostPerCard * 4)
            return;

            if (spinalCord.myPlayer.getStockpileNumberFullSets() > 6)
            return;

            Gpremacy.Dictionary dict = new Gpremacy.Dictionary();
            foreach (Gpremacy.ResourceCard rc in spinalCord.myPlayer.ResourceCards)
            {
            dict.IncValue(rc.Good, rc.Good.Value);
            }

            Resource lowest = null;
            int lowN = 999;
            foreach (DictionaryEntry de in dict)
            {
            if ((int)de.Value < lowN)
            {
                lowN = (int)de.Value;
                lowest = (Resource)de.Key;
            }
            }

            if (lowest == null)
            return;

            System.Console.WriteLine(this + " is prospecting for " + lowest);

            Processor.theGame.ShuffleResourceCards();

            int cardsFlipped;

            for (cardsFlipped=1; cardsFlipped<4; ++cardsFlipped)
            {
            if (Processor.theGame.JustShuffledResourceCards)
                Processor.theGame.JustShuffledResourceCards = false;
            else
                Processor.theGame.NextResourceCard();

            ResourceCard card = Processor.theGame.CurrentResourceCard;

            if (card == null)
                break;

            if (card.isResource() && (card.Good.Name == lowest.Name) )
            {
                System.Console.WriteLine(this + " has found " + card);
                /* Add this card to the player's hand, marked unopened */
                card.Active = false;
                Orig_AddResourceCard cmd4 = new Orig_AddResourceCard(card, spinalCord.myPlayer);
                spinalCord.sendCommand(cmd4);
                /* get this card, break */
                break;
            }
            }

            int totalCost = cardsFlipped*DeckDealer.GetInstance().CostPerCard;
            Orig_ChargeMoney cmd3 = new Orig_ChargeMoney(totalCost, spinalCord.myPlayer);
            spinalCord.sendCommand(cmd3);
        }