/// <summary> /// Executes this command /// </summary> public override void Execute() { List <string> sb = new List <string>(); IPlayer player = (IPlayer)Actor; ILexicalParagraph toActor = new LexicalParagraph("You exit this reality."); ILexicalParagraph toOrigin = new LexicalParagraph("$A$ exits this reality."); Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin } }; messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentZone, null); PlayerData playerDataWrapper = new PlayerData(); //Save the player out playerDataWrapper.WriteOnePlayer(player); player.CloseConnection(); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { IZone moveTo = (IZone)Subject; LexicalParagraph toActor = new LexicalParagraph() { Override = "You teleport." }; LexicalParagraph toOrigin = new LexicalParagraph() { Override = "$A$ disappears in a puff of smoke." }; LexicalParagraph toDest = new LexicalParagraph() { Override = "$A$ appears out of nowhere." }; Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin }, ToDestination = new List <ILexicalParagraph> { toDest } }; messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentZone, null); Actor.TryTeleport((IGlobalPosition)moveTo.CurrentLocation.Clone()); return(true); }
/// <summary> /// Executes this command /// </summary> public override void Execute() { List <string> sb = new List <string>(); //Just do a blank execution as the channel will handle doing the room updates if (Subject == null) { //sb.AddRange(OriginLocation.CurrentLocation.RenderToVisible(Actor)); ///Need to do like HMR with a simple "update UI" pipeline TODO Message blankMessenger = new Message(new LexicalParagraph("You observe your surroundings.")); blankMessenger.ExecuteMessaging(Actor, (IEntity)Subject, null, OriginLocation.CurrentRoom, null); return; } ILookable lookTarget = (ILookable)Subject; ILexicalParagraph toOrigin = new LexicalParagraph("$A$ looks at $T$."); ILexicalParagraph toSubject = new LexicalParagraph("$A$ looks at YOU."); Message messagingObject = new Message(lookTarget.RenderToVisible(Actor)) { ToOrigin = new List <ILexicalParagraph> { toOrigin }, ToSubject = new List <ILexicalParagraph> { toSubject } }; messagingObject.ExecuteMessaging(Actor, (IEntity)Subject, null, OriginLocation.CurrentRoom, null); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { List<string> sb = new List<string>(); IMobile chr = (IMobile)Actor; List<ILexicalParagraph> toActor = new List<ILexicalParagraph> { new LexicalParagraph("You look through your belongings.") }; foreach (IInanimate thing in chr.Inventory.EntitiesContained()) { toActor.Add(thing.RenderAsContents(chr, new[] { MessagingType.Visible })); } ILexicalParagraph toOrigin = new LexicalParagraph("$A$ sifts through $G$ belongings."); Message messagingObject = new Message(toActor) { ToOrigin = new List<ILexicalParagraph> { toOrigin } }; messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentRoom, null); return true; }
public virtual void RenderError(string error) { ILexicalParagraph toActor = new LexicalParagraph(error); Message messagingObject = new Message(toActor); messagingObject.ExecuteMessaging(Actor, null, null, null, null); }
public override void Execute() { IEnumerable <IPlayer> whoList = LiveCache.GetAll <IPlayer>().Where(player => player.Descriptor != null); ILexicalParagraph toActor = new LexicalParagraph(string.Join(",", whoList.Select(who => who.GetDescribableName(Actor)))); Message messagingObject = new Message(toActor); messagingObject.ExecuteMessaging(Actor, null, null, null, null); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { INonPlayerCharacter trainer = (INonPlayerCharacter)Subject; if (trainer == null || !trainer.DoITeachThings()) { RenderError("There is no trainer that teaches in that direction."); return(false); } //Do the list if (Target.GetType() == typeof(string)) { string listings = trainer.RenderInstructionList(Actor); Message listingMessage = new Message(new LexicalParagraph(listings)); listingMessage.ExecuteMessaging(Actor, null, null, null, null); } int price = -1; string errorMessage = "The trainer can not train that."; //We have an ability if (Target is IQuality proficency) { int profLevel = Actor.GetQuality(proficency.Name); if (profLevel >= 0) { errorMessage = trainer.Instruct((IMobile)Actor, proficency.Name, profLevel + 1, price); } } if (!string.IsNullOrWhiteSpace(errorMessage)) { RenderError(errorMessage); } ILexicalParagraph toArea = new LexicalParagraph("$A$ trains with $S$."); //TODO: language outputs Message messagingObject = new Message(new LexicalParagraph(string.Format("You learn from $S$ for {0}blz.", price))) { ToOrigin = new List <ILexicalParagraph> { toArea } }; messagingObject.ExecuteMessaging(Actor, trainer, null, OriginLocation.CurrentZone, null); return(true); }
internal override bool ExecutionBody() { //NPCs dont need to use this if (!Actor.GetType().GetInterfaces().Contains(typeof(IPlayer))) { return(false); } List <string> returnStrings = new List <string>(); StringBuilder sb = new StringBuilder(); Assembly commandsAssembly = Assembly.GetAssembly(typeof(CommandParameterAttribute)); IEnumerable <global::System.Type> loadedCommands = commandsAssembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(ICommand))); loadedCommands = loadedCommands.Where(comm => comm.GetCustomAttributes <CommandPermissionAttribute>().Any(att => att.MinimumRank <= Actor.Template <IPlayerTemplate>().GamePermissionsRank)); returnStrings.Add("Commands:"); List <string> commandNames = new List <string>(); foreach (global::System.Type command in loadedCommands) { foreach (CommandKeywordAttribute commandName in command.GetCustomAttributes <CommandKeywordAttribute>().Where(key => key.DisplayInHelpAndCommands)) { if (!commandNames.Contains(commandName.Keyword)) { commandNames.Add(commandName.Keyword); } } if (!commandNames.Contains(command.Name) && command.GetCustomAttribute <CommandSuppressName>() == null) { commandNames.Add(command.Name); } } sb.AppendLine(string.Join(", ", commandNames.Select(cmd => cmd.ToLower()).Distinct())); if (sb.Length > 0) { sb.Length -= 2; } returnStrings.Add(sb.ToString()); ILexicalParagraph toActor = new LexicalParagraph(string.Join(" ", returnStrings)); Message messagingObject = new Message(toActor); messagingObject.ExecuteMessaging(Actor, null, null, null, null); return(true); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { INonPlayerCharacter merchant = (INonPlayerCharacter)Subject; if (merchant == null || !merchant.DoISellThings()) { RenderError("There is no merchant that sells items in that direction."); return(false); } IInanimate thing = (IInanimate)Target; if (Target == null) { RenderError("The merchant does not sell that item."); return(false); } int price = merchant.PriceCheck(thing, true); if (price <= 0) { RenderError("The merchant will not sell that item."); return(false); } string errorMessage = merchant.MakeSale((IMobile)Actor, thing, price); if (!string.IsNullOrWhiteSpace(errorMessage)) { RenderError(errorMessage); } ILexicalParagraph toActor = new LexicalParagraph(string.Format("You purchase a $T$ from $S$ for {0}blz.", price)); ILexicalParagraph toArea = new LexicalParagraph("$A$ makes a purchase from $S$."); //TODO: language outputs Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toArea } }; messagingObject.ExecuteMessaging(Actor, merchant, thing, OriginLocation.CurrentZone, null); return(true); }
/// <summary> /// Executes this command /// </summary> public override void Execute() { ILexicalParagraph toActor = new LexicalParagraph(string.Format("You shout '{0}'", Subject)); ILexicalParagraph toArea = new LexicalParagraph(string.Format("$A$ shouts '{0}'", Subject)); //TODO: language outputs Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toArea } }; messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentZone, null); }
/// <summary> /// Executes this command /// </summary> public override void Execute() { INonPlayerCharacter merchant = (INonPlayerCharacter)Subject; if (merchant == null || !merchant.DoIBuyThings()) { RenderError("There is no merchant that buys items in that direction."); return; } IInanimate thing = (IInanimate)Target; if (Target == null) { RenderError("That item does not exist."); return; } int price = merchant.HaggleCheck(thing); if (price <= 0) { RenderError("The merchant will not buy that item."); return; } string errorMessage = merchant.MakePurchase((IMobile)Actor, thing, price); if (!string.IsNullOrWhiteSpace(errorMessage)) { RenderError(errorMessage); } ILexicalParagraph toActor = new LexicalParagraph(string.Format("You sell a $T$ to $S$ for {0}blz.", price)); ILexicalParagraph toArea = new LexicalParagraph("$A$ sells an item to $S$."); //TODO: language outputs Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toArea } }; messagingObject.ExecuteMessaging(Actor, merchant, thing, OriginLocation.CurrentZone, null); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { IInanimateTemplate newObject = (IInanimateTemplate)Subject; IMobile initator = (IMobile)Actor; List <string> sb = new List <string>(); IInanimate entityObject; //No target = spawn to inventory if (Target != null) { IGlobalPosition spawnTo = (IGlobalPosition)Target; entityObject = Activator.CreateInstance(newObject.EntityClass, new object[] { newObject }) as IInanimate; sb.Add(string.Format("{0} spawned to {1}.", entityObject.TemplateName, spawnTo.CurrentZone.Keywords[0])); } else { entityObject = Activator.CreateInstance(newObject.EntityClass, new object[] { newObject, initator.GetContainerAsLocation() }) as IInanimate; sb.Add(string.Format("{0} spawned to your inventory.", entityObject.TemplateName)); } //TODO: keywords is janky, location should have its own identifier name somehow for output purposes - DISPLAY short/long NAME ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); ILexicalParagraph toOrigin = new LexicalParagraph("$S$ appears in the $T$."); ILexicalParagraph toSubject = new LexicalParagraph("You are ALIVE"); ILexicalParagraph toTarget = new LexicalParagraph("You have been given $S$"); Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin }, ToSubject = new List <ILexicalParagraph> { toSubject }, ToTarget = new List <ILexicalParagraph> { toTarget } }; messagingObject.ExecuteMessaging(Actor, entityObject, OriginLocation.CurrentZone, OriginLocation.CurrentZone, null); return(true); }
/// <summary> /// Executes this command /// </summary> public override void Execute() { List <string> sb = new List <string>(); IPlayer player = (IPlayer)Actor; ILexicalParagraph toActor = new LexicalParagraph("You save your life."); Message messagingObject = new Message(toActor); messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentZone, null); PlayerData playerDataWrapper = new PlayerData(); //Save the player out playerDataWrapper.WriteOnePlayer(player); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { ILexicalParagraph toActor = new LexicalParagraph(string.Format("You say '{0}'", Subject)); ILexicalParagraph toArea = new LexicalParagraph(string.Format("$A$ says '{0}'", Subject)); //TODO: language outputs Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toArea } }; messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentZone, null); return(true); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { IEntity moveToPerson = (IEntity)Subject; if (moveToPerson.CurrentLocation == null) { throw new Exception("Invalid goto target."); } IGlobalPosition moveTo = (IGlobalPosition)moveToPerson.CurrentLocation.Clone(); LexicalParagraph toActor = new LexicalParagraph() { Override = "You teleport." }; LexicalParagraph toOrigin = new LexicalParagraph() { Override = "$A$ disappears in a puff of smoke." }; LexicalParagraph toDest = new LexicalParagraph() { Override = "$A$ appears out of nowhere." }; Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin }, ToDestination = new List <ILexicalParagraph> { toDest } }; messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentZone, null); Actor.TryTeleport(moveTo); return(true); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { IInanimate thing = (IInanimate)Subject; if (Target == null) { RenderError("There is no merchant in that direction."); return(false); } INonPlayerCharacter merchant = (INonPlayerCharacter)Target; if (merchant == null || (!merchant.DoIBuyThings())) { RenderError("There is no merchant that buys items in that direction."); return(false); } int price = merchant.HaggleCheck(thing); if (price <= 0) { RenderError("The merchant will not buy that item."); return(false); } ILexicalParagraph toActor = new LexicalParagraph(string.Format("The merchant appraises your {0} at {1}blz.", thing.GetDescribableName(Actor), price)); ILexicalParagraph toArea = new LexicalParagraph("$T$ looks very closely at $A$'s $S$."); //TODO: language outputs Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toArea } }; messagingObject.ExecuteMessaging(Actor, thing, merchant, OriginLocation.CurrentZone, null); return(true); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { INonPlayerCharacterTemplate newObject = (INonPlayerCharacterTemplate)Subject; List <string> sb = new List <string>(); IGlobalPosition spawnTo; //No target = spawn to room you're in if (Target != null) { spawnTo = (IGlobalPosition)Target; } else { spawnTo = OriginLocation; } INonPlayerCharacter entityObject = Activator.CreateInstance(newObject.EntityClass, new object[] { newObject, spawnTo }) as INonPlayerCharacter; //TODO: keywords is janky, location should have its own identifier name somehow for output purposes - DISPLAY short/long NAME sb.Add(string.Format("{0} spawned to {1}", entityObject.TemplateName, spawnTo.CurrentZone.Keywords[0])); ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); ILexicalParagraph toOrigin = new LexicalParagraph("$S$ appears suddenly."); ILexicalParagraph toSubject = new LexicalParagraph("You are ALIVE"); IMessage messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin }, ToSubject = new List <ILexicalParagraph> { toSubject } }; messagingObject.ExecuteMessaging(Actor, entityObject, spawnTo.CurrentZone, OriginLocation.CurrentZone, null); return(true); }
/// <summary> /// Executes this command /// </summary> public override void Execute() { IHelpful topic = (IHelpful)Subject; IList <string> sb = GetHelpHeader(topic); sb = sb.Concat(topic.RenderHelpBody()).ToList(); //If it's a command render the syntax help at the bottom if (topic.GetType().GetInterfaces().Contains(typeof(ICommand))) { ICommand subject = (ICommand)topic; sb.Add(string.Empty); sb = sb.Concat(subject.RenderSyntaxHelp()).ToList(); } ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); Message messagingObject = new Message(toActor); messagingObject.ExecuteMessaging(Actor, null, null, null, null); }
/// <summary> /// Executes this command /// </summary> public override void Execute() { IEntity thing = (IEntity)Subject; IContains actor = (IContains)Actor; IContains place = (IContains)OriginLocation; actor.MoveFrom(thing); place.MoveInto(thing); ILexicalParagraph toActor = new LexicalParagraph("You drop $S$."); ILexicalParagraph toOrigin = new LexicalParagraph("$A$ drops $S$."); IMessage messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin } }; messagingObject.ExecuteMessaging(Actor, thing, null, OriginLocation.CurrentRoom, null); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { List <string> sb = new List <string>(); IEntity thing = (IEntity)Subject; IContains actor = (IContains)Actor; IContains place; string toRoomMessage = "$A$ gets $S$."; if (Target != null) { place = (IContains)Target; toRoomMessage = "$A$ gets $S$ from $T$."; sb.Add("You get $S$ from $T$."); } else { place = (IContains)OriginLocation; sb.Add("You get $S$."); } place.MoveFrom(thing); actor.MoveInto(thing); ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); ILexicalParagraph toOrigin = new LexicalParagraph(toRoomMessage); Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin } }; messagingObject.ExecuteMessaging(Actor, thing, (IEntity)Target, OriginLocation.CurrentRoom, null); return(true); }
/// <summary> /// Executes this command /// </summary> public override void Execute() { List <string> sb = new List <string>(); if (!(Actor is IContains actorContainer)) { RenderError("You can't craft if you don't have an inventory."); return; } //We're after a list, not the actual command here if (Subject != null) { IEnumerable <IInanimateTemplate> itemsToMake = TemplateCache.GetAll <IInanimateTemplate>().Where(item => item.Produces > 0 && item.Components.Count() > 0); //Just a full list of all the things we can make then if (Target == null) { foreach (IInanimateTemplate item in itemsToMake) { IEnumerable <IInanimate> myItems = actorContainer.GetContents <IInanimate>(); if (item.Components.Any(component => myItems.Any(myItem => myItem.TemplateId == component.Item.Id))) { sb.Add(item.RenderBlueprints(Actor)); } } } else { //A list of everything that matches keyword string keyword = Target.ToString(); foreach (IInanimateTemplate item in itemsToMake.Where(itm => itm.Name.Contains(keyword))) { sb.Add(item.RenderBlueprints(Actor)); } } ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); Message messagingObject = new Message(toActor); messagingObject.ExecuteMessaging(Actor, null, null, null, null); return; } IInanimateTemplate itemToMake = (IInanimateTemplate)Target; string errorCrafting = itemToMake.Craft(Actor); if (!string.IsNullOrWhiteSpace(errorCrafting)) { RenderError(errorCrafting); } else { sb.Add(string.Format("You craft {0} {1}{2}.", itemToMake.Produces, itemToMake.Name, itemToMake.Produces > 1 ? "s" : "")); ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); ILexicalParagraph toOrigin = new LexicalParagraph(string.Format("$A$ crafts {0} {1}{2}.", itemToMake.Produces, itemToMake.Name, itemToMake.Produces > 1 ? "s" : "")); Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin } }; messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentZone, null); Actor.Save(); } return; }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { List <string> sb = new List <string>(); IPlayer playerActor = Actor.GetType().GetInterfaces().Contains(typeof(IPlayer)) ? Actor as IPlayer : null; if (playerActor != null && !playerActor.Template <IPlayerTemplate>().Account.Config.GossipSubscriber) { sb.Add(string.Format("You have disabled the Gossip network.", Subject)); } else { string directTarget = string.Empty; string directTargetGame = string.Empty; if (Subject != null) { string[] names = Subject.ToString().Split(new char[] { '@' }); if (names.Count() == 2) { directTarget = names[0]; directTargetGame = names[1]; } else if (names.Count() == 1) { directTarget = names[0]; } } GossipClient gossipClient = LiveCache.Get <GossipClient>("GossipWebClient"); string userName = Actor.TemplateName; if (playerActor != null) { userName = playerActor.AccountHandle; } if (!string.IsNullOrWhiteSpace(directTarget) && !string.IsNullOrWhiteSpace(directTargetGame)) { gossipClient.SendDirectMessage(userName, directTargetGame, directTarget, Target.ToString()); sb.Add(string.Format("You tell {1}@{2} '{0}'", Target, directTarget, directTargetGame)); } else { if (string.IsNullOrWhiteSpace(directTarget)) { gossipClient.SendMessage(userName, Target.ToString()); sb.Add(string.Format("You gossip '{0}'", Target)); } else { gossipClient.SendMessage(userName, Target.ToString(), directTarget); sb.Add(string.Format("You {1} '{0}'", Target, directTarget)); } } } ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); //TODO: language outputs Message messagingObject = new Message(toActor); messagingObject.ExecuteMessaging(Actor, null, null, null, null); return(true); }