/// <summary>
        /// Checks the validity of the current blade id passed
        /// </summary>
        /// <param name="bladeId"></param>
        /// <returns></returns>
        public static bool checkBladeTypeValidity(byte bladeId)
        {
            try
            {
                // Open the request message using an xml reader
                XmlReader xr = OperationContext.Current.IncomingMessageHeaders.GetReaderAtHeader(0);

                // Split the URL at the API name--Parameters junction indicated by the '?' character - taking the first string will ignore all parameters
                string[] urlSplit = xr.ReadElementContentAsString().Split('/');
                // Extract just the API name and rest of the URL, which will be the last item in the split using '/'
                string[] apiSplit = urlSplit[3].Split('?');

                BladeType val = BladeType.Unknown;
                invalidBladeFunction.TryGetValue(apiSplit[0], out val);

                // If the blade type does not support this function, return false, so we can send back useful info to user
                if ((byte)val == ChassisState.GetBladeType(bladeId))
                {
                    Tracer.WriteWarning("Command {0} not valid for Blade id {1}, Blade Type {2}",
                                        apiSplit[0], bladeId, ChassisState.GetBladeTypeName((byte)val));

                    return(false);
                }
            }
            catch (Exception ex)
            {
                Tracer.WriteError("Checking Blade Type validity encountered an exception" + ex);
                // We decide to go ahead and issue the command to the blade if the blade type check fails with exception,
                // This is done in order to not penalize a user command based on some failure in checking
                // The command might fail eventually, but with an unhelpful error message
            }
            return(true);
        }
Beispiel #2
0
 public BladeItem(BladeType type, int metal, float purity) : this()
 {
     Type      = type;
     Metal     = metal;
     Purity    = purity;
     Sharpness = new float[Type.Points.Length];
 }
        public Blade(string na, string desc, byte id, byte wep, byte type, byte damtyp, byte risk, short str, short inte, short agi, byte range, byte damage)
        {
            bladeType  = bladeTypes[type];
            statistics = new Statistics();

            name        = na;
            description = desc;
            this.id     = id;
            wepID       = wep;
            damageType  = damageTypes[damtyp];
            this.risk   = risk;

            statistics.STR.value = str;
            statistics.INT.value = inte;
            statistics.AGI.value = agi;

            this.range = range;
        }
 public Blade(BladeType t)
 {
     bladeType  = t;
     statistics = new Statistics();
 }