Example #1
0
        protected override string GetStartBattleString()
        {
            string msg = string.Join(", ", PlayerMessages.Select(v => $"<@{v.Value.Id}>"));

            SummonsMessage.ModifyAsync(m => m.Content = matchup.FlavourText);
            return($"{msg} get into Position!");
        }
Example #2
0
        public override bool UseItem(Player player)
        {
            var            mymod = (LicensesMod)this.mod;
            int            savings;
            int            oldStack    = this.item.stack;
            ItemDefinition randItemDef = this.AttemptToLicenseRandomItem(player, out savings);

            if (randItemDef == null)
            {
                Main.NewText("No items of the given tier left to license.", Color.Red);
                return(false);
            }

            int   targetRarity = WildcardLicenseItem.ComputeTargetRarityOfLicenseStackSize(oldStack);
            Color color        = ItemRarityAttributeHelpers.RarityColor[targetRarity];

            string randItemName = ItemAttributeHelpers.GetQualifiedName(randItemDef.Type);
            string msg          = randItemName + " licensed";

            if (savings > 0)
            {
                msg += " - " + savings + " discounted";
            }

            PlayerMessages.AddPlayerLabel(player, msg, color, 2 * 60, true);
            Main.NewText(msg, color);

            if (LicensesMod.Config.DebugModeInfo)
            {
                LogHelpers.Alert(randItemName + " unlocked");
            }

            return(true);
        }
Example #3
0
        ////////////////

        public bool ApplyExercise(Player player)
        {
            var mymod = StaminaMod.Instance;

            if (this.MaxStamina >= mymod.Config.MaxStaminaAmount)
            {
                return(false);
            }

            var myplayer = player.GetModPlayer <StaminaPlayer>();

            this.AddMaxStamina(player, mymod.Config.ExerciseGrowthAmount);

            if (myplayer.IsUsingSupplements)
            {
                this.AddMaxStamina(player, mymod.Config.ExerciseSupplementAddedGrowthAmount);
            }

            if (this.MaxStamina > mymod.Config.MaxStaminaAmount)
            {
                this.AddMaxStamina(player, mymod.Config.MaxStaminaAmount - this.MaxStamina);
            }

            string msg = "+" + mymod.Config.ExerciseGrowthAmount + " Stamina";

            PlayerMessages.AddPlayerLabel(player, msg, Color.Chartreuse, 60 * 3, true);

            Main.PlaySound(SoundID.Item47.WithVolume(0.5f));

            return(true);
        }
Example #4
0
        protected override string GetStartBattleString()
        {
            string msg = PlayerMessages
                         .Aggregate("", (s, v) => s += $"<@{v.Value.avatar.ID}>, ");

            return($"{matchup.FlavourText}\n{msg} get into Position!");
        }
        protected override string GetStartBattleString()
        {
            string msg = PlayerMessages
                         .Aggregate("", (s, v) => s += $"<@{v.Value.avatar.ID}>, ");

            SummonsMessage.ModifyAsync(m => m.Content = matchup.FlavourText);
            return($"{msg} get into Position!");
        }
Example #6
0
 public void BuildMessage(float TimeDelay, GameObject SenderObj, GameObject RecieverObj, PlayerMessages MessageToSend, Vector3 ExtraVectorInfo)
 {
     Sender       = SenderObj;
     Reciever     = RecieverObj;
     Msg          = MessageToSend;
     DisptachTime = TimeDelay;
     ExtraInfo    = ExtraVectorInfo;
 }
Example #7
0
 public static MsgPacket GenerateMsgPacket(this IPlayerEntity player, PlayerMessages message, MsgPacketType type)
 {
     return(new MsgPacket
     {
         Type = type,
         Message = player.GetLanguage(message)
     });
 }
Example #8
0
        void INotificationService.EnterRoom(Player player, PlayerMessages messages)
        {
            Clients[player.RoomReference.Id].receive(new PlayerPacket(messages));

            foreach (var clientId in player.ClientIds)
            {
                // Add to the new room
                Groups.Add(clientId, player.RoomReference.Id).Wait();
            }
        }
