Example #1
0
        /// <summary>
        /// Display game information in-world
        /// </summary>
        protected void DisplayGameInfo()
        {
            Scene scene = ButtonMap[m_playerId].Part.ParentGroup.Scene;

            scene.SimChat(string.Format("Current game state is {0}", m_controller.Game.State), WaterWarsConstants.SYSTEM_ANNOUNCEMENT_NAME);
            List <Player> players = m_controller.Game.Players.Values.ToList();

            scene.SimChat(string.Format("There are {0} registered players", players.Count), WaterWarsConstants.SYSTEM_ANNOUNCEMENT_NAME);
            foreach (Player player in players)
            {
                StringBuilder sb = new StringBuilder(string.Format("  {0} [{1}]", player.Name, player.Role.Type));

                if (m_controller.State is AbstractPlayState)
                {
                    AbstractPlayState aps = m_controller.State as AbstractPlayState;

                    if (aps.HasPlayerEndedTurn(player))
                    {
                        sb.Append(" (ended turn)");
                    }
                    else
                    {
                        sb.Append(" (not ended turn)");
                    }
                }

                scene.SimChat(sb.ToString(), WaterWarsConstants.SYSTEM_ANNOUNCEMENT_NAME);
            }
        }
Example #2
0
        public void ShowStatus()
        {
            m_log.InfoFormat(
                "[WATER WARS]: Game status is {0}, turn {1} of {2}",
                m_controller.Game.State, m_controller.Game.CurrentRound, m_controller.Game.TotalRounds);

            string playersTableFormat = "{0,-32}{1,-14}{2,-17}{3,-14}{4,-14}{5,-7}{6,-8}{7,-12}";

            List <Player> players;

            lock (m_controller.Game.Players)
                players = m_controller.Game.Players.Values.ToList();

            m_log.InfoFormat("There are {0} players", players.Count);
            m_log.InfoFormat(playersTableFormat, "Player", "Role", "Parcels owned", "Assets owned", "Water rights", "Water", "Cash", "Turn Ended");
            foreach (Player p in players)
            {
                List <BuyPoint> buyPointsOwned;
                lock (p.DevelopmentRightsOwned)
                    buyPointsOwned = p.DevelopmentRightsOwned.Values.ToList();

                int assetsCount = 0;

                foreach (BuyPoint bp in buyPointsOwned)
                {
                    lock (bp.GameAssets)
                        assetsCount += bp.GameAssets.Count;
                }

                string turnEnded;

                if (m_controller.State is AbstractPlayState)
                {
                    AbstractPlayState aps = m_controller.State as AbstractPlayState;

                    if (aps.HasPlayerEndedTurn(p))
                    {
                        turnEnded = "yes";
                    }
                    else
                    {
                        turnEnded = "no";
                    }
                }
                else
                {
                    turnEnded = "n/a";
                }

                m_log.InfoFormat(
                    playersTableFormat, p.Name, p.Role.Type, buyPointsOwned.Count, assetsCount, p.WaterEntitlement, p.Water, p.Money, turnEnded);
            }
        }