private static void DoWinTheGame(Player player, Location location)
        {
            if (player == null)
            {
                throw new ArgumentNullException($"Error: LocationAction DoWinTheGame null player.");
            }
            if (location == null)
            {
                throw new ArgumentNullException($"Error: LocationAction DoWinTheGame null location.");
            }

            if (player.IsAlive && player.Location == location)
            {
                GameEngine.SayToAll($"Congratulations to {player.Name} for deftly making it to THE TOWN and conquering the game!");
                if (player.HasClient)
                {
                    player.Client.SendUpdate($"\n\nCongratulations to you for deftly making it to THE TOWN and conquering the game!\nBUT IS THIS REALLY THE END?");
                    player.Client.KickClient("You won!");
                }
                GameEngine.Players.Remove(player);
            }
            else
            {
                GameEngine.SayToLocation(player.Location, $"{player.Name} was about to win the game but was interrupted!");
            }
        }
        private static void DoDrinkWater(Player player, Location location)
        {
            if (player == null)
            {
                throw new ArgumentNullException($"Error: LocationAction DoDrinkWater null player.");
            }
            if (location == null)
            {
                throw new ArgumentNullException($"Error: LocationAction DoDrinkWater null location.");
            }

            if (player.IsAlive && player.Location == location)
            {
                GameEngine.SayToLocation(location, $"{player.Name} drinks the water.");
                player.HealHP(4);
                player.AddEffect(new StatusEffect(EffectClass.Dysentery, effectValue: 5,
                                                  turnTickEvent: StatusEvents.DysenteryTick, effectExpiresEvent: StatusEvents.DysenteryCured));
                if (!player.HasFlag(QuestFlags.LearnedAboutDysentary))
                {
                    player.AddFlag(QuestFlags.LearnedAboutDysentary);
                    player.Notify("  *  To prevent heal scumming, certain healing locations inflict mild status ailments. Avoid drinking too fast and you'll be fine.");
                }
            }
            else
            {
                GameEngine.SayToLocation(player.Location, $"{player.Name} was about to drink some water but didn't succeed...");
            }
        }
Beispiel #3
0
        public static void Yell(Player player, string text)
        {
            if (player == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null player");
            }
            if (text == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null string");
            }
            // text.Length == 0   OK

            if (player.IsAlive)
            {
                text = TextUtils.CurateDialogue(text);
                if (text == "")
                {
                    GameEngine.SayToLocation(player.Location, $"{player.Name} yells loudly.");
                    GameEngine.SayToAdjacent(player.Location, $"There is a sound of somebody yelling coming from {player.Location}.");
                }
                else
                {
                    GameEngine.SayToLocation(player.Location, $"{player.Name} yells, \"{text}\"");
                    GameEngine.SayToAdjacent(player.Location, $"Somebody is yelling from {player.Location}, \"{text}\"");
                }
            }
        }
Beispiel #4
0
        private static void DoFrogsRibbit(Location location)
        {
            string text = "";

            switch (rng.Next(6))
            {
            case 0:
                text = $"  *  You hear a frog croaking {FlavorText.FromSomewhere()}.";
                break;

            case 1:
                text = "A loud 'ribbit' bursts out from the shallows.";
                break;

            case 2:
                text = $"  *  You see a splash of water {FlavorText.FromSomewhere()}.";
                break;

            case 3:
                text = "A frog ribbits.";
                break;

            case 4:
                text = "A pair of eyes emerge from the water staring at you, then re-submerge.";
                break;

            case 5:
                text = $"  *  You hear a 'ribbit-ribbit' come {FlavorText.FromSomewhere()}.";
                break;
            }
            GameEngine.SayToLocation(location, text);
        }