Example #9
0
        void INotificationService.EnterRoom(Player player, PlayerMessages messages)
        {
            Clients[player.RoomReference.Id].receive(new PlayerPacket(messages));

            foreach (var clientId in player.ClientIds)
            {
                // Add to the new room
                Groups.Add(clientId, player.RoomReference.Id).Wait();
            }
        }
Example #10
0
        void INotificationService.LeaveRoom(Player player, Reference <Room> room, PlayerMessages messages)
        {
            foreach (var clientId in player.ClientIds)
            {
                // Leave the old room
                Groups.Remove(clientId, room.Id).Wait();
            }

            Clients[room.Id].receive(new PlayerPacket(messages));
        }
Example #11
0
        void INotificationService.ToPlayer(Player player, PlayerMessages messages)
        {
            var packet = new PlayerPacket(messages);

            // Transmit to all user's connected clients
            foreach (var clientId in player.ClientIds)
            {
                Clients[clientId].receive(packet);
            }
        }
Example #12
0
        public string GetLanguage(PlayerMessages key, LanguageKey type)
        {
            string value = "";

            if (GetSetByLanguageKey(type)?.TryGetValue(key, out value) == false)
            {
                value = type + "_" + key;
            }

            return(value);
        }
Example #13
0
        public float AddRewardForPlayer(Player player, bool isGrind, bool isExpired, float reward)
        {
            if (isExpired)
            {
                return(0f);
            }

            var   mymod       = RewardsMod.Instance;
            float finalReward = reward;
            float oldPP       = this.ProgressPoints;

            if (isGrind)
            {
                finalReward *= mymod.PointsConfig.GrindKillMultiplier;
            }

            if (Main.netMode != 2 && mymod.SettingsConfig.ShowPointsPopups)
            {
                Color color = isGrind ? Color.DarkGray : Color.GreenYellow;

                if (Math.Abs(finalReward) >= 0.01f)
                {
                    string msg = "+" + Math.Round(finalReward, 2) + " PP";
                    PlayerMessages.AddPlayerLabel(player, msg, color, 60 * 3, true, false);
                }
                else if (Math.Abs(finalReward) > 0)
                {
                    PlayerMessages.AddPlayerLabel(player, "+PP", color, 60, true, false);
                }
            }

            this.ProgressPoints += finalReward;

            foreach (var hook in mymod.OnPointsGainedHooks)
            {
                hook(player, finalReward);
            }

            if (mymod.SettingsConfig.DebugModeKillInfo)
            {
                LogHelpers.Log("  AddRewardForPlayer - Player: " + player.name + " (" + player.whoAmI + ")"
                               + ", reward: " + finalReward + ((finalReward != reward) ? (" (was " + reward + ")") : "")
                               + ", isGrind:" + isGrind + ", isExpired:" + isExpired
                               + ", PP: " + this.ProgressPoints + " (was " + oldPP + ")"
                               );
            }
            if (mymod.SettingsConfig.DebugModePPInfo && finalReward != 0)
            {
                LogHelpers.Alert("PP added: " + finalReward + " (now " + this.ProgressPoints
                                 + " for " + (player?.name ?? "world") + ")");
            }

            return(finalReward);
        }
Example #14
0
        void INotificationService.ToPlayers(IEnumerable <Player> players, PlayerMessages messages)
        {
            var packet = new PlayerPacket(messages);

            foreach (var player in players)
            {
                foreach (var clientId in player.ClientIds)
                {
                    Clients[clientId].receive(packet);
                }
            }
        }
