private static void InitPowerUps()
 {
     powerUps = new PowerUp[3];
     powerUps[0] = new AdditionalMove();
     powerUps[1] = new Expand();
     powerUps[2] = new Extend();
 }
		void OnItemClick (object sender, AdapterView.ItemClickEventArgs e)
		{
			TreeItem selectedItem = DC.CurrentList[e.Position];
			var newData = DC.AddNewDataForLevel (selectedItem);
			var exp = new Expand<TreeItem> (DC);
			exp.ManipulateCollection (selectedItem, newData);
		}
Exemple #3
0
        private void LoadData()
        {
            DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager();

            SearchType searchType = SearchType.Begins;

            if (BContains)
            {
                searchType = SearchType.Contains;
            }

            DictionarySearchResultCollection resultCollection = null;

            // Translate page number into offset.
            // One less than the current page number (with sanity check), times the page size
            // translates from a "first page is 1" page number to a "first record is zero" offset into the
            // list of results.
            int offset = ((CurrentPageIndex > 0 ? CurrentPageIndex : 1) - 1) * PageSize;

            if (!String.IsNullOrEmpty(Expand)) // A-Z expand provided - do an A-Z search
            {
                string searchText;
                if (Expand.ToLower() == "all")
                {
                    searchText = "%";
                }
                else
                {
                    searchText = Expand;
                }

                string filter = GetDrugDictionaryFilter();

                resultCollection = _dictionaryAppManager.Expand(searchText, filter, offset, PageSize, NCI.Web.Dictionary.DictionaryType.drug, PageAssemblyContext.Current.PageAssemblyInstruction.Language, "v1");
            }

            if (resultCollection != null && resultCollection.Count() > 0)
            {
                resultListView.DataSource = resultCollection;
                resultListView.DataBind();
                NumResults         = resultCollection.ResultsCount;
                lblWord.Text       = Expand.Replace("[[]", "[");
                lblNumResults.Text = NumResults.ToString();
                if (NumResults == 0)
                {
                    RenderNoResults();
                }
            }
            else
            {
                RenderNoResults();
            }
        }
