예제 #1
0
        /// <summary>
        /// Constructor for BaseLanguage
        /// </summary>
        /// <param name="id">String holding language ID</param>
        /// <param name="nam">String holding language name</param>
        public BaseLanguage(String id, String nam)
        {
            // VALIDATION

            // ID
            // trim
            id = id.Trim();

            if (!Utility_Methods.ValidateLanguageID(id, "baseLang"))
            {
                throw new InvalidDataException("BaseLanguage ID must have the format 'lang_' followed by 1-2 letters");
            }

            // NAM
            // trim and ensure 1st is uppercase
            nam = Utility_Methods.FirstCharToUpper(nam.Trim());

            if (!Utility_Methods.ValidateName(nam))
            {
                throw new InvalidDataException("BaseLanguage name must be 1-40 characters long and contain only valid characters (a-z and ') or spaces");
            }

            this.id   = id;
            this.name = nam;
        }
예제 #2
0
        /// <summary>
        /// Constructor for Terrain
        /// </summary>
        /// <param name="id">String holding terrain code</param>
        /// <param name="desc">String holding terrain description</param>
        /// <param name="tc">double holding terrain travel cost</param>
        public Terrain(String id, string desc, double tc)
        {
            // VALIDATION

            // ID
            // trim
            id = id.Trim();

            if (!Utility_Methods.ValidateTerrainID(id))
            {
                throw new InvalidDataException("Terrain ID must have the format 'terr_' followed by some letters");
            }

            // DESC
            // trim and ensure 1st is uppercase
            desc = Utility_Methods.FirstCharToUpper(desc.Trim());

            if (!Utility_Methods.ValidateName(desc))
            {
                throw new InvalidDataException("Terrain description must be 1-40 characters long and contain only valid characters (a-z and ') or spaces");
            }

            // TC
            if (tc < 1)
            {
                throw new InvalidDataException("Terrain travelCost must be a double >= 1");
            }

            this.id          = id;
            this.description = desc;
            this.travelCost  = tc;
        }
예제 #3
0
        /// <summary>
        /// Constructor for TitleName
        /// </summary>
        /// <param name="lang">string holding Language ID</param>
        /// <param name="nam">string holding title name associated with specific language</param>
        public TitleName(string lang, string nam)
        {
            // VALIDATION

            // LANG
            // trim
            lang = lang.Trim();

            if ((!Utility_Methods.ValidateLanguageID(lang)) && (!lang.Equals("generic")))
            {
                throw new InvalidDataException("TitleName langID must either be 'generic' or have the format 'lang_' followed by 1-2 letters, ending in 1-2 numbers");
            }

            // NAM
            // trim and ensure 1st is uppercase
            nam = Utility_Methods.FirstCharToUpper(nam.Trim());

            if (!Utility_Methods.ValidateName(nam))
            {
                throw new InvalidDataException("TitleName name must be 1-40 characters long and contain only valid characters (a-z and ') or spaces");
            }

            this.langID = lang;
            this.name   = nam;
        }
예제 #4
0
        /// <summary>
        /// Constructor for Place_Serialised taking seperate values.
        /// For creating Place_Serialised from CSV file.
        /// </summary>
        /// <param name="id">String holding place ID</param>
        /// <param name="nam">String holding place name</param>
        /// <param name="own">String holding Place owner (ID)</param>
        /// <param name="tiHo">String holding place title holder (charID)</param>
        /// <param name="rnk">String holding Place rank (ID)</param>
        public Place_Serialised(String id, String nam, byte r, String tiHo = null, string own = null)
        {
            // VALIDATION

            // ID
            // trim and ensure is uppercase
            id = id.Trim().ToUpper();

            if (!Utility_Methods.ValidatePlaceID(id))
            {
                throw new InvalidDataException("Place_Serialised id must be 5 characters long, start with a letter, and end in at least 2 numbers");
            }

            // NAM
            // trim and ensure 1st is uppercase
            nam = Utility_Methods.FirstCharToUpper(nam.Trim());

            if (!Utility_Methods.ValidateName(nam))
            {
                throw new InvalidDataException("Place_Serialised name must be 1-40 characters long and contain only valid characters (a-z and ') or spaces");
            }

            // TIHO
            if (!String.IsNullOrWhiteSpace(tiHo))
            {
                // trim and ensure 1st is uppercase
                tiHo = Utility_Methods.FirstCharToUpper(tiHo.Trim());

                if (!Utility_Methods.ValidateCharacterID(tiHo))
                {
                    throw new InvalidDataException("Place_Serialised titleHolder must have the format 'Char_' followed by some numbers");
                }
            }

            // OWNER
            if (!String.IsNullOrWhiteSpace(owner))
            {
                // trim and ensure 1st is uppercase
                owner = Utility_Methods.FirstCharToUpper(owner.Trim());

                if (!Utility_Methods.ValidateCharacterID(owner))
                {
                    throw new InvalidDataException("Place_Serialised owner must have the format 'Char_' followed by some numbers");
                }
            }

            this.id          = id;
            this.name        = nam;
            this.owner       = own;
            this.titleHolder = tiHo;
            this.rank        = r;
        }
