Exemplo n.º 1
0
        public static void GossipChannel(string message, Player player)
        {
            var players = Cache.ReturnPlayers().Where(x => x.NewbieChannel.Equals(true));

            foreach (var pc in players)
            {
                HubContext.Instance.SendToClient("<span style='color:#7CEECE'>[Gossip] " + player.Name + ":</span> " + message, pc.HubGuid);
                Score.UpdateUIChannels(pc, "<span class='gossipChannel' style='color:#7CEECE'>[Gossip] " + player.Name + ":</span> " + message, "gossipChannelF");
            }
        }
Exemplo n.º 2
0
        public static void OocChannel(string message, Player player)
        {
            var players = Cache.ReturnPlayers().Where(x => x.NewbieChannel.Equals(true));

            foreach (var pc in players)
            {
                HubContext.Instance.SendToClient("<span style='color:#00AFF0'>[OOC] " + player.Name + ":</span> " + message, pc.HubGuid);
                Score.UpdateUIChannels(pc, "<span class='oocChannel' style='color:#00AFF0'>[OOC] " + player.Name + ":</span> " + message, "oocChannelF");
            }


            var discordToSay = "[OOC] " + player.Name + " " + message;

            var discordBot = new HomeController();

            discordBot.PostToDiscord(discordToSay);
        }
Exemplo n.º 3
0
        public static void SayTo(string message, Room room, Player player)
        {
            string playerName              = message;
            string actualMessage           = string.Empty;
            int    indexOfSpaceInUserInput = message.IndexOf(" ", StringComparison.Ordinal);

            if (indexOfSpaceInUserInput > 0)
            {
                playerName = message.Substring(0, indexOfSpaceInUserInput);

                if (indexOfSpaceInUserInput != -1)
                {
                    actualMessage = message.Substring(indexOfSpaceInUserInput, message.Length - indexOfSpaceInUserInput).TrimStart();
                    // message is everythign after the 1st space
                }
            }

            string playerId = player.HubGuid;

            Player recipientPlayer =
                room.players.FirstOrDefault(
                    x => x.Name.StartsWith(playerName, StringComparison.CurrentCultureIgnoreCase));

            if (recipientPlayer != null)
            {
                string recipientName = recipientPlayer.Name;
                HubContext.Instance.SendToClient("You say to " + recipientName + " \"" + actualMessage + "\"", playerId, null, false, false);
                HubContext.Instance.SendToClient(Helpers.ReturnName(player, recipientPlayer, string.Empty) + " says to you \"" + actualMessage + "\"", playerId, recipientName, true, true);

                Score.UpdateUIChannels(player, "You say to " + recipientName + " \"" + actualMessage + "\"", "roomChannelF");
                Score.UpdateUIChannels(recipientPlayer, Helpers.ReturnName(player, recipientPlayer, string.Empty) + " says to you \"" + actualMessage + "\"", "roomChannelF");
            }
            else
            {
                HubContext.Instance.SendToClient("No one here by that name.", playerId, null, false, false);
            }
        }