Example #15
0
        public override void Load()
        {
            HamstarHelpersMod.Instance = this;

            this.LoadConfigs();

            if (!this.HasUnhandledExceptionLogger && this.Config.DebugModeUnhandledExceptionLogging)
            {
                this.HasUnhandledExceptionLogger            = true;
                AppDomain.CurrentDomain.UnhandledException += HamstarHelpersMod.UnhandledLogger;
            }

            this.LoadHelpers = new TmlHelpers.LoadHelpers();
            this.Promises    = new Promises();

            this.Timers                    = new Timers();
            this.LogHelpers                = new DebugHelpers.LogHelpers();
            this.ModMetaDataManager        = new TmlHelpers.ModMetaDataManager();
            this.BuffHelpers               = new BuffHelpers.BuffHelpers();
            this.NetHelpers                = new NetHelpers.NetHelpers();
            this.ItemIdentityHelpers       = new ItemHelpers.ItemIdentityHelpers();
            this.NPCIdentityHelpers        = new NPCHelpers.NPCIdentityHelpers();
            this.ProjectileIdentityHelpers = new ProjectileHelpers.ProjectileIdentityHelpers();
            this.BuffIdentityHelpers       = new BuffHelpers.BuffIdentityHelpers();
            this.NPCBannerHelpers          = new NPCHelpers.NPCBannerHelpers();
            this.RecipeHelpers             = new RecipeHelpers.RecipeHelpers();
            this.TmlPlayerHelpers          = new TmlHelpers.TmlPlayerHelpers();
            this.WorldHelpers              = new WorldHelpers.WorldHelpers();
            this.ControlPanel              = new UIControlPanel();
            this.ModLockHelpers            = new TmlHelpers.ModHelpers.ModLockHelpers();
            this.EntityGroups              = new EntityGroups();
            this.PlayerMessages            = new PlayerMessages();
            this.Inbox           = new InboxControl();
            this.ModVersionGet   = new ModVersionGet();
            this.ServerBrowser   = new ServerBrowserReporter();
            this.MenuItemMngr    = new MenuItemManager();
            this.MenuUIMngr      = new MenuUIManager();
            this.OldMenuItemMngr = new Utilities.Menu.OldMenuItemManager();
            this.MusicHelpers    = new MusicHelpers();

#pragma warning disable 612, 618
            TmlHelpers.AltNPCInfo.DataInitialize();
            TmlHelpers.AltProjectileInfo.DataInitialize();
#pragma warning restore 612, 618

            if (!this.Config.DisableControlPanelHotkey)
            {
                this.ControlPanelHotkey = this.RegisterHotKey("Mod Helpers Control Panel", "O");
            }

            this.LoadModData();
        }
Example #16
0
        public void UnloadModules()
        {
            this.Loadables.OnModsUnload();

            this.Loadables                  = null;
            this.ReflectionHelpers          = null;
            this.PacketProtocolMngr         = null;
            this.ExceptionMngr              = null;
            this.Timers                     = null;
            this.LogHelpers                 = null;
            this.ModFeaturesHelpers         = null;
            this.BuffHelpers                = null;
            this.NetHelpers                 = null;
            this.NPCAttributeHelpers        = null;
            this.ProjectileAttributeHelpers = null;
            this.BuffIdentityHelpers        = null;
            this.NPCBannerHelpers           = null;
            this.RecipeFinderHelpers        = null;
            this.RecipeGroupHelpers         = null;
            this.PlayerHooks                = null;
            this.LoadHelpers                = null;
            this.GetModInfo                 = null;
            this.GetModTags                 = null;
            this.WorldStateHelpers          = null;
            this.ModLock                    = null;
            this.EntityGroups               = null;
            this.AnimatedColors             = null;
            this.AnimatedTextures           = null;
            this.PlayerMessages             = null;
            this.Inbox                 = null;
            this.ControlPanel          = null;
            this.MenuItemMngr          = null;
            this.MenuContextMngr       = null;
            this.MusicHelpers          = null;
            this.PlayerIdentityHelpers = null;
            this.LoadHooks             = null;
            this.CustomLoadHooks       = null;
            this.DataStore             = null;
            this.CustomHotkeys         = null;
            this.XnaHelpers            = null;
            this.Server                = null;
            //this.PlayerDataMngr = null;
            this.SupportInfo          = null;
            this.RecipeHack           = null;
            this.ModListHelpers       = null;
            this.ItemAttributeHelpers = null;
            this.WorldTimeHooks       = null;

            this.ControlPanelHotkey = null;
            this.DataDumpHotkey     = null;
        }
