Beispiel #1
0
        private static string GetExitDescription(Exits exit, Room room)
        {
            //there's a lot of sentence
            string[] vowel = new string[] { "a", "e", "i", "o", "u" };

            if (room.IsDark) {
                exit.Description = "something";
            }

            if (string.IsNullOrEmpty(exit.Description)) {
                exit.Description = exit.availableExits[exit.Direction.CamelCaseWord()].Title.ToLower();
            }

            if (exit.Description.Contains("that leads to")) {
                exit.Description += exit.availableExits[exit.Direction.CamelCaseWord()].Title.ToLower();
            }

            string directionCorrected = "To the " + exit.Direction.CamelCaseWord().FontColor(Utils.FontForeColor.CYAN) + " there is ";

            if (String.Compare(exit.Direction, "up", true) == 0 || String.Compare(exit.Direction, "down", true) == 0) {
                if (!room.IsDark) {
                    directionCorrected = exit.Description.UppercaseFirstWordInString();
                }
                else {
                    directionCorrected = "something";
                }

                directionCorrected += " leads " + exit.Direction.CamelCaseWord().FontColor(Utils.FontForeColor.CYAN) + " towards ";

                if (!room.IsDark) {
                    exit.Description = "somewhere";
                }
                else {
                    exit.Description = exit.availableExits[exit.Direction.CamelCaseWord()].Title.ToLower();
                }
            }

            if (!exit.Description.Contains("somewhere") && vowel.Contains(exit.Description[0].ToString())) {
                directionCorrected += "an ";
            }
            else if (!exit.Description.Contains("somewhere") && exit.Description != "something") {
                directionCorrected += "a ";
            }

            return (directionCorrected + exit.Description + ".");
        }
Beispiel #2
0
        private static string FindAnNpc(List<string> commands, Room room, out bool foundIt)
        {
            foundIt = false;
            string message = null;

            List<string> npcList = room.GetObjectsInRoom(Room.RoomObjects.Npcs);

            MongoCollection npcCollection = MongoUtils.MongoData.GetCollection("Characters", "NPCCharacters");
            IMongoQuery query = null;

            foreach (string id in npcList) {
                query = Query.EQ("_id", ObjectId.Parse(id));
                BsonDocument result = npcCollection.FindOneAs<BsonDocument>(query);

                string tempName = result["FirstName"].AsString + " " + result["LastName"].AsString;

                if (commands[2].ToLower().Contains(result["FirstName"].AsString.ToLower()) || commands[2].ToLower().Contains(result["LastName"].AsString.ToLower())) {

                    string[] position = commands[0].Split('.'); //we are spearating based on using the decimal operator after the name of the npc/item
                    if (position.Count() > 1) {
                        //ok so the player specified a specific NPC in the room list to examine and not just the first to match
                        int pos;
                        int.TryParse(position[position.Count() - 1], out pos);
                        if (pos != 0) {
                            string idToParse = GetObjectInPosition(pos, commands[2], room.Id);

                            query = Query.EQ("_id", ObjectId.Parse(idToParse));
                            result = npcCollection.FindOneAs<BsonDocument>(query);
                        }
                    }

                    if (result != null) {
                        message = result["Description"].AsString;
                        foundIt = true;
                        break;
                    }
                }
            }

            return message;
        }
Beispiel #3
0
        private static string FindAPlayer(List<string> commands, Room room, out bool foundIt)
        {
            foundIt = false;
            string message = null;
            List<string> chars = room.GetObjectsInRoom(Room.RoomObjects.Players);
            foreach (string id in chars) {
                Character.Character playerChar = MySockets.Server.GetAUser(id).Player as Character.Character;
                string tempName = playerChar.FirstName + " " + playerChar.LastName;
                if (commands[2].ToLower().Contains(playerChar.FirstName.ToLower()) || commands[2].ToLower().Contains(playerChar.LastName.ToLower())) {
                    message = playerChar.Examine();
                    foundIt = true;
                    break;
                }
            }

            return message;
        }
