public void ColorTokenService_NullText_ShouldThrowArgumentException() { ColorTokenService service = new ColorTokenService(); Assert.Throws(typeof(ArgumentException), () => { service.Black(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Blue(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Gray(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Green(null); }); Assert.Throws(typeof(ArgumentException), () => { service.LightPurple(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Orange(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Pink(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Purple(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Red(null); }); Assert.Throws(typeof(ArgumentException), () => { service.White(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Yellow(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Cyan(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Combat(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Dialog(null); }); Assert.Throws(typeof(ArgumentException), () => { service.DialogAction(null); }); Assert.Throws(typeof(ArgumentException), () => { service.DialogCheck(null); }); Assert.Throws(typeof(ArgumentException), () => { service.DialogHighlight(null); }); Assert.Throws(typeof(ArgumentException), () => { service.DialogReply(null); }); Assert.Throws(typeof(ArgumentException), () => { service.DM(null); }); Assert.Throws(typeof(ArgumentException), () => { service.GameEngine(null); }); Assert.Throws(typeof(ArgumentException), () => { service.SavingThrow(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Script(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Server(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Shout(null); }); Assert.Throws(typeof(ArgumentException), () => { service.SkillCheck(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Talk(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Tell(null); }); Assert.Throws(typeof(ArgumentException), () => { service.Whisper(null); }); }
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"; } } }); }
public void Main() { NWPlayer oPC = (_.GetLastDisturbed()); NWItem item = (_.GetInventoryDisturbItem()); NWPlaceable container = (NWGameObject.OBJECT_SELF); int disturbType = _.GetInventoryDisturbType(); var structureID = new Guid(container.GetLocalString("PC_BASE_STRUCTURE_ID")); var structure = DataService.PCBaseStructure.GetByID(structureID); var baseStructure = DataService.BaseStructure.GetByID(structure.BaseStructureID); int itemLimit = baseStructure.Storage + structure.StructureBonus; int itemCount = container.InventoryItems.Count(); string itemResref = item.Resref; if (disturbType == _.INVENTORY_DISTURB_TYPE_ADDED) { if (_.GetHasInventory(item) == _.TRUE) { item.SetLocalInt("RETURNING_ITEM", _.TRUE); ItemService.ReturnItem(oPC, item); oPC.SendMessage(ColorTokenService.Red("Containers cannot currently be stored inside banks.")); return; } if (itemCount > itemLimit) { ItemService.ReturnItem(oPC, item); oPC.SendMessage(ColorTokenService.Red("No more items can be placed inside.")); } else if (item.BaseItemType == _.BASE_ITEM_GOLD) { ItemService.ReturnItem(oPC, item); oPC.SendMessage(ColorTokenService.Red("Credits cannot be placed inside.")); } else { PCBaseStructureItem itemEntity = new PCBaseStructureItem { ItemName = item.Name, ItemResref = itemResref, ItemTag = item.Tag, PCBaseStructureID = structureID, ItemGlobalID = item.GlobalID.ToString(), ItemObject = SerializationService.Serialize(item) }; DataService.SubmitDataChange(itemEntity, DatabaseActionType.Insert); MessageHub.Instance.Publish(new OnStoreStructureItem(oPC, itemEntity)); } } else if (disturbType == _.INVENTORY_DISTURB_TYPE_REMOVED) { if (item.GetLocalInt("RETURNING_ITEM") == _.TRUE) { item.DeleteLocalInt("RETURNING_ITEM"); } else { var dbItem = DataService.PCBaseStructureItem.GetByItemGlobalID(item.GlobalID.ToString()); DataService.SubmitDataChange(dbItem, DatabaseActionType.Delete); MessageHub.Instance.Publish(new OnRemoveStructureItem(oPC, dbItem)); } } oPC.SendMessage(ColorTokenService.White("Item Limit: " + itemCount + " / ") + ColorTokenService.Red(itemLimit.ToString())); }
private string CreateSkillDetailsHeader(PCSkill pcSkill, int req) { Player player = DataService.Player.GetByID(pcSkill.PlayerID); Skill skill = SkillService.GetSkill(pcSkill.SkillID); string title; if (pcSkill.Rank <= 3) { title = "Untrained"; } else if (pcSkill.Rank <= 7) { title = "Neophyte"; } else if (pcSkill.Rank <= 13) { title = "Novice"; } else if (pcSkill.Rank <= 20) { title = "Apprentice"; } else if (pcSkill.Rank <= 35) { title = "Journeyman"; } else if (pcSkill.Rank <= 50) { title = "Expert"; } else if (pcSkill.Rank <= 65) { title = "Adept"; } else if (pcSkill.Rank <= 80) { title = "Master"; } else if (pcSkill.Rank <= 100) { title = "Grandmaster"; } else { title = "Unknown"; } title += " (" + pcSkill.Rank + ")"; string decayLock = ColorTokenService.Green("Decay Lock: ") + ColorTokenService.White("Unlocked"); if (pcSkill.IsLocked) { decayLock = ColorTokenService.Green("Decay Lock: ") + ColorTokenService.Red("Locked"); } // Skills which don't contribute to the cap cannot be locked (there's no reason for it.) // Display a message explaining this to the player instead. string noContributeMessage = string.Empty; if (!skill.ContributesToSkillCap) { decayLock = string.Empty; noContributeMessage = ColorTokenService.Green("This skill does not contribute to your cumulative skill cap.") + "\n\n"; } string rpXP = ColorTokenService.Green("Roleplay XP: ") + player.RoleplayXP + "\n"; Attribute primaryAttribute = DataService.Attribute.GetByID(skill.Primary); Attribute secondaryAttribute = DataService.Attribute.GetByID(skill.Secondary); Attribute tertiaryAttribute = DataService.Attribute.GetByID(skill.Tertiary); string primary = ColorTokenService.Green("Primary (+" + PlayerStatService.PrimaryIncrease + "): ") + primaryAttribute.Name + "\n"; string secondary = ColorTokenService.Green("Secondary (+" + PlayerStatService.SecondaryIncrease + "): ") + secondaryAttribute.Name + "\n"; string tertiary = ColorTokenService.Green("Tertiary (+" + PlayerStatService.TertiaryIncrease + "): ") + tertiaryAttribute.Name + "\n"; return (ColorTokenService.Green("Skill: ") + skill.Name + "\n" + ColorTokenService.Green("Rank: ") + title + "\n" + ColorTokenService.Green("Exp: ") + MenuService.BuildBar(pcSkill.XP, req, 100, ColorTokenService.TokenStart(255, 127, 0)) + "\n" + rpXP + primary + secondary + tertiary + noContributeMessage + decayLock + "\n\n" + ColorTokenService.Green("Description: ") + skill.Description + "\n"); }
public void Main() { NWPlaceable terminal = OBJECT_SELF; int bankID = terminal.GetLocalInt("BANK_ID"); if (bankID <= 0) { return; } NWPlayer player = GetLastDisturbed(); NWItem item = GetInventoryDisturbItem(); var disturbType = GetInventoryDisturbType(); int itemCount = terminal.InventoryItems.Count(); int itemLimit = terminal.GetLocalInt("BANK_LIMIT"); if (itemLimit <= 0) { itemLimit = 20; } if (disturbType == DisturbType.Added) { if (GetHasInventory(item) == true) { SetLocalBool(item, "RETURNING_ITEM", true); ItemService.ReturnItem(player, item); player.SendMessage(ColorTokenService.Red("Containers cannot currently be stored inside banks.")); return; } if (itemCount > itemLimit) { ItemService.ReturnItem(player, item); player.SendMessage(ColorTokenService.Red("No more items can be placed inside.")); } else { BankItem itemEntity = new BankItem { ItemName = item.Name, ItemTag = item.Tag, ItemResref = item.Resref, ItemID = item.GlobalID.ToString(), ItemObject = SerializationService.Serialize(item), BankID = bankID, PlayerID = player.GlobalID, DateStored = DateTime.UtcNow }; DataService.SubmitDataChange(itemEntity, DatabaseActionType.Insert); MessageHub.Instance.Publish(new OnStoreBankItem(player, itemEntity)); } } else if (disturbType == DisturbType.Removed) { if (GetLocalBool(item, "RETURNING_ITEM") == true) { item.DeleteLocalInt("RETURNING_ITEM"); } else { var record = DataService.BankItem.GetByItemID(item.GlobalID.ToString()); DataService.SubmitDataChange(record, DatabaseActionType.Delete); MessageHub.Instance.Publish(new OnRemoveBankItem(player, record)); } } player.SendMessage(ColorTokenService.White("Item Limit: " + (itemCount > itemLimit ? itemLimit : itemCount) + " / ") + ColorTokenService.Red("" + itemLimit)); }
/// <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)); } } }
public bool Run(params object[] args) { NWPlaceable terminal = Object.OBJECT_SELF; int bankID = terminal.GetLocalInt("BANK_ID"); if (bankID <= 0) { return(false); } NWPlayer player = _.GetLastDisturbed(); NWItem item = _.GetInventoryDisturbItem(); int disturbType = _.GetInventoryDisturbType(); int itemCount = terminal.InventoryItems.Count(); int itemLimit = terminal.GetLocalInt("BANK_LIMIT"); if (itemLimit <= 0) { itemLimit = 20; } if (disturbType == INVENTORY_DISTURB_TYPE_ADDED) { if (_.GetHasInventory(item) == TRUE) { item.SetLocalInt("RETURNING_ITEM", TRUE); ItemService.ReturnItem(player, item); player.SendMessage(ColorTokenService.Red("Containers cannot currently be stored inside banks.")); return(false); } if (itemCount > itemLimit) { ItemService.ReturnItem(player, item); player.SendMessage(ColorTokenService.Red("No more items can be placed inside.")); } else { BankItem itemEntity = new BankItem { ItemName = item.Name, ItemTag = item.Tag, ItemResref = item.Resref, ItemID = item.GlobalID.ToString(), ItemObject = SerializationService.Serialize(item), BankID = bankID, PlayerID = player.GlobalID, DateStored = DateTime.UtcNow }; DataService.SubmitDataChange(itemEntity, DatabaseActionType.Insert); } } else if (disturbType == INVENTORY_DISTURB_TYPE_REMOVED) { if (item.GetLocalInt("RETURNING_ITEM") == TRUE) { item.DeleteLocalInt("RETURNING_ITEM"); } else { var record = DataService.Single <BankItem>(x => x.ItemID == item.GlobalID.ToString()); DataService.SubmitDataChange(record, DatabaseActionType.Delete); } } player.SendMessage(ColorTokenService.White("Item Limit: " + (itemCount > itemLimit ? itemLimit : itemCount) + " / ") + ColorTokenService.Red("" + itemLimit)); return(true); }