Example #17
0
        public override void Unload()
        {
            this.UnloadModData();

            this.Promises.FulfillModUnloadPromises();

            try {
                if (this.HasUnhandledExceptionLogger)
                {
                    this.HasUnhandledExceptionLogger            = false;
                    AppDomain.CurrentDomain.UnhandledException -= HamstarHelpersMod.UnhandledLogger;
                }
            } catch { }

            this.ExceptionMngr             = null;
            this.Timers                    = null;
            this.ConfigJson                = null;
            this.PacketProtocols           = null;
            this.LogHelpers                = null;
            this.ModMetaDataManager        = null;
            this.BuffHelpers               = null;
            this.NetHelpers                = null;
            this.ItemIdentityHelpers       = null;
            this.NPCIdentityHelpers        = null;
            this.ProjectileIdentityHelpers = null;
            this.BuffIdentityHelpers       = null;
            this.NPCBannerHelpers          = null;
            this.RecipeHelpers             = null;
            this.TmlPlayerHelpers          = null;
            this.LoadHelpers               = null;
            this.ModVersionGet             = null;
            this.WorldHelpers              = null;
            this.ModLockHelpers            = null;
            this.EntityGroups              = null;
            this.AnimatedColors            = null;
            this.PlayerMessages            = null;
            this.Inbox = null;
            this.ControlPanelHotkey = null;
            this.ControlPanel       = null;
            this.ServerBrowser      = null;
            this.MenuItemMngr       = null;
            this.MenuUIMngr         = null;
            this.OldMenuItemMngr    = null;
            this.MusicHelpers       = null;
            this.Promises           = null;

            HamstarHelpersMod.Instance = null;
        }
        public void UnloadOuter()
        {
            this.ReflectionHelpers         = null;
            this.PacketProtocolMngr        = null;
            this.ExceptionMngr             = null;
            this.Timers                    = null;
            this.ConfigJson                = null;
            this.LogHelpers                = null;
            this.ModFeaturesHelpers        = null;
            this.BuffHelpers               = null;
            this.NetHelpers                = null;
            this.ItemIdentityHelpers       = null;
            this.NPCIdentityHelpers        = null;
            this.ProjectileIdentityHelpers = null;
            this.BuffIdentityHelpers       = null;
            this.NPCBannerHelpers          = null;
            this.RecipeIdentityHelpers     = null;
            this.RecipeGroupHelpers        = null;
            this.PlayerHooks               = null;
            this.LoadHelpers               = null;
            this.GetModInfo                = null;
            this.GetModTags                = null;
            this.WorldStateHelpers         = null;
            this.ModLock                   = null;
            this.EntityGroups              = null;
            this.AnimatedColors            = null;
            this.PlayerMessages            = null;
            this.Inbox                 = null;
            this.ControlPanel          = null;
            this.MenuItemMngr          = null;
            this.MenuContextMngr       = null;
            this.MusicHelpers          = null;
            this.PlayerIdentityHelpers = null;
            this.CustomEntMngr         = null;
            this.Promises              = null;
            this.DataStore             = null;
            this.CustomHotkeys         = null;
            this.XnaHelpers            = null;
            this.ServerInfo            = null;
            //this.PlayerDataMngr = null;
            this.SupportInfo    = null;
            this.RecipeHack     = null;
            this.ModListHelpers = null;

            this.ControlPanelHotkey = null;
            this.DataDumpHotkey     = null;
        }
