public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { //[Take Row] RecipeTWCell cell = tableView.CellAt(indexPath) as RecipeTWCell; if (cell != null) { if (cell.m_bWasChanged) { RecipeRecord rec = RecipeManager.GetRecipeRecord(m_tableItems[indexPath.Row].ID); rec.isFavourite = cell.m_bChecked ? 1 : 0; RecipeManager.SaveRecipeRecord(rec); cell.m_bWasChanged = false; } else { // add pages DukappPagedDataSource qsrc = new DukappPagedDataSource(2); DukappPagedVC mp = new DukappPagedVC(qsrc); MealsVC rec_meals = new MealsVC(m_tableItems[indexPath.Row], m_parent_vc); HowToCookVC cook_vc = new HowToCookVC(m_tableItems[indexPath.Row]); mp.m_pages.Add(rec_meals); mp.m_pages.Add(cook_vc); mp.SetViewControllers(new UIViewController[] { rec_meals }, UIPageViewControllerNavigationDirection.Forward, true, null); m_parent_vc.NavigationController.PushViewController(mp, true); } } }
public bool ChangeRecipe(CraftingActor actor, RecipeRecord recipe) { if (recipe.JobId != Job.Id) { return(false); } if (recipe.ResultLevel > Job.Level && Job.Id != (int)JobEnum.BASE) { return(false); } bool valid = true; for (int i = 0; valid && i < recipe.Ingredients.Length; i++) { var item = actor.Character.Inventory.TryGetItem(recipe.Ingredients[i]); valid = item != null && actor.MoveItemToPanel(item, (int)recipe.Quantities[i]); } if (!valid) { return(false); } ChangeAmount(1); return(true); }
public void PerformCraft(RecipeRecord currentRecipe) { var obj = new ObjectItem((byte)CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED, currentRecipe.ResultId, ItemRecord.GetItem(currentRecipe.ResultId).GenerateRandomEffect(), CharacterItemRecord.PopNextUID(), 1); Client.Character.Inventory.Add(new CharacterItemRecord(obj, Client.Character.Id)); Client.Send(new ExchangeCraftResultWithObjectDescMessage(2, new ObjectItemNotInContainer(currentRecipe.ResultId, obj.effects, obj.objectUID, 1))); Client.Character.AddJobXp(JobId, (ulong)(currentRecipe.ResultLevel * XpRatio)); }
public HowToCookVC(RecipeRecord recipe) : base(UserInterfaceIdiomIsPhone ? "HowToCookVC_iPhone" : "HowToCookVC_iPad", null) { m_recipe = recipe; m_PageIndex = 1; m_d_p = RecipeManager.GetPhaseForRecipe(m_recipe.ID); m_d_p.Sort(); }
public static void AddRecipeCommand(string value, WorldClient client) { var recipe = RecipeRecord.GetRecipe(ushort.Parse(value)); foreach (var item in recipe.IngredientsWithQuantities) { client.Character.Inventory.Add(item.Key, item.Value); } }
public void SetCraftRecipe(ushort resultid) { var recipe = RecipeRecord.GetRecipe(resultid); foreach (var item in recipe.IngredientsWithQuantities) { var obj = Client.Character.Inventory.Items.Find(x => x.GID == item.Key); AddItemToPanel(obj, item.Value); } }
public static void RecipeCommand(string value, WorldClient client) { for (int i = 0; i < 50; i++) { RecipeRecord recipe = RecipeRecord.GetRecipe(ushort.Parse(value)); foreach (var item in recipe.Ingredients) { client.Character.Inventory.AddItem(item.Key, item.Value); } } }
public MealsVC(RecipeRecord recipe, UIViewController parent = null) : base(UserInterfaceIdiomIsPhone ? "MealsVC_iPhone" : "MealsVC_iPad", null) { List <RecipeMealsRecord> rmr = RecipeManager.GetMealsForRecipe(recipe.ID); m_table_source = new MealTableSrc(rmr.ToArray()); this.Title = "Meals"; m_d_p = RecipeManager.GetPhaseForRecipe(recipe.ID); m_d_p.Sort(); //m_stage = "Stages: "; m_recipe = recipe; this.Title = recipe.RecipeName; m_PageIndex = 0; m_parent = parent; }
/// <summary> /// FAILLE WPE /// </summary> /// <param name="gid"></param> public void SetRecipe(ushort gid) { var recipe = RecipeRecord.GetRecipe(gid); if (recipe != null && recipe.ResultLevel <= Character.GetJob(JobType).Level) { foreach (var ingredient in recipe.Ingredients) { CharacterItemRecord item = Character.Inventory.GetFirstItem(ingredient.Key, ingredient.Value); if (item != null) { CraftedItems.AddItem(item, ingredient.Value); } } SetCount(1); } }
public override void Ready(bool ready, ushort step) { var crafterLevel = CharacterJobRecord.GetJob(Client.Character.Id, JobId).JobLevel; var currentRecipe = RecipeRecord.GetRecipe(CraftedItems, (ushort)SkillId); if (currentRecipe.IsNull()) { Client.Send(new ExchangeCraftResultMessage((sbyte)CraftResultEnum.CRAFT_IMPOSSIBLE)); return; } else if (currentRecipe.ResultLevel > crafterLevel) { Client.Character.Reply("Vous n'avez pas le niveau pour effectuer ce craft!"); return; } ReplayEngine = new CraftReplayEngine(this, currentRecipe); ReplayEngine.Start(); }
public int GetCraftXp(RecipeRecord recipe, int amount) { if (Id == (int)JobEnum.BASE) { return(0); } var level = Level; if (level == 200) { return(GetXpPerLevel(recipe, Level) * amount); } double upperBoundXp = UpperBoundExperience; double currentXp = Experience; double xp = 0; while (amount > 0) { if (level - JobManager.MAX_JOB_LEVEL_GAP > recipe.ItemTemplate.Level) { break; } var xpPerLevel = GetXpPerLevel(recipe, level); var amountBeforeLevelUp = (int)Math.Min(amount, Math.Ceiling((upperBoundXp - currentXp) / xpPerLevel)); amount -= amountBeforeLevelUp; xp += xpPerLevel * amountBeforeLevelUp; currentXp += xpPerLevel * amountBeforeLevelUp; if (currentXp >= upperBoundXp) { level++; upperBoundXp = ExperienceManager.Instance.GetCharacterNextLevelExperience((byte)level); } } return((int)Math.Floor(xp)); }
private int GetXpPerLevel(RecipeRecord recipe, int level) { if (level - JobManager.MAX_JOB_LEVEL_GAP > recipe.ItemTemplate.Level) { return(0); } var xpPerLevel = 20d * recipe.ItemTemplate.Level / (Math.Pow((level - recipe.ItemTemplate.Level), 1.1) / 10 + 1); if (recipe.ItemTemplate.CraftXpRatio > -1) { xpPerLevel *= recipe.ItemTemplate.CraftXpRatio / 100d; } else if (recipe.ItemTemplate.Type.CraftXpRatio > -1) { xpPerLevel *= recipe.ItemTemplate.Type.CraftXpRatio / 100d; } xpPerLevel *= Rates.JobXpRate; xpPerLevel = Math.Floor(xpPerLevel); return((int)xpPerLevel); }
/// <summary> /// Allows creation of a new volume /// </summary> /// <param name="input"> /// Configuration definition for the new volume /// </param> /// <returns>The created volume</returns> public Volume CreateVolume(CreateVolumeInput input) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", input); TokenResponse tokenResponse = RunMutation <TokenResponse>( @"createVolumeV3", parameters); RecipeRecordIdentifier identifier = DeliverTokenV2(tokenResponse); if (identifier == null) { throw new Exception("Uncomprehensive information returned from server"); } // wait for recipe completion DateTime start = DateTime.UtcNow; // recipe filter NPodRecipeFilter filter = new NPodRecipeFilter(); filter.NPodGuid = identifier.NPodGuid; filter.RecipeGuid = identifier.RecipeGuid; while (true) { Thread.Sleep(1000); // query for recipes RecipeRecordList recipes = GetNPodRecipes(filter); // if there is no record in the cloud wait a few more seconds // this case should not exist. TODO: Remove in next version. if (recipes.Items.Length == 0) { continue; } // based on the query there should be exactly one RecipeRecord recipe = recipes.Items[0]; // execution failed if (recipe.State == RecipeState.Failed) { string error = string.Concat("volume creation failed", recipe.Status); throw new Exception(error); } // execution completed if (recipe.State == RecipeState.Completed) { VolumeFilter volumeFilter = new VolumeFilter(); volumeFilter.Guid = new GuidFilter(); volumeFilter.Guid.MustEqual = tokenResponse.WaitOn; VolumeList list = GetVolumes(null, volumeFilter, null); if (list.FilteredCount >= 0) { return(list.Items[0]); } } // still ongoing double duration = (DateTime.UtcNow - start).TotalSeconds; double timeRemaining = NPOD_CREATE_WAITTIME_SEC - duration; if (timeRemaining <= 0) { throw new Exception("Snapshot creation timed out"); } } }
public CraftReplayEngine(CraftExchange craftinstance, RecipeRecord recipe) { Instance = craftinstance; Recipe = recipe; ActualReplayCountLeft = craftinstance.ReplayCount; }
public void Dispose() { Instance.ReplayEngine = null; Instance = null; Recipe = null; }
public static int SaveRecipeRecord(RecipeRecord item) { return(DukappCore.DAL.DukappRepository.SaveRecipeRecord(item)); }
public static int SaveRecipeRecord(RecipeRecord item) { return(instance.db.SaveItem <RecipeRecord>(item)); }
/// <summary> /// Allows creation of a new nPod /// /// <para> /// A nPod is a collection of network-connected application servers /// with SPUs installed that form an application cluster. Together, the /// SPUs in a nPod serve shared or local storage to the servers in the /// application cluster, e.g.a hypervisor cluster, container platform, /// or clustered bare metal application. /// </para> /// </summary> /// <param name="name"> /// Name of the new nPod /// </param> /// <param name="nPodGroupGuid"> /// The unique identifier of the nPod group this nPod will be added to /// </param> /// <param name="nPodSpuInputs"> /// List of SPU configuration information that will be used in the new /// nPod /// </param> /// <param name="templateGuid"> /// The unique identifier of the nPod template to use for the new nPod /// </param> /// <param name="note"> /// An optional note for the new nPod /// </param> /// <param name="timezone"> /// The timezone to be configured for all SPUs in the nPod /// </param> /// <param name="ignoreWarnings"> /// If specified and set to <c>true</c> the nPod creation will proceed /// even if nebulon ON reports warnings. It is advised to not ignore /// warnings. Consequently, the default behavior is that the nPod /// creation will fail when nebulon ON reports validation errors. /// </param> /// <returns>The new nPod</returns> public NPod CreateNPod( string name, Guid nPodGroupGuid, NPodSpuInput[] nPodSpuInputs, Guid templateGuid, string note, string timezone, bool ignoreWarnings) { // check for potential issues that nebulon ON predicts Issues issues = GetNewNPodIssues(nPodSpuInputs); issues.AssertNoIssues(ignoreWarnings); CreateNPodInput input = new CreateNPodInput(); input.Name = name; input.NPodGroupGuid = nPodGroupGuid; input.Spus = nPodSpuInputs; input.NPodTemplateGuid = templateGuid; input.Note = note; input.Timezone = timezone; // setup parameters for nPod creation GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", input, true); // make the request and deliver token TokenResponse tokenResponse = RunMutation <TokenResponse>( @"createNPod", parameters ); RecipeRecordIdentifier identifier = DeliverTokenV2(tokenResponse); if (identifier == null) { throw new Exception("Uncomprehensive information returned from server"); } // wait for recipe completion DateTime start = DateTime.UtcNow; // recipe filter NPodRecipeFilter filter = new NPodRecipeFilter(); filter.NPodGuid = identifier.NPodGuid; filter.RecipeGuid = identifier.RecipeGuid; while (true) { Thread.Sleep(5000); // query for recipes RecipeRecordList recipes = GetNPodRecipes(filter); // if there is no record in the cloud wait a few more seconds // this case should not exist. TODO: Remove in next version. if (recipes.Items.Length == 0) { continue; } // based on the query there should be exactly one RecipeRecord recipe = recipes.Items[0]; // execution failed if (recipe.State == RecipeState.Failed) { string error = string.Concat("nPod creation failed", recipe.Status); throw new Exception(error); } // execution completed if (recipe.State == RecipeState.Completed) { NPodFilter nPodFilter = new NPodFilter(); nPodFilter.NPodGuid = new GuidFilter(); nPodFilter.NPodGuid.MustEqual = identifier.NPodGuid; NPodList nPods = GetNebNPods( PageInput.First, nPodFilter, null ); return(nPods.Items[0]); } // still ongoing double duration = (DateTime.UtcNow - start).TotalSeconds; double timeRemaining = NPOD_CREATE_WAITTIME_SEC - duration; if (timeRemaining <= 0) { throw new Exception("nPod creation timed out"); } } }