コード例 #1
0
        private static void CompareMaps()
        {
            var todelete = new List <string>();

            foreach (var cell in Cells)
            {
                if (AbcCells.ContainsKey(cell.Value.CellNumber))
                {
                    continue;
                }

                todelete.Add(cell.Value.CellNumber);
            }

            foreach (var regnum in todelete)
            {
                Cells.Remove(regnum);
            }

            foreach (var abcCell in AbcCells)
            {
                if (Cells.ContainsKey(abcCell.Value.RegNum))
                {
                    continue;
                }

                var cell = new Cell
                {
                    CellNumber = abcCell.Value.RegNum,
                    Name       = abcCell.Value.Label
                };

                Cells.Add(cell.CellNumber, cell);
            }
        }
コード例 #2
0
        private static void LoadAbcMap()
        {
            var pathCellsXml = Path.Combine(Application.StartupPath, "abcells.xml");

            if (!File.Exists(pathCellsXml))
            {
                return;
            }

            string map2;

            try
            {
                map2 = File.ReadAllText(pathCellsXml, Encoding.UTF8);
            }
            catch
            {
                return;
            }

            //var sb = new StringBuilder();

            try
            {
                var xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(map2);
                var cellsNodeList = xmlDocument.GetElementsByTagName(AppConsts.TagAbcMapCell);
                foreach (XmlNode cellNode in cellsNodeList)
                {
                    if (cellNode.Attributes == null)
                    {
                        continue;
                    }

                    var abcCell = new AbcCell();
                    if (cellNode.Attributes[AppConsts.AttrAbcMapRegNum] == null)
                    {
                        continue;
                    }

                    abcCell.RegNum = cellNode.Attributes[AppConsts.AttrAbcMapRegNum].Value;
                    if (cellNode.Attributes[AppConsts.AttrAbcMapLabel] != null)
                    {
                        abcCell.Label = cellNode.Attributes[AppConsts.AttrAbcMapLabel].Value;
                        if (Cells.ContainsKey(abcCell.RegNum))
                        {
                            if (
                                !abcCell.Label.Equals(Cells[abcCell.RegNum].Tooltip,
                                                      StringComparison.CurrentCultureIgnoreCase))
                            {
                                //sb.Append(
                                //    $"Клетка [{abcCell.RegNum}] помечена как [{Cells[abcCell.RegNum].Tooltip}], должно быть [{abcCell.Label}]");
                                //sb.AppendLine();
                            }
                        }
                        else
                        {
                            //sb.Append($"Клетка [{abcCell.RegNum}] отсутствует");
                            //sb.AppendLine();
                        }
                    }

                    var cost = 0;
                    if (cellNode.Attributes[AppConsts.AttrAbcMapCost] != null)
                    {
                        if (!int.TryParse(cellNode.Attributes[AppConsts.AttrAbcMapCost].Value, out cost))
                        {
                            cost = 0;
                        }
                    }

                    abcCell.Cost = cost;
                    if (abcCell.Cost == 0)
                    {
                        if (Cells.ContainsKey(abcCell.RegNum))
                        {
                            var jcost = Cells[abcCell.RegNum].Cost;
                            if (jcost == 21)
                            {
                                abcCell.Cost = 30;
                            }
                            else
                            {
                                if (jcost == 28)
                                {
                                    abcCell.Cost = 40;
                                }
                                else
                                {
                                    if (jcost == 43)
                                    {
                                        abcCell.Cost = 60;
                                    }
                                }
                            }
                        }
                    }

                    var visited = DateTime.MinValue;
                    if (cellNode.Attributes[AppConsts.AttrAbcMapVisited] != null)
                    {
                        if (!DateTime.TryParse(cellNode.Attributes[AppConsts.AttrAbcMapVisited].Value, AppVars.EnUsCulture, DateTimeStyles.None, out visited))
                        {
                            visited = DateTime.MinValue;
                        }
                    }

                    abcCell.Visited = visited;

                    var verified = DateTime.MinValue;
                    if (cellNode.Attributes[AppConsts.AttrAbcMapVerified] != null)
                    {
                        if (!DateTime.TryParse(cellNode.Attributes[AppConsts.AttrAbcMapVerified].Value, AppVars.EnUsCulture, DateTimeStyles.None, out verified))
                        {
                            verified = DateTime.MinValue;
                        }
                    }

                    abcCell.Verified = verified;

                    AbcCells.Add(abcCell.RegNum, abcCell);
                }
            }
            catch
            {
            }

            //File.WriteAllText("maps-diff.txt", sb.ToString());
        }