Example #19
0
        private void LoadModules()
        {
            this.Loadables.OnModsLoad();

            this.ReflectionHelpers = new ReflectionHelpers();
            this.DataStore         = new DataStore();
            this.LoadHooks         = new LoadHooks();
            this.CustomLoadHooks   = new CustomLoadHooks();
            this.LoadHelpers       = new LoadHelpers();

            this.Timers             = new Timers();
            this.LogHelpers         = new LogHelpers();
            this.ModFeaturesHelpers = new ModFeaturesHelpers();
            this.PacketProtocolMngr = new PacketProtocolManager();

            this.BuffHelpers                = new BuffHelpers();
            this.NetHelpers                 = new NetPlayHelpers();
            this.NPCAttributeHelpers        = new NPCAttributeHelpers();
            this.ProjectileAttributeHelpers = new ProjectileAttributeHelpers();
            this.BuffIdentityHelpers        = new BuffAttributesHelpers();
            this.NPCBannerHelpers           = new NPCBannerHelpers();
            this.RecipeFinderHelpers        = new RecipeFinderHelpers();
            this.RecipeGroupHelpers         = new RecipeGroupHelpers();
            this.PlayerHooks                = new ExtendedPlayerHooks();
            this.WorldTimeHooks             = new WorldTimeHooks();
            this.WorldStateHelpers          = new WorldStateHelpers();
            this.ControlPanel               = new UIControlPanel();
            this.ModLock               = new ModLockService();
            this.EntityGroups          = new EntityGroups();
            this.PlayerMessages        = new PlayerMessages();
            this.Inbox                 = new InboxControl();
            this.GetModInfo            = new GetModInfo();
            this.GetModTags            = new GetModTags();
            this.MenuItemMngr          = new MenuItemManager();
            this.MenuContextMngr       = new MenuContextServiceManager();
            this.MusicHelpers          = new MusicHelpers();
            this.PlayerIdentityHelpers = new PlayerIdentityHelpers();
            this.CustomHotkeys         = new CustomHotkeys();
            this.XnaHelpers            = new XNAHelpers();
            this.Server                = new Server();
            //this.PlayerDataMngr = new PlayerDataManager();
            this.SupportInfo          = new SupportInfoDisplay();
            this.RecipeHack           = new RecipeHack();
            this.ModListHelpers       = new ModListHelpers();
            this.ItemAttributeHelpers = new ItemAttributeHelpers();
        }
 /// <summary>
 /// Gets a function that gets the floating text message for any given player.
 /// </summary>
 /// <param name="allies">The message for the teammates of the player that triggered the floating text.</param>
 /// <param name="neutrals">The message for neutral (not-involved) teams.</param>
 /// <param name="enemies">The message for enemies of the team that triggered the floating text.</param>
 /// <param name="playerTrigger">The team of the player that triggered the floating text.</param>
 /// <param name="enemyTeam">The team that was specifically targeted by the player, or "null" if all enemies were targeted.</param>
 /// <returns>A function for use in "CreateFloatingTextsForPlayers" that gets the correct message depending on the player it is sent to.</returns>
 public Func <StateMachine, string> ThreeMessages(PlayerMessages messages, Color playerTrigger, Color?enemyTeam)
 {
     return((st) =>
     {
         if (st.ActorData.Team == playerTrigger)
         {
             return messages.Allies;
         }
         else if (!enemyTeam.HasValue || (enemyTeam.HasValue && st.ActorData.Team == enemyTeam.Value))
         {
             return messages.Enemies;
         }
         else
         {
             return messages.Neutrals;
         }
     });
 }
Example #21
0
    public void DispatchMessage(float Delay, GameObject Sender, GameObject Reciever, PlayerMessages MessageToSend, Vector3 ExtraInfo = new Vector3())
    {
        if (Reciever == null)
        {
            Debug.Log("No Reciever Set For Sending Message");
            return;
        }

        Message Msg = new Message();

        Msg.BuildMessage(Time.time + Delay, Sender, Reciever, MessageToSend, ExtraInfo);

        //If no delay send message straight away
        if (Delay <= 0)
        {
            Discharge(Reciever, Msg);
        }
        else
        {
            DelayedMessages.Add(Msg);
            DelayedMessages.Sort(SortByDelay);
        }
    }
Example #22
0
        void INotificationService.LeaveRoom(Player player, Reference<Room> room, PlayerMessages messages)
        {
            foreach (var clientId in player.ClientIds)
            {
                // Leave the old room
                Groups.Remove(clientId, room.Id).Wait();
            }

            Clients[room.Id].receive(new PlayerPacket(messages));
        }
Example #23
0
 public static Task SendMessageAsync(this IPlayerEntity player, PlayerMessages message, MsgPacketType type)
 {
     return(player.SendPacketAsync(player.GenerateMsgPacket(message, type)));
 }
Example #24
0
 void INotificationService.ToRoom(Room room, PlayerMessages messages)
 {
     Clients[room.Id].receive(new PlayerPacket(messages));
 }