Beispiel #4
0
        private static string DisplayItemsInRoom(Room room)
        {
            StringBuilder sb = new StringBuilder();

            List<string> itemsInRoom = room.GetObjectsInRoom(Room.RoomObjects.Items);

            Dictionary<string, int> itemGroups = new Dictionary<string, int>();

            if (!room.IsDark) {
                foreach (string id in itemsInRoom) {

                    Items.Iitem item = Items.Items.GetByID(id);
                    if (item != null) {
                       // Items.Icontainer containerItem = item as Items.Icontainer;
                       // Items.Iedible edible = item as Items.Iedible;

                        if (item.ItemType.ContainsKey(Items.ItemsType.CONTAINER)) {
                            Items.Icontainer containerItem = item as Items.Icontainer;
                            if (!itemGroups.ContainsKey(item.Name + "$" + (containerItem.IsOpenable == true ? (containerItem.Opened ? "[Opened]" : "[Closed]") : "[container]"))) {
                                itemGroups.Add(item.Name + "$" + (containerItem.IsOpenable == true ? (containerItem.Opened ? "[Opened]" : "[Closed]") : "[container]"), 1);
                            }
                            else {
                                itemGroups[item.Name + "$" + (containerItem.IsOpenable == true ? (containerItem.Opened ? "[Opened]" : "[Closed]") : "[container]")] += 1;
                            }
                        }
                        else if (item.ItemType.ContainsKey(Items.ItemsType.DRINKABLE) || item.ItemType.ContainsKey(Items.ItemsType.EDIBLE)) {
                            if (!itemGroups.ContainsKey(item.Name)) {
                                itemGroups.Add(item.Name, 1);
                            }
                            else {
                                itemGroups[item.Name] += 1;
                            }
                        }
                        else {
                            if (!itemGroups.ContainsKey(item.Name + "$" + item.CurrentCondition)) {
                                itemGroups.Add(item.Name + "$" + item.CurrentCondition, 1);
                            }
                            else {
                                itemGroups[item.Name + "$" + item.CurrentCondition] += 1;
                            }
                        }
                    }
                }

                foreach (KeyValuePair<string, int> pair in itemGroups) {
                    string[] temp = pair.Key.Split('$');
                    sb.Append(temp[0] + " is laying here");
                    if (temp.Count() > 1 && !string.Equals(temp[1], "NONE", StringComparison.InvariantCultureIgnoreCase)) {
                        if (temp[1].Contains("[Opened]") || temp[1].Contains("[Closed]") || temp[1].Contains("[container]")) {
                            sb.AppendLine(". " + (temp[1] == "[container]" ? "" : temp[1]) + (pair.Value > 1 ? (" [x" + pair.Value + "]") : ""));
                        }
                        else {
                            sb.AppendLine(" in " + temp[1].Replace("_", " ").ToLower() + " condition." + (pair.Value > 1 ? ("[x" + pair.Value + "]") : ""));
                        }
                    }
                    else {
                        sb.AppendLine(".");
                    }
                }
            }
            else {
                int count = 0;
                foreach (string id in itemsInRoom) {
                    Items.Iitem item = Items.Items.GetByID(id);
                    if (item != null) {
                        count++;
                    }
                }

                if (count == 1) {
                    sb.AppendLine("Something is laying here.");
                }
                else if (count > 1) {
                    sb.AppendLine("Somethings are laying here.");
                }
            }

            return sb.ToString();
        }
Beispiel #5
0
        private static string FindAnItem(List<string> commands, User.User player, Room room, out bool foundIt)
        {
            foundIt = false;
            string message = null;

            List<string> itemsInRoom = room.GetObjectsInRoom(Room.RoomObjects.Items);

            foreach (string id in itemsInRoom) {
                Items.Iitem item = Items.ItemFactory.CreateItem(ObjectId.Parse(id));
                if (commands[2].ToLower().Contains(item.Name.ToLower())) {
                    message = item.Examine();
                    foundIt = true;
                    break;
                }
            }

            if (!foundIt) { //not in room check inventory
                List<Items.Iitem> inventory = player.Player.Inventory.GetInventoryAsItemList();
                foreach (Items.Iitem item in inventory) {
                    if (commands[2].ToLower().Contains(item.Name.ToLower())) {
                        message = item.Examine();
                        foundIt = true;
                        break;
                    }
                }
            }

            if (!foundIt) { //check equipment
                Dictionary<Items.Wearable, Items.Iitem> equipment = player.Player.Equipment.GetEquipment();
                foreach (Items.Iitem item in equipment.Values) {
                    if (commands[2].ToLower().Contains(item.Name.ToLower())) {
                        message = item.Examine();
                        foundIt = true;
                        break;
                    }
                }
            }

            return message;
        }
