//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); }
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; }
//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; }
public void GenerateRandom(int _seed, List <Item> _itemsMaster, List <Weapon> _weaponsMaster, List <Monster> _monstersMaster) { Random RNG = new Random(_seed); Buffs = Buff.Randomized(RNG.Next(), 10); Description = "You enter a randomly generated room. "; ExtraDescript = "This room was generated at random, so there's not much of a description. Sorry."; int rt = RNG.Next(5); if (rt == 0) { Description = "This room is poorly lit. "; ExtraDescript = "The only source of light in the room is a faint glow off some green fungus, "; ExtraDescript += "but from what you can see it is roughly square, with a dirt floor and rough "; ExtraDescript += "stone brick walls. The room stinks of mildew and decay. "; } else if (rt == 1) { Description = "You are in a large, round room. "; ExtraDescript = "This room is large and circular. It is brightly lit by an ornate, gold chandelier in the center, "; ExtraDescript += "and you can see file gold and lapis lazuli inlays in the marble floor. "; ExtraDescript += "The walls are ornamented with masterful bas relief sculptures of wars long past. "; } else if (rt == 2) { Description = "You are now standing in water. "; ExtraDescript = "This room is small and irregular in shape, and you are standing in ankle-deep water. "; ExtraDescript += "The water is murky with scum floating on top, but you feel silt beneath your feet "; ExtraDescript += "with no indication of a solid floor. "; } else if (rt == 3) { Description = "This room is warm and has a sandy floor. "; ExtraDescript = "This room is long and rectangular, with smooth stone brick walls and a floor covered in "; ExtraDescript += "pale yellow sand. It is very warm in here, and you sweat a little as you look around. "; } else if (rt == 4) { Description = "You are in a dim, hot room. "; ExtraDescript = "This is less of a room than a cave. The walls are craggy reddish stone covered in "; ExtraDescript += "scrapes, as if gouged by claws. It is very, very hot in here, and from cracks "; ExtraDescript += "in the floor you can hear screams rising from the dark. What is this awful place? "; } int n = RNG.Next(5); for (int i = 0; i < n; i++) { Contents.Add(_itemsMaster[(int)RNG.Next(_itemsMaster.Count)].Copy()); } n = RNG.Next(3); for (int i = 0; i < n; i++) { Contents.Add(_weaponsMaster[(int)RNG.Next(_weaponsMaster.Count)].Copy()); } n = RNG.Next(5); for (int i = 0; i < n; i++) { Contents.Add(_monstersMaster[(int)RNG.Next(_monstersMaster.Count)].Copy()); } Description += "There "; if (n == 0) { Description += "are no monsters "; } else if (n == 1) { Description += "is one monster "; } else if (n == 2) { Description += "are two monsters "; } else { Description += "are several monsters "; } Description += "in here.\n"; }