Beispiel #1
0
        public override void GiveMoney(Player p, int amount)
        {
            m_log.InfoFormat("[WATER WARS]: Giving {0} to {1}", WaterWarsUtils.GetMoneyUnitsText(amount), p.Name);

            p.Money += amount;

            m_controller.EventManager.TriggerMoneyGiven(p, amount);

            p.TriggerChanged();

            // FIXME: Should be done via event subscription.
            UpdateHudStatus(p);
        }
Beispiel #2
0
        protected override void PostStartState()
        {
            Dictionary <Player, int>    eotRevenues = CalculateOperatingRevenue();
            Dictionary <Player, int>    eotCosts    = CalculateMaintenanceCosts();
            Dictionary <Player, string> eotMessages = new Dictionary <Player, string>();

            foreach (Player p in Game.Players.Values)
            {
                // Right now we also want to reset all water the player has in hand.
                // TODO: This should be a separate rule
                p.Water = 0;

                p.Money += eotRevenues[p];
                p.Money -= eotCosts[p];
                p.Money -= p.CostOfLiving;

                m_controller.EventManager.TriggerRevenueReceived(p, eotRevenues[p], eotCosts[p], p.CostOfLiving);

                p.RecordHistory();

                int revenue = 0, costs = 0, capitalRevenue = 0, capitalCosts = 0;

                // Common financial components
                revenue        = p.WaterRevenueThisTurn;
                costs          = p.MaintenanceCosts + p.WaterCostsThisTurn + p.CostOfLiving;
                capitalRevenue = p.LandRevenueThisTurn + p.WaterRightsRevenueThisTurn;
                capitalCosts   = p.LandCostsThisTurn + p.WaterRightsCostsThisTurn;

                if (p.Role.Type == RoleType.Farmer)
                {
                    revenue += p.ProjectedRevenueFromProducts;
                    costs   += p.BuildCostsThisTurn;
                }
                else if (p.Role.Type == RoleType.Developer)
                {
                    revenue += p.BuildRevenueThisTurn;
                    costs   += p.BuildCostsThisTurn;
                }
                else if (p.Role.Type == RoleType.Manufacturer)
                {
                    revenue      += p.ProjectedRevenueFromProducts;
                    capitalCosts += p.BuildCostsThisTurn;
                }

                int    profit             = revenue - costs;
                string profitText         = WaterWarsUtils.GetMoneyUnitsText(profit);
                string revenueText        = WaterWarsUtils.GetMoneyUnitsText(revenue);
                string costsText          = WaterWarsUtils.GetMoneyUnitsText(costs);
                string capitalRevenueText = WaterWarsUtils.GetMoneyUnitsText(capitalRevenue);
                string capitalCostsText   = WaterWarsUtils.GetMoneyUnitsText(capitalCosts);

                m_log.InfoFormat(
                    "[WATER WARS]: {0} made {1} ({2} revenue - {3} costs) this turn, excluding {4} capital revenue, {5} capital costs",
                    p.Name, profitText, revenueText, costsText, capitalRevenueText, capitalCostsText);

                string msg = string.Format(REVENUE_AND_COST_MSG, profitText) + "\n";
//                string msg = string.Format(
//                    REVENUE_AND_COST_MSG, profitText, revenueText, costsText, capitalCostsText) + "\n";

                if (m_controller.Game.IsLastRound)
                {
                    msg += GAME_ENDED_STATUS_MSG;
                }
                else
                {
                    msg += BuildStageState.BUILD_PHASE_STARTING_MSG;
                }

                eotMessages[p] = msg;
            }

            // Do these actions after recording history so that project revenues (based on ga allocations) are correct
            List <AbstractGameAsset> assetsRemoved = AgeGameAssets();

            foreach (Player p in Game.Players.Values)
            {
                m_controller.Events.Post(p, eotMessages[p], EventLevel.All);
            }

            ResetPerTurnProperties();

            m_controller.EventManager.TriggerRevenueStageEnded(assetsRemoved);

            if (!m_controller.RoundManager.EndRound())
            {
                m_controller.GameDateManager.AdvanceDate();
                EndState(new BuildStageState(m_controller));
            }
            else
            {
                EndState(new GameEndedState(m_controller));
            }
        }