Beispiel #6
0
        //called from the LOOK command
        private static string DisplayPlayersInRoom(Room room, string ignoreId)
        {
            StringBuilder sb = new StringBuilder();

            if (!room.IsDark) {
                foreach (string id in room.GetObjectsInRoom(Room.RoomObjects.Players)) {
                    if (id != ignoreId) {
                        User.User otherUser = MySockets.Server.GetAUser(id);
                        if (otherUser != null && otherUser.CurrentState == User.User.UserState.TALKING) {
                            if (otherUser.Player.ActionState != CharacterEnums.CharacterActionState.Hiding && otherUser.Player.ActionState != CharacterEnums.CharacterActionState.Sneaking){  //(string.IsNullOrEmpty(PassesHideCheck(otherUser, ignoreId, out spot))) { //player should do a spot check this should not be a given
                                sb.AppendLine(otherUser.Player.FirstName + " is " + otherUser.Player.StanceState.ToString().ToLower() + " here.");
                            }
                        }
                    }
                }
                Dictionary<string, int> npcGroups = new Dictionary<string, int>();

                foreach (string id in room.GetObjectsInRoom(Room.RoomObjects.Npcs)) {
                    //MongoCollection npcs = MongoUtils.MongoData.GetCollection("Characters", "NPCCharacters"); //wtf is this here for? doesn't the for loop get all the NPC's?
                   // IMongoQuery query = Query.EQ("_id", ObjectId.Parse(id));
                   // BsonDocument npc = npcs.FindOneAs<BsonDocument>(query);

                    var npc = Character.NPCUtils.GetAnNPCByID(id);

                    //let's create groups for easy display
                    //if (!npcGroups.ContainsKey(npc.["FirstName"].AsString + "$" + npc["LastName"].AsString + "$" + npc["StanceState"])) {
                    //    npcGroups.Add(npc["FirstName"].AsString + "$" + npc["LastName"].AsString + "$" + npc["StanceState"], 1);
                    //}
                    //else {
                    //    npcGroups[npc["FirstName"].AsString + "$" + npc["LastName"].AsString + "$" + npc["StanceState"]] += 1;
                    //}

                    if (!npcGroups.ContainsKey(npc.FirstName + "$" + npc.LastName + "$" + npc.StanceState)) {
                        npcGroups.Add(npc.FirstName + "$" + npc.LastName + "$" + npc.StanceState, 1);
                    }
                    else {
                        npcGroups[npc.FirstName + "$" + npc.LastName + "$" + npc.StanceState] += 1;
                    }
                }

                foreach (KeyValuePair<string, int> pair in npcGroups) {
                    string[] temp = pair.Key.Split('$');
                    sb.AppendLine(temp[0] + " is " + temp[2].Replace("_", " ").ToLower() + " here. " + (pair.Value > 1 ? ("[x" + pair.Value + "]") : ""));
                }
            }
            else {
                int count = 0;
                foreach (string id in room.GetObjectsInRoom(Room.RoomObjects.Players)) {
                    if (id != ignoreId) {
                        User.User otherUser = MySockets.Server.GetAUser(id);
                        if (otherUser != null && otherUser.CurrentState == User.User.UserState.TALKING) {
                            if (otherUser.Player.ActionState != CharacterEnums.CharacterActionState.Hiding && otherUser.Player.ActionState != CharacterEnums.CharacterActionState.Sneaking) {  //player should do a spot check this should not be a given
                                count++;
                            }
                        }
                    }
                }
                count += room.GetObjectsInRoom(Room.RoomObjects.Npcs).Count;

                if (count == 1) {
                    sb.AppendLine("A presence is here.");
                }
                else if (count > 1) {
                    sb.AppendLine("Several presences are here.");
                }
            }

            return sb.ToString();
        }
