示例#1
0
        public WinDuke()
        {
            InitializeComponent();

            grain = new Grain();
            land = new Land();
            population = new Population();
            war = new War();

            Year = 0; // Set Year
            KingStatus = 0;
            Dead = false;
        }
示例#2
0
        /// <summary>
        /// Buy Land
        /// </summary>
        public bool BuyLand(Grain grain)
        {
            int Amount;
            bool Loop = true;

            Value += Functions.FNR(1, 10) - 5; // TODO : Need to bell curve this price with a trend

            do
            {
                //int X1 = INT(2 * C + FNX % (1) - 5);
                //X1 = -X1 * (X1 >= 4) - 4 * (X1 < 4);
                Amount = Functions.ReadInt("Land to buy at " + Value.ToString() + "HL./HA. = ");
                if (Amount == 0)
                {
                    return false;
                }
                else if ((Amount * Value) > grain.Total)
                {
                    Console.WriteLine("But you don't have enough grain for that.");
                    Console.WriteLine("You have " + grain.Total.ToString() + "HL. of grain left.");
                    int Total = grain.Total / Value;
                    Console.WriteLine("Enough to buy " + Total.ToString() + "HA. of land");
                }
                else
                {
                    Loop = false;
                }
            }
            while (Loop);

            //Distribute new land into the land buckets.
            int BinLand = Amount / 6;
            int BonusLand = Amount - (BinLand * 6); // Catch any missed in rounding MOD ought to do this as well

            for (int buck = 0; buck < 6; buck++) // Assign a bit of each percent
            {
                Percent[buck] += BinLand;
            }

            Percent[Functions.FNR(0, 5)] += BonusLand; // add the extra to lucky winner
            Bought = Amount + BonusLand;
            return true;
        }
示例#3
0
        /// <summary>
        /// Return a total amount of producing arcres
        /// </summary>
        /// <param name="LandPlanted"></param>
        /// <returns></returns>
        public int Plant(Grain grain, Population population)
        {
            int Amount;
            int Remaining;
            int RunningTotal = 0;
            float Per = 1;

            bool Loop = true;
            do
            {
                Amount = Functions.ReadInt("Land to be planted = ");
                if (Amount > Total)
                {
                    Functions.PrintF(ConsoleColor.Red, "But you don't have enough land.");
                    Functions.PrintF(ConsoleColor.Yellow, "You only have " + Total.ToString() + "HA. of land.");
                }
                else
                {
                    if ((Amount * 2) > grain.Total)
                    {
                        int Plantable = grain.Total / 2;
                        Functions.PrintF(ConsoleColor.Red, "Not enough grain.");
                        Functions.PrintF(ConsoleColor.Yellow, "You only have enough to plant " + Plantable.ToString() + "HA. of land.");
                    }
                    else
                    {
                        if (Amount > (population.Total * 4))
                        {
                            int Workable = population.Total * 4;
                            Functions.PrintF(ConsoleColor.Red, "But you don't have enoung peasants.");
                            Functions.PrintF(ConsoleColor.Yellow, "Your peasants can only plant " + Workable.ToString() + "HA. of land.");
                        }
                        else
                        {
                            //grain.Production(land.Plant(Amount));
                            Loop = false;
                        }
                    }
                }
            } while (Loop);

            Remaining = Amount;

            for (int buck = 0; buck < 6; buck++)
            {
                if (Remaining > Percent[buck])
                {
                    RunningTotal += (int)((float)Percent[buck] * Per);
                    Remaining -= Percent[buck];
                }
                else
                {
                    RunningTotal += Remaining;
                    Remaining = 0;
                }
                Per -= 0.20f;
            }

            return RunningTotal;
        }
