Exemple #1
0
 internal override bool TakeInput(GameClient invoker, string command, string rawCommand, string arguments)
 {
     if (invoker.shell != null && invoker.shell.location != null && invoker.shell.location.HasComponent(Text.CompRoom) && invoker.shell.HasComponent(Text.CompMobile))
     {
         MobileComponent mob = (MobileComponent)invoker.shell.GetComponent(Text.CompMobile);
         if (mob.CanMove())
         {
             string tmp = command;
             if (Text.shortExits.ContainsKey(tmp))
             {
                 tmp = Text.shortExits[tmp];
             }
             RoomComponent room = (RoomComponent)invoker.shell.location.GetComponent(Text.CompRoom);
             if (room.exits.ContainsKey(tmp))
             {
                 GameObject destination = (GameObject)Game.Objects.Get(room.exits[tmp]);
                 if (destination == null)
                 {
                     invoker.WriteLine($"Strangely, there is nothing to the {tmp}. You stay where you are.");
                 }
                 else
                 {
                     GameObject loc = invoker.shell.location;
                     invoker.WriteLine($"You depart to the {tmp}.");
                     destination.ShowToContents($"{mob.GetString(Text.FieldEnterMessage).Replace("$DIR", tmp)}");
                     invoker.shell.Move(destination);
                     loc.ShowToContents($"{mob.GetString(Text.FieldLeaveMessage).Replace("$DIR", tmp)}");
                 }
                 return(true);
             }
         }
     }
     return(InvokeCommand(invoker, command, arguments));
 }
Exemple #2
0
 internal List <string> GetEquippableSlots()
 {
     if (parent.HasComponent(Text.CompMobile))
     {
         MobileComponent mob = (MobileComponent)parent.GetComponent(Text.CompMobile);
         return(mob.equipmentSlots);
     }
     return(new List <string>()
     {
         "body"
     });
 }
Exemple #3
0
 internal List <string> GetWieldableSlots()
 {
     if (parent.HasComponent(Text.CompMobile))
     {
         MobileComponent mob = (MobileComponent)parent.GetComponent(Text.CompMobile);
         return(mob.graspers);
     }
     return(new List <string>()
     {
         "hands"
     });
 }
Exemple #4
0
 internal void CmdTest(GameObject invoker, CommandData cmd)
 {
     if (invoker.HasComponent(Text.CompMobile))
     {
         MobileComponent mob = (MobileComponent)invoker.GetComponent(Text.CompMobile);
         invoker.WriteLine($"Grasp:  {string.Join(", ", mob.graspers.ToArray())}");
         invoker.WriteLine($"Stance: {string.Join(", ", mob.stance.ToArray())}");
         invoker.WriteLine($"Strike: {string.Join(", ", mob.strikers.ToArray())}");
         invoker.WriteLine($"Equip:  {string.Join(", ", mob.equipmentSlots.ToArray())}");
         invoker.SendPrompt();
     }
     else
     {
         invoker.SendLine("You aren't a mob.");
     }
 }
        internal PlayerAccount CreateAccount(string userName, string passwordHash)
        {
            // Create the new, blank account.
            PlayerAccount acct = (PlayerAccount)CreateNewInstance(GetUnusedIndex(), false);

            acct.userName     = userName;
            acct.passwordHash = passwordHash;

            // Create the shell the client will be piloting around, saving data to, etc.
            GameObject gameObj = Modules.Templates.Instantiate("mob");

            gameObj.name    = Text.Capitalize(acct.userName);
            gameObj.gender  = Modules.Gender.GetByTerm(Text.GenderPlural);
            gameObj.aliases = new List <string>()
            {
                gameObj.name.ToLower()
            };
            VisibleComponent vis = (VisibleComponent)gameObj.GetComponent(Text.CompVisible);

            vis.SetValue(Text.FieldShortDesc, $"{gameObj.name}");
            vis.SetValue(Text.FieldRoomDesc, $"{gameObj.name} is here.");
            vis.SetValue(Text.FieldExaminedDesc, "and are completely uninteresting.");
            MobileComponent mob = (MobileComponent)gameObj.GetComponent(Text.CompMobile);

            mob.SetValue(Text.FieldEnterMessage, $"{gameObj.name} enters from the $DIR.");
            mob.SetValue(Text.FieldLeaveMessage, $"{gameObj.name} leaves to the $DIR.");
            mob.SetValue(Text.FieldDeathMessage, $"The corpse of {gameObj.name} lies here.");
            Game.Objects.QueueForUpdate(gameObj);

            acct.objectId = gameObj.id;

            // If the account DB is empty, give them admin roles.
            if (accounts.Count <= 0)
            {
                Debug.WriteLine($"No accounts found, giving admin roles to {acct.userName}.");
                acct.roles.Add(Modules.Roles.GetRole("builder"));
                acct.roles.Add(Modules.Roles.GetRole("administrator"));
            }

            // Finalize everything.
            accounts.Add(acct.userName, acct);
            AddDatabaseEntry(acct);
            return(acct);
        }
