public void GetUnsoldItem_TwoItemsRequested_TwoDifferentItemsRecieved() { Storage s = Storage.getStorageInstance(); ModelItem Puzzle1000 = new ModelItem { Name = "Puzzle, 1000 elementów", Model = "ver 1000 elementowa", Series = "Jeziora", Type = "Puzzle", Price = 29.95 }; SpecificItem Puzzle1000x1 = new SpecificItem { SerialNumber = "ABC123XYZ", PlaceInStorage = "D13A" }; SpecificItem Puzzle1000x2 = new SpecificItem { SerialNumber = "ABC124XYZ", PlaceInStorage = "D13A" }; SpecificItem Puzzle1000x3 = new SpecificItem { SerialNumber = "ABC125XYZ", PlaceInStorage = "D13B" }; s.AddItem(Puzzle1000x1, Puzzle1000); s.AddItem(Puzzle1000x2, Puzzle1000); s.AddItem(Puzzle1000x3, Puzzle1000); SpecificItem test = s.GetUnsoldItem(Puzzle1000); SpecificItem test2 = s.GetUnsoldItem(Puzzle1000); Assert.AreNotEqual(test.SerialNumber, test2.SerialNumber); }
public void GetUnsoldItem_NoUnsoldItems_ReturnsNull() { Storage s = Storage.getStorageInstance(); ModelItem Puzzle1000 = new ModelItem { Name = "Puzzle, 1000 elementów", Model = "ver 1000 elementowa", Series = "Jeziora", Type = "Puzzle", Price = 29.95 }; SpecificItem Puzzle1000x1 = new SpecificItem { SerialNumber = "ABC123XYZ", PlaceInStorage = "D13A" }; SpecificItem Puzzle1000x2 = new SpecificItem { SerialNumber = "ABC124XYZ", PlaceInStorage = "D13A" }; SpecificItem Puzzle1000x3 = new SpecificItem { SerialNumber = "ABC125XYZ", PlaceInStorage = "D13B" }; s.AddItem(Puzzle1000x1, Puzzle1000); s.AddItem(Puzzle1000x2, Puzzle1000); s.AddItem(Puzzle1000x3, Puzzle1000); SpecificItem test = s.GetUnsoldItem(Puzzle1000); test = s.GetUnsoldItem(Puzzle1000); test = s.GetUnsoldItem(Puzzle1000); test = s.GetUnsoldItem(Puzzle1000); Assert.IsNull(test); }
protected void UpdateHook(ItemOnShelfControlHooks hook, SpecificItem item) { if (hook != null && item != null) { hook.ItemId = item.Id; hook.Tooltip = item.Name; hook.ItemPrice = item.Price; } }
private string GetHtmlArticle() { var item = SpecificItem.ToFeedItem(); string result = string.Empty; result += $"<h2>{Title}</h2><br>"; result += $"<p>{item.Content}</p><br>"; result += $"<h3>{item.Author}</h3><br>"; result += $"<a href='{Link}'><h3>Read from source></h2></a><br>"; //result = RemoveUnusedTags(result); return($"<div>{result}</div>"); }
protected override void SetupFromSplitJsonString(string[] splitJsonString) { name = splitJsonString[0]; powerLevelEnum = EnumSetting.Load(splitJsonString[1]); stockAvailability = IntRangePerPowerLevel.Load(splitJsonString[2]); ingredient = Saveable <TIngredient> .Load(splitJsonString[3]); specificItems = new TSpecificItem[splitJsonString.Length - 4]; for (int i = 0; i < specificItems.Length; i++) { specificItems[i] = SpecificItem <TSpecificItem> .CreateFromJsonString(splitJsonString[i + 4]); } }
protected override string ConvertToJsonString(string[] jsonSplitter) { string jsonString = ""; jsonString += name + jsonSplitter[0]; jsonString += powerLevelEnum.name + jsonSplitter[0]; jsonString += stockAvailability.name + jsonSplitter[0]; jsonString += ingredient.name + jsonSplitter[0]; for (int i = 0; i < specificItems.Length; i++) { jsonString += SpecificItem <TSpecificItem> .GetJsonString(specificItems[i]) + jsonSplitter[0]; } return(jsonString); }
private string ConvertToHtml() { var item = SpecificItem.ToFeedItem(); string result = string.Empty; result += $"<a href='{Link}'><h2>{Title}</h2></a><br>"; result += $"<h4>{item.PublishDateString}</h4><br>"; string categories = GetCategories(); if (!string.IsNullOrEmpty(categories)) { result += $"<h4>Categories: {categories}</h4><br>"; } result += $"<p>{item.Description}</p><br>"; result += $"<h3>{item.Author}</h3><br>"; result = RemoveUnusedTags(result); return($"<div>{result}</div>"); }
public void Add(Player player, SpecificItem specificItem, int quantity) { try { List<ColumnValue> columns = new List<ColumnValue> (); columns.Add (new ColumnValue () { Item1 = "playerId", Item2 = player.Id.ToString() }); columns.Add (new ColumnValue () { Item1 = "specificItemId", Item2 = specificItem.Id.ToString() }); columns.Add (new ColumnValue () { Item1 = "quantity", Item2 = quantity.ToString() }); this.Insert (columns); } catch (MySqlException ex) { switch (ex.Number) { case 0: throw new DatabaseException ("Cannot connect to server. Contact administrator", ex); case 1045: throw new DatabaseException ("Invalid username/password, please try again", ex); default: throw new DatabaseException (ex.Message, ex); } } }
public void Delete(SpecificItem obj) { try { StatementValue where = new StatementValue (); where.Item1 = "id = " + StatementValue (0); where.Item2 = new List<string> (); where.Item2.Add (obj.Id.ToString ()); this.Delete (where); } catch (MySqlException ex) { switch (ex.Number) { case 0: throw new DatabaseException ("Cannot connect to server. Contact administrator", ex); case 1045: throw new DatabaseException ("Invalid username/password, please try again", ex); default: throw new DatabaseException (ex.Message, ex); } } }
public void GetUnsoldItem_RequestItem_ItemIsFlaggedAsSold() { Storage s = Storage.getStorageInstance(); ModelItem Puzzle1000 = new ModelItem { Name = "Puzzle, 1000 elementów", Model = "ver 1000 elementowa", Series = "Jeziora", Type = "Puzzle", Price = 29.95 }; SpecificItem Puzzle1000x1 = new SpecificItem { SerialNumber = "ABC123XYZ", PlaceInStorage = "D13A" }; s.AddItem(Puzzle1000x1, Puzzle1000); SpecificItem test = s.GetUnsoldItem(Puzzle1000); Assert.IsTrue(test.IsSold()); }
override public string ToString() { string str; str = ""; str += "Comparison type: " + MyInvestigationMode.ToString() + Environment.NewLine; if (MyInvestigationMode == InvestigationMode.FreeText) { str += "Allele case sensitive: " + (MyIsFreeTextCaseSensitive ? "ON" : "OFF") + Environment.NewLine; } if (SpecificItem.Trim() != "") { str += "Match item: " + SpecificItem; } else { str += "All-to-all comparison."; } str += Environment.NewLine; str += "Include self-comparison: " + (MyIncludeSelfComparison ? "ON" : "OFF") + Environment.NewLine; str += "Cutoff: " + MySimilarityCutoffPercent.ToString() + "% similarity for at least " + MyExperimentsCutoff.ToString() + " experiments"; return(str); }
public void Add(SpecificItem obj) { try { List<ColumnValue> columns = new List<ColumnValue> (); columns.Add (new ColumnValue () { Item1 = "id", Item2 = obj.Id.ToString() }); columns.Add (new ColumnValue () { Item1 = "name", Item2 = obj.Name }); columns.Add (new ColumnValue () { Item1 = "iconId", Item2 = obj.IconId.ToString() }); columns.Add (new ColumnValue () { Item1 = "price", Item2 = obj.Price.ToString() }); if (obj.Theme != null) { columns.Add (new ColumnValue () { Item1 = "themeId", Item2 = obj.Theme.Id.ToString() }); } columns.Add (new ColumnValue () { Item1 = "generalItemId", Item2 = obj.GeneralItem.Id.ToString() }); this.Insert (columns); } catch (MySqlException ex) { switch (ex.Number) { case 0: throw new DatabaseException ("Cannot connect to server. Contact administrator", ex); case 1045: throw new DatabaseException ("Invalid username/password, please try again", ex); default: throw new DatabaseException (ex.Message, ex); } } }
public override void OnFirstShow() { base.OnFirstShow (); hooks = canvas.GetComponent<PartyControlHooks> (); if (hooks == null) return; hooks.OnForwardHook = Forward; hooks.OnBackHook = Back; hooks.OnRefreshHook = Refresh; hooks.OnNextHook = ChangeItem; game = Gameplay.GameManager.Instance.ActiveGame; hooks.ThemeBG = AssetsManager.Instance.ThemeBackGrounds [game.Theme.IconId]; indicationStars = new List<int> (); //id unico para os itens que estao na party, dois itens iguais teem que ter ids diferentes uniqueID = 0; inventoryTotalList = new List<Quantifier<SpecificItem>> (); //initialize my list with 2 tables and 8 chairs SpecificItem specificItemTable = GameManager.Instance.SpecificItems.Find (x => x.Id == 59); SpecificItem specificItemChair = GameManager.Instance.SpecificItems.Find (x => x.Id == 58); Quantifier <SpecificItem> tables = new Quantifier<SpecificItem> (2, specificItemTable); inventoryTotalList.Add (tables); Quantifier<SpecificItem> chairs = new Quantifier<SpecificItem> (8, specificItemChair); inventoryTotalList.Add (chairs); //preender a minha lista de inventorio foreach (Player player in game.Players) { for (int i = 0; i < player.Inventory.Count; i++) { SpecificItem specificItem = player.Inventory [i].Item; int index = inventoryTotalList.FindIndex (speItem => speItem.Item.Id == specificItem.Id); if (index == -1) { SpecificItem specificItemCopy = new SpecificItem (specificItem.Id, specificItem.Name, specificItem.IconId, specificItem.Price, specificItem.Theme, specificItem.GeneralItem); Quantifier<SpecificItem> itemToAddWithQTD = new Quantifier<SpecificItem> (player.Inventory [i].Quantity, specificItemCopy); inventoryTotalList.Add (itemToAddWithQTD); } else { inventoryTotalList [index].Quantity += player.Inventory [i].Quantity; } } } inventoryTotalSize = inventoryTotalList.Count (); itemsInContainerList = new List<Quantifier<SpecificItem>> (); foreach (GameObject item in hooks.ItemsArea) { item.GetComponent<ItemGeneral> ().AddItem = AddItem; } itemIndex = 0; updateScene (); }
private void Refresh() { for (int i = 0; i < amountOfPlayers; i++) { playersInventory [i].Clear (); game.Players [i].ItemsReturned = 0; for (int j = 0; j < game.Players[i].Inventory.Count; j++) { SpecificItem specificItem = game.Players [i].Inventory [j].Item; SpecificItem specificItemCopy = new SpecificItem (specificItem.Id, specificItem.Name, specificItem.IconId, specificItem.Price, specificItem.Theme, specificItem.GeneralItem); Quantifier<SpecificItem> itemToAddWithQTD = new Quantifier<SpecificItem> (game.Players [i].Inventory [j].Quantity, specificItemCopy); playersInventory [i].Add (itemToAddWithQTD); } } for (int i = 0; i < amountOfPlayers; i++) { playersSpent [i] = game.Players [i].TotalSpent (); updateCardboardInv (i); } updateTotalSpendingAmount (); }
private void Advance() { //mudar os inventorios dos jogadores for (int i = 0; i < amountOfPlayers; i++) { game.Players [i].Inventory.Clear (); for (int j = 0; j < playersInventory[i].Count; j++) { SpecificItem specificItem = playersInventory [i] [j].Item; SpecificItem specificItemCopy = new SpecificItem (specificItem.Id, specificItem.Name, specificItem.IconId, specificItem.Price, specificItem.Theme, specificItem.GeneralItem); Quantifier<SpecificItem> itemToAddWithQTD = new Quantifier<SpecificItem> (playersInventory [i] [j].Quantity, specificItemCopy); game.Players [i].Inventory.Add (itemToAddWithQTD); } } game.CurrentCheckpoint = Game.Checkpoint.Party; GuiManager.Instance.messageCanvas.SetAndShow (MessageCanvasControl.LOADING_MESSAGE, false); Loom loom = Loom.Instance; loom.RunAsync (() => { try { GameManager.Instance.Entity.SyncSaveGame (game); loom.QueueOnMainThread (() => { GuiManager manager = GuiManager.Instance; manager.messageCanvas.Hide (); manager.Show (manager.partyIntroCanvas); }); } catch (Database.DatabaseException) { loom.QueueOnMainThread (() => { GuiManager.Instance.messageCanvas.SetAndShow ( "Ocorreu um erro com a Internet.\nPor favor tenta de novo.", true); }); } }); }
public void Save(Player player, SpecificItem specificItem, int quantity) { try { List<ColumnValue> columns = new List<ColumnValue> (); columns.Add (new ColumnValue () { Item1 = "quantity", Item2 = quantity.ToString() }); StatementValue where = new StatementValue (); where.Item1 = "playerId = @StatementValue0 AND specificItemId = @StatementValue1"; where.Item2 = new List<string> (); where.Item2.Add (player.Id.ToString ()); where.Item2.Add (specificItem.Id.ToString ()); this.Update (columns, where); } catch (MySqlException ex) { switch (ex.Number) { case 0: throw new DatabaseException ("Cannot connect to server. Contact administrator", ex); case 1045: throw new DatabaseException ("Invalid username/password, please try again", ex); default: throw new DatabaseException (ex.Message, ex); } } }
private void Refresh() { //apagar os elementos no meu itemContainer int children = hooks.ItemContainer.transform.childCount; for (int i = 0; i < children; i++) { GameObject.Destroy (hooks.ItemContainer.transform.GetChild (i).gameObject); } //limpar as listas itemsInContainerList.Clear (); inventoryTotalList.Clear (); //fazer reset ao itemIndex itemIndex = 0; //ativar botoes e tudo o que for preciso ativar for (int i = 0; i < hooks.ItemsArea.Count(); i++) { hooks.ItemsArea [i].SetActive (true); } //initialize my list with 2 tables and 8 chairs SpecificItem specificItemTable = GameManager.Instance.SpecificItems.Find (x => x.Id == 59); SpecificItem specificItemChair = GameManager.Instance.SpecificItems.Find (x => x.Id == 58); Quantifier<SpecificItem> tables = new Quantifier<SpecificItem> (2, specificItemTable); inventoryTotalList.Add (tables); Quantifier<SpecificItem> chairs = new Quantifier<SpecificItem> (8, specificItemChair); inventoryTotalList.Add (chairs); //preender a minha lista de inventorio foreach (Player player in game.Players) { for (int i = 0; i < player.Inventory.Count; i++) { SpecificItem specificItem = player.Inventory [i].Item; int index = inventoryTotalList.FindIndex (speItem => speItem.Item.Id == specificItem.Id); if (index == -1) { SpecificItem specificItemCopy = new SpecificItem (specificItem.Id, specificItem.Name, specificItem.IconId, specificItem.Price, specificItem.Theme, specificItem.GeneralItem); Quantifier<SpecificItem> itemToAddWithQTD = new Quantifier<SpecificItem> (player.Inventory [i].Quantity, specificItemCopy); inventoryTotalList.Add (itemToAddWithQTD); } else { inventoryTotalList [index].Quantity += player.Inventory [i].Quantity; } } } inventoryTotalSize = inventoryTotalList.Count (); updateScene (); }