Example #25
0
        void INotificationService.ToPlayers(IEnumerable<Player> players, PlayerMessages messages)
        {
            var packet = new PlayerPacket(messages);

            foreach (var player in players)
            {
                foreach (var clientId in player.ClientIds)
                    Clients[clientId].receive(packet);
            }
        }
        public override bool Equals(object obj)
        {
            PlayerMessages oth = obj as PlayerMessages;

            return(oth != null && oth.Trigger == Trigger && oth.Allies == Allies && oth.Neutrals == Neutrals && oth.Enemies == Enemies);
        }
Example #27
0
        public static Task SendChatMessageAsync(this IPlayerEntity player, PlayerMessages key, SayColorType color)
        {
            string msg = player.GetLanguage(key);

            return(player.SendPacketAsync(player.GenerateSayPacket(msg, color)));
        }
Example #28
0
 public static Task SendModalAsync(this IPlayerEntity player, PlayerMessages message, ModalPacketType type)
 {
     return(player.SendModalAsync(player.GetLanguage(message), type));
 }
Example #29
0
 void INotificationService.ToRoom(Room room, PlayerMessages messages)
 {
     Clients[room.Id].receive(new PlayerPacket(messages));
 }
Example #30
0
        public override void Execute(CommandContext context, CallerContext callerContext, Player callingPlayer, string[] args)
        {
            var room    = context.World.GetRoom(callingPlayer.RoomReference);
            var players = context.World.GetOnlinePlayers(room).Where(player => player.Name != callingPlayer.Name).ToList();

            if (args.IsNullOrEmpty()) // Look room
            {
                var look = new PlayerMessages();

                look.Messages.Add(new PlayerMessage(room.Name, MessageType.Title));

                if (!callingPlayer.BriefDescriptions)
                {
                    look.Messages.Add(new PlayerMessage(String.Format("   {0}", room.Description)));
                }

                if (room.Items.Any())
                {
                    look.Messages.Add(
                        new PlayerMessage(String.Format("There's {0} laying on the ground.", room.Items.ToDisplay())));
                }

                if (players.Any())
                {
                    look.Messages.Add(new PlayerMessage(players.ToDisplay(), MessageType.Important));
                }

                context.NotificationService.ToPlayer(callingPlayer, look);
            }
            else // Look at item or player
            {
                var lookFor = String.Join(" ", args).Trim();

                if (callingPlayer.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase)) // This player
                {
                    context.NotificationService.ToPlayer(callingPlayer, new PlayerMessages(callingPlayer.Description));
                }
                else if (players.Count(x => x.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase)) > 0) // Other player
                {
                    var target = players.First(x => x.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase));

                    context.NotificationService.ToPlayer(callingPlayer, new PlayerMessages(target.Description));

                    context.NotificationService.ToPlayer(target, new PlayerMessages(String.Format("{0} is looking you over.", callingPlayer.Name)));

                    context.NotificationService.ToPlayers(players.Where(x => x.Name != target.Name),
                                                          new PlayerMessages(String.Format("{0} is taking a good look at {1}.",
                                                                                           callingPlayer.Name, target.Name)));
                }
                else if (callingPlayer.Items.Count(x => x.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase)) > 0) // Item in inventory
                {
                    context.NotificationService.ToPlayer(callingPlayer, new PlayerMessages(
                                                             callingPlayer.Items.First(
                                                                 x =>
                                                                 x.Name.StartsWith(lookFor,
                                                                                   StringComparison.
                                                                                   OrdinalIgnoreCase))
                                                             .Description));
                }
                else if (room.Items.Count(x => x.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase)) > 0) // Item in room
                {
                    context.NotificationService.ToPlayer(callingPlayer, new PlayerMessages(
                                                             room.Items.First(
                                                                 x =>
                                                                 x.Name.StartsWith(lookFor,
                                                                                   StringComparison.
                                                                                   OrdinalIgnoreCase))
                                                             .Description));
                }
                else
                {
                    context.NotificationService.ToPlayer(callingPlayer,
                                                         new PlayerMessages(
                                                             "...You don't see anything like that around here"));
                }
            }
        }
Example #31
0
 void INotificationService.ToAll(PlayerMessages messages)
 {
     Clients.receive(new PlayerPacket(messages));
 }
