Ejemplo n.º 1
0
        public StarSystem(DraftStarSystem source)
        {
            Name   = source.Name;
            Level  = int.Parse(source?.Level);
            System = source.System;

            Resources = new List <ResourceType>();
            ProcessElements(source);
            ProcessHostiles(source);
        }
Ejemplo n.º 2
0
        protected void ProcessElements(DraftStarSystem source)
        {
            ResourceProperties.ForEach((prop) =>
            {
                var propValue    = prop.GetValue(source);
                var elementType  = ElementType.Crystal;
                var elementGrade = ElementGrade.None;
                if ((propValue?.ToString() ?? "") == "X")
                {
                    switch (prop.Name.Substring(prop.Name.Length - 1))
                    {
                    case "2":
                        elementType  = Enum.Parse <ElementType>(prop.Name.Substring(0, prop.Name.Length - 1));
                        elementGrade = ElementGrade.Two;
                        break;

                    case "3":
                        elementType  = Enum.Parse <ElementType>(prop.Name.Substring(0, prop.Name.Length - 1));
                        elementGrade = ElementGrade.Three;
                        break;

                    case "4":
                        elementType  = Enum.Parse <ElementType>(prop.Name.Substring(0, prop.Name.Length - 1));
                        elementGrade = ElementGrade.Four;
                        break;

                    default:
                        elementType  = Enum.Parse <ElementType>(prop.Name);
                        elementGrade = ElementGrade.None;
                        break;
                    }

                    Resources.Add(new ResourceType()
                    {
                        Type  = elementType,
                        Grade = elementGrade
                    });
                }
            });
        }
Ejemplo n.º 3
0
        protected void ProcessHostiles(DraftStarSystem source)
        {
            if ((source?.Battleship ?? "") == "X")
            {
                HostileTypes |= ShipType.Battleship;
            }

            if ((source?.Explorer ?? "") == "X")
            {
                HostileTypes |= ShipType.Explorer;
            }

            if ((source?.Interceptor ?? "") == "X")
            {
                HostileTypes |= ShipType.Interceptor;
            }

            if ((source?.Survey ?? "") == "X")
            {
                HostileTypes |= ShipType.Survey;
            }
        }