Exemple #4
0
            public void It_will_handle_overloaded_ctors()
            {
                var programmingLanguages = Expand.Table(@"  
                    Name    | YearInvented  | IsOpenSource  | Comment
                    C#      | 2001          | false         |
                    foobar  | 1996          | true          | Something I just invented for the sake of the test
                ").ToListOf <ProgrammingLanguage>();

                Assert.AreEqual(2, programmingLanguages.Count());
                var foobar = programmingLanguages.ElementAt(1);

                Assert.IsTrue(foobar.IsOpoenSource);
            }
Exemple #5
0
            public void Setup()
            {
                groupsOfProgrammingLanguages = Expand.GroupOfTables(@"
                    Static:
                    Name    | YearInvented  | IsOpenSource
                    C#      | 2001          | false
                    Java    | 1995          | true 

                    Dynamic:
                    Name        | YearInvented  | IsOpenSource
                    JavaScript  | 1994          | false
                ");
            }
Exemple #6
0
 /// <summary>Generate the code-behind</summary>
 protected override byte[] GenerateCode(string src_filepath, string src)
 {
     try
     {
         var current_dir = Path.GetDirectoryName(src_filepath) ?? string.Empty;
         var result      = Expand.Html(new StringSrc(src), current_dir);
         return(Encoding.UTF8.GetBytes(result));
     }
     catch (Exception ex)
     {
         var msg = "HTML Expansion failed" + Environment.NewLine + "Exception:" + Environment.NewLine + ex.Message;
         return(Encoding.UTF8.GetBytes(msg));
     }
 }
Exemple #7
0
            public void It_is_possible_to_specify_culture()
            {
                var persons = Expand.Table(@"
                    Name    | Salary
                    Steve   | 100,50
                    bill    | 50000,90
                ").Culture(new CultureInfo("nb-NO")).ToListOf <Person>();

                Assert.AreEqual(2, persons.Count);
                var steve = persons[0];
                var bill  = persons[1];

                Assert.AreEqual(100.50, steve.Salary);
                Assert.AreEqual(50000.90, bill.Salary);
            }
Exemple #8
0
            public void It_will_handle_two_groups()
            {
                var groups = Expand.GroupOfTables(@"
                    Static:
                    Name    | YearInvented  | IsOpenSource
                    C#      | 2001          | false

                    dynamic:
                    Name        | YearInvented  | IsOpenSource
                    JavaScript  | 1994      | false
                ");

                Assert.IsNotNull(groups.Group1);
                Assert.IsNotNull(groups.Group2);
                Assert.IsNull(groups.Group3);
            }
Exemple #9
0
    protected void InitializeEffect()
    {
        // エクスパンドエフェクトを取得
        expand = GetComponent <Expand>();
        if (expand)
        {
            expand.enabled = true;
        }

        // コントラクトエフェクトを取得
        contract = GetComponent <Contract>();
        if (contract)
        {
            contract.enabled = false;
        }
    }
Exemple #10
0
        public FlightReplayViewModel(Simulation simulation, bool isExpanded, INavigation navigation, IMediaPlayer player, ISettings settings)
        {
            this.player         = player;
            this.settings       = settings;
            Video               = simulation.Video;
            SimulationViewModel = new SimulationViewModel(simulation, player.Position, simulation.PresentationOptions);

            Scale = 1D;
            var ratio = Video.Width / Video.Height;

            width  = this.WhenAnyValue(x => x.Scale).Select(x => 1 / x * ratio * BaseSize).ToProperty(this, x => x.Width);
            height = this.WhenAnyValue(x => x.Scale).Select(x => 1 / x * BaseSize).ToProperty(this, x => x.Height);
            Play   = ReactiveCommand.Create(() => MediaPlayer.Play());
            Expand = ReactiveCommand.CreateFromTask(() => navigation.Go <FlightReplayViewModel>(new { simulation, isExpanded = true }), Observable.Return(!isExpanded));
            Expand.Subscribe(_ => IsExpanded = true);
            GoBack = ReactiveCommand.CreateFromTask(navigation.GoBack);
        }
            protected virtual IEnumerable <string> GetParts()
            {
                if (Select.Any())
                {
                    yield return("$select=" + String.Join(",", Select));
                }

                if (Expand.Any())
                {
                    yield return("$expand=" + String.Join(",", Expand.Select(e => $"{e.PropertyName}({e})")));
                }

                if (Filter.Any())
                {
                    yield return("$filter=" + String.Join(" and ", Filter));
                }
            }
        async System.Threading.Tasks.Task Toggle(MouseEventArgs args)
        {
            collapsed           = !collapsed;
            contentStyle        = collapsed ? "display: none;" : "display: block;";
            summaryContentStyle = !collapsed ? "display: none" : "display: block";

            if (collapsed)
            {
                await Collapse.InvokeAsync(args);
            }
            else
            {
                await Expand.InvokeAsync(args);
            }

            StateHasChanged();
        }
Exemple #13
0
    public static Expand Table(String inputData)
    {
        if (inputData == null)
        {
            throw new ArgumentNullException();
        }
        if (String.IsNullOrEmpty(inputData))
        {
            throw new ArgumentException("String can't be empty");
        }

        var expand = new Expand();

        expand.table = inputData;

        return(expand);
    }
Exemple #14
0
        protected override void Serialize(IDictionary<string, object> json)
        {
            if (!Enabled)
            {
                json["animation"] = false;
            }
            else
            {
                var options = Expand.ToJson();

                options.Merge(Collapse.ToJson());

                if (options.Keys.Any())
                {
                    json["animation"] = options;
                }
            }
        }
Exemple #15
0
            public void It_handle_norwegian_datetime_values()
            {
                var employees = Expand.GroupOfTables(@"
                    addresses:
                    StreetName          | StreetNumber
                    Elm street          | 1
                    Washington          | 2

                    employees:
                    Name    | Age | Salary      | Height    | DateOfBirth
                    Steve   | 55  | 150000      | 188,8     | 24.02.1955 13:00:10
                    Bill    | 56  | 160000,10   | 166,5     | 28.10.1955 12:10:05

                ").Culture(new CultureInfo("nb-NO")).Group2.ToListOf <Person>();

                Assert.AreEqual(2, employees.Count());
                Assert.AreEqual(new DateTime(1955, 2, 24, 13, 0, 10), employees.ElementAt(0).DateOfBirth);
            }
Exemple #16
0
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement(this.GetType().ToString());
            writer.WriteAttributeString("assembly", CurrentAssemblyName);
            writer.WriteAttributeString("title", title.Text);
            writer.WriteAttributeString("Expand", Expand.ToString());

            writer.WriteStartElement("widget");
            IXmlSerializable xmlitm = CurrentWidget as IXmlSerializable;

            if (xmlitm != null)
            {
                xmlitm.WriteXml(writer);
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Exemple #17
0
        public void ExpandRootButton()
        {
            if (!innerRingExpanded)
            {
                // set flag
                innerRingExpanded = true;

                // expand button
                Expand.Begin();

                // if there is only one button in the inner ring, expand the outer ring automatically if any items are in there
                if (Configuration?.SubButtonConfigurations?.Count() == 1 && Configuration.SubButtonConfigurations.ElementAtOrDefault(0)?.SubButtonConfigurations?.Count() > 0)
                {
                    // setup sub items
                    SetupSubItems(Configuration.SubButtonConfigurations.ElementAtOrDefault(0).SubButtonConfigurations.Select(subItem => itemContainerDict[subItem]));
                }
            }
        }
Exemple #18
0
        /// <summary>
        /// Setup shared by English and Spanish versions
        /// </summary>
        private void SetupCommon()
        {
            if (!string.IsNullOrEmpty(SrcGroup))
            {
                BContains = Convert.ToBoolean(SrcGroup);
            }

            if (!string.IsNullOrEmpty(Expand))
            {
                if (Expand.Trim() == "#")
                {
                    Expand = "[0-9]";
                }
                else
                {
                    Expand = Expand.Trim().ToUpper();
                }
            }
        }
    private Contract contract;                  // コントラクトエフェクト



    // Use this for initialization
    void Start()
    {
        // メニューの初期設定
        mode     = GearScript.Mode.Credit;
        nextMode = GearScript.Mode.Credit;



        // エクスパンドエフェクトを取得
        expand = GetComponent <Expand>();

        // コントラクトエフェクトを取得
        contract = GetComponent <Contract>();



        // フェードイン
        FadeIn();
    }
Exemple #20
0
        /// <summary>
        /// Returns the page's query parameters for use in paging.
        /// </summary>
        private Dictionary <string, string> GetPageQueryParams()
        {
            Dictionary <string, string> queryParams = new Dictionary <string, string>();

            //add expand
            if (!string.IsNullOrEmpty(Expand))
            {
                if (Expand.Trim() == "#")
                {
                    queryParams.Add("expand", "%23");
                }
                else
                {
                    queryParams.Add("expand", Expand.Trim());
                }
            }

            return(queryParams);
        }
Exemple #21
0
        private void LoadData()
        {
            DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager();

            SearchType searchType = SearchType.Begins;

            if (BContains)
            {
                searchType = SearchType.Contains;
            }

            DictionarySearchResultCollection resultCollection = null;

            if (!String.IsNullOrEmpty(Expand)) // A-Z expand provided - do an A-Z search
            {
                if (Expand.ToLower() == "all")
                {
                    resultCollection = _dictionaryAppManager.Search("%", searchType, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.term, PageAssemblyContext.Current.PageAssemblyInstruction.Language);
                }
                else
                {
                    resultCollection = _dictionaryAppManager.Search(Expand, searchType, 0, int.MaxValue, NCI.Web.Dictionary.DictionaryType.term, PageAssemblyContext.Current.PageAssemblyInstruction.Language);
                }
            }

            if (resultCollection != null && resultCollection.Count() > 0)
            {
                resultListView.DataSource = resultCollection;
                resultListView.DataBind();
                NumResults         = resultCollection.ResultsCount;
                lblWord.Text       = Expand.Replace("[[]", "[");
                lblNumResults.Text = NumResults.ToString();
                if (NumResults == 0)
                {
                    RenderNoResults();
                }
            }
            else
            {
                RenderNoResults();
            }
        }
        internal async Task ExpandExec(MouseEventArgs args, int paneIndex, string paneId)
        {
            var pane     = Panes[paneIndex];
            var paneNext = pane.Next();

            if (paneNext != null && paneNext.Collapsible && paneNext.IsLast && !pane.Collapsed)
            {
                if (Collapse.HasDelegate)
                {
                    var arg = new RadzenSplitterEventArgs {
                        PaneIndex = paneNext.Index, Pane = paneNext
                    };
                    await Collapse.InvokeAsync(arg);

                    if (arg.Cancel)
                    {
                        return;
                    }
                }

                paneNext.Collapsed = true;
            }
            else
            {
                if (Expand.HasDelegate)
                {
                    var arg = new RadzenSplitterEventArgs {
                        PaneIndex = pane.Index, Pane = pane
                    };
                    await Expand.InvokeAsync(arg);

                    if (arg.Cancel)
                    {
                        return;
                    }
                }

                pane.Collapsed = false;
            }

            await InvokeAsync(StateHasChanged);
        }
Exemple #23
0
        private void PerformCommand(string command, List <string> args)
        {
            // FIXME: Get first X characters where X is length of cmdchars, to support more-than-one-character command prefix
            if (command[0].ToString() == IrcSettings.Set.cmdchars)
            { // Check for double // command to skip alias processing
                command = command.Substring(1);
            }
            else
            { // Process aliases first and replace command and args appropriately
                foreach (var alias in IrcSettings.Aliases.ToArray())
                {
                    if (command.ToUpper() == alias.Key)
                    {
                        List <string> alias_args = alias.Value.Split(' ').ToList();
                        command = alias_args[0];
                        alias_args.RemoveAt(0);
                        if (alias_args.Count == 0)
                        {
                            alias_args.AddRange(args);
                            args = alias_args;
                        }
                        else
                        {
                            args = Expand.DollarArgs(alias_args, args);
                        }
                    }
                }
            }

            List <string> command_output = new List <string>();

            command_output = Commands.ProcessCommand(command, args);

            if (command_output.Count > 0)
            {
                Channel.EchoList(command_output);
            }
        }
        /// <summary>
        /// Create the <see cref="JoinTrie"/> from the paths in all the arguments
        /// </summary>
        private JoinTrie PrepareJoin(ArraySegment <string>?pathToCollection = null)
        {
            // construct the join tree
            var allPaths = new List <string[]>();

            if (Select != null)
            {
                allPaths.AddRange(Select.Select(e => e.Path));
            }

            if (Expand != null)
            {
                allPaths.AddRange(Expand.Select(e => e.Path));
            }

            if (Filter != null)
            {
                allPaths.AddRange(Filter.ColumnAccesses().Select(e => e.Path));
            }

            if (OrderBy != null)
            {
                allPaths.AddRange(OrderBy.ColumnAccesses().Select(e => e.Path));
            }

            if (pathToCollection != null)
            {
                var pathToCollectionEntity = new ArraySegment <string>(
                    pathToCollection.Value.Array,
                    pathToCollection.Value.Offset,
                    pathToCollection.Value.Count - 1);

                allPaths.Add(pathToCollectionEntity.ToArray());
            }

            // This will represent the mapping from paths to symbols
            return(JoinTrie.Make(ResultDescriptor, allPaths));
        }
Exemple #25
0
 private void Parse()
 {
     do
     {
         if (!OrderBy.IsFinished)
         {
             OrderBy.Parse();
         }
         if (!Expand.IsFinished)
         {
             Expand.Parse();
         }
         if (!Filter.IsFinished)
         {
             Filter.Parse();
         }
         if (!Select.IsFinished)
         {
             Select.Parse();
         }
     } while (!Expand.IsFinished || !Filter.IsFinished || !Select.IsFinished);
     IsParsed = true;
 }
Exemple #26
0
        /// <summary>
        /// Adds the expand string to the <see cref="StringBuilder"/> based on the enum provided
        /// </summary>
        /// <param name="expand">The enum needing to be converted to an expand string</param>
        /// <param name="stringBuilder">The string builder we want to expand into</param>
        private static void GetStringFromExpand(Expand expand, ref StringBuilder stringBuilder)
        {
            switch (expand)
            {
            default:
                throw new ExpandNotFoundException();

            case Expand.Event:
                stringBuilder.Append($"{DefaultExpand}event&^^");
                return;

            case Expand.Groups:
                stringBuilder.Append($"{DefaultExpand}groups&");
                return;

            case Expand.Phase:
                stringBuilder.Append($"{DefaultExpand}phase&");
                return;

            case Expand.Stations:
                stringBuilder.Append($"{DefaultExpand}stations&");
                return;
            }
        }
        internal async System.Threading.Tasks.Task SelectItem(RadzenAccordionItem item)
        {
            await CollapseAll(item);

            var itemIndex = items.IndexOf(item);

            if (!expandedIdexes.Contains(itemIndex))
            {
                expandedIdexes.Add(itemIndex);
                await Expand.InvokeAsync(itemIndex);
            }
            else
            {
                expandedIdexes.Remove(itemIndex);
                await Collapse.InvokeAsync(itemIndex);
            }

            if (!Multiple)
            {
                SelectedIndex = itemIndex;
            }

            StateHasChanged();
        }
Exemple #28
0
        public void Load()
        {
            Log.Info("Loading character templates...");

            using (var connection = SQLite.CreateConnection())
            {
                var temp = new Dictionary <uint, byte>();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM characters";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new CharacterTemplate();
                            var id       = reader.GetUInt32("id");
                            template.Race                   = (Race)reader.GetByte("char_race_id");
                            template.Gender                 = (Gender)reader.GetByte("char_gender_id");
                            template.ModelId                = reader.GetUInt32("model_id");
                            template.FactionId              = reader.GetUInt32("faction_id");
                            template.ZoneId                 = reader.GetUInt32("starting_zone_id");
                            template.ReturnDictrictId       = reader.GetUInt32("default_return_district_id");
                            template.ResurrectionDictrictId =
                                reader.GetUInt32("default_resurrection_district_id");
                            using (var command2 = connection.CreateCommand())
                            {
                                command2.CommandText = "SELECT * FROM item_body_parts WHERE model_id=@model_id";
                                command2.Prepare();
                                command2.Parameters.AddWithValue("model_id", template.ModelId);
                                using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader()))
                                {
                                    while (reader2.Read())
                                    {
                                        var itemId = reader2.GetUInt32("item_id", 0);
                                        var slot   = reader2.GetInt32("slot_type_id") - 23;
                                        template.Items[slot] = itemId;
                                    }
                                }
                            }

                            var templateId = (byte)(16 * (byte)template.Gender + (byte)template.Race);
                            _templates.Add(templateId, template);
                            temp.Add(id, templateId);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM character_buffs";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var characterId = reader.GetUInt32("character_id");
                            var buffId      = reader.GetUInt32("buff_id");
                            var template    = _templates[temp[characterId]];
                            template.Buffs.Add(buffId);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM character_supplies";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var ability = reader.GetByte("ability_id");
                            var item    = new AbilitySupplyItem
                            {
                                Id     = reader.GetUInt32("item_id"),
                                Amount = reader.GetInt32("amount"),
                                Grade  = reader.GetByte("grade_id")
                            };

                            if (!_abilityItems.ContainsKey(ability))
                            {
                                _abilityItems.Add(ability, new AbilityItems());
                            }
                            _abilityItems[ability].Supplies.Add(item);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM character_equip_packs";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var ability  = reader.GetByte("ability_id");
                            var template = new AbilityItems {
                                Ability = ability, Items = new EquipItemsTemplate()
                            };
                            var clothPack  = reader.GetUInt32("newbie_cloth_pack_id", 0);
                            var weaponPack = reader.GetUInt32("newbie_weapon_pack_id", 0);
                            if (clothPack > 0)
                            {
                                using (var command2 = connection.CreateCommand())
                                {
                                    command2.CommandText = "SELECT * FROM equip_pack_cloths WHERE id=@id";
                                    command2.Prepare();
                                    command2.Parameters.AddWithValue("id", clothPack);
                                    using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader()))
                                    {
                                        while (reader2.Read())
                                        {
                                            template.Items.Headgear         = reader2.GetUInt32("headgear_id");
                                            template.Items.HeadgearGrade    = reader2.GetByte("headgear_grade_id");
                                            template.Items.Necklace         = reader2.GetUInt32("necklace_id");
                                            template.Items.NecklaceGrade    = reader2.GetByte("necklace_grade_id");
                                            template.Items.Shirt            = reader2.GetUInt32("shirt_id");
                                            template.Items.ShirtGrade       = reader2.GetByte("shirt_grade_id");
                                            template.Items.Belt             = reader2.GetUInt32("belt_id");
                                            template.Items.BeltGrade        = reader2.GetByte("belt_grade_id");
                                            template.Items.Pants            = reader2.GetUInt32("pants_id");
                                            template.Items.PantsGrade       = reader2.GetByte("pants_grade_id");
                                            template.Items.Gloves           = reader2.GetUInt32("glove_id");
                                            template.Items.GlovesGrade      = reader2.GetByte("glove_grade_id");
                                            template.Items.Shoes            = reader2.GetUInt32("shoes_id");
                                            template.Items.ShoesGrade       = reader2.GetByte("shoes_grade_id");
                                            template.Items.Bracelet         = reader2.GetUInt32("bracelet_id");
                                            template.Items.BraceletGrade    = reader2.GetByte("bracelet_grade_id");
                                            template.Items.Back             = reader2.GetUInt32("back_id");
                                            template.Items.BackGrade        = reader2.GetByte("back_grade_id");
                                            template.Items.Cosplay          = reader2.GetUInt32("cosplay_id");
                                            template.Items.CosplayGrade     = reader2.GetByte("cosplay_grade_id");
                                            template.Items.Undershirts      = reader2.GetUInt32("undershirt_id");
                                            template.Items.UndershirtsGrade = reader2.GetByte("undershirt_grade_id");
                                            template.Items.Underpants       = reader2.GetUInt32("underpants_id");
                                            template.Items.UnderpantsGrade  = reader2.GetByte("underpants_grade_id");
                                        }
                                    }
                                }
                            }

                            if (weaponPack > 0)
                            {
                                using (var command2 = connection.CreateCommand())
                                {
                                    command2.CommandText = "SELECT * FROM equip_pack_weapons WHERE id=@id";
                                    command2.Prepare();
                                    command2.Parameters.AddWithValue("id", weaponPack);
                                    using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader()))
                                    {
                                        while (reader2.Read())
                                        {
                                            template.Items.Mainhand      = reader2.GetUInt32("mainhand_id");
                                            template.Items.MainhandGrade = reader2.GetByte("mainhand_grade_id");
                                            template.Items.Offhand       = reader2.GetUInt32("offhand_id");
                                            template.Items.OffhandGrade  = reader2.GetByte("offhand_grade_id");
                                            template.Items.Ranged        = reader2.GetUInt32("ranged_id");
                                            template.Items.RangedGrade   = reader2.GetByte("ranged_grade_id");
                                            template.Items.Musical       = reader2.GetUInt32("musical_id");
                                            template.Items.MusicalGrade  = reader2.GetByte("musical_grade_id");
                                        }
                                    }
                                }
                            }

                            _abilityItems.Add(template.Ability, template);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM bag_expands";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var expand = new Expand();
                            expand.IsBank     = reader.GetBoolean("is_bank", true);
                            expand.Step       = reader.GetInt32("step");
                            expand.Price      = reader.GetInt32("price");
                            expand.ItemId     = reader.GetUInt32("item_id", 0);
                            expand.ItemCount  = reader.GetInt32("item_count");
                            expand.CurrencyId = reader.GetInt32("currency_id");

                            if (!_expands.ContainsKey(expand.Step))
                            {
                                _expands.Add(expand.Step, new List <Expand> {
                                    expand
                                });
                            }
                            else
                            {
                                _expands[expand.Step].Add(expand);
                            }
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT id, buff_id FROM appellations";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new AppellationTemplate();
                            template.Id     = reader.GetUInt32("id");
                            template.BuffId = reader.GetUInt32("buff_id", 0);

                            _appellations.Add(template.Id, template);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM actability_groups";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new ActabilityTemplate();
                            template.Id              = reader.GetUInt32("id");
                            template.Name            = reader.GetString("name");
                            template.UnitAttributeId = reader.GetInt32("unit_attr_id");
                            _actabilities.Add(template.Id, template);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM expert_limits ORDER BY up_limit ASC";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        var step = 0;
                        while (reader.Read())
                        {
                            var template = new ExpertLimit();
                            template.Id               = reader.GetUInt32("id");
                            template.UpLimit          = reader.GetInt32("up_limit");
                            template.ExpertLimitCount = reader.GetByte("expert_limit");
                            template.Advantage        = reader.GetInt32("advantage");
                            template.CastAdvantage    = reader.GetInt32("cast_adv");
                            template.UpCurrencyId     = reader.GetUInt32("up_currency_id", 0);
                            template.UpPrice          = reader.GetInt32("up_price");
                            template.DownCurrencyId   = reader.GetUInt32("down_currency_id", 0);
                            template.DownPrice        = reader.GetInt32("down_price");
                            _expertLimits.Add(step++, template);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM expand_expert_limits ORDER BY expand_count ASC";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        var step = 0;
                        while (reader.Read())
                        {
                            var template = new ExpandExpertLimit();
                            template.Id          = reader.GetUInt32("id");
                            template.ExpandCount = reader.GetByte("expand_count");
                            template.LifePoint   = reader.GetInt32("life_point");
                            template.ItemId      = reader.GetUInt32("item_id", 0);
                            template.ItemCount   = reader.GetInt32("item_count");
                            _expandExpertLimits.Add(step++, template);
                        }
                    }
                }
            }

            var content = FileManager.GetFileContents("./Data/CharTemplates.json");

            if (string.IsNullOrWhiteSpace(content))
            {
                throw new IOException(
                          $"File {FileManager.AppPath + "Data/CharTemplates.json"} doesn't exists or is empty.");
            }

            if (JsonHelper.TryDeserializeObject(content, out List <CharacterTemplateConfig> charTemplates, out _))
            {
                foreach (var charTemplate in charTemplates)
                {
                    var point = new Point(charTemplate.Pos.X, charTemplate.Pos.Y, charTemplate.Pos.Z);
                    point.ZoneId = WorldManager
                                   .Instance
                                   .GetZoneId(charTemplate.Pos.WorldId, charTemplate.Pos.X, charTemplate.Pos.Y); // TODO ...

                    var template = _templates[(byte)(16 + charTemplate.Id)];
                    template.Position         = point;
                    template.NumInventorySlot = charTemplate.NumInventorySlot;
                    template.NumBankSlot      = charTemplate.NumBankSlot;

                    template                  = _templates[(byte)(32 + charTemplate.Id)];
                    template.Position         = point;
                    template.NumInventorySlot = charTemplate.NumInventorySlot;
                    template.NumBankSlot      = charTemplate.NumBankSlot;
                }
            }
            else
            {
                throw new Exception($"CharacterManager: Parse {FileManager.AppPath + "Data/CharTemplates.json"} file");
            }

            Log.Info("Loaded {0} character templates", _templates.Count);
        }
        /// <summary>
        /// Prepares the SELECT statement and the column map, using the <see cref="Select"/> argument
        /// </summary>
        private SqlSelectClause PrepareSelect(JoinTrie joinTree)
        {
            var selects = new HashSet <(string Symbol, string PropName)>();
            var columns = new List <(string Symbol, ArraySegment <string> Path, string PropName)>();

            void AddSelect(string symbol, ArraySegment <string> path, string propName)
            {
                // NULL happens when there is a select that has been segmented from the middle
                // and the first section of the segment no longer terminates with a simple property
                // propName = propName ?? "Id";
                if (propName == null)
                {
                    return;
                }

                if (selects.Add((symbol, propName)))
                {
                    columns.Add((symbol, path, propName));
                }
            }

            // Any path step that is touched by a select (which has a property) ignores the expand, the joinTree below
            // allows us to efficiently check if any particular step is touched by a select
            JoinTrie overridingSelectTree = Select == null ? null : JoinTrie.Make(ResultDescriptor, Select.Select(e => e.Path)); // Overriding select paths

            // Optimization: remember the joins that have been selected and don't select them again
            var selectedJoins = new HashSet <JoinTrie>();

            // For every expanded entity that has not been tainted by a select argument, we add all its properties to the list of selects
            Expand ??= ExpressionExpand.Empty;
            foreach (var expand in Expand.Union(ExpressionExpand.RootSingleton))
            {
                string[] path = expand.Path;
                for (int i = 0; i <= path.Length; i++)
                {
                    var subpath     = new ArraySegment <string>(path, 0, i);
                    var selectMatch = overridingSelectTree?[subpath];
                    if (selectMatch == null) // This expand is not overridden by a select
                    {
                        var join = joinTree[subpath];
                        if (join == null)
                        {
                            // Developer mistake
                            throw new InvalidOperationException($"The path '{string.Join('.', subpath)}' was not found in the joinTree");
                        }
                        else if (selectedJoins.Contains(join))
                        {
                            continue;
                        }
                        else
                        {
                            selectedJoins.Add(join);
                        }

                        foreach (var prop in join.EntityDescriptor.SimpleProperties)
                        {
                            AddSelect(join.Symbol, subpath, prop.Name);
                        }
                    }
                }
            }

            if (Select != null)
            {
                foreach (var select in Select)
                {
                    // Add the property
                    string[] path = select.Path;
                    {
                        var join     = joinTree[path];
                        var propName = select.Property; // Can be null
                        AddSelect(join.Symbol, path, propName);
                    }

                    // In this loop we ensure all levels to the selected properties
                    // have their Ids and Foreign Keys added to the select collection
                    for (int i = 0; i <= path.Length; i++)
                    {
                        var subpath = new ArraySegment <string>(path, 0, i);
                        var join    = joinTree[subpath];
                        if (join == null)
                        {
                            // Developer mistake
                            throw new InvalidOperationException($"The path '{string.Join('.', subpath)}' was not found in the joinTree");
                        }
                        else if (selectedJoins.Contains(join))
                        {
                            // All properties were added earlier in an expand
                            continue;
                        }
                        else
                        {
                            selectedJoins.Add(join);
                        }

                        // The Id is ALWAYS required in every EntityWithKey
                        if (join.EntityDescriptor.HasId)
                        {
                            AddSelect(join.Symbol, subpath, "Id");
                        }

                        // Add all the foreign keys to the next level down
                        foreach (var nextJoin in join.Values)
                        {
                            AddSelect(join.Symbol, subpath, nextJoin.ForeignKeyName);
                        }
                    }
                }
            }

            // If the foreign key to the principal query is specified, then always include that
            // otherwise there will be no way to link the collection to the principal query once we load the data
            if (!string.IsNullOrWhiteSpace(ForeignKeyToPrincipalQuery))
            {
                var path = Array.Empty <string>();
                AddSelect(joinTree.Symbol, path, ForeignKeyToPrincipalQuery);
            }

            // Deals with trees
            foreach (var path in PathsToParentEntitiesWithExpandedAncestors)
            {
                var join = joinTree[path];
                AddSelect(join.Symbol, path, "ParentId");
            }

            if (IsAncestorExpand)
            {
                var path = Array.Empty <string>();
                AddSelect(joinTree.Symbol, path, "ParentId");
            }

            // Change the hash set to a list so that the order is well defined
            return(new SqlSelectClause(columns));
        }
Exemple #30
0
 public void It_will_return_an_Expand_object()
 {
     Assert.IsInstanceOf <Expand>(Expand.Table("some inputData"));
 }
Exemple #31
0
 public void It_requires_string_to_contain_data()
 {
     Expand.Table("");
 }
Exemple #32
0
 public void It_requires_string_to_be_specified()
 {
     Expand.Table(null);
 }