Beispiel #5
0
        public static void SocketItem(Player player, ISocketed item, Gemstone gem)
        {
            if (player == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, player null error");
            }
            if (item == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, item null error");
            }
            if (gem == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, gem null error");
            }

            if (player.IsAlive)
            {
                if (item.Augment(gem))
                {
                    GameEngine.SayToLocation(player.Location, $"{player} sockets {gem.SetName()} in {item.SetName()}.");
                    player.RemoveItem(gem);
                }
                else
                {
                    player.Notify($"  *  You were unable to insert the item in the socket.");
                }
            }
            else if (!player.IsAlive)
            {
                player.Notify($"  *  You died before you could socket the item.");
            }
        }
Beispiel #6
0
        public static void Look(Player p1, Player p2)
        {
            if (p1 == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, p1 null error");
            }
            if (p2 == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, p2 null error");
            }

            if (p1.IsAlive && p1.Location == p2.Location)
            {
                GameEngine.SayToLocation(p1.Location, $"{p1.Name} takes a close look at {p2.Name}.");
                p1.Notify(p2.LookString());
            }
            else if (!p1.IsAlive)
            {
                p1.Notify($" * Your vision fades to black before you could get a good look.");
            }
            else if (p1.Location != p2.Location)
            {
                p1.Notify($" * You were separated from {p2.Name} before you could get a good look.");
            }
        }
Beispiel #7
0
        public static void Attack(Player p1, Player p2)
        {
            if (p1 == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, p1 null error");
            }
            if (p2 == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, p2 null error");
            }

            if (p1.IsAlive && p2.IsAlive && p1.Location == p2.Location)
            {
                if (Plugins.AttackMod != null)
                {
                    Plugins.AttackMod.AttackOverride(p1, p2);
                }
                else
                {
                    if (p1.Weapon == Prefabs.Unarmed)
                    {
                        GameEngine.SayToLocation(p1.Location, $"{p1.Name} punches {p2.Name}!");
                    }
                    else
                    {
                        GameEngine.SayToLocation(p1.Location, $"{p1.Name} attacks {p2.Name} with {p1.Weapon.SetName()}!");
                    }
                    int damageDealt = p1.Weapon.Damage - p2.Armor.Defense;
                    if (p2.HasFlag(QuestFlags.StoryCritical) && p2.HP - damageDealt <= 0)
                    {
                        GameEngine.SayToLocation(p1.Location, $"{p2.Name} deftly avoids it!");
                    }
                    else
                    {
                        if (damageDealt > 0)
                        {
                            p2.DamageHP(damageDealt, $"wounds from {p1.Weapon.SetName()}", p1);
                            p1.GetStatusEffects().ForEach(se => se.OnAttackHit(p2, se));
                            p1.RemoveExpiredStatusEffects();
                        }
                        else
                        {
                            p2.DamageHP(damageDealt, $"wounds from {p1.Weapon.SetName()}", p1);
                        }
                    }
                }
            }
            else if (!p1.IsAlive)
            {
                GameEngine.SayToLocation(p1.Location, $"{p1.Name} perished trying to strike down {p2.Name}.");
            }
            else if (!p2.IsAlive)
            {
                GameEngine.SayToLocation(p1.Location, $"{p1.Name} is pleased to see that {p2.Name} has perished.");
            }
            else if (p1.Location != p2.Location)
            {
                GameEngine.SayToLocation(p1.Location, $"{p1.Name} attacks the air but no one is there!");
            }
        }
        public static bool GuardHostileResponse(Player p1, Player p2, string speech)
        {
            if (p2.IsHostileToward(p1))
            {
                if (speech == "")
                {
                    GameEngine.SayToLocation(p2.Location, $"{p2.Name} ignores {p1.Name}.");
                }
                else
                {
                    switch (rng.Next(3))
                    {
                    case 0:
                        GameEngine.SayToLocation(p2.Location, $"{p2.Name} shouts, \"I will not parley with the enemy!\"");
                        break;

                    case 1:
                        GameEngine.SayToLocation(p2.Location, $"{p2.Name} shouts, \"You will pay for your transgressions!\"");
                        break;

                    case 2:
                        GameEngine.SayToLocation(p2.Location, $"{p2.Name} shouts, \"Prepare to meet your untimely end!\"");
                        break;
                    }
                }
                return(true);
            }
            return(false);
        }
        public static void LetPlayerEnterTownGate(Player p1, Player p2, Location destination)
        {
            GameEngine.SayToLocation(p1.Location, $"{p2.Name} stoically looks you up and down then signals the gatekeeper.");
            LocationConnector portcullis = p1.Location.GetConnector(destination);

            portcullis.Unlock();
            GameEngine.SayToLocation(p1.Location, $"The massive portcullis rattles as it raises up.");
            portcullis.SetTickEvent(new ConnectorSelfEvent(ConnectorEventTemplates.ClosePortcullisOnCountdown, countdown: 2));
        }