Example #32
0
 void INotificationService.ToAll(PlayerMessages messages)
 {
     Clients.receive(new PlayerPacket(messages));
 }
Example #33
0
        void INotificationService.ToPlayer(Player player, PlayerMessages messages)
        {
            var packet = new PlayerPacket(messages);

            // Transmit to all user's connected clients
            foreach (var clientId in player.ClientIds)
                Clients[clientId].receive(packet);
        }
Example #34
0
 public PlayerPacket(PlayerMessages messages)
 {
     Display = messages;
 }
 public static string GetLanguageFormat(this IPlayerEntity player, PlayerMessages key, params object[] objs) => string.Format(GameLanguageService.GetLanguage(key, player.Session.Language), objs);
 public static string GetLanguage(this IPlayerEntity player, PlayerMessages key) => GameLanguageService.GetLanguage(key, player.Session.Language);
Example #37
0
        public override void Execute(CommandContext context, CallerContext callerContext, Player callingPlayer, string[] args)
        {
            var room = context.World.GetRoom(callingPlayer.RoomReference);
            var players = context.World.GetOnlinePlayers(room).Where(player => player.Name != callingPlayer.Name).ToList();

            if (args.IsNullOrEmpty()) // Look room
            {
                var look = new PlayerMessages();

                look.Messages.Add(new PlayerMessage(room.Name, MessageType.Title));

                if (!callingPlayer.BriefDescriptions)
                    look.Messages.Add(new PlayerMessage(String.Format("   {0}", room.Description)));

                if (room.Items.Any())
                    look.Messages.Add(
                        new PlayerMessage(String.Format("There's {0} laying on the ground.", room.Items.ToDisplay())));

                if (players.Any())
                    look.Messages.Add(new PlayerMessage(players.ToDisplay(), MessageType.Important));

                context.NotificationService.ToPlayer(callingPlayer, look);
            }
            else // Look at item or player
            {
                var lookFor = String.Join(" ", args).Trim();

                if (callingPlayer.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase)) // This player
                    context.NotificationService.ToPlayer(callingPlayer, new PlayerMessages(callingPlayer.Description));
                else if (players.Count(x => x.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase)) > 0) // Other player
                {
                    var target = players.First(x => x.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase));

                    context.NotificationService.ToPlayer(callingPlayer, new PlayerMessages(target.Description));

                    context.NotificationService.ToPlayer(target, new PlayerMessages(String.Format("{0} is looking you over.", callingPlayer.Name)));

                    context.NotificationService.ToPlayers(players.Where(x => x.Name != target.Name),
                                                          new PlayerMessages(String.Format("{0} is taking a good look at {1}.",
                                                                                           callingPlayer.Name,target.Name)));
                }
                else if (callingPlayer.Items.Count(x => x.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase)) > 0) // Item in inventory
                {
                    context.NotificationService.ToPlayer(callingPlayer, new PlayerMessages(
                                                                            callingPlayer.Items.First(
                                                                                x =>
                                                                                x.Name.StartsWith(lookFor,
                                                                                                  StringComparison.
                                                                                                      OrdinalIgnoreCase))
                                                                                .Description));
                }
                else if (room.Items.Count(x => x.Name.StartsWith(lookFor, StringComparison.OrdinalIgnoreCase)) > 0) // Item in room
                {
                    context.NotificationService.ToPlayer(callingPlayer, new PlayerMessages(
                                                                            room.Items.First(
                                                                                x =>
                                                                                x.Name.StartsWith(lookFor,
                                                                                                  StringComparison.
                                                                                                      OrdinalIgnoreCase))
                                                                                .Description));
                }
                else
                {
                    context.NotificationService.ToPlayer(callingPlayer,
                                                         new PlayerMessages(
                                                             "...You don't see anything like that around here"));
                }
            }
        }
Example #38
0
        public static Task SendChatMessageFormat(this IPlayerEntity player, PlayerMessages key, SayColorType color, params object[] objs)
        {
            string msg = player.GetLanguageFormat(key, objs);

            return(player.SendPacketAsync(player.GenerateSayPacket(msg, color)));
        }