示例#4
0
        /// <summary>
        /// Food for Peasants
        /// </summary>
        public void FeedPeasant(Grain grain, Land land)
        {
            int Amount;
            bool Loop = true;

            do
            {
                Amount = Functions.ReadInt("Grain for food = ");
                if (Amount < grain.Total)
                {
                    Loop = false;
                }
                else
                {
                    Functions.PrintF(ConsoleColor.Gray, "You only have " + grain.Total.ToString() + "HL.");
                }
            }
            while (Loop);

            int Fed = Amount / Total;
            Starvations = 0; // So far....

            if (Fed < 14 && Amount < grain.Total)
            {
                Functions.PrintF(ConsoleColor.Red, "The peasent demonstrate before the castle.");
            }
            if (Fed < 13)
            {
                Functions.PrintF(ConsoleColor.DarkYellow, "Some peasants have starved");
                Starvations = -(Total - (Amount / 13));
            }

            UnhappyStavation = UnhappyStavation - (3 * Starvations) - (2 * Fed);

            return;
        }
示例#5
0
        /// <summary>
        /// WAR
        /// </summary>
        public Victory WithDuke(Grain grain, Land land, Population population)
        {
            int Casualties;
            int LandTaken;
            int Offense;
            int Defense;
            int Hired = 0;

            Functions.PrintF(ConsoleColor.Red, "A near by Duke threatens war; ");
            Offense = (85 + 18 * Functions.FNR(1, 6));
            Defense = (population.Total * Functions.FNR(1, 3)) + 13;

            if (Functions.ReadYesNo("Will you attack first?") == false)
            {
                if (Offense < Defense)
                {
                    Functions.PrintF(ConsoleColor.Green, "Peace negotiations successful");
                    return Victory.Draw;
                }
            }
            else
            {
                if (Functions.FNR(1, 20) != 1)
                {
                    Functions.PrintF(ConsoleColor.DarkYellow, "First strike failed - you need professionals");
                    Hired = HireMercinaries(40, 75);
                    GrainCost = Hired * 40;
                }
            }

            LandTaken = Offense - (Defense + (Hired * 2));

            if (-LandTaken > land.Total)
            {
                Functions.PrintF(ConsoleColor.Red, "You have been over run and have lost your entire Dukedom");
                return Victory.CompleteLoss;
            }

            if (LandTaken > 400)
            {
                Functions.PrintF(ConsoleColor.DarkGreen, "You have overrun the enemy and annexed his entire Dukedom");

                SoWGrain = 3513;
                SoWLand = LandTaken;
                DeathToll = Defense - 200;
                return Victory.CompleteWin;
            }

            if (LandTaken > 1)
            {
                Functions.PrintF(ConsoleColor.Green, "You have won the war");
                SoWGrain = (int)((float)LandTaken * 1.7);
                SoWLand = LandTaken;
                DeathToll = -Defense;
                return Victory.SimpleWin;
            }
            else
            {
                Functions.PrintF(ConsoleColor.Red, "You have lost the war");
                SoWGrain = -(int)((float)LandTaken * 1.7);
                SoWLand = -LandTaken;
                DeathToll = -Defense;
                return Victory.SimpleLoss;
            }

            return Victory.Draw;
        }
示例#6
0
        /// <summary>
        /// War with the King
        /// </summary>
        /// <returns></returns>
        public bool WithKing(Grain grain, Land land, Population population)
        {
            int Count = (grain.Total / 100);

            Functions.PrintF(ConsoleColor.Red, "\nThe king's army is about to attack your ducy!!!");
            Functions.PrintF(ConsoleColor.Yellow, "At 100 HL. each (pay in advance).");
            Functions.PrintF(ConsoleColor.Yellow, "You have hired " + Count.ToString() + " foreign mercinaries.");

            if (land.Total * Count + population.Total < 2500)
            {
                Functions.PrintF(ConsoleColor.DarkRed, "\nYour head is placed atop of the castle gate.");
                return false;
            }
            else
            {
                Functions.PrintF(ConsoleColor.DarkGreen, "\nWipe the blood from the crown - you are High King!");
                Functions.PrintF(ConsoleColor.Yellow, "A near by monarchy THREATENS WAR!");
                Functions.PrintF(ConsoleColor.Yellow, "HOW MANY ........\n\n\n");
                return true;
            }
        }