Exemple #6
0
        internal void ExaminedBy(GameObject viewer, bool fromInside)
        {
            string mainDesc = $"{Colours.Fg(Text.Capitalize(shortDescription),Colours.BoldWhite)}.";

            if (parent.HasComponent(Text.CompMobile))
            {
                string startingToken;
                string theyAre;
                string their;
                if (parent == viewer)
                {
                    startingToken = "You're";
                    theyAre       = "You're";
                    their         = "Your";
                }
                else
                {
                    startingToken = "That's";
                    theyAre       = $"{Text.Capitalize(parent.gender.He)} {parent.gender.Is}";
                    their         = Text.Capitalize(parent.gender.His);
                }

                MobileComponent mob = (MobileComponent)parent.GetComponent(Text.CompMobile);
                mainDesc = $"{startingToken} {mainDesc}\n{theyAre} a {mob.race}";
                if (viewer == parent)
                {
                    mainDesc += $". When people look at you, they see:\n{Text.Capitalize(parent.gender.He)} {parent.gender.Is} a {mob.race}";
                }
                if (examinedDescription == null || examinedDescription.Length <= 0)
                {
                    mainDesc += ".";
                }
                else if (examinedDescription[0] == '.' || examinedDescription[0] == '!' || examinedDescription[0] == '?')
                {
                    mainDesc += examinedDescription;
                }
                else
                {
                    mainDesc += $" {examinedDescription}";
                }

                List <string> clothing = parent.GetVisibleContents(viewer, false);
                if (clothing.Count > 0)
                {
                    mainDesc += $"\n{theyAre} carrying:";
                    foreach (string line in clothing)
                    {
                        mainDesc += $"\n{Text.Capitalize(line)}";
                    }
                }
                else
                {
                    mainDesc += $"\n{theyAre} completely naked.";
                }

                foreach (KeyValuePair <string, GameObject> bp in mob.limbs)
                {
                    if (bp.Value == null)
                    {
                        mainDesc += $"\n{their} {bp.Key} is missing!";
                    }
                    else
                    {
                        mainDesc += $"\n{their} {bp.Key} is healthy.";
                    }
                }
            }
            else
            {
                mainDesc += $"\n{Colours.Fg(examinedDescription, Colours.BoldBlack)}";
                if (parent.contents.Count > 0)
                {
                    List <string> roomAppearances = parent.GetVisibleContents(viewer, false);
                    if (roomAppearances.Count > 0)
                    {
                        mainDesc = $"{mainDesc}\n{string.Join(" ", roomAppearances.ToArray())}";
                    }
                }
            }

            if (parent.HasComponent(Text.CompRoom))
            {
                RoomComponent roomComp = (RoomComponent)parent.GetComponent(Text.CompRoom);
                mainDesc = $"{mainDesc}\n{Colours.Fg(roomComp.GetExitString(), Colours.BoldCyan)}";
            }

            if (parent.HasComponent(Text.CompPhysics))
            {
                PhysicsComponent phys = (PhysicsComponent)parent.GetComponent(Text.CompPhysics);
                mainDesc = $"{mainDesc}\n{phys.GetExaminedSummary(viewer)}";
            }

            viewer.WriteLine(mainDesc);
            viewer.SendPrompt();
        }
