Exemple #1
0
        private static void UnlockDoor(User.User player, Door door)
        {
            if (!player.Player.InCombat) {
                List<string> message = new List<string>();
                Room room = Room.GetRoom(player.Player.Location);
                bool hasKey = false;
                if (!room.IsDark) {
                    if (door.Lockable) {
                        if (door.RequiresKey) {
                            //let's see if the player has the key in his inventory or a skeleton key (opens any door)
                            List<Items.Iitem> inventory = player.Player.Inventory.GetInventoryAsItemList();
                            List<Items.Iitem> keyList = inventory.Where(i => i.ItemType.ContainsKey(Items.ItemsType.KEY)).ToList();
                            Items.Ikey key = null;
                            foreach (Items.Iitem keys in keyList) {
                                key = keys as Items.Ikey;
                                if (key.DoorID == door.Id || key.SkeletonKey) {
                                    hasKey = true;
                                    break;
                                }
                            }
                        }
                        if (!door.Open && !door.Destroyed && ((door.RequiresKey && hasKey) || !door.RequiresKey)) {
                            door.Locked = false;
                            door.UpdateDoorStatus();
                            //I may end up putting these strings in the general collection and then each method just supplies the verb
                            message.Add(String.Format("You unlock {0} {1}.", GetArticle(door.Description[0]), door.Description));
                            message.Add(String.Format("{0} unlocks {1} {2}.", player.Player.FirstName, GetArticle(door.Description[0]), door.Description));
                        }
                        else if (door.Destroyed) {
                            message.Add("Why would you want to unlock something that is in pieces?");
                        }
                        else if (!hasKey) {
                            message.Add("You don't have the key to unlock this door.");
                        }
                        else {
                            message.Add("It can't be unlocked, the door is open.");
                        }
                    }
                    else {
                        message.Add("It can't be unlocked.");
                    }
                }
                else {
                    message.Add("You can't see anything! Let alone what you are trying to unlock.");
                }

                player.MessageHandler(message[0]);
                if (message.Count > 1) {
                    room.InformPlayersInRoom(message[1], new List<string>(new string[] { player.UserID }));
                }
            }
            else {
                player.MessageHandler("You are in the middle of combat there are more pressing matters at hand than unlocking something.");
            }
        }
Exemple #2
0
        private static void OpenDoor(User.User player, Door door)
        {
            if (!player.Player.InCombat) {
                List<string> message = new List<string>();
                Room room = Room.GetRoom(player.Player.Location);
                if (!room.IsDark) {
                    if (door.Openable) {
                        if (!door.Open && !door.Locked && !door.Destroyed) {
                            door.Open = true;
                            door.UpdateDoorStatus();
                            message.Add(String.Format("You open {0} {1}.", GetArticle(door.Description[0]), door.Description));
                            message.Add(String.Format("{0} opens {1} {2}.", player.Player.FirstName, GetArticle(door.Description[0]), door.Description));
                        }
                        else if (door.Open && !door.Destroyed) {
                            message.Add("It's already open.");
                        }
                        else if (door.Locked && !door.Destroyed) {
                            message.Add("You can't open it because it is locked.");
                        }
                        else if (door.Destroyed) {
                            message.Add("It's more than open it's in pieces!");
                        }
                    }
                    else {
                        message.Add("It can't be opened.");
                    }
                }
                else {
                    message.Add("You can't see anything! Let alone what you are trying to open.");
                }

                player.MessageHandler(message[0]);
                if (message.Count > 1) {
                    room.InformPlayersInRoom(message[1], new List<string>(new string[] { player.UserID }));
                }
            }
            else {
                player.MessageHandler("You are in the middle of combat, there are more pressing matters at hand than opening something.");
            }
        }
Exemple #3
0
 private static void OpenADoor(Door door)
 {
     door.Open = true;
     door.UpdateDoorStatus();
 }
Exemple #4
0
        private static void CloseDoor(User.User player, Door door)
        {
            if (!player.Player.InCombat) {
                Room room = Room.GetRoom(player.Player.Location);
                List<string> message = new List<string>();
                if (!room.IsDark) {
                    if (door.Openable) {
                        if (door.Open && !door.Destroyed) {
                            door.Open = false;
                            door.UpdateDoorStatus();
                            //I may end up putting these strings in the general collection and then each method just supplies the verb
                            message.Add(String.Format("You close {0} {1}.", GetArticle(door.Description[0]), door.Description));
                            message.Add(String.Format("{0} closes {1} {2}.", player.Player.FirstName, GetArticle(door.Description[0]), door.Description));
                        }
                        else if (door.Destroyed) {
                            message.Add("You can't close it because it is in pieces!");
                        }
                        else {
                            message.Add("It's already closed.");
                        }
                    }
                    else {
                        message.Add("It can't be closed.");
                    }
                }
                else {
                    message.Add("You can't see anything! Let alone what you are trying to close.");
                }

                player.MessageHandler(message[0]);
                if (message.Count > 1) {
                    room.InformPlayersInRoom(message[1], new List<string>(new string[] { player.UserID }));
                }
            }
            else {
                player.MessageHandler("You are in the middle of combat, there are more pressing matters at hand than closing something.");
            }
        }
Exemple #5
0
 private static void CloseADoor(Door door)
 {
     door.Open = false;
     door.UpdateDoorStatus();
 }
Exemple #6
0
 private static double CalculateDefense(Door door)
 {
     //TODO:some doors may have some resistance to damage add that here
     double result = 0.0;
     return result;
 }