Esempio 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);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor for Place using Fief_Serialised, Province_Serialised or Kingdom_Serialised object.
        /// For use when de-serialising.
        /// </summary>
        /// <param name="fs">Fief_Serialised object to use as source</param>
        /// <param name="ps">Province_Serialised object to use as source</param>
        /// <param name="ks">Kingdom_Serialised object to use as source</param>
        public Place(Fief_Serialised fs = null, Province_Serialised ps = null, Kingdom_Serialised ks = null)
        {
            Place_Serialised placeToUse = null;

            if (fs != null)
            {
                placeToUse = fs;
            }
            else if (ps != null)
            {
                placeToUse = ps;
            }
            else if (ks != null)
            {
                placeToUse = ks;
            }

            if (placeToUse != null)
            {
                this.id   = placeToUse.id;
                this.name = placeToUse.name;
                // owner to be inserted later
                this.owner       = null;
                this.titleHolder = placeToUse.titleHolder;
                // rank to be inserted later
                this.rank = null;
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 /// <summary>
 /// Constructor for Kingdom using Kingdom_Serialised object.
 /// For use when de-serialising.
 /// </summary>
 /// <param name="ks">Kingdom_Serialised object to use as source</param>
 public Kingdom(Kingdom_Serialised ks)
     : base(ks: ks)
 {
     // nationality to be inserted later
     this.nationality = null;
 }