예제 #5
0
        /// <summary>
        /// Constructor for Kingdom_Serialised taking seperate values.
        /// For creating Kingdom_Serialised from CSV file.
        /// </summary>
        /// <param name="nat">Kingdom's Nationality object</param>
        public Kingdom_Serialised(String id, String nam, byte r, string nat, String tiHo = null, string own = null)
            : base(id, nam, r, own: own, tiHo: tiHo)
        {
            // VALIDATION

            // NAT
            // trim and ensure 1st is uppercase
            nat = Utility_Methods.FirstCharToUpper(nat.Trim());

            if (!Utility_Methods.ValidateNationalityID(nat))
            {
                throw new InvalidDataException("Kingdom_Serialised nationality ID must be 1-3 characters long, and consist entirely of letters");
            }

            this.nationality = nat;
        }
예제 #6
0
        /// <summary>
        /// Constructor for Position
        /// </summary>
        /// <param name="holder">string holding ID of the office holder</param>
        /// <param name="nat">Nationality associated with the position</param>
        public Position(byte id, TitleName[] ti, byte stat, string holder, Nationality nat)
            : base(id, ti, stat)
        {
            // VALIDATION

            // HOLDER
            if (!String.IsNullOrWhiteSpace(holder))
            {
                // trim and ensure 1st is uppercase
                holder = Utility_Methods.FirstCharToUpper(holder.Trim());

                if (!Utility_Methods.ValidateCharacterID(holder))
                {
                    throw new InvalidDataException("Position officeHolder id must have the format 'Char_' followed by some numbers");
                }
            }

            this.officeHolder = holder;
            this.nationality  = nat;
        }
예제 #7
0
        /// <summary>
        /// Constructor for Position_Serialised taking seperate values.
        /// For creating Position_Serialised from CSV file.
        /// </summary>
        /// <param name="id">byte holding Position ID</param>
        /// <param name="ti">title name in various languages</param>
        /// <param name="stat">byte holding stature for this position</param>
        /// <param name="holder">string ID of the office holder</param>
        /// <param name="nat">string holding ID of Nationality associated with the position</param>
        public Position_Serialised(byte id, TitleName[] ti, byte stat, string holder, string nat)
        {
            // VALIDATION

            // STAT
            if (stat < 1)
            {
                stat = 1;
            }
            else if (stat > 3)
            {
                stat = 3;
            }

            // HOLDER
            if (!String.IsNullOrWhiteSpace(holder))
            {
                // trim and ensure 1st is uppercase
                holder = Utility_Methods.FirstCharToUpper(holder.Trim());

                if (!Utility_Methods.ValidateCharacterID(holder))
                {
                    throw new InvalidDataException("Position_Serialised officeHolder id must have the format 'Char_' followed by some numbers");
                }
            }

            // NAT
            // trim and ensure 1st is uppercase
            nat = Utility_Methods.FirstCharToUpper(nat.Trim());

            if (!Utility_Methods.ValidateNationalityID(nat))
            {
                throw new InvalidDataException("Position_Serialised nationality ID must be 1-3 characters long, and consist entirely of letters");
            }

            this.id           = id;
            this.title        = ti;
            this.stature      = stat;
            this.officeHolder = holder;
            this.nationality  = nat;
        }
예제 #8
0
        /// <summary>
        /// Constructor for Trait
        /// </summary>
        /// <param name="id">String holding trait ID</param>
        /// <param name="nam">String holding trait name</param>
        /// <param name="effs">Dictionary(string, double) holding trait effects</param>
        public Trait(String id, String nam, Dictionary <Globals_Game.Stats, double> effs)
        {
            // VALIDATION

            // ID
            // trim
            id = id.Trim();

            if (!Utility_Methods.ValidateTraitID(id))
            {
                throw new InvalidDataException("Trait ID must have the format 'trait_' followed by some numbers");
            }

            // NAM
            // trim and ensure 1st is uppercase
            nam = Utility_Methods.FirstCharToUpper(nam.Trim());

            if (!Utility_Methods.ValidateName(nam))
            {
                throw new InvalidDataException("Trait name must be 1-40 characters long and contain only valid characters (a-z and ') or spaces");
            }

            // effect values
            double[] effVals = new double[effs.Count];
            effs.Values.CopyTo(effVals, 0);

            for (int i = 0; i < effVals.Length; i++)
            {
                if ((effVals[i] < -0.99) || (effVals[i] > 0.99))
                {
                    throw new InvalidDataException("All Trait effect values must be doubles between -0.99 and 0.99");
                }
            }

            this.id      = id;
            this.name    = nam;
            this.effects = effs;
        }
