Exemplo n.º 1
0
        /// <summary>
        /// Serialises a Kingdom object
        /// </summary>
        /// <returns>Kingdom_Serialised object</returns>
        /// <param name="k">Kingdom to be converted</param>
        public static Kingdom_Serialised Kingdom_serialise(Kingdom k)
        {
            Kingdom_Serialised kingOut = null;

            kingOut = new Kingdom_Serialised(k);
            return(kingOut);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor for Province using Province_Serialised object.
 /// For use when de-serialising.
 /// </summary>
 /// <param name="ps">Province_Serialised object to use as source</param>
 public Province(Province_Serialised ps)
     : base(ps: ps)
 {
     this.taxRate = ps.taxRate;
     // kingdom to be inserted later
     this.kingdom = null;
 }
Exemplo n.º 3
0
 public ClientKingdom(Kingdom k)
 {
     this.id   = k.id;
     this.name = k.name;
     this.rank = k.rank.id;
     this.nat  = k.nationality.natID;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor for Place_Serialised.
        /// For use when serialising.
        /// </summary>
        /// <param name="k">Kingdom object to be used as source</param>
        public Place_Serialised(Kingdom k = null, Province p = null, Fief f = null)
        {
            Place placeToUse = null;

            if (k != null)
            {
                placeToUse = k;
            }
            else if (p != null)
            {
                placeToUse = p;
            }
            else if (f != null)
            {
                placeToUse = f;
            }

            if (placeToUse != null)
            {
                this.id          = placeToUse.id;
                this.name        = placeToUse.name;
                this.owner       = placeToUse.owner.charID;
                this.titleHolder = placeToUse.titleHolder;
                this.rank        = placeToUse.rank.id;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the province's rightful kingdom (i.e. the kingdom that it traditionally belongs to)
        /// </summary>
        /// <returns>The kingdom</returns>
        public Kingdom GetRightfulKingdom()
        {
            Kingdom thisKingdom = null;

            if (this.kingdom != null)
            {
                thisKingdom = this.kingdom;
            }

            return(thisKingdom);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructor for Province
        /// </summary>
        /// <param name="otax">Double holding province tax rate</param>
        /// <param name="king">Province's Kingdom object</param>
        public Province(String id, String nam, Double otax, String tiHo = null, PlayerCharacter own = null, Kingdom king = null, Rank r = null)
            : base(id, nam, tiHo, own, r)
        {
            // VALIDATION

            // OTAX
            if (!Utility_Methods.ValidatePercentage(otax))
            {
                throw new InvalidDataException("Province taxrate must be a double between 0 and 100");
            }

            this.taxRate = otax;
            this.kingdom = king;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the province's current kingdom (i.e. the kingdom of the current owner)
        /// </summary>
        /// <returns>The kingdom</returns>
        public Kingdom GetCurrentKingdom()
        {
            Kingdom thisKingdom = null;

            foreach (KeyValuePair <string, Kingdom> kingdomEntry in Globals_Game.kingdomMasterList)
            {
                if (kingdomEntry.Value.nationality == this.owner.nationality)
                {
                    thisKingdom = kingdomEntry.Value;
                    break;
                }
            }

            return(thisKingdom);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Writes a Kingdom or Kingdom_Serialised object to the database
        /// </summary>
        /// <returns>bool indicating success</returns>
        /// <param name="gameID">Game (bucket) to write to</param>
        /// <param name="k">Kingdom to write</param>
        /// <param name="ks">Kingdom_Serialised to write</param>
        public static bool DatabaseWrite_Kingdom(string gameID, Kingdom k = null, Kingdom_Serialised ks = null)
        {
            if (k != null)
            {
                // convert Kingdom into Kingdom_Serialised
                ks = DatabaseWrite.Kingdom_serialise(k);
            }

            var rKing         = new RiakObject(gameID, ks.id, ks);
            var putKingResult = Globals_Server.rClient.Put(rKing);

            if (!putKingResult.IsSuccess)
            {
                Globals_Server.logError("Write failed: Kingdom " + rKing.Key + " to bucket " + rKing.Bucket);
            }

            return(putKingResult.IsSuccess);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Constructor for Kingdom_Serialised.
 /// For use when serialising.
 /// </summary>
 /// <param name="king">Kingdom object to be used as source</param>
 public Kingdom_Serialised(Kingdom king)
     : base(k: king)
 {
     this.nationality = king.nationality.natID;
 }
Exemplo n.º 10
0
        public Province(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            var tmpKing = info.GetString("king");

            this.kingdom = Globals_Game.kingdomMasterList[tmpKing];
        }