Beispiel #1
0
        private void Import(WarSylkItem from, WarSylkItem target)
        {
            bool isChangedTargetData = false;

            foreach (var fromItem in from.Columns)
            {
                // filter
                switch (fromItem.ColumnId)
                {
                case 3:
                case 5:
                case 22:
                case 23:
                case 24:
                case 25:
                case 29:
                case 30:
                case 37:
                case 38:
                case 39:
                case 40:
                case 42:
                case 43:
                case 44:
                case 45:
                case 46:
                case 47:
                    break;

                default:
                    continue;
                }

                var targetItem = target.Columns.FirstOrDefault(x => x.ColumnId == fromItem.ColumnId);
                if (targetItem != null && fromItem.Value != targetItem.Value)
                {
                    Echo($"{target.RawCode} get import {fromItem.Value}, old: {targetItem.Value}");
                    targetItem.Value = fromItem.Value;
                }
                else if (targetItem == null)
                {
                    Echo($"{target.RawCode} new value: {fromItem.Value}");
                    target.Columns.Add(new WarSylkColumn(fromItem.ColumnId, fromItem.Value, fromItem.Coordinate));
                    isChangedTargetData = true;
                }
            }

            if (isChangedTargetData)
            {
                target.Columns.OrderBy(x => x.ColumnId);
            }
        }
Beispiel #2
0
        private void ObjectiveText(List <string> body, List <WarSylkItem> list, bool isNeedUpGameData)
        {
            int i   = 0;
            int max = body.Count - 1;

            while (i <= max)
            {
                string line         = body[i];
                bool   isSystemLine = true;
                //string line = body.First();
                //if (line == null)
                //    break;

                // Find ID row
                var reg   = new Regex(RegRowPatern);
                var match = reg.Match(line);
                if (match.Success)
                {
                    if (lastWarItem != null) // Event msg
                    {
                        Echo(lastWarItem.ToStringConsole());
                    }

                    int rowNumber = Convert.ToInt32(match.Groups[1].Value);
                    lastWarItem = new WarSylkItem(i + 1);
                    list.Add(lastWarItem);
                    isSystemLine = false;
                }

                if (lastWarItem != null)
                {
                    // Find Column
                    reg   = new Regex(RegColumnPatern);
                    match = reg.Match(line);

                    // Get colum Index
                    if (match.Success)
                    {
                        lastColum = Convert.ToInt32(match.Groups[1].Value);
                    }

                    // Find Row Value
                    reg   = new Regex(RegGetValuePatern);
                    match = reg.Match(line);
                    if (match.Success)
                    {
                        string coord = match.Groups[1].Value;
                        string value = match.Groups[2].Value;
                        lastWarItem.AddValue(lastColum, value, coord);
                        isSystemLine = false;
                    }
                    else
                    {
                        if (lastWarItem != null) // Event msg
                        {
                            Echo(lastWarItem.ToStringConsole());
                        }
                        isSystemLine = true;
                    }
                }

                if (isSystemLine && isNeedUpGameData)
                {
                    list.Add(new WarSylkItem(i + 1, line));
                }

                i++;
            }

            body.Clear();
            Console.WriteLine("EndLoop");
        }