Пример #1
0
        public static void Say(string message, Player player, Room room)
        {
            string playerId = player.HubGuid;

            HubContext.SendToClient("You say " + message, playerId, null, false, false);
            HubContext.broadcastToRoom(player.Name + " says " + message, room.players, playerId, true);
        }
Пример #2
0
        public void recieveFromClient(string message, String playerGuid)
        {
            Player PlayerData;
            Room   RoomData;

            _PlayerCache.TryGetValue(playerGuid, out PlayerData);



            var room = new Tuple <string, string, int>(PlayerData.Region, PlayerData.Area, PlayerData.AreaId);



            if (_AreaCache.TryGetValue(room, out RoomData))
            {
                _AreaCache.TryGetValue(room, out RoomData);
            }
            else
            {
                var RoomLoadData = new LoadRoom
                {
                    Region = PlayerData.Region,
                    Area   = PlayerData.Area,
                    id     = PlayerData.AreaId
                };
                RoomData = RoomLoadData.LoadRoomFile();
                _AreaCache.TryAdd(room, RoomData);
            }

            HubContext.SendToClient("<p style='color:#999'>" + message + "<p/>", PlayerData.HubGuid);


            Command.ParseCommand(message, PlayerData, RoomData);
        }
Пример #3
0
        public static void StartKick(Player attacker, Room room)
        {
            //TODO: Fix His to be gender specific
            //TODO: Fist? what if it's a paw?

            if (!_taskRunnning && attacker.Target != null)
            {
                // find target if not in fight
                HubContext.SendToClient("You pull your leg back", attacker.HubGuid);
                HubContext.SendToClient(Helpers.ReturnName(attacker, null) + " pulls " + Helpers.ReturnHisOrHers(attacker.Gender) + " leg back ready to kick at you.", attacker.HubGuid,
                                        attacker.Target.HubGuid, false, true);
                HubContext.broadcastToRoom(
                    Helpers.ReturnName(attacker, null) + " pulls " + Helpers.ReturnHisOrHers(attacker.Gender) + " leg back ready to kick at " + Helpers.ReturnName(attacker.Target, null),
                    room.players, attacker.HubGuid, true);

                Task.Run(() => DoKick(attacker, room));
            }
            else
            {
                if (attacker.Target == null)
                {
                    HubContext.SendToClient("You stop your kick", attacker.HubGuid);
                    return;
                }

                HubContext.SendToClient("You are already trying to kick", attacker.HubGuid);
            }
        }