예제 #9
0
        /// <summary>
        /// Constructor for Ailment
        /// </summary>
        /// <param name="id">String holding ailment ID</param>
        /// <param name="descr">string holding ailment description</param>
        /// <param name="wh">string holding ailment date</param>
        /// <param name="eff">uint holding current ailment effect</param>
        /// <param name="minEff">uint holding minimum ailment effect</param>
        public Ailment(String id, string descr, string wh, uint eff, uint minEff)
        {
            // VALIDATION

            // ID
            // trim and ensure 1st is uppercase
            id = Utility_Methods.FirstCharToUpper(id.Trim());

            if (!Utility_Methods.ValidateAilmentID(id))
            {
                throw new InvalidDataException("Ailment ID must have the format 'Ail_' followed by some numbers");
            }

            // DESCR
            // trim and ensure 1st is uppercase
            descr = Utility_Methods.FirstCharToUpper(descr.Trim());

            if (!Utility_Methods.ValidateName(descr))
            {
                throw new InvalidDataException("Ailment description must be 1-40 characters long and contain only valid characters (a-z and ') or spaces");
            }

            // WHEN
            // trim and ensure 1st is uppercase
            wh = Utility_Methods.FirstCharToUpper(wh.Trim());

            // check contains season
            if (!wh.Contains("Spring"))
            {
                if (!wh.Contains("Summer"))
                {
                    if (!wh.Contains("Autumn"))
                    {
                        if (!wh.Contains("Winter"))
                        {
                            throw new InvalidDataException("Ailment 'when' must specify the season and year in which the ailment occurred");
                        }
                    }
                }
            }

            // EFF
            // check must be 1-5
            if ((eff < 1) || (eff > 5))
            {
                throw new InvalidDataException("Ailment effect must be a uint between 1-5");
            }

            // MINEFF
            // check not > 1
            if (minEff > 1)
            {
                throw new InvalidDataException("Ailment minimumEffect must be a uint less than 2");
            }

            this.ailmentID     = id;
            this.description   = descr;
            this.when          = wh;
            this.effect        = eff;
            this.minimumEffect = minEff;
        }
예제 #10
0
        /// <summary>
        /// Create a new JournalEntry- used for more complex messages that would be more appropriate to be reconstructed on the client side
        /// </summary>
        /// <param name="m"></param>
        /// <param name="id"></param>
        /// <param name="yr"></param>
        /// <param name="seas"></param>
        /// <param name="pers"></param>
        /// <param name="typ"></param>
        /// <param name="loc"></param>
        /// <param name="desc"></param>
        public JournalEntry(ProtoMessage m, uint id, uint yr, byte seas, String[] pers, String typ, String loc = null, string desc = null)
        {
            this.entryDetails = m;
            // VALIDATION

            // SEAS
            // check between 0-3
            if (!Utility_Methods.ValidateSeason(seas))
            {
                throw new InvalidDataException("JournalEntry season must be a byte between 0-3");
            }

            // PERS
            if (pers.Length > 0)
            {
                for (int i = 0; i < pers.Length; i++)
                {
                    // split using'|'
                    string[] persSplit = pers[i].Split('|');
                    if (persSplit.Length > 1)
                    {
                        // character ID: trim and ensure 1st is uppercase
                        if (!persSplit[0].Contains("all"))
                        {
                            persSplit[0] = Utility_Methods.FirstCharToUpper(persSplit[0].Trim());
                        }
                        // trim role
                        persSplit[1] = persSplit[1].Trim();
                        // put back together
                        pers[i] = persSplit[0] + "|" + persSplit[1];
                    }

                    if (!Utility_Methods.ValidateJentryPersonae(pers[i]))
                    {
                        throw new InvalidDataException("Each JournalEntry personae must consist of 2 sections of letters, divided by '|', the 1st of which must be a valid character ID");
                    }
                }
            }

            // TYPE
            if (String.IsNullOrWhiteSpace(typ))
            {
                throw new InvalidDataException("JournalEntry type must be a string > 0 characters in length");
            }

            // LOC
            if (!String.IsNullOrWhiteSpace(loc))
            {
                // trim and ensure is uppercase
                loc = loc.Trim().ToUpper();

                if (!Utility_Methods.ValidatePlaceID(loc))
                {
                    throw new InvalidDataException("JournalEntry location id must be 5 characters long, start with a letter, and end in at least 2 numbers");
                }
            }

            this.jEntryID = id;
            this.year     = yr;
            this.season   = seas;
            this.personae = pers;
            this.type     = typ;
            if (!String.IsNullOrWhiteSpace(loc))
            {
                this.location = loc;
            }
            this.viewed = false;
        }