Exemplo n.º 4
0
        public static void Say(string message, Player player, Room room)
        {
            string playerId = player.HubGuid;

            HubContext.Instance.SendToClient($"<span class='sayColor'>You say, \"{message}\"</span>", playerId, null, false, false);

            Score.UpdateUIChannels(player, $"<span class='sayColor'>You say, \"{message}\"</span>", "roomChannelF");

            foreach (var character in room.players)
            {
                if (player != character)
                {
                    var roomMessage = $"<span class='sayColor'>{ Helpers.ReturnName(player, character, string.Empty)} says \"{message}\"</span>";

                    Score.UpdateUIChannels(character, $"<span class='sayColor'>{ Helpers.ReturnName(player, character, string.Empty)} says \"{message}\"</span>", "roomChannelF");

                    HubContext.Instance.SendToClient(roomMessage, character.HubGuid);
                }
            }


            //check npc response
            foreach (var mob in room.mobs)
            {
                var       response              = string.Empty;
                var       responseEmote         = string.Empty;
                var       responseGiveItemEmote = string.Empty;
                Item.Item responseGiveItem      = null;
                Skill     responseGiveSkill     = null;
                var       hasQuest              = false;
                var       questId = 0;
                var       GivePrerequisiteItem = false;

                if (mob.Dialogue != null)
                {
                    foreach (var dialogue in mob.Dialogue)
                    {
                        foreach (var keyword in dialogue.Keyword)
                        {
                            if (message.Contains(keyword))
                            {
                                response      = dialogue.Response;
                                responseEmote = dialogue.DoEmote;
                            }
                        }
                    }
                }



                if (response == string.Empty)
                {
                    if (mob.DialogueTree != null)
                    {
                        foreach (var tree in mob.DialogueTree)
                        {
                            if (message.Equals(tree.MatchPhrase))
                            {
                                responseGiveItem      = tree.GiveItem;
                                responseGiveItemEmote = tree.GiveItemEmote;
                                response          = tree.Message;
                                responseGiveSkill = tree.GiveSkill;
                                if (tree.GiveQuest != null)
                                {
                                    hasQuest = (bool)tree.GiveQuest;
                                }
                                if (tree.GivePrerequisiteItem != null)
                                {
                                    GivePrerequisiteItem = (bool)tree.GivePrerequisiteItem;
                                }
                                if (tree.QuestId != null)
                                {
                                    questId = (int)tree.QuestId;
                                }
                            }
                        }
                    }
                }

                if (response != String.Empty)
                {
                    Thread.Sleep(120); // hack, sometimes the responses calls before the questions??

                    HubContext.Instance.SendToClient("<span class='sayColor'>" + mob.Name + " says to you \"" + response.Replace("$playerName", player.Name) + "\"<span>", playerId);

                    Score.UpdateUIChannels(player, "<span class='sayColor'>" + mob.Name + " says to you \"" + response.Replace("$playerName", player.Name) + "\"<span>", "roomChannelF");



                    if (!string.IsNullOrEmpty(responseEmote))
                    {
                        HubContext.Instance.SendToClient(player.Name + " " + responseEmote, playerId);
                    }

                    if (!string.IsNullOrEmpty(responseGiveItemEmote))
                    {
                        HubContext.Instance.SendToClient(responseGiveItemEmote, playerId);
                    }

                    if (responseGiveItem != null)
                    {
                        Player.AddItem(player, responseGiveItem);
                        Score.UpdateUiInventory(player);
                    }

                    if (responseGiveSkill != null)
                    {
                        player.Skills.Add(responseGiveSkill);
                        HubContext.Instance.SendToClient("You have learned " + responseGiveSkill.Name, playerId);
                    }



                    //check branch to show responses from
                    var speak = mob.DialogueTree.FirstOrDefault(x => x.Message.Equals(response));


                    foreach (var respond in speak.PossibleResponse)
                    {
                        var textChoice =
                            "<a class='multipleChoice' href='javascript:void(0)' onclick='$.connection.mIMHub.server.recieveFromClient(\"say " +
                            respond.Response + "\",\"" + player.HubGuid + "\")'>[say, " + respond.Response +
                            "]</a>";
                        HubContext.Instance.AddNewMessageToPage(player.HubGuid, textChoice);
                    }


                    if (hasQuest)
                    {
                        //find quest
                        var quest = mob.Quest.FirstOrDefault(x => x.Id.Equals(questId));

                        var playerHasQuest = player.QuestLog.FirstOrDefault(x => quest != null && x.Name.Equals(quest.Name));

                        if (playerHasQuest == null)
                        {
                            //to player log
                            player.QuestLog.Add(quest);
                            Score.UpdateUiQlog(player);

                            HubContext.Instance.SendToClient("<span class='questColor'>Quest Added:<br />" + quest.Name + " </span> ", playerId);

                            if (GivePrerequisiteItem)
                            {
                                HubContext.Instance.SendToClient(quest.PrerequisiteItemEmote, playerId);

                                foreach (var qitem in quest.PrerequisiteItem)
                                {
                                    HubContext.Instance.SendToClient(mob.Name + " gives you " + Helpers.ReturnName(null, null, qitem.name), playerId);

                                    Player.AddItem(player, qitem);
                                }

                                Score.UpdateUiInventory(player);

                                foreach (var character in room.players)
                                {
                                    if (player != character)
                                    {
                                        var roomMessage = $"{ Helpers.ReturnName(mob, character, string.Empty)}  {quest.PrerequisiteItemEmote}";

                                        HubContext.Instance.SendToClient(roomMessage, character.HubGuid);
                                    }
                                }
                            }
                        }
                    }
                }


                else
                {
                    //generic responses?
                }

                if (mob.EventOnComunicate.Count > 0)
                {
                    var triggerEvent = mob.EventOnComunicate.FirstOrDefault(x => x.Value.Equals("yes"));

                    Event.ParseCommand(triggerEvent.Key, player, mob, room, "yes", "player");
                }
            }
        }