示例#1
0
        /// <summary>
        /// Updates the object with the new settings.
        /// Used when a player changes his settings of the game
        /// </summary>
        /// <param name="settings"></param>
        public void UpdateSettings(XmlGameSettings settings)
        {
            if (_DoNotReplaceDeserts != settings.DoNotReplaceDeserts)
                DoNotReplaceDeserts = settings.DoNotReplaceDeserts;

            if (_GameType != settings.GameType)
                GameType = settings.GameType;

            if (_IsLadder != settings.IsLadder)
                IsLadder = settings.IsLadder;

            if (_BoardGuid != settings.Map)
                Map = settings.Map;

            if (_MaximumCardsInHandWhenSeven != settings.MaximumCardsInHandWhenSeven)
                MaximumCardsInHandWhenSeven = settings.MaximumCardsInHandWhenSeven;

            if (_MaxPlayers != settings.MaxPlayers)
                MaxPlayers = settings.MaxPlayers;

            if (_MinPlayers != settings.MinPlayers)
                MinPlayers = settings.MinPlayers;

            if (_Name != settings.Name)
                Name = settings.Name;

            if (_No2VPPlayersRobbing != settings.No2VPPlayersRobbing)
                No2VPPlayersRobbing = settings.No2VPPlayersRobbing;

            if (_NoSevensFirstRound != settings.NoSevensFirstRound)
                NoSevensFirstRound = settings.NoSevensFirstRound;

            if (_ReplaceDesertWithJungles != settings.ReplaceDesertWithJungles)
                ReplaceDesertWithJungles = settings.ReplaceDesertWithJungles;

            if (_ReplaceDesertWithVolcanos != settings.ReplaceDesertWithVolcanos)
                ReplaceDesertWithVolcanos = settings.ReplaceDesertWithVolcanos;

            if (_TournamentStart != settings.TournamentStart)
                TournamentStart = settings.TournamentStart;

            if (_TradingAfterBuilding != settings.TradingAfterBuilding)
                TradingAfterBuilding = settings.TradingAfterBuilding;

            if (_VpToWin != settings.VpToWin)
                VpToWin = settings.VpToWin;
        }
示例#2
0
        /// <summary>
        /// Prepares a saved board definition into a playable board.
        /// 1. Puts hexes from InitialRandomHexes list on RandomHexes
        /// 2. Replaces random ports from those out of RandomPorts bag
        /// 3. Replaces deserts by volcano/jungles if necessary
        /// </summary>
        public void PrepareForPlay(XmlGameSettings settings)
        {
            Random random = new Random();
            Hex newHex = null;

            // we assume each hex has a territory associated with it
            for (int i=0; i< Hexes.Count;i++)
            {
                Hex hex = Hexes[i];
                ITerritoryHex terrHex = hex as ITerritoryHex;
                if (terrHex != null)
                {
                    // grab the according territory from the list
                    Territory territory = _Territories.ToList().Find
                        (t => t.ID == terrHex.TerritoryID);

                    // Replace randomhexes with a new hex picked form the list of resources
                    RandomHex randomHex = hex as RandomHex;
                    if (randomHex != null)
                    {
                        // pick a hex from the list of hexes in the territory
                        newHex = territory.HexList.PickHexFromList(
                            (int)(random.NextDouble() * territory.HexList.CountAll));

                        //copy terrtoryID to new hex
                        ((ITerritoryHex)newHex).TerritoryID = randomHex.TerritoryID;
                        newHex.Location = hex.Location;

                        if (newHex is ResourceHex)
                        {
                            int chitno = (int)(random.NextDouble() * territory.ChitList.CountAll);
                            ((ResourceHex)newHex).XmlChit = new Chit() { ChitNumber = territory.ChitList.PickNumberFromBag() };
                        }
                    }

                    //Replace randomchit by actual chitnumbers from the correct bag
                    if (hex is ResourceHex)
                    {
                        ResourceHex resourceHex = hex as ResourceHex;
                        if (resourceHex.XmlChit == null)
                        {
                            resourceHex.XmlChit = new Chit() { ChitNumber = EChitNumber.None };
                        }
                        if (resourceHex.XmlChit.ChitNumber == EChitNumber.Random)
                        {
                            int chitno = (int)(random.NextDouble() * territory.ChitList.CountAll);
                            resourceHex.XmlChit = new Chit();
                            resourceHex.XmlChit.ChitNumber = territory.ChitList.PickNumberFromBag();
                        }
                    }

                    // swap randomport for ports from the list of randomports
                    /* TODO: determine ownership of port for landhex where port
                     * is connected to
                    if (hex is SeaHex)
                    {
                        SeaHex seaHex = hex as SeaHex;
                        if (seaHex.XmlPort != null)
                        {
                            if (seaHex.XmlPort.PortType == EPortType.Random)
                            {
                                EPortType porttype = territory.PortList.PickPortFromBag();
                                seaHex.XmlPort = new Port() { PortType = porttype };
                            }
                        }
                    }
                     */

                    //Replace desert by volcano or jungle if setting is on on mainland
                    if (!settings.DoNotReplaceDeserts &&
                        hex is DesertHex &&
                        territory.IsMainland)
                    {
                        if (settings.ReplaceDesertWithVolcanos)
                        {
                            newHex = new VolcanoHex()
                            {
                                XmlChit = new Chit() { ChitNumber = territory.ChitList.PickRandomChit() },
                                Location = hex.Location
                            };
                        }
                        if (settings.ReplaceDesertWithJungles)
                        {
                            newHex = new JungleHex()
                            {
                                XmlChit = new Chit() { ChitNumber = territory.ChitList.PickRandomChit() },
                                Location = hex.Location
                            };
                        }
                    }

                    // swap the new hex with the old one
                    if (newHex != null)
                    {
                        _Hexes[hex.Location] = newHex;
                        newHex = null;
                    }
                }
            }

            //TODO: Create a list of chit swaps to swap out 6/8 and 9/9 neighbours
            // This allows for a nice visualization where this process is
            // clearly showed to the players
        }
示例#3
0
 public ServerGame(XmlGameSettings settings)
 {
     _Game = new XmlGame() { Settings = settings };
 }
示例#4
0
 public ServerGame(XmlGameSettings settings)
 {
     _Settings = settings;
 }