private void LoadItemListPage() { var model = MarketService.GetPlayerMarketData(GetPC()); IEnumerable <PCMarketListing> listings; DateTime now = DateTime.UtcNow; int marketRegionID = MarketService.GetMarketRegionID(Object.OBJECT_SELF); // Pull items by category if (model.BrowseMode == MarketBrowseMode.ByCategory) { listings = DataService.Where <PCMarketListing>(x => x.DateExpires > now && x.MarketRegionID == marketRegionID && x.MarketCategoryID == model.BrowseCategoryID && x.DateSold == null && x.DateRemoved == null); } // Pull items being sold by a specific player else { listings = DataService.Where <PCMarketListing>(x => x.DateExpires > now && x.MarketRegionID == marketRegionID && x.SellerPlayerID == model.BrowsePlayerID && x.DateSold == null && x.DateRemoved == null); } // Build the response list. ClearPageResponses("ItemListPage"); AddResponseToPage("ItemListPage", ColorTokenService.Green("Refresh"), true, Guid.Empty); foreach (var listing in listings) { string listingName = BuildItemName(listing); AddResponseToPage("ItemListPage", listingName, true, listing.ID); } }
private void LoadMainPage() { var player = GetPC(); var data = BaseService.GetPlayerTempData(player); var bases = DataService .Where <PCBase>(x => x.PlayerID == player.GlobalID && x.ApartmentBuildingID == data.ApartmentBuildingID).OrderBy(o => o.DateInitialPurchase) .ToList(); string header = ColorTokenService.Green("Apartment Rental Terminal") + "\n\n"; header += "Apartments you are currently renting can be found in the list below. You may also rent an apartment here."; SetPageHeader("MainPage", header); ClearPageResponses("MainPage"); AddResponseToPage("MainPage", ColorTokenService.Green("Lease New Apartment")); int count = 1; foreach (var apartment in bases) { string name = "Apartment #" + count; if (!string.IsNullOrWhiteSpace(apartment.CustomName)) { name = apartment.CustomName; } AddResponseToPage("MainPage", name, true, apartment.ID); count++; } }
private void LoadHeader() { NWPlayer player = GetPC(); player.SetLocalBool("ITEM_RENAMING_LISTENING", true); NWItem item = player.GetLocalObject("ITEM_BEING_RENAMED"); string originalName = item.GetLocalString("RENAMED_ITEM_ORIGINAL_NAME"); if (string.IsNullOrWhiteSpace(originalName)) { originalName = item.Name; } string currentName = item.Name; string renamingName = player.GetLocalString("RENAMED_ITEM_NEW_NAME"); if (string.IsNullOrWhiteSpace(renamingName)) { renamingName = "{UNSPECIFIED}"; } string header = "You are renaming an item.\n\n"; header += ColorTokenService.Green("Original Name: ") + originalName + "\n"; header += ColorTokenService.Green("Current Name: ") + currentName + "\n"; header += ColorTokenService.Green("New Name: ") + renamingName + "\n"; header += "Type in a new name, click 'Refresh', and then select 'Change Name' to make the changes. Click 'Reset Name' to switch back to the item's original name."; SetPageHeader("MainPage", header); }
private void RenameResponses(int responseID) { switch (responseID) { case 1: string newDescription = GetPC().GetLocalString("NEW_DESCRIPTION_TO_SET"); if (string.IsNullOrWhiteSpace(newDescription)) { _.FloatingTextStringOnCreature("Type in a new name to the chat bar and then press 'Next'.", GetPC().Object, _.FALSE); return; } string header = "Your new name follows. If you need to make a change, click 'Back', type in a new description, and then hit 'Next' again.\n\n"; header += ColorTokenService.Green("New Description: ") + "\n\n"; header += newDescription; SetPageHeader("ConfirmRenamePage", header); ChangePage("ConfirmRenamePage"); break; case 2: GetPC().DeleteLocalInt("LISTENING_FOR_DESCRIPTION"); GetPC().DeleteLocalString("NEW_DESCRIPTION_TO_SET"); break; } }
private void LoadConfirmPage() { var model = GetDialogCustomData <Model>(); var pcPerk = DataService.PCPerk.GetByID(model.PCPerkID); var perk = DataService.Perk.GetByID(pcPerk.PerkID); var minimumLevel = 1; if (IsGrantedByBackground((PerkType)perk.ID)) { minimumLevel = 2; } int refundAmount = DataService.PerkLevel.GetAllByPerkID(perk.ID).Where(x => x.Level <= pcPerk.PerkLevel && x.Level >= minimumLevel).Sum(x => x.Price); string header = ColorTokenService.Green("Perk: ") + perk.Name + "\n"; header += ColorTokenService.Green("Level: ") + pcPerk.PerkLevel + "\n\n"; header += "You will receive " + ColorTokenService.Green(refundAmount.ToString()) + " SP if you refund this perk. Are you sure you want to refund it?"; SetPageHeader("ConfirmPage", header); SetResponseText("ConfirmPage", 1, model.IsConfirming ? "CONFIRM REFUND" : "Confirm Refund"); }
/// <summary> /// Displays all the chat commands available to a user /// </summary> /// <param name="user"></param> /// <param name="target"></param> /// <param name="targetLocation"></param> /// <param name="args"></param> public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { bool isDM = user.IsDM || AuthorizationService.IsPCRegisteredAsDM(user); var classes = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => typeof(IChatCommand).IsAssignableFrom(p) && p.IsClass) .OrderBy(o => o.Name) .ToArray(); foreach (var @class in classes) { var attribute = @class.GetCustomAttribute <CommandDetailsAttribute>(); if (attribute == null) { continue; } if (attribute.Permissions.HasFlag(CommandPermissionType.Player) && user.IsPlayer || attribute.Permissions.HasFlag(CommandPermissionType.DM) && isDM) { user.SendMessage(ColorTokenService.Green("/" + @class.Name.ToLower()) + ColorTokenService.White(": " + attribute.Description)); } } }
private void LoadStylePage(BuildingType buildingType) { var data = BaseService.GetPlayerTempData(GetPC()); // Header int styleID = data.StructureItem.GetLocalInt("STRUCTURE_BUILDING_EXTERIOR_ID"); if (buildingType == BuildingType.Interior) { styleID = data.StructureItem.GetLocalInt("STRUCTURE_BUILDING_INTERIOR_ID"); } var currentStyle = DataService.BuildingStyle.GetByID(styleID); string header = ColorTokenService.Green("Building Style: ") + currentStyle.Name + "\n\n"; header += "Change the style by selecting from the list below."; SetPageHeader("StylePage", header); // Responses ClearPageResponses("StylePage"); if (buildingType == BuildingType.Interior) { AddResponseToPage("StylePage", "Preview Interior", true, new Tuple <int, BuildingType>(-2, BuildingType.Interior)); } var styles = DataService.BuildingStyle.GetAll().Where(x => x.BuildingTypeID == (int)buildingType && x.BaseStructureID == data.BaseStructureID && x.IsActive).ToList(); foreach (var style in styles) { var args = new Tuple <int, BuildingType>(style.ID, buildingType); AddResponseToPage("StylePage", style.Name, true, args); } }
private void LoadManageStructureDetails() { ClearPageResponses("ManageStructureDetailsPage"); var data = BaseService.GetPlayerTempData(GetPC()); var structure = data.ManipulatingStructure.Structure; var pcBaseStructureID = data.ManipulatingStructure.Structure.Area.GetLocalString("PC_BASE_STRUCTURE_ID"); Guid?structureID = string.IsNullOrWhiteSpace(pcBaseStructureID) ? null : (Guid?)new Guid(pcBaseStructureID); bool canRetrieveStructures; bool canPlaceEditStructures; if (structureID != null) { canRetrieveStructures = BasePermissionService.HasStructurePermission(GetPC(), (Guid)structureID, StructurePermission.CanRetrieveStructures); canPlaceEditStructures = BasePermissionService.HasStructurePermission(GetPC(), (Guid)structureID, StructurePermission.CanPlaceEditStructures); } else { canRetrieveStructures = BasePermissionService.HasBasePermission(GetPC(), data.ManipulatingStructure.PCBaseID, BasePermission.CanRetrieveStructures); canPlaceEditStructures = BasePermissionService.HasBasePermission(GetPC(), data.ManipulatingStructure.PCBaseID, BasePermission.CanPlaceEditStructures); } string header = ColorTokenService.Green("Structure: ") + structure.Name + "\n\n"; header += "What would you like to do with this structure?"; SetPageHeader("ManageStructureDetailsPage", header); AddResponseToPage("ManageStructureDetailsPage", "Retrieve Structure", canRetrieveStructures); AddResponseToPage("ManageStructureDetailsPage", "Rotate", canPlaceEditStructures); }
public static void SubscribeEvents() { MessageHub.Instance.Subscribe <OnModuleLoad>(x => { var classes = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => typeof(IChatCommand).IsAssignableFrom(p) && p.IsClass) .OrderBy(o => o.Name) .ToArray(); foreach (var @class in classes) { var attribute = @class.GetCustomAttribute <CommandDetailsAttribute>(); if (attribute == null) { continue; } if (attribute.Permissions.HasFlag(CommandPermissionType.Player)) { _helpTextPlayer += ColorTokenService.Green("/" + @class.Name.ToLower()) + ColorTokenService.White(": " + attribute.Description) + "\n"; } if (attribute.Permissions.HasFlag(CommandPermissionType.DM)) { _helpTextDM += ColorTokenService.Green("/" + @class.Name.ToLower()) + ColorTokenService.White(": " + attribute.Description) + "\n"; } } }); }
private void LoadBrowseByCategoryPage() { string header = ColorTokenService.Green("Galactic Trade Network - Browse by Category") + "\n\n"; header += "Please select a category."; SetPageHeader("BrowseByCategoryPage", header); NWPlaceable terminal = NWGameObject.OBJECT_SELF; int marketRegionID = MarketService.GetMarketRegionID(terminal); IEnumerable <PCMarketListing> listings = DataService.PCMarketListing .GetAllByMarketRegionID(marketRegionID) .Where(x => x.DateExpires > DateTime.UtcNow && x.DateSold == null && x.DateRemoved == null); IEnumerable <int> categoryIDs = listings.Select(s => s.MarketCategoryID).Distinct(); IEnumerable <MarketCategory> categories = DataService.MarketCategory.GetAllByIDs(categoryIDs) .OrderBy(o => o.Name); ClearPageResponses("BrowseByCategoryPage"); AddResponseToPage("BrowseByCategoryPage", ColorTokenService.Green("Refresh"), true, -1); foreach (var category in categories) { AddResponseToPage("BrowseByCategoryPage", category.Name, true, category.ID); } }
private void BuildPlayerDetailsPage(NWPlayer player) { ClearPageResponses("PlayerDetailsPage"); var data = BaseService.GetPlayerTempData(GetPC()); var permission = DataService.SingleOrDefault <PCBaseStructurePermission>(x => x.PlayerID == player.GlobalID && x.PCBaseStructureID == data.StructureID && !x.IsPublicPermission); // Intentionally excluded permissions: CanAdjustPermissions, CanCancelLease bool canPlaceEditStructures = permission?.CanPlaceEditStructures ?? false; bool canAccessStructureInventory = permission?.CanAccessStructureInventory ?? false; bool canEnterBuilding = permission?.CanEnterBuilding ?? false; bool canAdjustPermissions = permission?.CanAdjustPermissions ?? false; bool canRetrieveStructures = permission?.CanRetrieveStructures ?? false; bool canRenameStructures = permission?.CanRenameStructures ?? false; bool canEditPrimaryResidence = permission?.CanEditPrimaryResidence ?? false; bool canRemovePrimaryResidence = permission?.CanRemovePrimaryResidence ?? false; bool canChangeStructureMode = permission?.CanChangeStructureMode ?? false; bool canAdjustPublicPermissions = permission?.CanAdjustPublicPermissions ?? false; bool canFlyStarship = permission?.CanFlyStarship ?? false; bool isStarship = GetPC().Area.GetLocalInt("BUILDING_TYPE") == (int)Enumeration.BuildingType.Starship; string header = ColorTokenService.Green("Name: ") + player.Name + "\n\n"; header += ColorTokenService.Green("Permissions:\n\n"); header += "Can Place/Edit Structures: " + (canPlaceEditStructures ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Access Structure Inventory: " + (canAccessStructureInventory ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Enter Building: " + (canEnterBuilding ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Adjust Permissions: " + (canAdjustPermissions ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Retrieve Structures: " + (canRetrieveStructures ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Rename Structures: " + (canRenameStructures ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Edit Primary Residence: " + (canEditPrimaryResidence ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Remove Primary Residence: " + (canRemovePrimaryResidence ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Change Structure Mode: " + (canChangeStructureMode ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Adjust PUBLIC Permissions: " + (canAdjustPublicPermissions ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; if (isStarship) { header += "Can Fly Starship: " + (canFlyStarship ? ColorTokenService.Green("YES") :ColorTokenService.Red("NO")) + "\n"; } SetPageHeader("PlayerDetailsPage", header); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Place/Edit Structures", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Access Structure Inventory", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Enter Building", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Adjust Permissions", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Retrieve Structures", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Rename Structures", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Edit Primary Residence", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Remove Primary Residence", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Change Structure Mode", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Adjust PUBLIC Permissions", true, player); // Add new non-conditional responses here to avoid confusing the response handling logic. if (isStarship) { AddResponseToPage("PlayerDetailsPage", "Toggle: Can Fly Starship", true, player); } }
private void ChangeAssociationResponses(int responseID) { string header; switch (responseID) { case 1: // Jedi Order header = ColorTokenService.Green("Jedi Order\n\n"); header += "The Guardians of peace and justice in the Republic, the Jedi Order is a large group of Light Side Force users led by the Jedi Council. Wishing to uphold the ideals of peace and bring balance to the Force they are stalwart defenders of the Galaxy. Association to the Jedi Order is held by Jedi of all positions as well as their closest allies."; break; case 2: // Mandalorian header = ColorTokenService.Green("Mandalorian\n\n"); header += "Mandalorians are one of the supreme fighting cultures on the Galaxy. Ruled by the Mand’alor of that period, they are a fractured group consisting of Clans grouped together under a House by the racially inclusive population. Though there is currently no Mand’alor to lead them their culture lives on through each member. Association with Mandalorians is held by members or hopefuls, Military figures, and Mercenaries."; break; case 3: // Sith Empire header = ColorTokenService.Green("Sith Empire\n\n"); header += "Founded by exiled members of the Jedi Order, the Sith Order consists of those who utilize a focus on the Dark Side of the Force. Unlike the Jedi, the Sith Order wishes to impose their power and will onto others by show of force. Seeing themselves as the true powers of the Galaxy, they seek to rule it above all things. Association to the Sith Order is held by Sith of all positions as well as some of their underlings and aspiring hopefuls."; break; case 4: // Smugglers header = ColorTokenService.Green("Smugglers\n\n"); header += "Smugglers, though not a specific organization, are prevalent throughout the Galaxy. Though they can come from anywhere they generally look out for themselves, selling their services to any willing to pay and almost always for the largest coin. With monetary gain as their primary motivator Smugglers do not hurt for work. Association with the likes of Smugglers is held by any willing to move products or transition supplies from one set of hands to another."; break; case 5: // Unaligned header = ColorTokenService.Green("Unaligned\n\n"); header += "The Unaligned are any who seek out a future for themselves without the strings of being associated with one of the organizations on the main galactic stage. Looking out for their own interests and striving for a better future for themselves, being unaligned is most off the frequent outlook for those in the farther reaches of the galaxy."; break; case 6: // Hutt Cartel header = ColorTokenService.Green("Hutt Cartel\n\n"); header += "One of the largest criminal organizations both in reach and numbers, the Hutt Cartel is a powerful group of Hutts that place their slimy tails in everything they can get their hands on. Dealing in everything from weapons to drugs and assassinations to slavery, the Hutt Cartel knows no bounds to the type of crime they will deal in so long as it is profitable. Association with the Hutt Cartel is held by the likes of assassins, thieves, and gang members, as well as those that aspire to cheat their way through life."; break; case 7: // Republic header = ColorTokenService.Green("Republic\n\n"); header += "For a little over 20 thousand years the Republic has been the ruling force throughout the Galaxy. It’s ruling body is comprised of Senators representing planets and systems. The Jedi Order works with the Republic as their primary peacekeepers with a large Galactic Republic Military Force consisting of individuals from all walks of life. Association to the Republic is held by Military and Political figures throughout the Galaxy, as well as Jedi seeking to hold back the tides of chaos that wish to tear it down."; break; case 8: // Czerka header = ColorTokenService.Green("Czerka Corporation\n\n"); header += "The Czerka Corporation is a galaxy spanning organization that works to make a profit no matter the cost. Though previously unaligned it has recent allied itself with the Sith Empire for exclusive trade benefits throughout their conquered worlds. Dealing in mining resources, weapons, and droids, Czerka are some of the galaxies current forerunners in technology and trade. Association with Czerka can be held by nearly anyone with the ability and drive to create and trade for a profit."; break; case 9: // Sith Order header = ColorTokenService.Green("Sith Order\n\n"); header += "Founded by exiled members of the Jedi Order, the Sith Order consists of those who utilize a focus on the Dark Side of the Force. Unlike the Jedi, the Sith Order wishes to impose their power and will onto others by show of force. Seeing themselves as the true powers of the Galaxy, they seek to rule it above all things. Association to the Sith Order is held by Sith of all positions as well as some of their underlings and aspiring hopefuls."; break; default: return; } var model = GetDialogCustomData <Model>(); model.AssociationID = responseID; SetPageHeader("ConfirmAssociationPage", header); ChangePage("ConfirmAssociationPage"); }
public void LoadMainMenu() { ClearPageResponses("MainPage"); string header = ColorTokenService.Green("HoloCom Menu\n\n"); SetPageHeader("MainPage", header); NWPlayer user = GetPC(); AddResponseToPage("MainPage", "End current call with " + HoloComService.GetTargetForActiveCall(user).Name, HoloComService.IsInCall(user), HoloComService.GetTargetForActiveCall(user)); AddResponseToPage("MainPage", "Answer incoming call from " + HoloComService.GetCallSender(user).Name, HoloComService.IsCallReceiver(user) && !HoloComService.IsInCall(user), HoloComService.GetCallSender(user)); AddResponseToPage("MainPage", "Decline incoming call from " + HoloComService.GetCallSender(user).Name, HoloComService.IsCallReceiver(user) && !HoloComService.IsInCall(user), HoloComService.GetCallSender(user)); if (HoloComService.IsCallReceiver(user) || HoloComService.IsInCall(user) || HoloComService.IsCallSender(user)) { return; } foreach (var player in NWModule.Get().Players) { if (player == user || !player.IsPlayer) { continue; } string message = "Call " + player.Name; if (HoloComService.IsInCall(player)) { message += ColorTokenService.Red(" (LINE BUSY)"); } AddResponseToPage("MainPage", message, true, player); } }
private void LoadManageMarketListingsPage() { string header = ColorTokenService.Green("Galactic Trade Market - Manage Market Listings") + "\n\n"; header += "The following is a list of items you are currently selling. Pick one to edit or remove the listing."; SetPageHeader("MarketListingsPage", header); var player = GetPC(); var regionID = MarketService.GetMarketRegionID(NWGameObject.OBJECT_SELF); var listings = DataService.PCMarketListing.GetAllBySellerPlayerID(player.GlobalID) .Where(x => x.DateSold == null && x.DateRemoved == null && x.MarketRegionID == regionID); ClearPageResponses("MarketListingsPage"); foreach (var listing in listings) { string itemName = BuildItemName(listing); // Display an EXPIRED tag on the item name if the listing has expired. if (listing.DateExpires < DateTime.UtcNow) { itemName += ColorTokenService.Red(" [EXPIRED]"); } AddResponseToPage("MarketListingsPage", itemName, true, listing.ID); } }
private void MainPageResponses(int responseID) { NWPlayer player = GetPC(); string planet; int price; string destinationTag; switch (responseID) { case 1: // Viscara planet = "Viscara"; price = 100; destinationTag = "VISCARA_LANDING"; break; case 2: // Mon Cala planet = "Mon Cala"; price = 200; destinationTag = "MON_CALA_LANDING"; break; case 3: // Hutlar planet = "Hutlar"; price = 300; destinationTag = "HUTLAR_LANDING"; break; case 4: // Tatooine planet = "Tatooine"; price = 400; destinationTag = "TATOOINE_LANDING"; break; default: return; } string header = ColorTokenService.Green("Selected Destination: ") + planet + "\n"; header += ColorTokenService.Green("Price: ") + price + "\n\n"; header += "This trip is one-way and non-refundable. Are you sure you want to take this flight?"; // Check if player has enough money if (player.Gold < price) { header += "\n\n" + ColorTokenService.Red("You do not have enough credits to purchase this flight!"); SetResponseVisible("ConfirmPage", 1, false); } else { SetResponseVisible("ConfirmPage", 1, true); } // Store selected data for later use in the conversation. var model = new Model(price, destinationTag); SetDialogCustomData(model); SetPageHeader("ConfirmPage", header); ChangePage("ConfirmPage"); }
private void BuildMainPageHeader() { var data = BaseService.GetPlayerTempData(GetPC()); Player player; if (data.BuildingType == BuildingType.Interior || data.BuildingType == BuildingType.Starship) { Guid structureID = data.StructureID; player = DataService.Player.GetByPrimaryResidencePCBaseStructureIDOrDefault(structureID); } else if (data.BuildingType == BuildingType.Apartment) { Guid pcBaseID = data.PCBaseID; player = DataService.Player.GetByPrimaryResidencePCBaseIDOrDefault(pcBaseID); } else { SetPageHeader("MainPage", "Unable to select residency for this building type. Notify an admin there's a problem."); return; } string residentName = player == null ? "[Unclaimed]" : player.CharacterName; string header = "Selecting a primary residence grants your character benefits such as increased XP gain and bonuses. These are modified based on the structures you place inside your primary residence.\n\n" + "You may only have one primary residence at a time. A building or starship may only have one primary resident at a time.\n\n" + "Your primary residence may be revoked by the base owner or any player with permission to do so.\n\n"; header += ColorTokenService.Green("Primary Resident: ") + residentName + "\n"; SetPageHeader("MainPage", header); }
private void LoadManageMarketListingDetailsPage() { var player = GetPC(); var model = MarketService.GetPlayerMarketData(player); var category = DataService.MarketCategory.GetByID(model.ItemMarketCategoryID); // Build the header string header = ColorTokenService.Green("Galactic Trade Market - Manage Market Listing") + "\n\n"; header += ColorTokenService.Green("Item: ") + model.ItemStackSize + "x " + model.ItemName + "\n"; header += ColorTokenService.Green("Category: ") + category.Name + "\n"; if (model.ItemRecommendedLevel > 0) { header += ColorTokenService.Green("Recommended Level: ") + model.ItemRecommendedLevel + "\n"; } header += ColorTokenService.Green("Sell Price: ") + model.SellPrice + " credits\n"; header += ColorTokenService.Green("Seller Note: ") + model.SellerNote + "\n\n"; if (model.IsListingExpired) { header += ColorTokenService.Red("This listing has expired."); } else { DateTime now = DateTime.UtcNow; var delta = model.ListingExpirationDate - now; string expirationTime = TimeService.GetTimeLongIntervals(delta.Days, delta.Hours, delta.Minutes, delta.Seconds, false); header += ColorTokenService.Green("This listing expires in " + expirationTime + "."); } SetPageHeader("MarketListingDetailsPage", header); }
private void LoadMainPage() { var player = GetPC(); var data = BaseService.GetPlayerTempData(player); var pcBaseStructureID = new Guid(data.TargetArea.GetLocalString("PC_BASE_STRUCTURE_ID")); var structure = DataService.PCBaseStructure.GetByID(pcBaseStructureID); var mode = DataService.StructureMode.GetByID(structure.StructureModeID); var modeType = (StructureModeType)mode.ID; string header = "You may change the active mode of this building here. Only one mode may be set at a time.\n\nBe aware that switching modes will remove all primary residents for the building.\n\n"; header += ColorTokenService.Green("Current Mode: ") + mode.Name; if (modeType == StructureModeType.Residence) { SetResponseVisible("MainPage", 1, false); } else if (modeType == StructureModeType.Workshop) { SetResponseVisible("MainPage", 2, false); } else if (modeType == StructureModeType.Storefront) { SetResponseVisible("MainPage", 3, false); } SetResponseVisible("MainPage", 3, false); // Temporarily hide the Storefront option until it's implemented. SetPageHeader("MainPage", header); }
private void LoadBrowseBySellerPage() { string header = ColorTokenService.Green("Galactic Trade Network - Browse by Seller") + "\n\n"; header += "Please select a seller."; SetPageHeader("BrowseBySellerPage", header); NWPlaceable terminal = NWGameObject.OBJECT_SELF; int marketRegionID = MarketService.GetMarketRegionID(terminal); IEnumerable <PCMarketListing> listings = DataService.PCMarketListing .GetAllByMarketRegionID(marketRegionID) .Where(x => x.DateExpires > DateTime.UtcNow && x.DateSold == null && x.DateRemoved == null); IEnumerable <Guid> playerIDs = listings.Select(s => s.SellerPlayerID).Distinct(); IEnumerable <Player> players = DataService.Player.GetAllByIDs(playerIDs) .OrderBy(o => o.CharacterName); ClearPageResponses("BrowseBySellerPage"); AddResponseToPage("BrowseBySellerPage", ColorTokenService.Green("Refresh"), true, Guid.Empty); foreach (var player in players) { AddResponseToPage("BrowseBySellerPage", player.CharacterName, true, player.ID); } }
public override void Initialize() { string header = "Please type the new description for your character into the chat box. Then press the 'Next' button.\n\n"; header += ColorTokenService.Green("Current Description: ") + "\n\n"; header += _.GetDescription(GetPC().Object); SetPageHeader("MainPage", header); GetPC().SetLocalInt("LISTENING_FOR_DESCRIPTION", 1); }
private void LoadRotatePage() { var data = BaseService.GetPlayerTempData(GetPC()); var structure = data.ManipulatingStructure.Structure; float facing = structure.Facing; string header = ColorTokenService.Green("Current Direction: ") + facing; SetPageHeader("RotatePage", header); }
private void LoadBaseDetailsPage() { var data = BaseService.GetPlayerTempData(GetPC()); PCBase pcBase = DataService.PCBase.GetByID(data.PCBaseID); Area dbArea = DataService.Area.GetByResref(pcBase.AreaResref); var owner = DataService.Player.GetByID(pcBase.PlayerID); bool canExtendLease = BasePermissionService.HasBasePermission(GetPC(), pcBase.ID, BasePermission.CanExtendLease); bool canCancelLease = BasePermissionService.HasBasePermission(GetPC(), pcBase.ID, BasePermission.CanCancelLease); int dailyUpkeep = dbArea.DailyUpkeep + (int)(dbArea.DailyUpkeep * (owner.LeaseRate * 0.01f)); string header = ColorTokenService.Green("Location: ") + dbArea.Name + " (" + pcBase.Sector + ")\n\n"; header += ColorTokenService.Green("Owned By: ") + owner.CharacterName + "\n"; header += ColorTokenService.Green("Purchased: ") + pcBase.DateInitialPurchase + "\n"; header += ColorTokenService.Green("Rent Due: ") + pcBase.DateRentDue + "\n"; header += ColorTokenService.Green("Daily Upkeep: ") + dailyUpkeep + " credits\n\n"; header += "Daily upkeep may be paid up to 30 days in advance.\n"; // Starships have slightly different setups. They only pay rent when in a public starport and // the cost is set by the starport. if (pcBase.PCBaseTypeID == (int)Enumeration.PCBaseType.Starship) { canCancelLease = false; if (SpaceService.IsLocationPublicStarport(pcBase.ShipLocation)) { var shipLocationGuid = new Guid(pcBase.ShipLocation); SpaceStarport starport = DataService.SpaceStarport.GetByID(shipLocationGuid); header = ColorTokenService.Green("Location: ") + starport.Name + " (" + starport.Planet + ")\n"; header += ColorTokenService.Green("Rent Due: ") + pcBase.DateRentDue + "\n"; header += ColorTokenService.Green("Daily Upkeep: ") + starport.Cost + " credits\n\n"; } else { header = "This ship has no lease currently. You only need to pay when in a starport."; canExtendLease = false; } } SetPageHeader("BaseDetailsPage", header); const int MaxAdvancePay = 30; DateTime newRentDate = pcBase.DateRentDue.AddDays(1); TimeSpan ts = newRentDate - DateTime.UtcNow; bool canPayRent = ts.TotalDays < MaxAdvancePay; SetResponseVisible("BaseDetailsPage", 1, canPayRent && canExtendLease); newRentDate = pcBase.DateRentDue.AddDays(7); ts = newRentDate - DateTime.UtcNow; canPayRent = ts.TotalDays < MaxAdvancePay; SetResponseVisible("BaseDetailsPage", 2, canPayRent && canExtendLease); SetResponseVisible("BaseDetailsPage", 3, canCancelLease); }
private void LoadChangePricePage() { var player = GetPC(); var model = MarketService.GetPlayerMarketData(player); string header = ColorTokenService.Green("Galactic Trade Network - Change Sell Price") + "\n\n"; header += ColorTokenService.Green("Current Price: ") + model.SellPrice; SetPageHeader("ChangePricePage", header); }
public override PlayerDialog SetUp(NWPlayer player) { PlayerDialog dialog = new PlayerDialog("MainPage"); DialogPage mainPage = new DialogPage( "If you die, you will return to the last cloning facility you registered at. Would you like to register to this cloning facility?", ColorTokenService.Green("Register") ); dialog.AddPage("MainPage", mainPage); return(dialog); }
public override PlayerDialog SetUp(NWPlayer player) { PlayerDialog dialog = new PlayerDialog("MainPage"); DialogPage mainPage = new DialogPage("<SET LATER>", ColorTokenService.Green("Refresh"), "Change Name", "Reset Name"); dialog.AddPage("MainPage", mainPage); return(dialog); }
private string GetMainPageHeader() { Player pcEntity = PlayerService.GetPlayerEntity(GetPC().GlobalID); int totalSP = SkillService.GetPCTotalSkillCount(GetPC()); int totalPerks = PerkService.GetPCTotalPerkCount(GetPC().GlobalID); return(ColorTokenService.Green("Total SP: ") + totalSP + " / " + SkillService.SkillCap + "\n" + ColorTokenService.Green("Available SP: ") + pcEntity.UnallocatedSP + "\n" + ColorTokenService.Green("Total Perks: ") + totalPerks + "\n"); }
private string BuildKeyItemHeader(int responseID) { DialogResponse response = GetResponseByID(GetCurrentPageName(), responseID); int keyItemID = (int)response.CustomData; KeyItem entity = KeyItemService.GetKeyItemByID(keyItemID); string header = ColorTokenService.Green("Key Item: ") + entity.Name + "\n\n"; header += ColorTokenService.Green("Description: ") + entity.Description + "\n"; return(header); }
private void BuildPlayerDetailsPage(NWPlayer player) { ClearPageResponses("PlayerDetailsPage"); var data = BaseService.GetPlayerTempData(GetPC()); var permission = DataService.SingleOrDefault <PCBasePermission>(x => x.PlayerID == player.GlobalID && x.PCBaseID == data.PCBaseID && !x.IsPublicPermission); // Intentionally excluded permissions: CanAdjustPermissions, CanCancelLease bool canPlaceEditStructures = permission?.CanPlaceEditStructures ?? false; bool canAccessStructureInventory = permission?.CanAccessStructureInventory ?? false; bool canManageBaseFuel = permission?.CanManageBaseFuel ?? false; bool canExtendLease = permission?.CanExtendLease ?? false; bool canEnterBuildings = permission?.CanEnterBuildings ?? false; bool canRetrieveStructures = permission?.CanRetrieveStructures ?? false; bool canRenameStructures = permission?.CanRenameStructures ?? false; bool canEditPrimaryResidence = permission?.CanEditPrimaryResidence ?? false; bool canRemovePrimaryResidence = permission?.CanRemovePrimaryResidence ?? false; bool canChangeStructureMode = permission?.CanChangeStructureMode ?? false; bool canDockShip = permission?.CanDockStarship ?? false; bool canAdjustPublicPermissions = permission?.CanAdjustPublicPermissions ?? false; string header = ColorTokenService.Green("Name: ") + player.Name + "\n\n"; header += ColorTokenService.Green("Permissions:\n\n"); header += "Can Place/Edit Structures: " + (canPlaceEditStructures ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Access Structure Inventory: " + (canAccessStructureInventory ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Manage Base Fuel: " + (canManageBaseFuel ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Extend Lease: " + (canExtendLease ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Enter Buildings: " + (canEnterBuildings ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Retrieve Structures: " + (canRetrieveStructures ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Rename Structures: " + (canRenameStructures ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Edit Primary Residence: " + (canEditPrimaryResidence ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Remove Primary Residence: " + (canRemovePrimaryResidence ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Change Structure Mode: " + (canChangeStructureMode ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Dock Starships: " + (canDockShip ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; header += "Can Adjust PUBLIC Permissions: " + (canAdjustPublicPermissions ? ColorTokenService.Green("YES") : ColorTokenService.Red("NO")) + "\n"; SetPageHeader("PlayerDetailsPage", header); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Place/Edit Structures", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Access Structure Inventory", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Manage Base Fuel", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Extend Lease", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Enter Buildings", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Retrieve Structures", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Rename Structures", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Edit Primary Residence", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Change Structure Mode", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Dock Starships", true, player); AddResponseToPage("PlayerDetailsPage", "Toggle: Can Adjust PUBLIC Permissions", true, player); }
// ReSharper disable once UnusedMember.Local public static void Main() { // Breaking the rules for the examine event because the result of the services is used in the following // service call. We still signal an event for this, but in general all of the logic should go into this method. using (new Profiler(nameof(mod_on_examine))) { NWPlayer examiner = (_.OBJECT_SELF); NWObject examinedObject = NWNXObject.StringToObject(NWNXEvents.GetEventData("EXAMINEE_OBJECT_ID")); if (ExaminationService.OnModuleExamine(examiner, examinedObject)) { MessageHub.Instance.Publish(new OnModuleExamine()); return; } string description; if (_.GetIsPC(examinedObject.Object) == true) { // https://github.com/zunath/SWLOR_NWN/issues/853 // safest probably to get the modified (non-original) description only for players // may want to always get the modified description for later flexibility? description = _.GetDescription(examinedObject.Object, false) + "\n\n"; } else { description = _.GetDescription(examinedObject.Object, true) + "\n\n"; } if (examinedObject.IsCreature) { var racialID = Convert.ToInt32(_.Get2DAString("racialtypes", "Name", (int)_.GetRacialType(examinedObject))); string racialtype = _.GetStringByStrRef(racialID); if (!description.Contains(ColorTokenService.Green("Racial Type: ") + racialtype)) { description += ColorTokenService.Green("Racial Type: ") + racialtype; } } description = ModService.OnModuleExamine(description, examiner, examinedObject); description = ItemService.OnModuleExamine(description, examinedObject); description = DurabilityService.OnModuleExamine(description, examinedObject); if (!string.IsNullOrWhiteSpace(description)) { _.SetDescription(examinedObject.Object, description, false); _.SetDescription(examinedObject.Object, description); } } MessageHub.Instance.Publish(new OnModuleExamine()); }
private void LoadSalvagePage() { var player = GetPC(); var model = CraftService.GetPlayerCraftingData(player); NWPlaceable tempStorage = _.GetObjectByTag("TEMP_ITEM_STORAGE"); var item = SerializationService.DeserializeItem(model.SerializedSalvageItem, tempStorage); var componentType = DataService.ComponentType.GetByID(model.SalvageComponentTypeID); string header = ColorTokenService.Green("Item: ") + item.Name + "\n\n"; header += "Reassembling this item will create the following " + ColorTokenService.Green(componentType.Name) + " component(s). Chance to create depends on your perks, skills, and harvesting bonus on items.\n\n"; // Always create one item with zero bonuses. header += componentType.Name + " (No Bonuses) [RL: 0] " + GetChanceColor(100) + "\n"; // Now check specific custom properties which are stored as local variables on the item. header += ProcessPropertyDetails(item.HarvestingBonus, componentType.Name, "Harvesting Bonus", 3); header += ProcessPropertyDetails(item.PilotingBonus, componentType.Name, "Piloting Bonus", 3); header += ProcessPropertyDetails(item.ScanningBonus, componentType.Name, "Scanning Bonus", 3); header += ProcessPropertyDetails(item.ScavengingBonus, componentType.Name, "Scavenging Bonus", 3); header += ProcessPropertyDetails(item.CooldownRecovery, componentType.Name, "Cooldown Recovery", 3); header += ProcessPropertyDetails(item.CraftBonusArmorsmith, componentType.Name, "Armorsmith", 3); header += ProcessPropertyDetails(item.CraftBonusWeaponsmith, componentType.Name, "Weaponsmith", 3); header += ProcessPropertyDetails(item.CraftBonusCooking, componentType.Name, "Cooking", 3); header += ProcessPropertyDetails(item.CraftBonusEngineering, componentType.Name, "Engineering", 3); header += ProcessPropertyDetails(item.CraftBonusFabrication, componentType.Name, "Fabrication", 3); header += ProcessPropertyDetails(item.HPBonus, componentType.Name, "HP", 5, 0.5f); header += ProcessPropertyDetails(item.FPBonus, componentType.Name, "FP", 5, 0.5f); header += ProcessPropertyDetails(item.EnmityRate, componentType.Name, "Enmity", 3); header += ProcessPropertyDetails(item.LuckBonus, componentType.Name, "Luck", 3); header += ProcessPropertyDetails(item.MeditateBonus, componentType.Name, "Meditate", 3); header += ProcessPropertyDetails(item.RestBonus, componentType.Name, "Rest", 3); header += ProcessPropertyDetails(item.MedicineBonus, componentType.Name, "Medicine", 3); header += ProcessPropertyDetails(item.HPRegenBonus, componentType.Name, "HP Regen", 3); header += ProcessPropertyDetails(item.FPRegenBonus, componentType.Name, "FP Regen", 3); header += ProcessPropertyDetails(item.BaseAttackBonus, componentType.Name, "Base Attack Bonus", 3, 6f); header += ProcessPropertyDetails(item.StructureBonus, componentType.Name, "Structure Bonus", 3); header += ProcessPropertyDetails(item.SneakAttackBonus, componentType.Name, "Sneak Attack", 3); header += ProcessPropertyDetails(item.DamageBonus, componentType.Name, "Damage", 3); header += ProcessPropertyDetails(item.StrengthBonus, componentType.Name, "STR", 3); header += ProcessPropertyDetails(item.DexterityBonus, componentType.Name, "DEX", 3); header += ProcessPropertyDetails(item.ConstitutionBonus, componentType.Name, "CON", 3); header += ProcessPropertyDetails(item.WisdomBonus, componentType.Name, "WIS", 3); header += ProcessPropertyDetails(item.IntelligenceBonus, componentType.Name, "INT", 3); header += ProcessPropertyDetails(item.CharismaBonus, componentType.Name, "CHA", 3); header += ProcessPropertyDetails(item.DurationBonus, componentType.Name, "Duration", 3); SetPageHeader("SalvagePage", header); // Remove the temporary copy from the game world. item.Destroy(); }