/// <summary> /// Returns a string with all the statuses of all active room units. /// </summary> public string getRoomUnitStatuses() { fuseStringBuilder FSB = new fuseStringBuilder(); if (this.roomPets != null) { lock (this.roomPets) { foreach (roomPet lPet in this.roomPets) { FSB.Append(lPet.ToStatusString()); } } } lock (this.roomUsers) { foreach (roomUser lUser in this.roomUsers.Values) { FSB.Append(lUser.ToStatusString()); } } return(FSB.ToString()); }
/// <summary> /// Returns the item list of all the items in the hand ordered by ID. /// </summary> public string getHandItemCasts() { fuseStringBuilder Items = new fuseStringBuilder(); int startID = 0; int endID = this.handItems.Count; if (this.handStripPageIndex == 255) { this.handStripPageIndex = (byte)((endID - 1) / 9); } calculateStripOffset: if (endID > 0) { startID = this.handStripPageIndex * 9; if (endID > (startID + 9)) { endID = startID + 9; } if (startID >= endID) { this.handStripPageIndex--; goto calculateStripOffset; } for (int stripSlotID = startID; stripSlotID < endID; stripSlotID++) { Items.Append(this.handItems[stripSlotID].ToStripString(stripSlotID)); } } return(Items.ToString()); }
/// <summary> /// Returns the favorite rooms of a given user as a string. /// </summary> /// <param name="User">The userInformation object of the user to retrieve the favorite rooms for.</param> public string getFavoriteRooms(userInformation User) { int guestRoomCount = 0; StringBuilder Rooms = new StringBuilder(); Database Database = new Database(false, true); Database.addParameterWithValue("userid", User.ID); Database.Open(); DataTable dTable = Database.getTable("SELECT rooms.*,users.username AS owner FROM rooms LEFT JOIN users ON rooms.ownerid = users.id WHERE rooms.id IN (SELECT roomid FROM rooms_favorites WHERE userid = @userid) ORDER BY rooms.id DESC LIMIT 30"); // User flats first foreach (DataRow dRow in dTable.Rows) { roomInformation Room = roomInformation.Parse(dRow, true); if (Room.isUserFlat) { guestRoomCount++; } Rooms.Append(Room.ToString(User)); } fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendWired(guestRoomCount); FSB.Append(Rooms.ToString()); return(FSB.ToString()); }
/// <summary> /// Creates the messenger buddy string of this user information and returns it. /// </summary> public override string ToString() { fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendWired(this.ID); FSB.appendClosedValue(this.Username); FSB.appendWired(this.Sex == 'M'); FSB.appendClosedValue(messengerMotto); bool isOnline = Engine.Game.Users.userIsLoggedIn(this.ID); FSB.appendWired(isOnline); if (isOnline) // User is online { Session userSession = Engine.Game.Users.getUserSession(this.ID); if (userSession == null) { FSB.Append("Hotel View"); } else { if (userSession.inRoom) { if (userSession.roomInstance.Information.isUserFlat) { FSB.Append("Floor1a"); } else { FSB.Append(userSession.roomInstance.Information.Name); } } this.lastActivity = DateTime.Now; } } else { FSB.Append("Hotel View"); } FSB.appendChar(2); FSB.appendClosedValue(messengerLastActivity); FSB.appendClosedValue(this.Figure); return(FSB.ToString()); }
/// <summary> /// Creates the messenger buddy status string of this user information and returns it. /// </summary> public string ToStatusString() { fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendWired(this.ID); FSB.appendClosedValue(messengerMotto); bool isOnline = Engine.Game.Users.userIsLoggedIn(this.ID); FSB.appendWired(isOnline); if (isOnline) // User is online { Session userSession = Engine.Game.Users.getUserSession(this.ID); if (userSession.inRoom) { if (userSession.roomInstance.Information.isUserFlat) { FSB.Append("Floor1a"); } else { FSB.Append(userSession.roomInstance.Information.Name); } } else { FSB.Append("on Hotel View"); } } else { FSB.Append(messengerLastActivity); } FSB.appendChar(2); return(FSB.ToString()); }
/// <summary> /// Returns a string with all the statuses of all active room units. /// </summary> public string getRoomUnitStatuses() { fuseStringBuilder FSB = new fuseStringBuilder(); if (this.roomPets != null) { lock (this.roomPets) { foreach (roomPet lPet in this.roomPets) { FSB.Append(lPet.ToStatusString()); } } } if (this.roomBots != null) { lock (this.roomBots) { foreach (roomUser lBot in this.roomBots) { lBot.rotationHead = lBot.bInfo.rotation; lBot.rotationBody = lBot.bInfo.rotation; FSB.Append(lBot.ToStatusString()); } } } lock (this.roomUsers) { foreach (roomUser lUser in this.roomUsers.Values) { FSB.Append(lUser.ToStatusString()); } } 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 this floor item to a string representation and returns it. /// </summary> public override string ToString() { /* Format example: public space object * 2732 invisichair 27 32 1 2 */ /* Format example: furniture * 802610 * chair_polyfon * PB PA I I H 0.0 * 0,0,0 * * H data */ fuseStringBuilder FSB = new fuseStringBuilder(); if (!this.Definition.Behaviour.isPublicSpaceObject) { FSB.appendClosedValue(this.ID.ToString()); FSB.appendClosedValue(this.Definition.Sprite); FSB.appendWired(this.X); FSB.appendWired(this.Y); FSB.appendWired(this.Definition.Length); FSB.appendWired(this.Definition.Width); FSB.appendWired(this.Rotation); FSB.appendClosedValue(stringFunctions.formatFloatForClient(this.Z)); FSB.appendClosedValue(this.Definition.Color); FSB.appendClosedValue(null); FSB.appendWired(this.teleporterID); FSB.appendClosedValue(this.customData); } else { //FSB.appendWhiteSpacedValue(this.ID.ToString()); FSB.appendWhiteSpacedValue(this.customData); FSB.appendWhiteSpacedValue(this.Definition.Sprite); FSB.appendWhiteSpacedValue(this.X.ToString()); FSB.appendWhiteSpacedValue(this.Y.ToString()); FSB.appendWhiteSpacedValue(this.Z.ToString()); FSB.Append(this.Rotation.ToString()); FSB.appendChar(13); } return(FSB.ToString()); }
/// <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> /// Returns a string with all the offered trade items represented as a string. /// </summary> public string getTradeOfferItems() { fuseStringBuilder FSB = new fuseStringBuilder(); if (this.isTrading) { for (int slotID = 0; slotID < this.tradeOfferItemIDs.Count; slotID++) { stripItem pItem = this.getHandItem(this.tradeOfferItemIDs[slotID]); if (pItem != null) { FSB.Append(pItem.ToStripString(slotID)); } } } return(FSB.ToString()); }
/// <summary> /// Parses the generic roomInformation object to a room information string. /// </summary> /// <param name="viewingUser">The userInformation object of the user that requests the flat information string.</param> public string ToString(userInformation viewingUser) { fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendWired(this.ID); // Room ID if (!this.isUserFlat) // Public space flag { FSB.appendWired(true); } FSB.appendClosedValue(this.Name); // Room name if (this.isUserFlat) // User flat { if (this.showOwner || this.ownerID == viewingUser.ID || viewingUser.hasFuseRight("fuse_see_all_roomowners")) { FSB.appendClosedValue(this.Owner); } else { FSB.Append("-"); } FSB.appendClosedValue(this.accessType.ToString()); } FSB.appendWired(this.currentVisitors); FSB.appendWired(this.maxVisitors); if (!this.isUserFlat) { FSB.appendWired(this.categoryID); } FSB.appendClosedValue(this.Description); if (!this.isUserFlat) { FSB.appendWired(this.ID); FSB.appendWired(false); FSB.appendClosedValue(this.CCTs); FSB.appendWired(false); FSB.appendWired(true); } return(FSB.ToString()); }
/// <summary> /// Returns a string with all the string representations of all the wall items in this room instance. /// </summary> /// <returns></returns> public string getWallItems() { if (this.Information.isUserFlat) { fuseStringBuilder FSB = new fuseStringBuilder(); lock (this.wallItems) { foreach (wallItem lItem in this.wallItems) { FSB.Append(lItem.ToString()); FSB.appendChar(13); } } return FSB.ToString(); } else return ""; }
/// <summary> /// Returns a string with all the string representations of all the floor items in this room instance. /// </summary> /// <param name="publicSpaceItems">Supply true to return the public space items, false for user items.</param> public string getFloorItems(bool publicSpaceItems) { fuseStringBuilder FSB = new fuseStringBuilder(); if (!(publicSpaceItems && this.Information.isUserFlat)) { if (!publicSpaceItems) FSB.appendWired(this.floorItems.Count); lock (this.floorItems) { foreach (floorItem lItem in this.floorItems) { FSB.Append(lItem.ToString()); } } } return FSB.ToString(); }
/// <summary> /// Returns a string with all the string representations of all the wall items in this room instance. /// </summary> /// <returns></returns> public string getWallItems() { if (this.Information.isUserFlat) { fuseStringBuilder FSB = new fuseStringBuilder(); lock (this.wallItems) { foreach (wallItem lItem in this.wallItems) { FSB.Append(lItem.ToString()); FSB.appendChar(13); } } return(FSB.ToString()); } else { return(""); } }
/// <summary> /// Returns a string with all the string representations of all the floor items in this room instance. /// </summary> /// <param name="publicSpaceItems">Supply true to return the public space items, false for user items.</param> public string getFloorItems(bool publicSpaceItems) { fuseStringBuilder FSB = new fuseStringBuilder(); if (!(publicSpaceItems && this.Information.isUserFlat)) { if (!publicSpaceItems) { FSB.appendWired(this.floorItems.Count); } lock (this.floorItems) { foreach (floorItem lItem in this.floorItems) { FSB.Append(lItem.ToString()); } } } return(FSB.ToString()); }
/// <summary> /// Builds the string for the client that displays the index of games and their details. /// </summary> public string buildGameIndex() { int[] gameAmounts = new int[3]; fuseStringBuilder ptxtGames = new fuseStringBuilder(); foreach (arcadeGame lGame in mGames) { ptxtGames.Append(lGame.ToSummaryString()); gameAmounts[(int)lGame.State]++; } fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendWired(gameAmounts[0]); // Amount of 'waiting' games if (gameAmounts[1] > 0 || gameAmounts[2] > 0) { FSB.appendWired(gameAmounts[1]); // Amount of started games FSB.appendWired(gameAmounts[2]); // Amount of ended games } FSB.Append(ptxtGames.ToString()); return(FSB.ToString()); }
/// <summary> /// Converts this item instance representation to a string that displays this item on a strip (hand or trading box) and returns it. /// </summary> /// <param name="slotID">The current slot ID of this item on the strip.</param> public string ToStripString(int stripSlotID) { /* * Wallitem: * + "SI" * + itemID * + slotID * + stripItemType 'I' * + itemID * + sprite * + color (incase of decoration or post.it pad: customdata) * + recycleable 1/0 * + "/" * * Flooritem: * + "SI" * + itemID (negative) * + slotID * + stripItemType 'S' * + itemID * + sprite * + length * + width * + customdata * + color * + recycleable 1/0 * + sprite * + "/" */ fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendStripValue("SI"); //if (!this.Definition.isWallItem) // Floor item ID = negative, so prefix with '-' // FSB.Append("-"); FSB.appendStripValue(this.ID.ToString()); FSB.appendStripValue(stripSlotID.ToString()); if (this.Definition.Behaviour.isWallItem) { FSB.appendStripValue("I"); } else { FSB.appendStripValue("S"); } FSB.appendStripValue(this.ID.ToString()); FSB.appendStripValue(this.Definition.Sprite); if (this.Definition.Behaviour.isWallItem) { FSB.appendStripValue(this.customData); FSB.appendStripValue("0"); // Not-recycleable } else { FSB.appendStripValue(this.Definition.Length.ToString()); FSB.appendStripValue(this.Definition.Width.ToString()); FSB.appendStripValue(this.customData); FSB.appendStripValue(this.Definition.Color); FSB.appendStripValue("0"); // Not-recycleable FSB.appendStripValue(this.Definition.Sprite); } FSB.Append("/"); return(FSB.ToString()); }
/// <summary> /// 100 - "Ad" /// </summary> public void GRPC() { for (int i = 0; i < this.Session.User.Multiplier; i++) { string[] purchaseArguments = Request.Content.Split(Convert.ToChar(13)); storeCataloguePage pPage = Engine.Game.Store.getCataloguePage(purchaseArguments[1]); if (pPage == null) { return; } 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 = Engine.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 Engine.Game.Store.requestSaleShipping(receivingUserID, pSale.saleCode, true, purchaseArguments[5] == "1", presentBoxNote, customData ?? ""); // Update user valueables and log transaction Session.User.updateValueables(); Engine.Game.Store.logTransaction(Session.User.ID, "stuff_store", -pSale.Price); } }