Beispiel #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            room = new Room(pbCanvas.Width, pbCanvas.Height);
            player = new Player(pbCanvas.Width/2, pbCanvas.Height/2, pbCanvas.Width, pbCanvas.Height);

            enemies.Add(new Enemy(10, 10, pbCanvas.Width, pbCanvas.Height));

            enemyTimer.Interval = enemyInterval;

            lblScoreName.Text = strings.strings[0];
            lblPaused.Text = "";
            lblRoomsName.Text = strings.strings[2];
            btnStart.Text = strings.strings[4];

            coinSound = new SoundPlayer(Resources.coin);
        }
Beispiel #8
0
        /// <summary>
        /// Informs all parties of the outcome of the combat round.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="enemy"></param>
        /// <param name="room"></param>
        /// <param name="damage"></param>
        /// <param name="defense"></param>
        /// <param name="attack"></param>
        private static void SendRoundOutcomeMessage(User.User player, User.User enemy, Room room, double damage, double defense, double attack)
        {
            //TODO: Get the message based weapon type/special weapon (blunt, blade, axe, pole, etc.)
            //Get the weapon type and append it to the "Hit" or "Miss" type when getting the message
            //ex: HitSword, HitClub, MissAxe, MissUnarmed could even get really specific HitRustyShortSword, MissLegendaryDaggerOfBlindness
            //Make a method to figure out the type by having a lookup table in the DB that points to a weapon type string
            if (damage < 0) {
                player.MessageHandler(ParseMessage(GetMessage("Combat", "Hit", MessageType.Self), player, enemy, damage, defense, attack));
                enemy.MessageHandler(ParseMessage(GetMessage("Combat", "Hit", MessageType.Target), player, enemy, damage, defense, attack));
                string roomMessage = ParseMessage(GetMessage("Combat", "Hit", MessageType.Room), player, enemy, damage, defense, attack);

                room.InformPlayersInRoom(roomMessage, new List<string>(new string[] { player.UserID, enemy.UserID }));
                enemy.Player.ApplyEffectOnAttribute("Hitpoints", damage);

                Character.NPC npc = enemy.Player as Character.NPC;
                if (npc != null) {
                    npc.IncreaseXPReward(player.UserID, (damage * -1.0));
                }
            }
            else {
                player.MessageHandler(ParseMessage(GetMessage("Combat", "Miss", MessageType.Self), player, enemy, damage, defense, attack));
                enemy.MessageHandler(ParseMessage(GetMessage("Combat", "Miss", MessageType.Target), player, enemy, damage, defense, attack));
                string roomMessage = ParseMessage(GetMessage("Combat", "Miss", MessageType.Room), player, enemy, damage, defense, attack);
                room.InformPlayersInRoom(roomMessage, new List<string>(new string[] { player.UserID, enemy.UserID }));
            }
        }