コード例 #3
0
        internal static string CellDivText(int x, int y, int scale, string link, bool showmove, bool isframe)
        {
            var coor = MakePosition(x, y);

            if (coor == null)
            {
                return(string.Empty);
            }

            Position position;

            if (!Location.TryGetValue(coor, out position))
            {
                return(string.Empty);
            }

            var regnum = position.RegNum;

            if (regnum == null)
            {
                return(string.Empty);
            }

            Cell cell;

            if (!Cells.TryGetValue(regnum, out cell))
            {
                return(string.Empty);
            }

            var border = string.Empty;
            var id     = string.Empty;

            if (isframe)
            {
                border = "border:1px solid red;";
            }

            if (showmove)
            {
                border = "border:1px solid red;";
            }

            if (showmove)
            {
                id = "id=\"movingcell\" ";
            }
            else
            {
                if (AppVars.AutoMoving &&
                    AppVars.AutoMovingMapPath != null &&
                    AppVars.AutoMovingMapPath.Path.Length > 0 &&
                    Array.IndexOf(AppVars.AutoMovingMapPath.Path, regnum) >= 0)
                {
                    border = "border:1px solid red;";
                }
            }

            var cellnumcolor = HexColorCost(cell.Cost);

            var shortlabel = cell.Tooltip;

            if (shortlabel.IndexOf(',') != -1)
            {
                shortlabel = shortlabel.Split(',')[1];
            }

            var sb = new StringBuilder();

            sb.Append($"<div {id} style=\"position:relative; left:2px; top:2px; width:90px; height:90px; {border} padding:2px; text-shadow:1px 1px 1px, -1px -1px 1px, -1px 1px 1px, 1px -1px 1px; font-family:Tahoma; font-size:9px; font-weight:bold; text-decoration:none;\">");
            sb.Append($"<span style=\"font-size:11px; color:{cellnumcolor}\">{regnum}</span>");
            sb.Append($"<br><span style=\"color:#C0C0C0\">{shortlabel}</span>");

            if (cell.HasFish)
            {
                sb.Append("<br><span style=\"color:#33CCFF\">Рыба</span>");
            }
            else
            {
                if (cell.HasWater)
                {
                    sb.Append("<br><span style=\"color:#33CCFF\">Вода</span>");
                }
            }

            if (!string.IsNullOrEmpty(cell.BotsTooltip))
            {
                sb.Append($"<br><span style=\"color:#88BBDD\">Боты {cell.MinBotLevel}");
                if (cell.MaxBotLevel > cell.MinBotLevel)
                {
                    sb.Append($"-{cell.MaxBotLevel}");
                }

                sb.Append("</span>");
            }

            if (!string.IsNullOrEmpty(cell.HerbGroup) && !cell.HerbGroup.Equals("0"))
            {
                HerbCell herbCell;
                if (AppVars.Profile.HerbCells.TryGetValue(cell.CellNumber, out herbCell))
                {
                    sb.AppendLine();
                    var diffUpdatedInTicks = DateTime.Now.Subtract(AppVars.Profile.ServDiff).Ticks - herbCell.UpdatedInTicks;
                    var diffUpdated        = TimeSpan.FromTicks(diffUpdatedInTicks);
                    sb.Append("<br><span style=\"color:#");
                    if (diffUpdated.TotalHours < 1)
                    {
                        sb.Append("00CC00");
                    }
                    else
                    {
                        if (diffUpdated.TotalHours < 2)
                        {
                            sb.Append("009900");
                        }
                        else
                        {
                            if (diffUpdated.TotalHours < 3)
                            {
                                sb.Append("006600");
                            }
                            else
                            {
                                sb.Append(diffUpdated.TotalHours < 6 ? "003300" : "999999");
                            }
                        }
                    }

                    sb.Append("\">Травы ");
                    sb.Append(cell.HerbGroup);
                    if (diffUpdated.TotalHours < 6)
                    {
                        var timeUpdated = TimeSpan.FromTicks(herbCell.UpdatedInTicks);
                        sb.Append(" (");
                        sb.Append(timeUpdated.Hours);
                        sb.Append(':');
                        sb.AppendFormat("{0:00}", timeUpdated.Minutes);
                        sb.Append(")");
                    }

                    sb.Append("</span>");
                }
                else
                {
                    sb.Append($"<br><span style=\"color:#999999\">Травы {cell.HerbGroup}</span>");
                }
            }

            AbcCell abccell;

            if (AbcCells.TryGetValue(regnum, out abccell))
            {
                var span = DateTime.Now.Subtract(AppVars.Profile.ServDiff).Subtract(abccell.Visited);
                if (span.TotalDays < 1.0)
                {
                    var visitedcolor = HexColorVisited(span.TotalHours);
                    sb.Append($"<br><span style=\"color:{visitedcolor}\">{abccell.Visited.Hour:D2}:{abccell.Visited.Minute:D2}</span>");
                }
            }

            sb.Append("</div>");
            return(sb.ToString());
        }