private void AddMembership(FluentQueryBuilder queryBuilder) { var ownerOfApplication = new ApplicationOwner() { guid = Guid.NewGuid().ToString("N"), name = "RAM" }; var user = new User() { guid = Guid.NewGuid().ToString("N"), firstName = "Alex", lastName = "Stroukov", email = "*****@*****.**" }; var membership = new Membership() { guid = Guid.NewGuid().ToString("N"), licence = "asajzjdZKHJXZJKSjsLSlSjjs897JS8shKSJSHLSKS" }; var userRole = new UserRole() { guid = Guid.NewGuid().ToString("N"), name = "Administrator" }; var hasUserRelationship = new HasUser() { }; var hasRoleRelationship = new HasAction() { }; var hasApplicationRelationship = new HasApplication() { }; var usedByApplicationRelationship = new UsedByApplication() { }; var userOfApplicationRelationship = new UserOfApplication() { }; var entityGridBasicTemplate = new Template { guid = Guid.NewGuid().ToString("N"), name = "entityGridBasic", location = string.Format("StagedSpa/templates/{0}", "entity-grid-basic.html") }; var entityDetailsBasicTemplate = new Template { guid = Guid.NewGuid().ToString("N"), name = "entityDetailsBasic", location = string.Format("StagedSpa/templates/{0}", "entity-details-basic.html") }; var hasEntityGridScreen = new HasScreen{ screenType = Enum.ScreenTypeEnum.EntityGrid}; var hasEntityDetailsScreen = new HasScreen { screenType = Enum.ScreenTypeEnum.EntityDetails }; var hasTemplate = new HasTemplate { }; var hasMembershipRelationship = new HasMembership() { runsOutOnMillis = (long)(DateTime.UtcNow.AddMonths(1) - new DateTime(1970, 1, 1)).TotalMilliseconds }; queryBuilder .Create(ownerOfApplication) .Create(user) .Create(membership) .Create(_application) .Create(userRole) .Create(assetsScreen) .Create(assetDetailsScreen) .Create(entityGridBasicTemplate) .Create(entityDetailsBasicTemplate) .Create(_navigateToEntityDetailsCommand) .Create(_navigateToEntityDetailsCommand2) .Create(_eGridWidget) .Create(_eGridTileWidget) .Create(_seGridWidget) .Create(_seGridTileWidget) .Create(_dpTextWidget) .Create(_dpTextWidget2) .Create(_dpTextWidget3) .Create(_epDropdownWidget) .RelateTo(_eGridTileWidget, new HasAction(), _navigateToEntityDetailsCommand) .RelateTo(_navigateToEntityDetailsCommand, new RelatedActionScreen(), assetDetailsScreen) .RelateTo(_seGridTileWidget, new HasAction(), _navigateToEntityDetailsCommand2) .RelateTo(_navigateToEntityDetailsCommand2, new RelatedActionScreen(), assetDetailsScreen) .RelateTo(ownerOfApplication, hasMembershipRelationship, membership) .RelateTo(ownerOfApplication, hasUserRelationship, user) .RelateTo(user, hasRoleRelationship, userRole) .RelateTo(ownerOfApplication, hasApplicationRelationship, _application) .RelateTo(user, userOfApplicationRelationship, _application) .RelateTo(userRole, usedByApplicationRelationship, _application) .RelateTo(_application, hasEntityDetailsScreen, assetDetailsScreen) .RelateTo(_application, hasEntityGridScreen, assetsScreen) .RelateTo(assetsScreen, hasTemplate, entityGridBasicTemplate) .RelateTo(entityGridBasicTemplate, new HasWidget (), _eGridWidget) .RelateTo(_eGridWidget, new HasWidget(), _eGridTileWidget) .RelateTo(assetDetailsScreen, hasTemplate, entityDetailsBasicTemplate) .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _dpTextWidget) .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _epDropdownWidget) .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _dpTextWidget2) .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _dpTextWidget3) .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _seGridWidget) .RelateTo(_seGridWidget, new HasWidget(), _seGridTileWidget) ; }
/// <summary> /// CoreItem should always be the lowest item priority in the inventory, so we can assume /// that there will be no more commands that could match after this method. Thus, if we can't /// match the string at the beginning of commands, GetAction will still skip the commands /// array anyway. /// </summary> /// <param name="player"> /// The player trying to execute the action.</param> /// <param name="commands">A string of action commands to be parsed in order. This should contain quoted strings and /// core action handles (SAY, GIVE, IF, etc) only.</param> /// <returns>The action built from the commands array.</returns> override public bool DoAction(Player player, ref string[] commands, ref bool lastAction) { Action action = null; if (commands != null && commands.Length > 0) { int index = 0; switch (commands[0].ToUpper()) { case "SAY": { SayAction sayAction = new SayAction(player); index++; if (commands.Length > 1) { sayAction.Message = commands[1]; index++; } action = sayAction; } break; case "IF": { IfElseAction ifAction = new IfElseAction(player); index++; if (commands.Length > 1) { index += ifAction.Parse(commands.Skip(1).ToArray()); } action = ifAction; } break; case "NOT": { NotAction notAction = new NotAction(player); commands = commands.Skip(1).ToArray(); // skip to next action player.Inventory.DoAction(ref commands, ref lastAction); notAction.Op = lastAction; // no index increment, the ref is our increment action = notAction; } break; case "AND": { AndAction andAction = new AndAction(player); commands = commands.Skip(1).ToArray(); andAction.Op1 = lastAction; player.Inventory.DoAction(ref commands, ref lastAction); andAction.Op2 = lastAction; // no index increment, the ref is our increment action = andAction; } break; case "OR": { OrAction orAction = new OrAction(player); commands = commands.Skip(1).ToArray(); orAction.Op1 = lastAction; player.Inventory.DoAction(ref commands, ref lastAction); orAction.Op2 = lastAction; // no index increment, the ref is our increment action = orAction; } break; case "GIVE": { GiveAction giveAction = new GiveAction(player); index++; if (commands.Length > 1) { giveAction.ItemName = commands[1]; index++; } if (commands.Length > 3 && commands[2].ToUpper() == "TO") { giveAction.ToItemName = commands[3]; index += 2; } action = giveAction; } break; case "TAKE": { TakeAction takeAction = new TakeAction(player); index++; if (commands.Length > 1) { takeAction.ItemName = commands[1]; index++; } if (commands.Length > 3 && commands[2].ToUpper() == "FROM") { takeAction.FromItemName = commands[3]; index += 2; } action = takeAction; } break; case "HAS": { HasAction hasAction = new HasAction(player); index++; if (commands.Length > 1) { hasAction.ItemName = commands[1]; index++; } if (commands.Length > 3 && commands[2].ToUpper() == "IN") { hasAction.InItemName = commands[3]; index += 2; } action = hasAction; } break; case "GO": { GoAction goAction = new GoAction(player); index++; if (commands.Length > 1) { goAction.GiveItemName = commands[1]; goAction.TakeItemName = GoItemString; index++; } if (goAction.ExecuteWhenCreated()) { GoItemString = goAction.GiveItemName; } action = goAction; } break; case "INV": { GroupAction groupAction = new GroupAction(player); index++; foreach (Item item in player.Inventory.Items .Where(item => !item.Hidden)) { SayAction sayAction = new SayAction(player); sayAction.Message = item.DisplayName; groupAction.Add(sayAction); } if (groupAction.Actions.Count < 1) { SayAction sayAction = new SayAction(player); sayAction.Message = "You have no items."; groupAction.Add(sayAction); } action = groupAction; } break; default: // unrecognized? This is the base item, so there's no other items that could have matching actions. index++; // ignore it. break; } commands = commands.Skip(index).ToArray(); } if (action != null) { lastAction = action.Execute(); return(true); } else { return(false); } }