public StructureItem TransformStructure(swgemurpcserver.rpc.SWGEmuCharacterStructureItem charStructItem)
        {
            var item = new StructureItem()
            {
                display_name = charStructItem.DisplayName,
                object_id    = charStructItem.ObjectId,
                object_name  = charStructItem.ObjectName
            };

            if (StringDetails != null)
            {
                item.resolved_object_name = StringDetails.Get(charStructItem.ObjectName);
            }

            return(item);
        }
Beispiel #2
0
        public int solution(string[] words)
        {
            // write your code in C# 6.0 with .NET 4.5 (Mono)
            Dictionary <char, StringDetailsList> d = new Dictionary <char, StringDetailsList>();

            for (int i = 0; i < words.Length; i++)
            {
                for (int j = 0; j < words[i].Length; j++)
                {
                    char x = words[i][j];

                    StringDetails sd = new StringDetails {
                        Index = i, Chr = words[i][j], AvlPosition = j == 0 ? Positions.Front : Positions.None, Count = 1
                    };

                    while (j + 1 < words[i].Length && words[i][j + 1] == sd.Chr)
                    {
                        sd.Count++;
                        j++;
                    }

                    if (j == words[i].Length - 1)
                    {
                        sd.AvlPosition += 2;
                    }

                    if (!d.ContainsKey(sd.Chr))
                    {
                        d.Add(sd.Chr, new StringDetailsList());
                    }

                    d[sd.Chr].Add(sd);
                }
            }


            int bigMax = 0;

            foreach (char key in d.Keys)
            {
                bigMax = Math.Max(bigMax, d[key].CalcBestCount());
            }

            return(bigMax);
        }
Beispiel #3
0
            public void Add(StringDetails sd)
            {
                switch (sd.AvlPosition)
                {
                case Positions.Front:
                    _frontList.Add(sd);
                    break;

                case Positions.None:
                    _maxNoneCount = Math.Max(sd.Count, _maxNoneCount);
                    break;

                case Positions.Back:
                    _backList.Add(sd);
                    break;

                case Positions.Both:
                    _bothCount += sd.Count;
                    break;
                }
            }
Beispiel #4
0
            public int CalcBestCount()
            {
                StringDetails maxFront = GetMax(-1, _frontList);
                StringDetails maxBack  = GetMax(-1, _backList);

                if (maxFront.Index == maxBack.Index)
                {
                    var newMaxFront = GetMax(maxFront.Index, _frontList);
                    var newMaxBack  = GetMax(maxBack.Index, _backList);

                    if (newMaxBack.Count + maxFront.Count > maxBack.Count + newMaxFront.Count)
                    {
                        maxBack = newMaxBack;
                    }
                    else
                    {
                        maxFront = newMaxFront;
                    }
                }

                return(Math.Max(_maxNoneCount, maxFront.Count + maxBack.Count + _bothCount));
            }
Beispiel #5
0
            public StringDetails GetMax(int excludeIndex, List <StringDetails> list)
            {
                if (list.Count == 0 || (list.Count == 1 && excludeIndex == 0))
                {
                    return new StringDetails {
                               Index = -1, Count = 0
                    }
                }
                ;

                StringDetails maxDetails = new StringDetails {
                    Index = -1, Count = 0
                };

                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].Index != excludeIndex && list[i].Count > maxDetails.Count)
                    {
                        maxDetails = list[i];
                    }
                }
                return(maxDetails);
            }
        public StructureItemDetails TransformStructureDetails(swgemurpcserver.rpc.SWGEmuStructureItemDetails details)
        {
            StructureItemDetails structItem = null;

            if (details.HasBuildingDetails)
            {
                structItem = new BuildingStructureItemDetails()
                {
                    contained_items = details.BuildingDetails.ContainedItemsList.ToList()
                                      .ConvertAll <object>(cur => InventoryTransform.TransformInventoryItem(cur)).ToList()
                };
            }
            else if (details.HasInstallationDetails)
            {
                InstallationStructureItemDetails instDetails = null;
                if (details.InstallationDetails.HasFactoryDetails)
                {
                    instDetails = new FactoryInstallationItemDeatils()
                    {
                        shcematic        = InventoryTransform.TransformInventoryItem(details.InstallationDetails.FactoryDetails.Schematic),
                        ingredient_items = details.InstallationDetails.FactoryDetails.IngredientItemsList.ToList()
                                           .ConvertAll <object>(cur => InventoryTransform.TransformInventoryItem(cur)).ToList()
                    };
                }
                else if (details.InstallationDetails.HasHarvesterDetails)
                {
                    instDetails = new HarvesterInstallationItemDetails()
                    {
                        extraction_rate = details.InstallationDetails.HarvesterDetails.ExtractionRate
                    };
                }

                if (instDetails == null)
                {
                    instDetails = new InstallationStructureItemDetails();
                }

                instDetails.actual_rate     = details.InstallationDetails.ActualRate;
                instDetails.max_hopper_size = details.InstallationDetails.MaxHopperSize;
                instDetails.actual_rate     = details.InstallationDetails.ActualRate;
                instDetails.hopper_items    = details.InstallationDetails.HopperItemsList.ToList()
                                              .ConvertAll <object>(cur => InventoryTransform.TransformInventoryItem(cur)).ToList();

                structItem = instDetails;
            }

            if (structItem == null)
            {
                structItem = new StructureItemDetails();
            }
            structItem.owner_account_id     = details.OwnerAccountId;
            structItem.owner_object_guid    = details.OwnerObjectId;
            structItem.portals_file_name    = details.PortalsFileName;
            structItem.template_file_name   = details.TemplateFileName;
            structItem.appearance_file_name = details.AppearanceFileName;
            structItem.decay_percent        = details.DecayPercent;
            structItem.display_name         = details.DisplayName;
            structItem.lot_size             = details.LotSize;
            structItem.maintenance          = details.Maintenance;
            structItem.object_id            = details.ObjectId;
            structItem.object_name          = details.ObjectName;
            structItem.owner_display_name   = details.OwnerDisplayName;
            structItem.power   = details.Power;
            structItem.world_x = details.WorldX;
            structItem.world_y = details.WorldY;
            structItem.world_z = details.WorldZ;
            structItem.zone    = details.Zone;

            if (StringDetails != null)
            {
                structItem.resolved_object_name = StringDetails.Get(details.ObjectName);
            }

            return(structItem);
        }