/// <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; }
/// <summary> /// Serialises a Province object /// </summary> /// <returns>Province_Serialised object</returns> /// <param name="p">Province to be converted</param> public static Province_Serialised Province_serialise(Province p) { Province_Serialised oOut = null; oOut = new Province_Serialised(p); return(oOut); }
/// <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; } }
/// <summary> /// Writes a Province or Province_Serialised object to the database /// </summary> /// <returns>bool indicating success</returns> /// <param name="gameID">Game (bucket) to write to</param> /// <param name="p">Province to write</param> /// <param name="ps">Province_Serialised to write</param> public static bool DatabaseWrite_Province(string gameID, Province p = null, Province_Serialised ps = null) { if (p != null) { // convert Province into Province_Serialised ps = DatabaseWrite.Province_serialise(p); } var rProv = new RiakObject(gameID, ps.id, ps); var putProvResult = Globals_Server.rClient.Put(rProv); if (!putProvResult.IsSuccess) { Globals_Server.logError("Write failed: Province " + rProv.Key + " to bucket " + rProv.Bucket); } return(putProvResult.IsSuccess); }