Beispiel #10
0
        private static void DoIdle(Player player)
        {
            if (player == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null player");
            }

            if (player.IsAlive)
            {
                switch (rng.Next(6))
                {
                case 0:
                    GameEngine.SayToLocation(player.Location, $"{player.Name} wanders about.");
                    break;

                case 1:
                    GameEngine.SayToLocation(player.Location, $"{player.Name} stands around doing nothing.");
                    break;

                case 2:
                    GameEngine.SayToLocation(player.Location, $"{player.Name} waits patiently.");
                    break;

                case 3:
                    GameEngine.SayToLocation(player.Location, $"{player.Name} shifts {player.Genderize("his", "her", "its")} weight from side to side.");
                    break;

                case 4:
                    if (player.HasState(EffectClass.Dysentery))
                    {
                        GameEngine.SayToLocation(player.Location, $"{player.Name} prominently farts.");
                        GameEngine.SayToAdjacent(player.Location, $"There is a sound of somebody farting coming from {player.Location}.");
                    }
                    else
                    {
                        GameEngine.SayToLocation(player.Location, $"{player.Name} sighs.");
                    }
                    break;

                case 5:
                    if (player.HasState(EffectClass.Dysentery))
                    {
                        GameEngine.SayToLocation(player.Location, $"{player.Name} coughs a wet cough.");
                        GameEngine.SayToAdjacent(player.Location, $"There is a wet coughing sound coming from from {player.Location}.");
                    }
                    else
                    {
                        GameEngine.SayToLocation(player.Location, $"{player.Name} has a hiccup.");
                    }
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #11
0
 public static bool GuardEmptySpeech(Player p1, Player p2, string speech)
 {
     if (speech == "")
     {
         GameEngine.SayToLocation(p2.Location, $"{p2.Name} replies, \"Traveler, state your business.\"");
         p1.Notify("  *  Type 't1 let me in'");
         return(true);
     }
     return(false);
 }
Beispiel #12
0
        public static void ClosePortcullisOnCountdown(LocationConnector connector)
        {
            int timeLeft = connector.OnTickEvent.CountdownTick();

            if (connector.OnTickEvent.TimesUp)
            {
                connector.Lock();
                GameEngine.SayToLocation(connector.Parent, "The portcullis into the town comes crashing down!");
                GameEngine.SayToLocation(connector.Destination, "The portcullis into the town comes crashing down!");
                connector.ClearTickEvent();
            }
        }
Beispiel #13
0
        public void AddItem(Item item)
        {
            if (item == null)
            {
                throw new ArgumentNullException($"No item was specified when trying to add item to {this.Name}");
            }

            if (items.Count >= 5)
            {
                Item randomItem = items[new Random().Next(items.Count)];
                GameEngine.SayToLocation(this, $"A magical leprechaun appears, grabs a {item} and runs off with it!");
                items.Remove(randomItem);
            }
            items.Add(item);
        }
Beispiel #14
0
        public void DamageHP(int damageValue, string causeOfDamage, Player sourcePlayer)
        {
            if (causeOfDamage == null)
            {
                throw new ArgumentNullException("Error: Player.DamageHP causeOfDamage null string");
            }
            if (causeOfDamage == null)
            {
                throw new ArgumentException("Error: Player.DamageHP causeOfDamage null string");
            }
            // sourcePlayer == null OK

            if (damageValue <= 0)
            {
                if (sourcePlayer != null)
                {
                    AddHate(sourcePlayer, 3);
                }
                GameEngine.SayToLocation(Location, $"{Name} HP: NO DAMAGE! ({causeOfDamage})");
                return;
            }

            if (sourcePlayer != null)
            {
                AddHate(sourcePlayer, 8);
            }

            HP -= damageValue;
            if (HP < 0 && sourcePlayer != null)
            {
                HP = 0;
            }
            if (HP < 1 && sourcePlayer == null)
            {
                HP = 1;
            }
            GameEngine.SayToLocation(Location, $"{Name} HP: -{damageValue} => {HP} ({causeOfDamage})");
            if (HP == 0)
            {
                if (IsPlayerReallyDefeated())
                {
                    this.causeOfDeath = causeOfDamage;
                    GameEngine.SayToLocation(Location, $"{Name} has fallen to {causeOfDeath}!");
                    PersonalEffects.Add(new StatusEffect(EffectClass.Decay, turnTickEvent: StatusEvents.CorpseRot, effectValue: 12));
                    Weapon killingWeapon = sourcePlayer.Weapon;
                }
            }
        }
Beispiel #15
0
        public static void DropItem(Player player, Location location, string arg2)
        {
            if (player == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, player null error");
            }
            if (location == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, location null error");
            }
            if (arg2 == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, arg2 null error");
            }
            // if (arg2.Length == 0) OK

            if (player.IsAlive)
            {
                if (arg2.Length == 0)
                {
                    player.Notify("  *  Type: 'drop item-name'");
                    return;
                }

                Item item = player.GetItem(arg2);
                if (item == null)
                {
                    player.Notify($"  *  Could not find an item that goes by '{arg2}' on your person");
                    return;
                }

                if (player.RemoveItem(item))
                {
                    GameEngine.SayToLocation(player.Location, $"{player.Name} dropped {item.SetName()} on the ground.");
                    player.Location.AddItem(item);
                }
            }
            else if (!player.IsAlive)
            {
                player.Notify($"  *  You died before you could drop the item.");
            }
            else if (player.Location != location)
            {
                player.Notify($"  *  You left the area before you could drop the item.");
            }
        }
Beispiel #16
0
        public static void GetItemFromLocation(Player player, Location location, string arg2)
        {
            if (player == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, player null error");
            }
            if (location == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, location null error");
            }
            if (arg2 == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, arg2 null error");
            }
            // if (arg2.Length == 0) OK

            if (player.IsAlive && player.Location == location)
            {
                if (arg2.Length == 0)
                {
                    player.Notify("  *  Type: 'get item-name'");
                    return;
                }
                Item item = location.GetItem(arg2);
                if (item == null)
                {
                    player.Notify($"  *  Cannot find item '{arg2}' at [{location.Name}]");
                    return;
                }

                if (location.RemoveItem(item))
                {
                    GameEngine.SayToLocation(player.Location, $"{player.Name} picks up the {item}.");
                    player.AddItem(item);
                }
            }
            else if (!player.IsAlive)
            {
                player.Notify($"  *  You died before you could pick up the item.");
            }
            else if (player.Location != location)
            {
                player.Notify($"  *  You left the area before you could pick up the item.");
            }
        }
Beispiel #17
0
        public static void TravelFromPointToPoint(Player player, Location startingPoint, Location destination, string exitText = "", string enterText = "")
        {
            if (player == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null player");
            }
            if (destination == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null starting location");
            }
            if (destination == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null ending location");
            }
            if (exitText == "")
            {
                exitText = $"{player.Name} leaves {startingPoint} and heads for {destination}.";
            }
            if (enterText == "")
            {
                enterText = $"{player.Name} enters {destination} from {startingPoint}.";
            }

            if (player.IsAlive && player.Location == startingPoint)
            {
                LocationConnector exitConnector = startingPoint.GetConnector(destination);
                if (exitConnector == null || (exitConnector.IsUnlocked))
                {
                    exitConnector.OnPlayerExit.PerformAction(player);
                    GameEngine.SayToLocation(player.Location, exitText);
                    player.Relocate(destination);
                    GameEngine.SayToLocation(player.Location, enterText);
                    LocationConnector enterConnector = destination.GetConnector(startingPoint);
                    enterConnector.OnPlayerEnter.PerformAction(player);
                }
                else
                {
                    GameEngine.SayToLocation(player.Location, $"{player.Name} tries to go to {destination.Name} but the way is locked.");
                }
            }
            else
            {
                GameEngine.SayToLocation(player.Location, $"{player.Name} was travelling but got interrupted.");
            }
        }
        public void Equip(Weapon equippedWeapon)         // equipitem
        {
            if (equippedWeapon == null)
            {
                return;
            }

            if (this.weapon != null)
            {
                Inventory.AddItem(this.weapon);
            }
            if (Inventory.HasItem(equippedWeapon))
            {
                Inventory.RemoveItem(equippedWeapon);
            }
            GameEngine.SayToLocation(Location, equippedWeapon.EquipString(this));
            this.weapon = equippedWeapon;
        }
        public void Equip(Armor equippedArmor)
        {
            if (equippedArmor == null)
            {
                return;
            }

            if (this.armor != null)
            {
                Inventory.AddItem(this.armor);
            }
            if (Inventory.HasItem(equippedArmor))
            {
                Inventory.RemoveItem(equippedArmor);
            }
            GameEngine.SayToLocation(Location, equippedArmor.EquipString(this));
            this.armor = equippedArmor;
        }
Beispiel #20
0
 public void HealHP(int healValue)
 {
     if (healValue <= 0)
     {
         GameEngine.SayToLocation(Location, $"{Name} HP: Heal ineffective!");
         return;
     }
     if (HP == MaxHP)
     {
         return;
     }
     HP += healValue;
     if (HP > MaxHP)
     {
         HP = MaxHP;
     }
     GameEngine.SayToLocation(Location, $"{Name} HP: +{healValue} => {HP}");
 }
Beispiel #21
0
        private static void DoBirdsFlyBy(Location location)
        {
            string text = "";

            switch (rng.Next(11))
            {
            case 0:
                text = $"{FlavorText.ARandomBird()} goes flying past overhead.";
                break;

            case 1:
                text = "  *  You see a large eagle overhead.";
                break;

            case 2:
                text = "  *  You hear the chirping of birds.";
                break;

            case 3:
                text = "  *  The chirping of birds fills the air.";
                break;

            case 4:
                text = $"  *  You hear a fluttering of wings {FlavorText.ToSomewhere()}.";
                break;

            case 5:
                text = "  *  Some leaves rustle as two birds fly through them.";
                break;

            case 6:
                text = $"{FlavorText.ARandomBird()} flies through the air.";
                break;

            case 7:
            case 8:
            case 9:
            case 10:
                text = $"{FlavorText.ARandomBird()} can be seen flying {FlavorText.ToSomewhere()}.";
                break;
            }
            GameEngine.SayToLocation(location, text);
        }
Beispiel #22
0
        public static void SearchCorpse(Player p1, Player p2)
        {
            if (p1 == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, p1 null error");
            }
            if (p2 == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, p2 null error");
            }

            if (p1.IsAlive && !p2.IsAlive && p1.Location == p2.Location)
            {
                string firstHalf = $"{p1.Name} searches {p2.Name}'s body...";
                if (p2.HasLoot())
                {
                    Item foundItem = p2.GetLoot();
                    GameEngine.SayToLocation(p1.Location, $"{firstHalf}{p1.Genderize("he", "she", "it")} finds {foundItem.SetName()}!");
                    p1.AddItem(foundItem);
                }
                else if (p2.HasClient)
                {
                    GameEngine.SayToLocation(p1.Location, $"{firstHalf}but couldn't find anything of value.");
                }
                else
                {
                    GameEngine.SayToLocation(p1.Location, $"{firstHalf}but couldn't find anything of value so {p1.Genderize("he", "she", "it")} buries {p2.Name}.");
                    GameEngine.Players.Remove(p2);
                }
            }
            else if (!p1.IsAlive)
            {
                p1.Notify($" * You died before you could search {p2.Name}'s p2.");
            }
            else if (p2.IsAlive)
            {
                p1.Notify($" * {p2.Name} is not dead and cannot be searched for items.");
            }
            else if (p1.Location != p2.Location)
            {
                p1.Notify($" * {p2.Name} is not anywhere nearby.");
            }
        }
Beispiel #23
0
        protected bool IsPlayerReallyDefeated()
        {
            Item resurrectItem = GetItem(ItemType.HolyAnkh);

            if (resurrectItem != null)
            {
                RemoveItem(resurrectItem);
                GameEngine.SayToLocation(Location, $"{this.Name}'s Holy Ankh shatters as life energy flows back into {Genderize("him", "her", "it")}!");
                this.Refresh();
                return(false);
            }
            else if (HasFlag(QuestFlags.StoryCritical))
            {
                GameEngine.SayToLocation(Location, $"{this.Name} struggles to survive!");
                this.HP = 1;
                return(false);
            }
            return(true);
        }
        private static void DoProdWater(Player player, Location location)
        {
            if (player == null)
            {
                throw new ArgumentNullException($"Error: LocationAction DoProdWater null player.");
            }
            if (location == null)
            {
                throw new ArgumentNullException($"Error: LocationAction DoProdWater null location.");
            }

            if (player.IsAlive && player.Location == location && player.HasItem(ItemType.Stick))
            {
                GameEngine.SayToLocation(location, $"{player.Name} prods the water with a crook...");
                if (!player.HasFlag(QuestFlags.ProddedCloths))
                {
                    player.AddFlag(QuestFlags.ProddedCloths);
                    player.Notify("  *  GET! You found yourself some new clothes!");
                    GameEngine.SayToLocation(location, $"{player.Name} picks up bits of clothing from the putrid water.");
                    Armor newArmor = (Armor)Prefabs.NewItem(ItemType.Cloth);
                    newArmor.AddSocket();
                    player.AddItem(newArmor);
                }
                else if (!player.HasFlag(QuestFlags.ProddedRustSword))
                {
                    player.AddFlag(QuestFlags.ProddedRustSword);
                    player.Notify("  *  GET! You found yourself a rusty sword!");
                    GameEngine.SayToLocation(location, $"{player.Name} picks up a broken, rusty sword from the putrid water.");
                    Weapon newWeapon = (Weapon)Prefabs.NewItem(ItemType.RustySword);
                    newWeapon.AddSocket();
                    player.AddItem(newWeapon);
                }
                else
                {
                    GameEngine.SayToLocation(location, $"...but gets distracted by {player.Genderize("his handsome", "her beautiful", "its mesmerizing")} reflection.");
                }
            }
            else
            {
                GameEngine.SayToLocation(player.Location, $"{player.Name} was about to prod the water with a stick but didn't succeed...");
            }
        }
Beispiel #25
0
        public static void SayToAdjacent(Location location, string text)
        {
            if (location == null)
            {
                throw new ArgumentNullException("Cannot SayToAdjacent to a null location");
            }
            if (text == null)
            {
                throw new ArgumentNullException("Cannot SayToAdjacent with a null string");
            }
            if (text.Length == 0)
            {
                throw new ArgumentException("Cannot SayToAdjacent with empty string");
            }

            foreach (LocationConnector nearby in location.Connections.Values)
            {
                GameEngine.SayToLocation(nearby.Destination, text);
            }
        }
Beispiel #26
0
        public static void Chat(Player player, string text = "")
        {
            if (player == null)
            {
                throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null player");
            }
            if (text == null)
            {
                text = "";
            }
            if (text.Length == 0)
            {
                text = "I like swords!";
            }

            if (player.IsAlive)
            {
                text = TextUtils.CurateDialogue(text);
                GameEngine.SayToLocation(player.Location, $"{player.Name} says, \"{text}\"");
            }
        }
Beispiel #27
0
        public static void SayIdleGuardWords(Player player)
        {
            switch (new Random().Next(4))
            {
            case 0:
                GameEngine.SayToLocation(player.Location, $"{player.Name} says, \"I used to be an adventurer like you. Then I took an arrow in the knee...\"");
                break;

            case 1:
                GameEngine.SayToLocation(player.Location, $"{player.Name} says, \"Let me guess... someone stole your sweetroll.\"");
                break;

            case 2:
                GameEngine.SayToLocation(player.Location, $"{player.Name} says, \"No lollygaggin'.\"");
                break;

            case 3:
                GameEngine.SayToLocation(player.Location, $"{player.Name} says, \"I'd be a lot warmer and a lot happier with a bellyful of mead...\"");
                break;
            }
        }
 public void AddItem(Item item)
 {
     if (HasItems(item.Template) >= 5)
     {
         GameEngine.SayToLocation(Location, $"{this.Name} realizes {Genderize("he", "she", "it")} has too many {item}s and drops one on the ground.");
         Location.AddItem(item);
     }
     else
     {
         if (item is Weapon)
         {
             Weapon newWeapon = (Weapon)item;
             if (newWeapon.AverageDamage > Weapon.AverageDamage)
             {
                 Equip(newWeapon);
             }
             else
             {
                 Inventory.AddItem(item);
             }
         }
         else if (item is Armor)
         {
             Armor newArmor = (Armor)item;
             if (newArmor.AverageDefense > Armor.AverageDefense)
             {
                 Equip(newArmor);
             }
             else
             {
                 Inventory.AddItem(item);
             }
         }
         else
         {
             Inventory.AddItem(item);
         }
     }
 }
Beispiel #29
0
        public static Player NewPlayer(string playerName, Gender gender, Location location = null, GameClient client = null)
        {
            if (playerName == null)
            {
                throw new ArgumentNullException("Error: Player name string null at Prefabs.NewPlayer player creation");
            }
            if (playerName.Length == 0)
            {
                throw new ArgumentNullException("Error: Player name set to blank at Prefabs.NewPlayer player creation");
            }
            if (playerName.Length < GameEngine.MinimumNameLength || playerName.Length > GameEngine.MaximumNameLength)
            {
                throw new ArgumentOutOfRangeException($"Error: Player.NewPlayer name length must be between {GameEngine.MinimumNameLength} and {GameEngine.MaximumNameLength} characters.");
            }
            if (location == null)
            {
                location = WorldMap.PlayerSpawnPoint;
            }
            // client null OK

            Player player = new Player(UnitType.PlayerCharacter, TextUtils.FormatName(playerName), 20, gender, Faction.Players, Race.Human, location: location);

            if (client != null)
            {
                player.AssignClient(client);
                client.AssignAvatar(player);
            }

            player.AddItem(ItemType.RabbitsFoot);
            GameEngine.AddPlayer(player);

            foreach (IPlayerModifiable playerMod in Plugins.PlayerMods)
            {
                player = playerMod.ModifyNewPlayer(player);
            }
            GameEngine.SayToLocation(location, $"{player.Name} appears!");

            return(player);
        }
Beispiel #30
0
        public static bool GuardHelpResponse(Player p1, Player p2, string speech, string speechLower)
        {
            if (speechLower.Contains("can you") || speechLower.Contains("help") || speechLower.Contains("come") || speechLower.Contains("follow"))
            {
                switch (rng.Next(3))
                {
                case 0:
                    GameEngine.SayToLocation(p1.Location, $"{p2.Name} shakes {p2.Genderize("his", "her", "it")} head, \"I must stay my post.\"");
                    break;

                case 1:
                    GameEngine.SayToLocation(p1.Location, $"{p2.Name} shakes {p2.Genderize("his", "her", "it")} head, \"I must obey my orders.\"");
                    break;

                case 2:
                    GameEngine.SayToLocation(p1.Location, $"{p2.Name} shakes {p2.Genderize("his", "her", "it")} head, \"I cannot.\"");
                    break;
                }
                return(true);
            }
            return(false);
        }