Exemple #7
0
        internal void CmdStrike(GameObject invoker, CommandData cmd)
        {
            GameObject targetObj = null;

            if (cmd.objTarget != null && cmd.objTarget != "")
            {
                targetObj = invoker.FindGameObjectNearby(cmd.objTarget);
            }
            if (targetObj == null)
            {
                invoker.WriteLine($"You cannot find '{cmd.objTarget}' nearby.");
                invoker.SendPrompt();
                return;
            }

            string     usingItem     = cmd.objWith;
            GameObject strikeWith    = null;
            GameObject strikeAgainst = null;

            if (invoker.HasComponent(Text.CompInventory))
            {
                InventoryComponent inv = (InventoryComponent)invoker.GetComponent(Text.CompInventory);
                if (usingItem == null || usingItem == "")
                {
                    foreach (string slot in inv.GetWieldableSlots())
                    {
                        if (inv.carrying.ContainsKey(slot))
                        {
                            usingItem = inv.carrying[slot].id.ToString();
                            break;
                        }
                    }
                }
                else if (inv.GetWieldableSlots().Contains(usingItem))
                {
                    if (inv.carrying.ContainsKey(usingItem))
                    {
                        usingItem = inv.carrying[usingItem].id.ToString();
                    }
                    else
                    {
                        invoker.WriteLine($"You are not holding anything in your {usingItem}!");
                        invoker.SendPrompt();
                        return;
                    }
                }
            }

            if (strikeWith == null && invoker.HasComponent(Text.CompMobile))
            {
                MobileComponent mob = (MobileComponent)invoker.GetComponent(Text.CompMobile);
                if ((usingItem == null || usingItem == "") && mob.strikers.Count > 0)
                {
                    usingItem = mob.strikers[Game.rand.Next(0, mob.strikers.Count)];
                }
                if (mob.strikers.Contains(usingItem))
                {
                    strikeWith = mob.limbs[usingItem];
                }
            }

            if (strikeWith == null)
            {
                GameObject prop = invoker.FindGameObjectInContents(usingItem);
                if (prop != null && invoker.HasComponent(Text.CompInventory))
                {
                    InventoryComponent inv = (InventoryComponent)invoker.GetComponent(Text.CompInventory);
                    if (inv.IsWielded(prop))
                    {
                        if (!prop.HasComponent(Text.CompPhysics))
                        {
                            invoker.SendLine($"You cannot use {prop.GetShort()} as a weapon.");
                            return;
                        }
                        strikeWith = prop;
                    }
                }
            }

            if (strikeWith == null)
            {
                invoker.WriteLine($"You are not holding '{usingItem}'.");
                invoker.SendPrompt();
                return;
            }

            if (targetObj.HasComponent(Text.CompMobile))
            {
                MobileComponent mob     = (MobileComponent)targetObj.GetComponent(Text.CompMobile);
                string          checkBp = cmd.objIn;
                if (checkBp == null || checkBp == "")
                {
                    checkBp = mob.GetWeightedRandomBodypart();
                }
                if (mob.limbs.ContainsKey(checkBp) && mob.limbs[checkBp] != null)
                {
                    strikeAgainst = mob.limbs[checkBp];
                }
                else
                {
                    invoker.WriteLine($"{Text.Capitalize(targetObj.GetShort())} is missing that bodypart!");
                    invoker.SendPrompt();
                    return;
                }
            }

            string strikeString          = $"{strikeWith.GetShort()}, {strikeAgainst.HandleImpact(invoker, strikeWith, 3.0)}";
            string firstPersonStrikeWith = strikeString;

            if (firstPersonStrikeWith.Substring(0, 2) == "a ")
            {
                firstPersonStrikeWith = firstPersonStrikeWith.Substring(2);
            }
            else if (firstPersonStrikeWith.Substring(0, 3) == "an ")
            {
                firstPersonStrikeWith = firstPersonStrikeWith.Substring(3);
            }
            if (strikeWith.HasComponent(Text.CompBodypart))
            {
                BodypartComponent body = (BodypartComponent)strikeWith.GetComponent(Text.CompBodypart);
                if (body.isNaturalWeapon)
                {
                    strikeString = $"{invoker.gender.His} {strikeString}";
                }
            }

            string bpString = $" in the {strikeAgainst.GetShort()}";

            invoker.ShowNearby(invoker, targetObj,
                               $"You strike {targetObj.GetShort()}{bpString} with your {firstPersonStrikeWith}!",
                               $"{Text.Capitalize(invoker.GetShort())} strikes you{bpString} with {strikeString}!",
                               $"{Text.Capitalize(invoker.GetShort())} strikes {targetObj.GetShort()}{bpString} with {strikeString}!"
                               );
        }