Пример #1
0
 public Room()
 {
     Contents = new Inventory();
     Buffs = new Buff();
     Description = "A blank, empty room.";
     ExtraDescript = "There's seriously nothing here. It's just a square room with ";
     ExtraDescript += "white walls. Where is that light even coming from? How do you ";
     ExtraDescript += "get out!?";
 }
Пример #2
0
        public string Drop(string _text, Inventory _playerInventory)
        {
            string result = "You cannot drop that.";

            for (int i = 0; i < _playerInventory.Count; i++)
            {
                if (_playerInventory[i].Name.ToLower() == _text.ToLower())
                {
                    items.Add(_playerInventory[i]);
                    _playerInventory.RemoveAt(i);

                    result = "You drop the " + _text + ".";
                    return result;
                }
            }

            return result;
        }
Пример #3
0
        public string Take(List<Token> _tokens, Inventory _playerInventory)
        {
            string result = "You cannot take that.";
            int tokenOffset = 0;

            if (_tokens.Count >= 2) //Make sure the given tokens are valid
            {
                while (_tokens[tokenOffset].Text.ToLower() != "take")
                {
                    tokenOffset++;
                }
                string targetName = _tokens[tokenOffset + 1].Text;
                List<string> targetAdjectives = _tokens[tokenOffset + 1].Adjectives;
                int bestMatch = 0;
                int bestMatchIndex = -1;
                for (int i = 0; i < items.Count; i++)
                {
                    int matchCount = 0;
                    //If the name is a match
                    if (items[i].Name.ToLower() == targetName.ToLower() && !(items[i] is Monster))
                    {
                        matchCount++;
                        if (items[i].Adjectives.Count > 0 && targetAdjectives.Count > 0)
                        {
                            foreach (string adjectiveA in items[i].Adjectives)
                            {
                                foreach (string adjectiveB in targetAdjectives)
                                {
                                    if (adjectiveA.ToLower() == adjectiveB.ToLower())
                                    {
                                        matchCount++;
                                    }
                                }
                            }
                        }
                        if (matchCount > bestMatch)
                        {
                            bestMatchIndex = i;
                        }
                    }
                }

                if (bestMatchIndex != -1)
                {
                    result = "You take the " + items[bestMatchIndex].GetFullName() + ".";
                    _playerInventory.Add(items[bestMatchIndex]);
                    items.RemoveAt(bestMatchIndex);
                    return result;
                }
            }
            return result;
        }
Пример #4
0
        //Avoid using this one.
        public string Take(string _text, Inventory _playerInventory)
        {
            string result = "You cannot take that.";

            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].Name.ToLower() == _text.ToLower() && !(items[i] is Monster))
                {
                    _playerInventory.Add(items[i]);
                    items.RemoveAt(i);

                    result = "You take the " + _text + ".";
                    return result;
                }
            }

            return result;
        }
Пример #5
0
 public Player()
 {
     Health = 100;
     Adjectives = null;
     Buffs = new Buff(10, 10, 10, 10, 10, 10);
     Contents = new Inventory();
 }
Пример #6
0
        public void DrawInventory(Inventory _inventory, int _lines)
        {
            string title = "INVENTORY [" + _inventory.Weight + "/" + _inventory.MaxWeight + "lbs] [" + _inventory.Count + "/" + _inventory.Capacity + "]";

            DrawBox(1, 1, Width - 2, _lines + 2, title, true);
            int i = 0;
            int column_width = 20;
            int column = 0;

            /*while (i < _lines && i < _inventory.Count)
            {
                Console.SetCursorPosition(3, 2 + i);
                _inventory[i].Write();
                i++;
            }*/

            while ((column + 1) * column_width < Width)
            {
                while (i < (column + 1) * _lines && i < _inventory.Count)
                {
                    if (column > 0)
                    {
                        Console.SetCursorPosition(column * column_width, 1);
                        //Console.Write("╤");
                        for (int j = 1; j <= _lines; j++)
                        {
                            Console.SetCursorPosition(column * column_width, 1 + j);
                            Console.Write("│");
                        }
                        Console.SetCursorPosition(column * column_width, 2 + _lines);
                        Console.Write("╧");
                    }

                    Console.SetCursorPosition(3 + (column * column_width), (i - column * _lines) + 2);
                    _inventory[i].Write();
                    //Console.Write(column);
                    i++;
                }
                column++;
            }
        }