예제 #1
0
        /// <summary>
        /// Gets the exercise amplifying descriptor which can be
        /// Exercise, Joker, or Faker.
        /// </summary>
        /// <param name="symbolCode">the symbol code</param>
        /// <returns>the display character for Exercise, Joker, or Faker or (char)0 if there is an error</returns>
        public static char GetExerciseAmplifyingDescriptor(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return((char)0);
            }

            int identityKey = GetCode(symbolCode);

            if (identityKey == Joker)
            {
                return('J');
            }

            if (identityKey == Faker)
            {
                return('K');
            }

            if (identityKey == ExerciseAssumedFriend || identityKey == ExerciseFriend || identityKey == ExerciseNeutral ||
                identityKey == ExercisePending || identityKey == ExerciseUnknown)
            {
                return('X');
            }

            // Check the Navy's special cases
            if (Exercise.IsMatch(symbolCode))
            {
                return('X');
            }

            return((char)0);
        }
예제 #2
0
        /// <summary>
        /// Get the battle dimension code from the symbol code.
        /// </summary>
        /// <param name="symbolCode">the symbol code</param>
        /// <returns>the battle dimension code</returns>
        public static int GetCode(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(0);
            }

            int codingScheme = CodingScheme.GetCode(symbolCode);

            switch (codingScheme)
            {
            case CodingScheme.EmergencyManagement:
                return(Ems.ContainsKey(symbolCode[EmIndex]) ? Ems[symbolCode[EmIndex]] : 0);

            case CodingScheme.StabilityOperations:
                return(Sos.ContainsKey(symbolCode[SoIndex]) ? Sos[symbolCode[SoIndex]] : 0);

            case CodingScheme.Intelligence:
            case CodingScheme.Warfighting:
                return(Bds.ContainsKey(symbolCode[BdIndex]) ? Bds[symbolCode[BdIndex]] : 0);

            case CodingScheme.Weather:
                return(Metocs.ContainsKey(symbolCode[MetocIndex]) ? Metocs[symbolCode[MetocIndex]] : 0);

            case CodingScheme.TacticalGraphics:
                return(Tgs.ContainsKey(symbolCode[TgIndex]) ? Tgs[symbolCode[TgIndex]] : 0);
            }

            return(0);
        }
예제 #3
0
        /// <summary>
        /// Maps the actual standard identity into one of the four basic standard identities (affiliations)
        /// which include Friend, Hostile, Neutral, and Unknown. Normalize here strictly means "What will the templates understand?"
        /// </summary>
        /// <param name="symbolCode">the symbol code</param>
        /// <returns>an arbitrary integer representing Friend, Hostile, Neutral or Unknown or 0 if there is an error</returns>
        public static int GetNormalizedStandardIdentity(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(0);
            }

            switch (GetCode(symbolCode))
            {
            case ExercisePending:
            case Pending:
            case Unknown:
            case ExerciseUnknown:
                return(Unknown);

            case AssumedFriend:
            case ExerciseFriend:
            case Friend:
            case Joker:     // uses the friendly shape
            case Faker:     // uses the friendly shape
            case ExerciseAssumedFriend:
                return(Friend);

            case ExerciseNeutral:
            case Neutral:     // neutral
                return(Neutral);

            case Hostile:     // hostile
            case Suspect:
                return(Hostile);

            default:
                return(0);
            }
        }
예제 #4
0
        /// <summary>
        /// Determines whether a given symbol code has a non-empty mobility component
        /// </summary>
        /// <param name="symbolCode">
        /// The symbol code to check for mobility.
        /// </param>
        /// <returns>
        /// True is the symbol code contains a mobility component.
        /// </returns>
        public static bool IsMobility(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(false);
            }

            return(symbolCode[Index] == 'M' || symbolCode[Index] == 'N');
        }
예제 #5
0
        /// <summary>
        /// Get the two character string that is the combined modifier code
        /// </summary>
        /// <param name="symbolCode">the symbol code</param>
        /// <returns>the combined two character modifier code</returns>
        public static string GetCode(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(null);
            }

            return(symbolCode.Substring(Index, 2));
        }
예제 #6
0
        /// <summary>
        /// Get the symbol code's character for the coding scheme
        /// </summary>
        /// <param name="symbolCode">the symbol code</param>
        /// <returns>the coding scheme for the symbol code</returns>
        public static int GetCode(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(0);
            }

            return(Css.ContainsKey(symbolCode[Index]) ? Css[symbolCode[Index]] : 0);
        }