Пример #4
0
        private static async Task DoCreateSpring(Player attacker, Room room)
        {
            _taskRunnning   = true;
            attacker.Status = Player.PlayerStatus.Busy;


            await Task.Delay(500);

            var castingTextAttacker = $"A pool of water suddenly appears on the floor and starts to spew water in the air.";

            HubContext.SendToClient(castingTextAttacker, attacker.HubGuid);

            foreach (var character in room.players)
            {
                if (character != attacker)
                {
                    var roomMessage = $"A pool of water suddenly appears on the floor and starts to spew water in the air.";

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

            var magicalSpring = MagicalSpring.MagicalWaterSpring();

            room.items.Add(magicalSpring);


            Player.SetState(attacker);
            _taskRunnning = false;
        }
Пример #5
0
        public static void greet(PlayerSetup.Player player, PlayerSetup.Player mob, Room.Room room, string message = "")
        {
            var isMobHere = room.mobs.FirstOrDefault(x => x.Name.Equals(mob.Name));

            if (isMobHere == null)
            {
                return;
            }

            if (player.Type == PlayerSetup.Player.PlayerTypes.Player && message == string.Empty)
            {
                if (!string.IsNullOrEmpty(mob.GreetMessage))
                {
                    string greetMessageToRoom = mob.GreetMessage + " " + player.Name;

                    foreach (var character in room.players)
                    {
                        var roomMessage = $"{ Helpers.ReturnName(mob, character, string.Empty)} says \"{greetMessageToRoom}\"";

                        HubContext.SendToClient(roomMessage, character.HubGuid);
                    }
                }
            }
            else
            {
            }
        }
Пример #6
0
        private async Task DoShockingGrasp(Player attacker, Player target, Room room)
        {
            attacker.Status = Player.PlayerStatus.Busy;

            await Task.Delay(500);

            if (attacker.ManaPoints < ShockingGraspAb().ManaCost)
            {
                HubContext.SendToClient("You attempt to draw energy but fail", attacker.HubGuid);
                attacker.ActiveSkill = null;
                Player.SetState(attacker);
                return;
            }

            var die = new PlayerStats();

            var dam = die.dice(5, 6);

            var toHit  = Helpers.GetPercentage(attacker.Skills.Find(x => x.Name.Equals(ShockingGraspAb().Name, StringComparison.CurrentCultureIgnoreCase)).Proficiency, 95); // always 5% chance to miss
            int chance = die.dice(1, 100);

            Fight2.ShowAttack(attacker, target, room, toHit, chance, ShockingGraspAb(), dam);


            Score.ReturnScoreUI(target);


            Player.SetState(attacker);

            Fight2.PerpareToFightBack(attacker, room, target.Name, true);

            target = null;
            attacker.ActiveSkill = null;
        }
Пример #7
0
        public static bool CanDoSkill(PlayerSetup.Player player)
        {
            if (player.Status == PlayerSetup.Player.PlayerStatus.Sleeping)
            {
                HubContext.SendToClient("You can't do that while asleep.", player.HubGuid);

                return(false);
            }

            if (player.Status == PlayerSetup.Player.PlayerStatus.Ghost)
            {
                HubContext.SendToClient("You can't do that while dead.", player.HubGuid);

                return(false);
            }

            if (player.Status == PlayerSetup.Player.PlayerStatus.Dead)
            {
                HubContext.SendToClient("You can't do that while dead.", player.HubGuid);

                return(false);
            }

            if (player.Status == PlayerSetup.Player.PlayerStatus.Resting)
            {
                HubContext.SendToClient("You can't do that while resting.", player.HubGuid);

                return(false);
            }


            return(true);
        }
Пример #8
0
        public static void EnterRoom(Player player, Room room, string direction = "", bool teleported = false)
        {
            var directionOrigin = oppositeDirection(direction, true);

            for (int i = 0; i < room.players.Count; i++)
            {
                if (teleported == false)
                {
                    string name     = Helpers.ReturnName(player, room.players[i], string.Empty);
                    string movement = "walks in "; // runs, hovers, crawls. Steps out of a portal, appears?


                    if (player.Affects?.FirstOrDefault(
                            x => x.Name.Equals("Fly", StringComparison.CurrentCultureIgnoreCase)) != null)
                    {
                        movement = "floats in ";
                    }

                    direction = oppositeDirection(direction, false);
                    string enterText = name + " " + movement + direction;

                    if (player.HubGuid != null)
                    {
                        if (player.Name != room.players[i].Name)
                        {
                            HubContext.getHubContext.Clients.Client(room.players[i].HubGuid)
                            .addNewMessageToPage(enterText);
                        }
                        else
                        {
                            if (player.Status == Player.PlayerStatus.Standing)
                            {
                                if (player.Affects?.FirstOrDefault(
                                        x => x.Name.Equals("Fly", StringComparison.CurrentCultureIgnoreCase)) != null)
                                {
                                    enterText = "You float in " + direction;
                                }
                                else
                                {
                                    enterText = "You walk in " + direction;
                                }

                                HubContext.getHubContext.Clients.Client(room.players[i].HubGuid)
                                .addNewMessageToPage(enterText);
                            }
                        }

                        var roomdata = LoadRoom.DisplayRoom(room, room.players[i].Name);
                        Score.UpdateUiRoom(room.players[i], roomdata);
                    }
                    else
                    {
                        if (room.players[i].HubGuid != null)
                        {
                            HubContext.SendToClient(enterText, room.players[i].HubGuid);
                        }
                    }
                }
            }
        }
Пример #9
0
        public static void SleepPlayer(PlayerSetup.Player player, Room.Room room)
        {
            if (player.Status != PlayerSetup.Player.PlayerStatus.Sleeping)
            {
                player.Status = PlayerSetup.Player.PlayerStatus.Sleeping;

                HubContext.SendToClient("You laydown and go to sleep", player.HubGuid);

                if (!string.IsNullOrEmpty(room.EventWake))
                {
                    Event.ParseCommand(room.EventWake, player, null, room, "sleep");
                }


                foreach (var mob in room.mobs)
                {
                    if (!string.IsNullOrEmpty(mob.EventWake))
                    {
                        Event.ParseCommand(mob.EventWake, player, mob, room, "sleep");
                    }
                }
            }

            else
            {
                HubContext.SendToClient("You are already asleep", player.HubGuid);
            }
        }
Пример #10
0
        /// <summary>
        /// Starts a fight between two players or mobs
        /// The defender can only fight it's original target
        /// so cant fight back at multiple targets
        /// </summary>
        /// <param name="attacker">The attacker</param>
        /// <param name="room">The room</param>
        /// <param name="defenderName">The defenders Name for now</param>
        /// <returns></returns>
        public static void PerpareToFight(Player attacker, Room room, string defenderName)
        {
            if (attacker == null)
            {
                return;
            }

            /* player can only attack one target
             * if player gets attacked by something else they cannot fight back until
             * they have ended the fight they are already in.
             * player defence should be divided by the number of people they are being attacked by.
             *
             */

            //automated Combat rounds for melee attacks

            //find defender
            Player defender = FindValidTarget(room, defenderName, attacker);


            if (defender == null)
            {
                HubContext.SendToClient("No one here by that name", attacker.HubGuid);
                return;
            }

            defender.Status = Player.PlayerStatus.Fighting;
            attacker.Status = Player.PlayerStatus.Fighting;

            AddFightersIdtoRoom(attacker, defender, room);

            StartFight(attacker, defender, room);
        }
Пример #11
0
        public static Player FindValidTarget(Room room, string defender, Player attacker)
        {
            Player defendingPlayer = room.players.FirstOrDefault(x => x.Name.StartsWith(defender, StringComparison.CurrentCultureIgnoreCase))
                                     ?? room.mobs.FirstOrDefault(x => x.Name.ToLower().Contains(defender.ToLower()));

            if (defendingPlayer == null)
            {
                HubContext.SendToClient("No one here", attacker.HubGuid);
                attacker.Status = Player.PlayerStatus.Standing;
                return(null);
            }

            if (attacker.Name.Equals(defendingPlayer.Name))
            {
                HubContext.SendToClient("You can't kill yourself", attacker.HubGuid);
                return(null);
            }


            if (attacker.HitPoints <= 0)
            {
                HubContext.SendToClient("You cannot attack anything while dead", attacker.HubGuid);
                attacker.Status = Player.PlayerStatus.Standing;
                return(null);
            }

            if (defendingPlayer.HitPoints <= 0)
            {
                HubContext.SendToClient("They are already dead.", attacker.HubGuid);
                attacker.Status = Player.PlayerStatus.Standing;
                return(null);
            }

            return(defendingPlayer);
        }
Пример #12
0
        public static void listItems(PlayerSetup.Player player, Room.Room room)
        {
            var itemsForSell = "<table><thead><tr><td>Item</td><td>Price</td></tr></thead><tbody>";
            var mob          = room.mobs.FirstOrDefault(x => x.Shop.Equals(true));

            if (mob != null)
            {
                if (mob.itemsToSell.Count > 0)
                {
                    foreach (var item in mob.itemsToSell)
                    {
                        itemsForSell += "<tr><td>" + item.name + "</td> <td>" + item.Gold + " GP</td></tr>";
                    }

                    itemsForSell += "</tbody></table>";
                }
                else
                {
                    HubContext.SendToClient("Sorry I have nothing to sell you.", player.HubGuid);
                    return;
                }

                //e.g Yes sure here are my wares.
                HubContext.SendToClient(mob.Name + " says to you " + mob.sellerMessage, player.HubGuid);

                //show player items
                HubContext.SendToClient(itemsForSell, player.HubGuid);
            }
            else
            {
                HubContext.SendToClient("There is no merchant here", player.HubGuid);
            }
        }
Пример #13
0
        private static async Task DoWeaken(Player attacker, Room room)
        {
            _taskRunnning   = true;
            attacker.Status = Player.PlayerStatus.Busy;


            await Task.Delay(500);


            var castingTextAttacker =
                Helpers.ReturnName(_target, attacker, null) + "'s muscles shrink making them look weaker.";

            var castingTextDefender = "You feel weaker as your muscles shrink.";

            HubContext.SendToClient(castingTextAttacker, attacker.HubGuid);
            HubContext.SendToClient(castingTextDefender, _target.HubGuid);

            foreach (var character in room.players)
            {
                if (character == attacker)
                {
                    continue;
                }

                if (character != _target)
                {
                    var roomMessage = $"{Helpers.ReturnName(_target, character, string.Empty)}'s  muscles shrink making them look weaker.";

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

            _target.Strength -= 2;


            var weakenAff = new Affect
            {
                Name     = "Weaken",
                Duration = attacker.Level + 5,
                AffectLossMessagePlayer = "Your muscles regain there mass and strength.",
                AffectLossMessageRoom   = $" muscles regain there mass and strength."
            };


            if (_target.Affects == null)
            {
                _target.Affects = new List <Affect>();
                _target.Affects.Add(weakenAff);
            }
            else
            {
                _target.Affects.Add(weakenAff);
            }

            Score.ReturnScoreUI(_target);

            Player.SetState(attacker);
            _target       = null;
            _taskRunnning = false;
        }
Пример #14
0
        public static void fleeCombat(PlayerSetup.Player player, Room.Room room)
        {
            if (player.Status == PlayerSetup.Player.PlayerStatus.Fighting)
            {
                //hardcode 50% flee success rate

                if (Helpers.Rand(1, 100) >= 50)
                {
                    HubContext.SendToClient("You Flee", player.HubGuid);

                    var exit = Helpers.diceRoll.Next(room.exits.Count);

                    player.Status = PlayerSetup.Player.PlayerStatus.Standing;

                    HubContext.SendToClient(player.Name + " Flee's from combat", player.Target.HubGuid);

                    player.Target = null;

                    Room.Movement.Move(player, room, room.exits[exit].name);
                }
                else
                {
                    HubContext.SendToClient("You fail to flee", player.HubGuid);
                }
            }
            else
            {
                HubContext.SendToClient("Flee from whom, you're not fighting anyone", player.HubGuid);
            }
        }
Пример #15
0
        public void GainLevel(PlayerSetup.Player player)
        {
            if (HasGainedLevel(player))
            {
                player.Level += 1;
                var carryOverExcessXp = Math.Max(player.Experience - player.ExperienceToNextLevel, 0);
                player.Experience            = carryOverExcessXp;
                player.ExperienceToNextLevel = GetTNL(player);

                var selectedClass = PlayerClass.ClassList().FirstOrDefault(x => x.Value.Name.ToLower().StartsWith(player.SelectedClass, StringComparison.CurrentCultureIgnoreCase));
                var dice          = new Helpers();

                var hpGain        = dice.dice(1, selectedClass.Value.MinHpGain, selectedClass.Value.MaxHpGain);
                var manaGain      = dice.dice(1, selectedClass.Value.MinHpGain, selectedClass.Value.MaxHpGain);
                var enduranceGain = dice.dice(1, selectedClass.Value.MinHpGain, selectedClass.Value.MaxHpGain);
                //tell user they have gained a level

                player.MaxHitPoints  += hpGain;
                player.MaxManaPoints += manaGain;
                player.MaxMovePoints += enduranceGain;

                //tell user how much HP / mana / mvs / practices / trains they have gained

                HubContext.SendToClient("Congratulations, you are now level " + player.Level + ". You have gained. HP: " + hpGain + " Mana: " + manaGain + " End: " + enduranceGain, player.HubGuid);

                Save.SavePlayer(player);
                //save player

                //check player hasn't leveled again
                GainLevel(player);
            }
        }
Пример #16
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 = (Player)ManipulateObject.FindObject(room, player, "", playerName, "all");

            if (recipientPlayer != null)
            {
                string recipientName = recipientPlayer.Name;
                HubContext.SendToClient("You say to " + recipientName + " \"" + actualMessage + "\"", playerId, null, false, false);
                HubContext.SendToClient(Helpers.ReturnName(player, recipientPlayer, string.Empty) + " says to you \"" + actualMessage + "\"", playerId, recipientName, true, true);
            }
            else
            {
                HubContext.SendToClient("No one here by that name.", playerId, null, false, false);
            }
        }
Пример #17
0
        public static void StartPunch(Player attacker, Room room)
        {
            //TODO: Fix His to be gender specific
            //TODO: Fist? what if it's a paw?

            if (!_taskRunnning)
            {
// find target if not in fight
                HubContext.SendToClient("You clench your fist and pull your arm back", attacker.HubGuid);
                HubContext.SendToClient(attacker.Name + " Pulls his arm back aiming a punch at you.", attacker.HubGuid,
                                        attacker.Target.HubGuid, false, true);


                foreach (var character in room.players)
                {
                    if (attacker != character || attacker.Target != character)
                    {
                        var hisOrHer    = Helpers.ReturnHisOrHers(attacker, character);
                        var roomMessage = $"{ Helpers.ReturnName(attacker, character, string.Empty)} clenches his fist and pulls his arm back aiming for {Helpers.ReturnName(attacker.Target, attacker, string.Empty)}";

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


                Task.Run(() => DoPunch(attacker, room));
            }
            else
            {
                HubContext.SendToClient("You are already trying to punch", attacker.HubGuid);
            }
        }
Пример #18
0
        public static void ShowPrompt(Player player)
        {
            int hp      = PlayerStats.GetHp(player);
            int maxHP   = PlayerStats.GetMaxHp(player);
            int mana    = PlayerStats.GetMana(player);
            int maxMana = PlayerStats.GetMaxMana(player);
            int move    = PlayerStats.GetMove(player);
            int maxMove = PlayerStats.GetMaxMove(player);

            var prompt = new StringBuilder();

            prompt.Append("<")
            .Append(hp)
            .Append("/")
            .Append(maxHP)
            .Append("HP ")
            .Append(mana)
            .Append("/")
            .Append(maxMana)
            .Append("MP ")
            .Append(move)
            .Append("/")
            .Append(maxMove)
            .Append("Mvs")
            .Append(">");


            HubContext.SendToClient(prompt.ToString(), player.HubGuid);
        }
Пример #19
0
        public static void WakePlayer(PlayerSetup.Player player, Room.Room room)
        {
            if (player.Status == PlayerSetup.Player.PlayerStatus.Sleeping)
            {
                player.Status = PlayerSetup.Player.PlayerStatus.Standing;

                HubContext.SendToClient("You wake and stand up", player.HubGuid);

                if (!string.IsNullOrEmpty(room.EventWake))
                {
                    Event.ParseCommand(room.EventWake, player, null, room, "wake");
                }


                foreach (var mob in room.mobs)
                {
                    if (!string.IsNullOrEmpty(mob.EventWake))
                    {
                        Event.ParseCommand(mob.EventWake, player, mob, room, "wake");
                    }
                }

                Command.ParseCommand("look", player, room);
            }

            else
            {
                HubContext.SendToClient("You are already awake", player.HubGuid);
            }
        }
Пример #20
0
        public static async Task KickIdlePlayers()
        {
            try
            {
                foreach (var player in MIMHub._PlayerCache.ToList())
                {
                    if (player.Value != null && player.Value.LastCommandTime.AddMinutes(1) < DateTime.UtcNow)
                    {
                        HubContext.SendToClient("You disappear in the void", player.Value.HubGuid);

                        var room =
                            MIMHub._AreaCache.FirstOrDefault(
                                x =>
                                x.Value.area.Equals(player.Value.Area) && x.Value.areaId.Equals(player.Value.AreaId) &&
                                x.Value.region.Equals(player.Value.Region));

                        if (room.Value != null)
                        {
                            foreach (var players in room.Value.players.ToList())
                            {
                                HubContext.broadcastToRoom(player.Value.Name + " disappears in the void",
                                                           room.Value.players,
                                                           player.Value.HubGuid, true);
                            }
                        }
                    }

                    if (player.Value != null && player.Value.LastCommandTime.AddMinutes(2) < DateTime.UtcNow)
                    {
                        var room =
                            MIMHub._AreaCache.FirstOrDefault(
                                x =>
                                x.Value.area.Equals(player.Value.Area) && x.Value.areaId.Equals(player.Value.AreaId) &&
                                x.Value.region.Equals(player.Value.Region));


                        PlayerSetup.Player removedChar = null;

                        MIMHub._PlayerCache.TryRemove(player.Value.HubGuid, out removedChar);

                        if (removedChar != null)
                        {
                            Command.ParseCommand("quit", player.Value, room.Value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "KickIdlePlayers"
                };

                Save.LogError(log);
            }
        }
Пример #21
0
        public static void ExitRoom(Player player, Room room, string direction)
        {
            for (int i = 0; i < room.players.Count; i++)
            {
                string name     = Helpers.ReturnName(player, room.players[i], string.Empty);
                string movement = "walks "; // runs, hovers, crawls. Steps out of a portal, appears?

                if (player.Affects?.FirstOrDefault(
                        x => x.Name.Equals("Fly", StringComparison.CurrentCultureIgnoreCase)) != null)
                {
                    movement = "floats ";
                }

                string exitDir  = direction;                            // string prevDirection = "South";
                string exitText = name + " " + movement + exitDir;

                if (player.Name != room.players[i].Name)
                {
                    HubContext.getHubContext.Clients.Client(room.players[i].HubGuid).addNewMessageToPage(exitText);
                }
                else
                {
                    exitText = "You walk " + direction;

                    if (player.Affects?.FirstOrDefault(
                            x => x.Name.Equals("Fly", StringComparison.CurrentCultureIgnoreCase)) != null)
                    {
                        exitText = "You float " + direction;
                    }

                    HubContext.getHubContext.Clients.Client(player.HubGuid).addNewMessageToPage(exitText);
                }

                var roomdata = LoadRoom.DisplayRoom(room, room.players[i].Name);
                Score.UpdateUiRoom(room.players[i], roomdata);
            }


            if (player.Followers != null && player.Followers.Count > 0)
            {
                foreach (var follower in player.Followers.ToList())
                {
                    HubContext.SendToClient(Helpers.ReturnName(follower, player, string.Empty) + " follows you " + direction, player.HubGuid);
                    HubContext.SendToClient("You follow " + Helpers.ReturnName(player, follower, string.Empty) + " " + direction, follower.HubGuid);

                    if (follower.HubGuid == null)
                    {
                        Movement.MobMove(follower, player, room, direction);
                    }
                    else
                    {
                        Command.ParseCommand(direction, follower, room);
                    }
                }
            }

            player.MovePoints -= 1;
            Score.UpdateUiPrompt(player);
        }
Пример #22
0
        public static void buyItems(PlayerSetup.Player player, Room.Room room, string itemName)
        {
            var mob = room.mobs.FirstOrDefault(x => x.Shop.Equals(true));

            if (mob != null)
            {
                if (mob.Shop)
                {
                    if (string.IsNullOrEmpty(itemName))
                    {
                        HubContext.SendToClient("Buy? Buy what?", player.HubGuid);
                        return;
                    }

                    var itemToBuy = mob.itemsToSell.FirstOrDefault(x => x.name.ToLower().Contains(itemName.ToLower()));

                    if (itemToBuy != null)
                    {
                        var    result  = AvsAnLib.AvsAn.Query(itemToBuy.name);
                        string article = result.Article;

                        //Can afford

                        if (player.Gold >= itemToBuy.Gold)
                        {
                            itemToBuy.location = Item.Item.ItemLocation.Inventory;
                            player.Inventory.Add(itemToBuy);
                            HubContext.SendToClient(
                                "You buy " + article + itemToBuy.name + " from " + mob.Name,
                                player.HubGuid);

                            foreach (var character in room.players)
                            {
                                if (player != character)
                                {
                                    var hisOrHer    = Helpers.ReturnHisOrHers(player, character);
                                    var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} buys {article} {itemToBuy.name} from {mob.Name}";

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

                            Score.UpdateUiInventory(player);
                            //deduct gold

                            player.Gold -= itemToBuy.Gold;
                        }
                        else
                        {
                            HubContext.SendToClient("You can't afford " + article + " " + itemToBuy.name, player.HubGuid);
                        }
                    }
                }
                else
                {
                    HubContext.SendToClient("Sorry I don't sell that", player.HubGuid);
                }
            }
        }
Пример #23
0
        public static void KickAb(Player attacker, Player defender, Room room)
        {
            Skill kick = null;

            if (KickSkill != null)
            {
                kick = KickSkill;
            }
            else
            {
                var skill = new Skill
                {
                    Name             = "Kick",
                    CoolDown         = 0,
                    Delay            = 0,
                    LevelObtained    = 1,
                    Passive          = false,
                    Proficiency      = 75,
                    UsableFromStatus = "Standing",
                    Syntax           = "Kick <Target>"
                };



                KickSkill = skill;
            }

            if (attacker.Level >= kick.LevelObtained)
            {
                if (attacker.Target != null)
                {
                    if (attacker.Status == Player.PlayerStatus.Standing || attacker.Status == Player.PlayerStatus.Fighting)
                    {
                        return;
                    }

                    var die = new PlayerStats();
                    var dam = die.dice(1, attacker.Strength);

                    if (defender.HitPoints > 0)
                    {
                        defender.HitPoints -= dam;
                    }

                    if (defender.HitPoints <= 0)
                    {
                        defender.HitPoints = 0;
                    }


                    HubContext.SendToClient("You kick " + defender.Name, attacker.HubGuid);
                    HubContext.SendToClient(attacker.Name + " kicks you", defender.HubGuid);
                }
                else
                {
                    HubContext.SendToClient("You are not fighting anyone ", attacker.HubGuid);
                }
            }
        }
Пример #24
0
 public static void DebugPlayer(Player player)
 {
     HubContext.SendToClient("Debug:", player.HubGuid);
     HubContext.SendToClient("Player Target: " + player.Target?.Name, player.HubGuid);
     HubContext.SendToClient("Player is Fighting: " + player.ActiveFighting, player.HubGuid);
     HubContext.SendToClient("Player Has active skill: " + player.ActiveSkill?.Name, player.HubGuid);
     HubContext.SendToClient("Player status: " + player.Status, player.HubGuid);
 }
Пример #25
0
        public static void StartMagicMissile(Player attacker, Room room, string target = "")
        {
            //Check if player has spell
            var hasSpell = Skill.CheckPlayerHasSkill(attacker, MagicMissileAb().Name);

            if (hasSpell == false)
            {
                HubContext.SendToClient("You don't know that spell.", attacker.HubGuid);
                return;
            }

            var foundTarget = Skill.FindTarget(target, room);

            if (foundTarget != null && attacker.Target == null && target != "")
            {
                Fight2.PerpareToFight(attacker, room, foundTarget.Name, true);
            }


            if (!_taskRunnning && attacker.Target != null)
            {
                if (attacker.ManaPoints < MagicMissileAb().ManaCost)
                {
                    HubContext.SendToClient("You clasp your hands together but fail to form any energy", attacker.HubGuid);

                    var excludePlayerInBroadcast = new List <string>();
                    excludePlayerInBroadcast.Add(attacker.HubGuid);

                    HubContext.SendToAllExcept(Helpers.ReturnName(attacker, null) + " clasps " + Helpers.ReturnHisOrHers(attacker.Gender) + " hands together but fails to form any energy", excludePlayerInBroadcast, room.players);

                    return;
                }

                attacker.ManaPoints -= MagicMissileAb().ManaCost;

                Score.UpdateUiPrompt(attacker);

                HubContext.SendToClient("A red ball begins swirling between your hands as you begin chanting magic missle", attacker.HubGuid);

                HubContext.SendToClient("A red ball begins swirling between " + Helpers.ReturnName(attacker, null) + " hands " + Helpers.ReturnHisOrHers(attacker.Gender) + " as they begin chanting magic missle", attacker.HubGuid,
                                        attacker.Target.HubGuid, false, true);

                HubContext.broadcastToRoom("A red ball begins swirling between " +
                                           Helpers.ReturnName(attacker, null) + " hands " + Helpers.ReturnHisOrHers(attacker.Gender) + " as they begin chanting magic missle " + Helpers.ReturnName(attacker.Target, null), room.players, attacker.HubGuid, true);

                Task.Run(() => DoMagicMissile(attacker, room));
            }
            else
            {
                if (attacker.Target == null)
                {
                    HubContext.SendToClient("Cast magic missile at whom?", attacker.HubGuid);
                    return;
                }

                HubContext.SendToClient("You are trying to cast magic missle", attacker.HubGuid);
            }
        }
Пример #26
0
        public static void UpdateAffects(PlayerSetup.Player player, IHubContext context)
        {
            try
            {
                if (player.Affects == null)
                {
                    return;
                }

                foreach (var af in player.Affects)
                {
                    if (af.Duration == 0 || af.Duration <= 0)
                    {
                        player.Affects.Remove(af);

                        // put in method? or change way we handle invis
                        if (af.Name == "Invis")
                        {
                            player.invis = false;
                        }

                        if (af.Name == "Chill Touch")
                        {
                            player.Equipment.Wielded = "Nothing";
                            var chillTouch = player.Inventory.FirstOrDefault(x => x.name.Equals("Chill Touch"));
                            player.Inventory.Remove(chillTouch);
                        }

                        if (af.AffectLossMessageRoom != null)
                        {
                            HubContext.SendToClient(af.AffectLossMessagePlayer, player.HubGuid);
                        }

                        if (af.AffectLossMessageRoom != null)
                        {
                            var room = Cache.getRoom(player);

                            foreach (var character in room.players)
                            {
                                if (player != character)
                                {
                                    HubContext.SendToClient(
                                        Helpers.ReturnName(player, character, string.Empty) + " " +
                                        af.AffectLossMessageRoom, character.HubGuid);
                                }
                            }
                        }
                    }

                    af.Duration -= 1;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #27
0
        public static void EmoteActionToRoom(string message, Player player)
        {
            var players = Cache.ReturnPlayers().Where(x => x.AreaId.Equals(player.AreaId) && x.Area.Equals(player.Area) && x.Region.Equals(player.Region));

            foreach (var pc in players)
            {
                HubContext.SendToClient(player.Name + " " + message, pc.HubGuid);
            }
        }
Пример #28
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.SendToClient("<span style='color:#00AFF0'>[OOC] " + player.Name + ":</span> " + message, pc.HubGuid);
            }
        }
Пример #29
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.SendToClient("OOC: " + player.Name + " says :" + message, pc.HubGuid);
            }
        }
Пример #30
0
        public static void FollowThing(PlayerSetup.Player follower, Room.Room room, string thingToFollow)
        {
            string[] options      = thingToFollow.Split(' ');
            int      nth          = -1;
            string   getNth       = string.Empty;
            string   objectToFind = String.Empty;


            if (options.Length == 3)
            {
                objectToFind = options[2];

                if (objectToFind.IndexOf('.') != -1)
                {
                    getNth = objectToFind.Substring(0, objectToFind.IndexOf('.'));
                    int.TryParse(getNth, out nth);
                }
            }

            var findPerson = FindItem.Player(room.players, nth, objectToFind);

            if (findPerson == null)
            {
                return;
            }

            if (findPerson.Followers == null)
            {
                findPerson.Followers = new List <PlayerSetup.Player>();
            }

            //check if player already following player

            if (findPerson.Followers.Contains(follower))
            {
                if (follower.HubGuid != null)
                {
                    HubContext.SendToClient("You are already following them.", follower.HubGuid);
                }
            }
            else
            {
                HubContext.SendToClient($"{Helpers.ReturnName(follower, findPerson, String.Empty)} begins following you", findPerson.HubGuid);

                foreach (var character in room.players)
                {
                    if (character != follower || character != findPerson)
                    {
                        HubContext.SendToClient($"{Helpers.ReturnName(follower, findPerson, String.Empty)} begins following {Helpers.ReturnName(findPerson, follower, String.Empty)}", character.HubGuid);
                    }
                }

                findPerson.Followers.Add(follower);
            }
        }