Beispiel #9
0
		private async void FillMap(Room room) {
           await Task.Run(() => {
                AI.PathFinding.TreeNode startNode = new AI.PathFinding.TreeNode(room);
                startNode.Parent = startNode;
                AI.PathFinding.TreeTraverser traverser = new AI.PathFinding.TreeTraverser(startNode, "");
                Stack<AI.PathFinding.TreeNode> traversedTree = traverser.GetTraversedNodes();

                Crainiate.Diagramming.Model model = new Model();

                PointF position = new PointF(200, 400);

                Table roomNode = new Table();
                roomNode.BackColor = Color.Green;


                foreach (AI.PathFinding.TreeNode treeNode in traversedTree.Reverse()) {
                    if (model.Shapes.ContainsKey(treeNode.ID.ToString())) {
                        position = model.Shapes[treeNode.ID.ToString()].Location;
                    }

                    roomNode.Location = position;

                    roomNode.Heading = treeNode.ID.ToString();
                    roomNode.SubHeading = treeNode.Title;

                    if (!model.Shapes.ContainsKey(treeNode.ID.ToString())) {
                        model.Shapes.Add(treeNode.ID.ToString(), roomNode);
                    }

                    Arrow arrow = new Arrow();
                    arrow.DrawBackground = false;
                    arrow.Inset = 0;

                    foreach (var adjNode in treeNode.AdjacentNodes) {
                        RoomExits direction = (RoomExits)Enum.Parse(typeof(RoomExits), adjNode.Key);

                        Table adjShape = new Table();
                        adjShape.Heading = adjNode.Value.ID.ToString();
                        adjShape.SubHeading = adjNode.Value.Title;
                        adjShape.BackColor = Color.LightBlue;

                        switch (direction) {
                            case RoomExits.North:
                                adjShape.Location = new PointF(position.X, position.Y - 100);
                                break;
                            case RoomExits.South:
                                adjShape.Location = new PointF(position.X, position.Y + 100);
                                break;
                            case RoomExits.East:
                                adjShape.Location = new PointF(position.X + 150, position.Y);
                                break;
                            case RoomExits.West:
                                adjShape.Location = new PointF(position.X - 150, position.Y);
                                break;
                            case RoomExits.Up:
                                adjShape.Location = new PointF(position.X - 150, position.Y - 100);
                                break;
                            case RoomExits.Down:
                                adjShape.Location = new PointF(position.X + 150, position.Y + 100);
                                break;
                        }

                        if (!model.Shapes.ContainsKey(adjNode.Value.ID.ToString())) {
                            model.Shapes.Add(adjNode.Value.ID.ToString(), adjShape);
                        }
                        Connector line = new Connector(model.Shapes[treeNode.ID.ToString()], model.Shapes[adjNode.Value.ID.ToString()]);
                        line.End.Marker = arrow;

                        model.Lines.Add(model.Lines.CreateKey(), line);

                        adjShape = new Table();
                    }

                    roomNode = new Table();
                }

                mapDiagram.SetModel(model);
                mapDiagram.Invoke((MethodInvoker)delegate { mapDiagram.Refresh(); });
            });
		}
Beispiel #10
0
        private static Items.Iiluminate FindLightInEquipment(List <string> commands, User.User player, Rooms.Room room)
        {
            Items.Iitem lightItem = null;
            if (commands.Count > 0)
            {
                string itemName = GetItemName(commands, "").ToString();
                //let's see if player has a lightsource equipped
                foreach (Items.Iitem item in player.Player.Equipment.GetEquipment().Values)
                {
                    if (item.WornOn == Items.Wearable.WIELD_LEFT || item.WornOn == Items.Wearable.WIELD_RIGHT)
                    {
                        Items.Iiluminate temp = item as Items.Iiluminate;
                        if (temp != null && temp.isLightable)
                        {
                            lightItem = item;
                            break;
                        }
                    }
                }
            }
            else   //let's be smart and figure out what lightSource he wants activated, first come first serve otherwise
            {
                foreach (Items.Iitem item in player.Player.Equipment.GetEquipment().Values)
                {
                    Items.Iiluminate lightsource = item as Items.Iiluminate;
                    if (lightsource != null && lightsource.isLightable)
                    {
                        lightItem = item;
                        break;
                    }
                }
                if (lightItem == null)   //not in players equipment let's check the room
                {
                    foreach (string itemId in room.GetObjectsInRoom(Room.RoomObjects.Items))
                    {
                        lightItem = Items.Items.GetByID(itemId);
                        Items.Iiluminate lightsource = lightItem as Items.Iiluminate;
                        if (lightsource != null && lightsource.isLightable)
                        {
                            break;
                        }
                        //if it's a container and it's open see if it has a lightsource inside
                        if (lightItem.ItemType.ContainsKey(Items.ItemsType.CONTAINER))
                        {
                            Items.Icontainer containerItem = lightItem as Items.Icontainer;
                            if (containerItem.Opened)
                            {
                                foreach (string id in containerItem.GetContents())
                                {
                                    lightItem   = Items.Items.GetByID(itemId);
                                    lightsource = lightItem as Items.Iiluminate;
                                    if (lightsource != null && lightsource.isLightable)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(lightItem as Items.Iiluminate);
        }