예제 #7
0
        /// <summary>
        /// Get the battle dimension code from the symbol code.
        /// </summary>
        /// <param name="symbolCode">The symbol code.</param>
        /// <returns>The battle dimension code.</returns>
        public static char GetCode(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return((char)0);
            }

            return(symbolCode[Index]);
        }
예제 #8
0
        /// <summary>
        /// Get the combined modifier code for the coding scheme.
        /// </summary>
        /// <param name="symbolCode">the symbol code</param>
        /// <returns>a friendly name for the combined modifier code</returns>
        public static string GetName(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(string.Empty);
            }

            char leadCode  = ModifierCode.GetCode(symbolCode);
            char trailCode = Echelon.GetCode(symbolCode);

            if (leadCode == ModifierCode.Mobility || leadCode == ModifierCode.Towed)
            {
                return(Mobility.GetName(symbolCode));
            }

            if (leadCode == ModifierCode.Installation)
            {
                return((trailCode == 'B') ? "Feint Dummy Installation" : "Installation");
            }

            string mod = ModifierCode.GetName(symbolCode);
            string ech = Echelon.GetName(symbolCode);

            if (string.IsNullOrEmpty(mod) || string.IsNullOrEmpty(ech))
            {
                return(string.Empty);
            }

            if (mod == "None" && ech == "None")
            {
                return(string.Empty);
            }

            if (mod == "None")
            {
                return(ech);
            }

            if (ech == "None")
            {
                return(mod);
            }

            return(mod + "\n" + ech);
        }
예제 #9
0
        /// <summary>
        /// Determines if the background color should be hostile.
        /// This includes Hostile, Joker, Faker, and Suspect.
        /// </summary>
        /// <param name="symbolCode">the symbol code</param>
        /// <returns>true if the background color should be hostile</returns>
        public static bool IsColorHostile(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(false);
            }

            switch (symbolCode[Index])
            {
            case 'H':
            case 'J':
            case 'K':
            case 'S':
                return(true);
            }

            return(false);
        }
예제 #10
0
        /// <summary>
        /// Generate a full or partial "X" shape to represent damaged or destroyed entities
        /// </summary>
        /// <param name="symbolCode">symbol code for the entity</param>
        /// <returns>shape representing the damage</returns>
        internal static Shape Generate(string symbolCode)
        {
            if (!SymbolData.Check(ref symbolCode))
            {
                return(null);
            }

            if (GetCode(symbolCode) == PresentDamaged)
            {
                return(new Path
                {
                    Style = SymbolData.GetStyle("TS50"),
                    Data = new PathGeometry
                    {
                        Figures = new PathFigureCollection
                        {
                            Segment(-120, 174, 120, -174)
                        }
                    }
                });
            }

            if (GetCode(symbolCode) == PresentDestroyed)
            {
                return(new Path
                {
                    Style = SymbolData.GetStyle("TS50"),
                    Data = new PathGeometry
                    {
                        Figures = new PathFigureCollection
                        {
                            Segment(-120, 174, 120, -174),
                            Segment(-120, -174, 120, 174)
                        }
                    }
                });
            }

            return(null);
        }
예제 #11
0
 /// <summary>
 /// Get the echelon code for the given symbol code.
 /// </summary>
 /// <param name="symbolCode">the symbol code</param>
 /// <returns>the echelon code for the given symbol code</returns>
 public static char GetCode(string symbolCode)
 {
     return(!SymbolData.Check(ref symbolCode) ? (char)0 : symbolCode[Index]);
 }
예제 #12
0
 /// <summary>
 /// Get the two character country code for the given symbol code
 /// </summary>
 /// <param name="symbolCode">the symbol code</param>
 /// <returns>the two character country code for the given symbol code</returns>
 public static string GetCode(string symbolCode)
 {
     return(!SymbolData.Check(ref symbolCode) ? string.Empty : symbolCode.Substring(Index, 2));
 }
예제 #13
0
 /// <summary>
 /// Get the standard identity (aka affiliation) for the given symbol code.
 /// </summary>
 /// <param name="symbolCode">the symbol code</param>
 /// <returns>an arbitrary standard identity integer code for the given symbol code</returns>
 public static int GetCode(string symbolCode)
 {
     return(!SymbolData.Check(ref symbolCode)
                ? 0
                : (Sis.ContainsKey(symbolCode[Index]) ? Sis[symbolCode[Index]] : 0));
 }