/// <summary> /// Converts this catalogue page sale representation to a string and returns it. /// </summary> public override string ToString() { try { fuseStringBuilder szSaleDetails = new fuseStringBuilder(); szSaleDetails.appendTabbedValue(this.Name); szSaleDetails.appendTabbedValue(this.Description); szSaleDetails.appendTabbedValue(this.Price.ToString()); szSaleDetails.appendTabbedValue(null); szSaleDetails.appendTabbedValue(this.saleItemType); // 'i', 's', 'd' etc szSaleDetails.appendTabbedValue(this.itemIcon); szSaleDetails.appendTabbedValue(this.itemSize); szSaleDetails.appendTabbedValue(this.itemDimensions); szSaleDetails.appendTabbedValue(this.saleCode); if (this.isPackage || this.pItem.Sprite == "poster") szSaleDetails.appendTabbedValue(null); if (this.isPackage) { szSaleDetails.appendTabbedValue(this.pPackageItems.Count.ToString()); foreach (storeCataloguePackageItem lPackageItem in this.pPackageItems) { szSaleDetails.appendTabbedValue(ObjectTree.Game.Items.generateSpecialSprite(ref lPackageItem.pItem.Sprite, lPackageItem.specialSpriteID)); szSaleDetails.appendTabbedValue(lPackageItem.pAmount.ToString()); szSaleDetails.appendTabbedValue(lPackageItem.pItem.Color); } } else { if (!this.pItem.Behaviour.isWallItem) // Wall items do not have colors szSaleDetails.appendTabbedValue(this.pItem.Color); } return szSaleDetails.ToString(); } catch { return ""; } }
/// <summary> /// 100 - "Ad" /// </summary> public void GRPC() { string[] purchaseArguments = Request.Content.Split(Convert.ToChar(13)); storeCataloguePage pPage = ObjectTree.Game.Store.getCataloguePage(purchaseArguments[1]); if (!pPage.roleHasAccess(Session.User.Role)) // No access return; storeCatalogueSale pSale = pPage.getSale(purchaseArguments[3]); #region Credits balance + valid item check if (pSale == null || pSale.Price > Session.User.Credits) // Sale not found/not able to purchase { Response.Initialize(68); // "AD" sendResponse(); return; } #endregion int receivingUserID = Session.User.ID; string customData = null; string presentBoxNote = null; if (!pSale.isPackage) { #region Handle custom data if (pSale.pItem.Behaviour.isDecoration) { int decorationValue = 0; if (int.TryParse(purchaseArguments[4], out decorationValue) && decorationValue > 0) { customData = decorationValue.ToString(); } else { return; } } else if (pSale.pItem.Behaviour.isPrizeTrophy) { stringFunctions.filterVulnerableStuff(ref purchaseArguments[4], true); fuseStringBuilder sb = new fuseStringBuilder(); sb.appendTabbedValue(Session.User.Username); sb.appendTabbedValue(DateTime.Today.ToShortDateString()); sb.Append(purchaseArguments[4]); // Inscription customData = sb.ToString(); } if (pSale.saleCode.Length == 4 && pSale.saleCode.IndexOf("pet") == 0) // Pet sale { // Verify petname string[] petData = purchaseArguments[4].Split(Convert.ToChar(2)); if (petData[0].Length > 15) // Name too long, truncate name petData[0] = petData[0].Substring(0, 15); stringFunctions.filterVulnerableStuff(ref petData[0], true); // Verify pet type int petType = int.Parse(pSale.saleCode.Substring(3)); // Verify race byte Race = 0; try { Race = byte.Parse(petData[1]); } catch { } petData[1] = Race.ToString(); // Verify color try { ColorTranslator.FromHtml("#" + petData[2]); } catch { return; } // Hax! customData = petData[0] // Name + Convert.ToChar(2) + petType.ToString() // Type + Convert.ToChar(2) + petData[1] // Race + Convert.ToChar(2) + petData[2]; // Color } #endregion } #region Handle presents if (purchaseArguments[5] == "1") { if (purchaseArguments[6].ToLower() != Session.User.Username.ToLower()) // Receiving user is different than buyer { receivingUserID = ObjectTree.Game.Users.getUserID(purchaseArguments[6]); if (receivingUserID == 0) // Receiving user was not found { Response.Initialize(76); // "AL" Response.Append(purchaseArguments[6]); sendResponse(); return; } } presentBoxNote = purchaseArguments[7]; stringFunctions.filterVulnerableStuff(ref presentBoxNote, true); } #endregion // Charge buyer Session.User.Credits -= pSale.Price; Session.refreshCredits(); // Create items and deliver ObjectTree.Game.Store.requestSaleShipping(receivingUserID, pSale.saleCode, true, purchaseArguments[5] == "1", presentBoxNote, customData); // Update user valueables and log transaction Session.User.updateValueables(); ObjectTree.Game.Store.logTransaction(Session.User.ID, "stuff_store", -pSale.Price); }
/// <summary> /// Converts this wall item to a string representation and returns it. /// </summary> public override string ToString() { fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendTabbedValue(this.ID.ToString()); FSB.appendTabbedValue(this.Definition.Sprite); FSB.appendTabbedValue(" "); FSB.appendTabbedValue(this.wallPosition); if(this.customData != null) FSB.Append(this.customData); return FSB.ToString(); }
/// <summary> /// Generates the trade box for a given session and returns it as as string. /// </summary> /// <param name="Session">The Woodpecker.Sessions.Session object to generate the trade box string for.</param> public string generateTradeBox(Session Session) { fuseStringBuilder Box = new fuseStringBuilder(); if (Session.itemStripHandler.isTrading) { Box.appendTabbedValue(Session.User.Username); Box.appendTabbedValue(Session.itemStripHandler.tradeAccept.ToString().ToLower()); Box.Append(Session.itemStripHandler.getTradeOfferItems()); Box.appendChar(13); } return Box.ToString(); }
/// <summary> /// Converts the required fields from this object to a user flat information string. The 'show owner username' property is handled here as well, by checking the permissions of the given user. /// </summary> /// <param name="viewingUser">The userInformation object of the user that requests the flat information string.</param> /// <returns></returns> public string ToUserFlatString() { fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendTabbedValue(this.ID.ToString()); FSB.appendTabbedValue(this.Name); FSB.appendTabbedValue(this.Owner); FSB.appendTabbedValue(this.accessType.ToString()); FSB.appendTabbedValue("x"); FSB.appendTabbedValue(this.currentVisitors.ToString()); FSB.appendTabbedValue(this.maxVisitors.ToString()); FSB.appendTabbedValue("null"); FSB.appendTabbedValue(this.Description); FSB.appendTabbedValue(this.Description); FSB.appendChar(13); return FSB.ToString(); }