public itemInfo CloneItem(itemInfo Item) { itemInfo NewItem = new itemInfo(); NewItem.InteractionName = new List<string>(); if (Item.InteractionName != null) foreach (string name in Item.InteractionName) { NewItem.InteractionName.Add(name); } NewItem.Name = Item.Name; NewItem.Examine = Item.Examine; NewItem.AttackMod = Item.AttackMod; NewItem.DefenseMod = Item.DefenseMod; NewItem.HPmod = Item.HPmod; NewItem.CanPickUp = Item.CanPickUp; NewItem.Class = Item.Class; NewItem.GoodHit = Item.BadHit; NewItem.MedHit = Item.MedHit; NewItem.BadHit = Item.BadHit; NewItem.Value = Item.Value; NewItem.ItemNeeded = Item.ItemNeeded; NewItem.interactionResponse = Item.interactionResponse; NewItem.XP = Item.XP; //NewItem.ImagePath = Item.ImagePath; //NewItem.ImageLocation = Item.ImageLocation; return NewItem; }
public static void SurpriseAttack(string enemy) { Random RNG = new Random(); double BaseAttack; int Counter; int defend = RNG.Next(1, 3); LoDConsole.WriteLine(WordWrap(string.Concat("You carefully wait, and when you think you have the upper hand, you attack ", enemy))); //Thread.Sleep(1000); if (defend == 1) { LoDConsole.WriteLine(WordWrap("Expecting violence they draw their weapon and defend\n")); //Thread.Sleep(1000); Combat(Player.WeaponHeld, enemy); } else { LoDConsole.WriteLine(WordWrap("Completely surprised they do not have a chance to defend themselves\n")); //Thread.Sleep(1000); BaseAttack = RNG.Next(1, 6); if (BaseAttack == 1 || BaseAttack == 2) { //bad attack LoDConsole.WriteLine(WordWrap(string.Concat("You attack enemy ", enemy, " with your ", Player.WeaponHeld.Name, "\n", Player.WeaponHeld.BadHit))); } else if (BaseAttack == 3 || BaseAttack == 4) { //Medium Weak Attack LoDConsole.WriteLine(WordWrap(string.Concat("You attack enemy ", enemy, " with your ", Player.WeaponHeld.Name, "\n", Player.WeaponHeld.MedHit))); } else if (BaseAttack == 5 || BaseAttack == 6) { //Critical Attack LoDConsole.WriteLine(WordWrap(string.Concat("You attack enemy ", enemy, " with your ", Player.WeaponHeld.Name, "\n", Player.WeaponHeld.GoodHit))); } BaseAttack = BaseAttack * Player.WeaponHeld.AttackMod; Counter = 0; bool GaveHit = false; while (CurrentRoom.Enemy != null && Counter < CurrentRoom.Enemy.Count && GaveHit == false) { if (CurrentRoom.Enemy[Counter].name.ToLower() == enemy.ToLower()) { EnemyProfile ThisEnemy = CurrentRoom.Enemy[Counter]; int Fortitude = RNG.Next(1, 100); if (Fortitude > ThisEnemy.armor) ThisEnemy.HPBonus = ThisEnemy.HPBonus - BaseAttack; else ThisEnemy.HPBonus = ThisEnemy.HPBonus - Math.Ceiling((double)(BaseAttack / 110) * ThisEnemy.armor); //LoDConsole.WriteLine("Enemy {0} has {1} HP left", enemy, CurrentRoom.Enemy[Counter].HPBonus); if (ThisEnemy.HPBonus < 0) //if the enemy has been killed { LoDConsole.WriteLine(); if (CurrentRoom.Enemy[Counter].DeathMessage == null) { LoDConsole.WriteLine(WordWrap(string.Concat("With this hit you kill the enemy ", CurrentRoom.Enemy[Counter].name))); } else { LoDConsole.WriteLine(WordWrap(CurrentRoom.Enemy[Counter].DeathMessage)); } if (CurrentRoom.items == null) CurrentRoom.items = new List<itemInfo>(); CurrentRoom.items.Add(ThisEnemy.Weapon); itemInfo newItem = new itemInfo(); newItem.Name = string.Concat(ThisEnemy.name, "'s body"); newItem.Class = "Object"; newItem.Examine = string.Concat("The slashed and torn body of enemy ", ThisEnemy.name); newItem.CanPickUp = false; newItem.InteractionName = new List<string>(); newItem.InteractionName.Add("body"); newItem.InteractionName.Add("corpse"); newItem.InteractionName.Add("enemy"); newItem.InteractionName.Add(string.Concat(ThisEnemy.name, "'s body")); newItem.InteractionName.Add(ThisEnemy.name); CurrentRoom.items.Add(newItem); if (ThisEnemy.Money != 0) LoDConsole.WriteLine("\nYou take {0} gold coins from {1}'s corpse", ThisEnemy.Money.ToString(), enemy); Player.Money = Player.Money + ThisEnemy.Money; //take money from enemy Player.XP = Player.XP + ThisEnemy.XP; //Take XP EventTrigger("killenemy", ThisEnemy.name); if (CurrentRoom.Enemy.Count - 1 != 0) { //Remove the fighter CurrentRoom.Enemy.RemoveAt(Counter); } else { EventTrigger("killallenemies"); CurrentRoom.Enemy.Clear(); //break; } } else CurrentRoom.Enemy[Counter] = ThisEnemy; GaveHit = true; } Counter++; } } }
public static void EnterCommand(string PlayerCommand) { //Take in a player command //LoDConsole.Write(">"); //PlayerCommand = Console.ReadLine(); PlayerCommand = CleanPlayerInput(PlayerCommand); //Clean the input of unusual characters if (!ClearConsole) LoDConsole.WriteLine(""); else LoDConsole.Clear(); try { #region Help if (PlayerCommand.ToLower() == "help" || PlayerCommand.ToLower() == "commands" || PlayerCommand.ToLower().Contains("how do i") || PlayerCommand.ToLower().Contains("how can i")) { using (StreamReader file = new System.IO.StreamReader(@".\System Files\GameEngineHelp.sys", true)) { LoDConsole.WriteLine(WordWrap(file.ReadToEnd())); } } #endregion #region Movement else if ( (PlayerCommand.ToLower().Split(' ')[0] == "go" && PlayerCommand.ToLower().Split(' ')[1] != "into") || PlayerCommand.ToLower().Split(' ')[0] == "move" || PlayerCommand.ToLower().Split(' ')[0] == "travel" || PlayerCommand.ToLower() == "north" || PlayerCommand.ToLower() == "east" || PlayerCommand.ToLower() == "south" || PlayerCommand.ToLower() == "west" ) { if (!CurrentRoom.LockedIn) { int[] ProposedMove = new int[3]; ProposedMove[0] = Player.CurrentPos[0]; ProposedMove[1] = Player.CurrentPos[1]; ProposedMove[2] = Player.CurrentPos[2]; string Direction = string.Empty; if (PlayerCommand.ToLower().Split(' ')[0] == "go" || PlayerCommand.ToLower().Split(' ')[0] == "move" || PlayerCommand.ToLower().Split(' ')[0] == "travel") Direction = PlayerCommand.ToLower().Split(' ')[1]; else Direction = PlayerCommand.ToLower(); switch (Direction) { case "north": ProposedMove[0] = ProposedMove[0] - 1; break; case "east": ProposedMove[1] = ProposedMove[1] + 1; break; case "south": ProposedMove[0] = ProposedMove[0] + 1; break; case "west": ProposedMove[1] = ProposedMove[1] - 1; break; default: ProposedMove = Player.CurrentPos; break; } ThisFloor.CurrentFloor[ProposedMove[0], ProposedMove[1]].Explored = true; PotentialRoom = GetRoomInfo(ProposedMove); if (PotentialRoom.CanMove == true) { if (PotentialRoom.Description == null || PotentialRoom.Description == string.Empty) LoDConsole.WriteLine(WordWrap("I Successfully move into Row ") + Char.ConvertFromUtf32(ProposedMove[0] + 65) + " Col " + (ProposedMove[1] + 1) + " Level " + (ProposedMove[2] + 1)); else LoDConsole.WriteLine(WordWrap(PotentialRoom.Description)); ThisFloor.CurrentFloor[Player.CurrentPos[0], Player.CurrentPos[1]] = CurrentRoom; CurrentRoom = PotentialRoom; Player.CurrentPos = ProposedMove; EventTrigger("moveinto"); } else if (PotentialRoom.Description == null || PotentialRoom.Description == string.Empty) LoDConsole.WriteLine(WordWrap("Looks like I can't go that way.")); else LoDConsole.WriteLine(WordWrap(PotentialRoom.Description)); } else { LoDConsole.WriteLine("You cannot leave the current area"); if (CurrentRoom.Enemy != null) attacked(); } } #endregion #region Buildings else if ((PlayerCommand.ToLower().Split(' ')[0] == "go" && PlayerCommand.ToLower().Split(' ')[1] == "into") || PlayerCommand.ToLower().Split(' ')[0] == "enter") { if (!Player.InBuilding) { if (CurrentRoom.Building.BuildingName != null) { if (!CurrentRoom.LockedIn) { string target = string.Empty; if (PlayerCommand.ToLower().Split(' ')[0] == "go" && PlayerCommand.ToLower().Split(' ')[1] == "into") { for (int i = 2; i < PlayerCommand.Split(' ').Length; i++) { target = target + " " + PlayerCommand.Split(' ')[i]; } } else if (PlayerCommand.ToLower().Split(' ')[0] == "enter") { for (int i = 1; i < PlayerCommand.Split(' ').Length; i++) { target = target + " " + PlayerCommand.Split(' ')[i]; } } target = target.Trim(); if (target != string.Empty && target.ToLower() == CurrentRoom.Building.BuildingName.ToLower()) { if (CurrentRoom.Building.CanMove == true) { SaveWorld(); CurrentRoom = GoIntoBuilding(CurrentRoom.Building); LoDConsole.WriteLine(WordWrap(CurrentRoom.Description)); EventTrigger("moveinto"); } else LoDConsole.WriteLine(WordWrap(target + " is locked.")); } else if (target != CurrentRoom.Building.BuildingName) LoDConsole.WriteLine(target + " is not something you can enter."); else LoDConsole.WriteLine("Go into where?"); } else { LoDConsole.WriteLine("You cannot leave the current area"); if (CurrentRoom.Enemy != null) attacked(); } } else LoDConsole.WriteLine("There is no building here to enter"); } else LoDConsole.WriteLine("You are Already inside a building"); } else if (PlayerCommand.ToLower().Split(' ')[0] == "leave") { if (Player.InBuilding == true) { if (!CurrentRoom.LockedIn) { ThisFloor.CurrentFloor[Player.CurrentPos[0], Player.CurrentPos[1]].Building = LeaveBuilding(CurrentRoom); CurrentRoom = GetRoomInfo(Player.CurrentPos); LoDConsole.WriteLine(WordWrap(CurrentRoom.Description)); EventTrigger("moveinto"); } else { LoDConsole.WriteLine("You cannot leave the current area"); if (CurrentRoom.Enemy != null) attacked(); } } else LoDConsole.WriteLine(WordWrap("You are not currently inside a building")); } #endregion #region Descriptions else if (CommandContains(PlayerCommand, "who am i") || CommandContains(PlayerCommand, "whoami")) { LoDConsole.WriteLine(WordWrap(string.Concat("Your name is ", Player.name))); } else if (CommandContains(PlayerCommand, "status")) { PlayerStatus(); } else if (CommandContains(PlayerCommand, "describe")) { LoDConsole.WriteLine(WordWrap(CurrentRoom.Description)); } else if (CommandContains(PlayerCommand, "objective")) { LoDConsole.WriteLine(WordWrap(string.Concat("Your Current Objective is: ", Player.Objective))); } else if (CommandContains(PlayerCommand, "money")) { LoDConsole.WriteLine("You currently have {0} gold coins", Player.Money.ToString()); } #endregion #region Read else if (CommandContains(PlayerCommand, "read")) { if (CurrentRoom.items != null || Player.inventory.Count != 0) { string target = string.Empty; if (PlayerCommand.ToLower().Split(' ').Length != 1) { for (int i = 1; i < PlayerCommand.ToLower().Split(' ').Length; i++) { target = target + PlayerCommand.ToLower().Split(' ')[i]; } } else { target = LoDConsole.ReadLine("What do you want to read?","Read",string.Empty); } LoDConsole.WriteLine(WordWrap(ReadItem(target.Trim()))); } else LoDConsole.WriteLine("There is nothing to read"); } #endregion #region Inventory else if (CommandContains(PlayerCommand, "inventory")) { if (Player.inventory.Count != 0) { LoDConsole.WriteLine(WordWrap(string.Concat("You are currently using ", (Player.MaxItems - Player.invspace), "/", Player.MaxItems, " of your inventory\n"))); int index = 1; foreach (itemInfo Item in Player.inventory) { LoDConsole.WriteLine(WordWrap(string.Concat(index, ": ", Item.Name))); index++; } LoDConsole.WriteLine(""); } else LoDConsole.WriteLine("Your inventory is empty"); } #endregion #region Ask else if (CommandContains(PlayerCommand, "ask about")) { string Target = string.Empty; string Topic = string.Empty; bool topicstart = false; if (PlayerCommand.ToLower().Contains("about")) { for (int i = 1; i < PlayerCommand.Split(' ').Length; i++) { if (PlayerCommand.Split(' ')[i].ToLower() == "about") { topicstart = true; } else if (topicstart == false) { Target = Target + " " + PlayerCommand.Split(' ')[i]; } else if (topicstart == true) { Topic = Topic + " " + PlayerCommand.Split(' ')[i]; } } AskQuestion(Target.Trim(), Topic.Trim()); } else LoDConsole.WriteLine(WordWrap("Ask who about what?")); } #endregion #region Take Item else if (CommandContains(PlayerCommand, "take") || CommandContains(PlayerCommand, "pick") || CommandContains(PlayerCommand, "get")) { string ObjectName = string.Empty; if (Player.invspace > 0) { if (PlayerCommand.ToLower() == "take" || PlayerCommand.ToLower() == "pick" || PlayerCommand.ToLower() == "pick up" || PlayerCommand.ToLower() == "get") { LoDConsole.Write("What do you want to pick up?: "); ObjectName = LoDConsole.ReadLine("What do you want to pick up?", "Pick Up", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); int index = 2; if (strArray[0].ToLower() == "take" || strArray[0].ToLower() == "get") { index = 2; ObjectName = strArray[1]; } else if (strArray[0] == "pick" && strArray[1] == "up") { index = 3; ObjectName = strArray[2]; } while (index < strArray.Length) { ObjectName = string.Concat(ObjectName, " ", strArray[index]); index++; //LoDConsole.WriteLine(WordWrap("item is {0}", item); } ObjectName = ObjectName.Trim(); } TakeItem(ObjectName); } else LoDConsole.WriteLine("There is no space in your inventory to pick anything up"); } #endregion #region DropItem else if (CommandContains(PlayerCommand, "drop")) { if (Player.inventory.Count != 0) { string ObjectName = string.Empty; if (PlayerCommand.ToLower() == "drop") { int index = 1; foreach (itemInfo Item in Player.inventory) { LoDConsole.WriteLine(WordWrap(string.Concat(index, ": ", Item.Name))); index++; } ObjectName = LoDConsole.ReadLine("Which item do you wish to drop", "Drop Item", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); ObjectName = strArray[1]; int index = 2; while (index < strArray.Length) { ObjectName = string.Concat(ObjectName, " ", strArray[index]); index++; //LoDConsole.WriteLine(WordWrap("item is {0}", item); } ObjectName = ObjectName.Trim(); } LoDConsole.WriteLine(WordWrap(DropItem(ObjectName))); } else LoDConsole.WriteLine(WordWrap("There are no items in your inventory")); } #endregion #region Look At Item else if (CommandContains(PlayerCommand, "look at")) { string ObjectName = string.Empty; if (PlayerCommand.ToLower() == "look at") { ObjectName = LoDConsole.ReadLine("What do you want to look at?", "Look At", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); ObjectName = strArray[2]; int index = 3; while (index < strArray.Length) { ObjectName = string.Concat(ObjectName, " ", strArray[index]); index++; //LoDConsole.WriteLine(WordWrap("item is {0}", item); } ObjectName = ObjectName.Trim(); } LoDConsole.WriteLine(WordWrap(LookAtItem(ObjectName))); } #endregion #region Examine Item else if (CommandContains(PlayerCommand, "examine") || CommandContains(PlayerCommand, "inspect")) { if (Player.inventory.Count != 0) { string ObjectName = string.Empty; if (PlayerCommand.ToLower() == "examine" || PlayerCommand.ToLower() == "inspect") { int index = 1; foreach (itemInfo Item in Player.inventory) { LoDConsole.WriteLine(WordWrap("{0}: {1}"), index.ToString(), Item.Name); index++; } ObjectName = LoDConsole.ReadLine("What item do you want to examine?", "Examine", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); ObjectName = strArray[1]; int index = 2; while (index < strArray.Length) { ObjectName = string.Concat(ObjectName, " ", strArray[index]); index++; //LoDConsole.WriteLine(WordWrap("item is {0}", item); } ObjectName = ObjectName.Trim(); } ExamineItem(ObjectName); } else LoDConsole.WriteLine(WordWrap("There are no items in your inventory")); } #endregion #region Use Item else if (CommandContains(PlayerCommand, "use") || CommandContains(PlayerCommand, "put")) { int index = 0; string item = string.Empty; string target = string.Empty; if (CurrentRoom.items != null) { if (PlayerCommand.ToLower() == "use" || PlayerCommand.ToLower() == "put") { item = LoDConsole.ReadLine("What item do you want to " + PlayerCommand.ToLower().Split(' ')[0] + "?", PlayerCommand.ToLower().Split(' ')[0], string.Empty); target = LoDConsole.ReadLine("What do you want to " + PlayerCommand.ToLower().Split(' ')[0] + " " + item + " on?", "Target", string.Empty); } else if (CurrentRoom.items != null) { item = PlayerCommand.Split(' ')[1]; bool itemFound = false; bool targetFound = false; index = 2; while (index < (PlayerCommand.Split(' ').Length)) { if (PlayerCommand.Split(' ')[index].ToLower() == "on" || PlayerCommand.Split(' ')[index].ToLower() == "in") { itemFound = true; index++; target = PlayerCommand.Split(' ')[index].ToLower(); targetFound = true; } else if (itemFound == false) { item = string.Concat(item, " ", PlayerCommand.Split(' ')[index].ToLower()); } else { target = string.Concat(target, " ", PlayerCommand.Split(' ')[index].ToLower()); } index++; } if (targetFound == false) { LoDConsole.WriteLine("Objects in the room:\n"); for (index = 0; index < CurrentRoom.items.Count; index++) { //if (CurrentRoom.items[index].Class == "Interaction Object") LoDConsole.WriteLine(string.Concat(CurrentRoom.items[index].Name)); LoDConsole.WriteLine(string.Concat(CurrentRoom.items[index].Name)); } target = LoDConsole.ReadLine("What do you want to use " + item + " on?", "Target", string.Empty); } } UseItem(item, target); } else { LoDConsole.WriteLine("There is nothing in the room to interact with"); } } #endregion #region View Wares else if (CommandContains(PlayerCommand, "view wares")) { int index; string VendorName; if (CurrentRoom.Civilians != null) { if (PlayerCommand.ToLower().Split(' ').Length > 2) { string[] strArray = PlayerCommand.Split(' '); VendorName = strArray[2]; index = 3; while (index < strArray.Length) { VendorName = string.Concat(VendorName, " ", strArray[index]); index++; //LoDConsole.WriteLine(WordWrap("item is {0}", item); } VendorName = VendorName.Trim(); } else { LoDConsole.WriteLine("Civilians in the room:\n"); for (index = 0; index < CurrentRoom.Civilians.Count; index++) { if (CurrentRoom.Civilians[index].willSell == true) LoDConsole.WriteLine(string.Concat(CurrentRoom.Civilians[index].name, " - ", CurrentRoom.Civilians[index].MerchantType)); } VendorName = LoDConsole.ReadLine("Who do you want to view the inventory of?", "View Wares", string.Empty); } bool vendorFound = false; index = 0; while (vendorFound == false && CurrentRoom.Civilians != null && index < CurrentRoom.Civilians.Count) { if (VendorName.ToLower() == CurrentRoom.Civilians[index].name.ToLower()) { if (CurrentRoom.Civilians[index].willSell == true) { vendorFound = true; LoDConsole.WriteLine(); LoDConsole.WriteLine("Item\t\t\tClass\t\t\tPrice"); for (int Count = 0; Count < CurrentRoom.Civilians[index].inventory.Count; Count++) { if (CurrentRoom.Civilians[index].inventory[Count].Name == null) LoDConsole.Write("null\t\t"); if (CurrentRoom.Civilians[index].inventory[Count].Name.Length < 8) LoDConsole.Write("{0}\t\t", CurrentRoom.Civilians[index].inventory[Count].Name); else if (CurrentRoom.Civilians[index].inventory[Count].Name.Length <= 15) LoDConsole.Write("{0}\t", CurrentRoom.Civilians[index].inventory[Count].Name); else LoDConsole.Write(CurrentRoom.Civilians[index].inventory[Count].Name); if (CurrentRoom.Civilians[index].inventory[Count].Class == null) LoDConsole.Write("null\t\t\t"); else if (CurrentRoom.Civilians[index].inventory[Count].Class.Length < 8) LoDConsole.Write("{0}\t\t\t", CurrentRoom.Civilians[index].inventory[Count].Class); else if (CurrentRoom.Civilians[index].inventory[Count].Class.Length <= 15) LoDConsole.Write("{0}\t\t", CurrentRoom.Civilians[index].inventory[Count].Class); else if (CurrentRoom.Civilians[index].inventory[Count].Class.Length <= 21) LoDConsole.Write("{0}\t", CurrentRoom.Civilians[index].inventory[Count].Class); else LoDConsole.Write(CurrentRoom.Civilians[index].inventory[Count].Class); if (CurrentRoom.Civilians[index].inventory[Count].Value != 0) LoDConsole.Write("\t{0}\n", CurrentRoom.Civilians[index].inventory[Count].Value.ToString()); else LoDConsole.Write("\tnull\n"); //LoDConsole.WriteLine(WordWrap(string.Concat(CurrentRoom.Civilians[index].inventory[Count].Name, "\t", CurrentRoom.Civilians[index].inventory[Count].Class, "\t",CurrentRoom.Civilians[index].inventory[Count].Value))); } } else LoDConsole.WriteLine(WordWrap(string.Concat(CurrentRoom.Civilians[index].name, " is not willing to sell you anything"))); } index++; } if (!vendorFound) LoDConsole.WriteLine(VendorName + " is either not here or not a merchant"); } else LoDConsole.WriteLine("There is nobody currently selling anything in this area"); } #endregion #region Bribe else if (CommandContains(PlayerCommand, "bribe")) { int index; string WhoToBribe = string.Empty; int BribeAmount = 0; bool dontrun = false; if (CurrentRoom.Enemy != null || CurrentRoom.Civilians != null) { if (PlayerCommand.ToLower() == "bribe") { LoDConsole.WriteLine("People in the room who may accept a bribe:\n"); if (CurrentRoom.Enemy != null) { for (index = 0; index < CurrentRoom.Enemy.Count; index++) { LoDConsole.WriteLine(CurrentRoom.Enemy[index].name); } } if (CurrentRoom.Civilians != null) { for (index = 0; index < CurrentRoom.Civilians.Count; index++) { LoDConsole.WriteLine(CurrentRoom.Civilians[index].name); } } WhoToBribe = LoDConsole.ReadLine("Who do you want to bribe?", "Bribe", string.Empty); Int32.TryParse(LoDConsole.ReadLine("How much do you want to give them?","Bribe Amount","0"), out BribeAmount); if (BribeAmount == 0) { dontrun = true; LoDConsole.WriteLine("You cannot bribe somebody with that amount"); } } else if (PlayerCommand.Split(' ')[0].ToLower() == "bribe") { WhoToBribe = PlayerCommand.Split(' ')[1]; int i = 2; int n; bool AmountFound = false; while (AmountFound == false && i < PlayerCommand.Split(' ').Length) { if (Int32.TryParse(PlayerCommand.Split(' ')[i], out n)) { BribeAmount = n; AmountFound = true; } else WhoToBribe = string.Concat(WhoToBribe, " ", PlayerCommand.Split(' ')[i]); i++; } if (AmountFound == false) { Int32.TryParse(LoDConsole.ReadLine("How much do you want to give to " + WhoToBribe + "?", "Bribe Amount", "0"), out BribeAmount); } if (BribeAmount == 0) { dontrun = true; LoDConsole.WriteLine("You cannot bribe somebody with that amount"); } } else { dontrun = true; LoDConsole.WriteLine(WordWrap("I can't quite work out how many things you just said, try again")); } if (dontrun == false) { if (isEnemy(WhoToBribe)) PayOff(WhoToBribe, BribeAmount); else if (isNPC(WhoToBribe)) GiveItem(BribeAmount + " gold", WhoToBribe); else LoDConsole.WriteLine("That person does not appear to be here..."); } } else LoDConsole.WriteLine(WordWrap("There are no people in the room to bribe")); } #endregion #region Buy Item else if (CommandContains(PlayerCommand, "buy")) { int index; string vendor = string.Empty; string ItemName = string.Empty; if (Player.invspace > 0) { if (CurrentRoom.Civilians != null) { if (PlayerCommand.ToLower() == "buy") { ItemName = LoDConsole.ReadLine("What item do you want to buy?", "Buy Item", string.Empty); //player didn't specify item or person LoDConsole.WriteLine("Civilians in the room:\n"); for (index = 0; index < CurrentRoom.Civilians.Count; index++) { if (CurrentRoom.Civilians[index].willSell == true) LoDConsole.WriteLine(string.Concat(CurrentRoom.Civilians[index].name, " - ", CurrentRoom.Civilians[index].MerchantType)); } vendor = ItemName = LoDConsole.ReadLine("Who do you want to buy from?", "Merchants", string.Empty); } else if (PlayerCommand.Split(' ').Length >= 2) { //ItemName = PlayerCommand.Split(' ')[1].ToLower(); ItemName = PlayerCommand.Split(' ')[1].ToLower(); bool itemFound = false; bool vendorFound = false; index = 2; while (index < (PlayerCommand.Split(' ').Length)) { if (PlayerCommand.Split(' ')[index].ToLower() == "from") { itemFound = true; index++; vendor = PlayerCommand.Split(' ')[index].ToLower(); vendorFound = true; } else if (itemFound == false) { ItemName = string.Concat(ItemName, " ", PlayerCommand.Split(' ')[index].ToLower()); } else { vendor = string.Concat(vendor, " ", PlayerCommand.Split(' ')[index].ToLower()); } index++; } if (vendorFound == false) { LoDConsole.WriteLine("Civilians in the room:\n"); for (index = 0; index < CurrentRoom.Civilians.Count; index++) { if (CurrentRoom.Civilians[index].willSell == true) LoDConsole.WriteLine(string.Concat(CurrentRoom.Civilians[index].name, " - ", CurrentRoom.Civilians[index].MerchantType)); } vendor = LoDConsole.ReadLine("Who do you want to buy " + ItemName + " from?", "Merchants", string.Empty); } } BuyItem(ItemName, vendor); } else LoDConsole.WriteLine("There is nobody willing to buy anything from you here"); } else LoDConsole.WriteLine("There is no space in your inventory to buy anything."); } #endregion #region Sell Item else if (CommandContains(PlayerCommand, "sell")) { int index; string vendor = string.Empty; string ItemName = string.Empty; itemInfo ItemToSell = new itemInfo(); if (CurrentRoom.Civilians != null) { if (PlayerCommand.ToLower() == "sell") { LoDConsole.Write(" "); ItemName = LoDConsole.ReadLine("What item do you want to sell?", "Sell Item", string.Empty); index = 0; bool itemfound = false; while (itemfound == false && index < Player.inventory.Count) { if (ItemName.ToLower() == Player.inventory[index].Name.ToLower()) { itemfound = true; ItemToSell = Player.inventory[index]; } index++; } //player didn't specify item or person LoDConsole.WriteLine("Civilians in the room:\n"); for (index = 0; index < CurrentRoom.Civilians.Count; index++) { if (CurrentRoom.Civilians[index].willBuy == true) LoDConsole.WriteLine(string.Concat(CurrentRoom.Civilians[index].name, " - ", CurrentRoom.Civilians[index].MerchantType)); } vendor = LoDConsole.ReadLine("Who do you want to sell to?", "Merchants", string.Empty); } else if (PlayerCommand.Split(' ').Length >= 2) { //ItemName = PlayerCommand.Split(' ')[1].ToLower(); ItemName = PlayerCommand.Split(' ')[1].ToLower(); bool itemFound = false; bool vendorFound = false; index = 2; while (index < (PlayerCommand.Split(' ').Length)) { if (PlayerCommand.Split(' ')[index].ToLower() == "to") { itemFound = true; index++; vendor = PlayerCommand.Split(' ')[index].ToLower(); vendorFound = true; } else if (itemFound == false) { ItemName = string.Concat(ItemName, " ", PlayerCommand.Split(' ')[index].ToLower()); } else { vendor = string.Concat(vendor, " ", PlayerCommand.Split(' ')[index].ToLower()); } index++; } index = 0; itemFound = false; while (itemFound == false && index < Player.inventory.Count) { if (ItemName.ToLower() == Player.inventory[index].Name.ToLower()) { itemFound = true; ItemToSell = Player.inventory[index]; } index++; } if (itemFound == true && vendorFound == false) { LoDConsole.WriteLine("Civilians in the room:\n"); for (index = 0; index < CurrentRoom.Civilians.Count; index++) { if (CurrentRoom.Civilians[index].willBuy == true) LoDConsole.WriteLine(string.Concat(CurrentRoom.Civilians[index].name, " - ", CurrentRoom.Civilians[index].MerchantType)); } vendor = LoDConsole.ReadLine("Who do you want to sell "+ItemName+" to?", "Merchants", string.Empty); } } SellItem(ItemToSell, vendor); } else LoDConsole.WriteLine("There is nobody willing to buy anything from you here"); } #endregion #region Give Item else if (CommandContains(PlayerCommand, "give")) { string itemName = string.Empty; string targetNPC = string.Empty; bool itemFound = false; for (int i = 1; i < PlayerCommand.Split(' ').Length; i++) { if (PlayerCommand.Split(' ')[i].ToLower() == "to") itemFound = true; else if (!itemFound) itemName = itemName + " " + PlayerCommand.Split(' ')[i]; else targetNPC = targetNPC + " " + PlayerCommand.Split(' ')[i]; } if (!string.IsNullOrEmpty(itemName) && string.IsNullOrEmpty(targetNPC)) { targetNPC = LoDConsole.ReadLine("Who do you want to give " + itemName.Trim() + " to?", "Give Item", string.Empty); } else if (!itemFound && targetNPC == string.Empty) { itemName = LoDConsole.ReadLine("Who do you want to give?", "Give Item", string.Empty); targetNPC = LoDConsole.ReadLine("Who do you want to give " + itemName.Trim() + " to?", "Give Item", string.Empty); } //if (itemName.Trim().ToLower() == "gold") LoDConsole.WriteLine(WordWrap("You cannot gift gold at this time")); else GiveItem(itemName.Trim(), targetNPC.Trim()); } #endregion #region Talk to else if (CommandContains(PlayerCommand, "talk")) { int index; string NPCname = string.Empty; if (CurrentRoom.Civilians != null) { if (PlayerCommand.ToLower() == "talk to" || PlayerCommand.ToLower() == "talk") { LoDConsole.WriteLine("Non-Hostile people in the room:\n"); for (index = 0; index < CurrentRoom.Civilians.Count; index++) { LoDConsole.WriteLine(WordWrap(CurrentRoom.Civilians[index].name)); } LoDConsole.Write("\nWho do you want to talk to? "); NPCname = LoDConsole.ReadLine("Who do you want to talk to?", "Talk", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); foreach (string word in strArray) { if (word != "to" && word != "talk") NPCname = string.Concat(NPCname, " ", word); } } if (NPCname == string.Empty) LoDConsole.WriteLine("Talk to who?"); else LoDConsole.WriteLine(WordWrap(TalkToNPC(NPCname.Trim()))); } else { LoDConsole.WriteLine("There are no non-hostile people to talk to"); } } #endregion #region Suicide else if (PlayerCommand.Contains("suicide") || PlayerCommand.ToLower() == "attack self" || PlayerCommand.ToLower() == "hit self" || PlayerCommand.ToLower() == string.Concat("hit ", Player.name.ToLower()) || PlayerCommand.ToLower() == string.Concat("attack ", Player.name.ToLower()) || PlayerCommand.ToLower() == "kill self") { if (PlayerCommand.Contains("suicide") && CurrentRoom.SuicideAction != null) LoDConsole.WriteLine(WordWrap(CurrentRoom.SuicideAction)); else LoDConsole.WriteLine(WordWrap("You raise your weapon above your head. Screaming in blind rage for some unknown reason. You strike yourself until you die")); Player.HPBonus = 0; //LoDConsole.WriteLine("I GET HERE, and my health is {0}", Player.HPBonus); } #endregion #region Attack else if (CommandContains(PlayerCommand, "attack") || CommandContains(PlayerCommand, "hit") || CommandContains(PlayerCommand, "fight")) { string enemy; int index; bool enemyfound = false; if (CurrentRoom.Enemy != null && CurrentRoom.Enemy.Count > 0) { if (PlayerCommand.ToLower() == "attack" || PlayerCommand.ToLower() == "hit" || PlayerCommand.ToLower() == "fight") { LoDConsole.WriteLine(WordWrap("Enemies in room:\n")); for (index = 0; index < CurrentRoom.Enemy.Count; index++) { LoDConsole.WriteLine(WordWrap(CurrentRoom.Enemy[index].name)); } enemy = LoDConsole.ReadLine("Who do you want to attack?", "Combat", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); enemy = strArray[1]; for (int i = 2; i < strArray.Length; i++) { enemy = enemy + " " + strArray[i]; } } index = 0; while (CurrentRoom.Enemy != null && index < CurrentRoom.Enemy.Count && enemyfound == false) { if (CurrentRoom.Enemy[index].name.ToLower() == enemy.ToLower()) { Combat(Player.WeaponHeld, enemy); enemyfound = true; } index++; } if (enemyfound == false) LoDConsole.WriteLine(WordWrap(string.Concat("Could not find ", enemy, " in the area"))); } else if (CurrentRoom.Civilians != null && CurrentRoom.Civilians.Count > 0) { if (PlayerCommand.ToLower() == "attack" || PlayerCommand.ToLower() == "hit" || PlayerCommand.ToLower() == "fight") { enemy = LoDConsole.ReadLine("Who do you want to attack?", "Give Item", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); enemy = strArray[1]; for (int i = 2; i < strArray.Length; i++) { enemy = enemy + " " + strArray[i]; } } StartFight(enemy); } else LoDConsole.WriteLine(WordWrap("There is nobody in the room to fight")); } #endregion #region Equip/Wear else if (CommandContains(PlayerCommand, "equip") || CommandContains(PlayerCommand, "wear")) { EquipItem(PlayerCommand); } #endregion #region Eat/Drink else if (CommandContains(PlayerCommand, "eat") || CommandContains(PlayerCommand, "drink") || CommandContains(PlayerCommand, "consume")) { if (Player.inventory.Count != 0) { int index; string ObjectName = string.Empty; if (PlayerCommand.ToLower() == "eat" || PlayerCommand.ToLower() == "drink" || PlayerCommand.ToLower() == "consume") { LoDConsole.WriteLine("Food in your inventory:\n"); foreach (itemInfo Item in Player.inventory) { if (Item.Class == "Food" || Item.Class == "Drink") { LoDConsole.WriteLine(WordWrap(Item.Name)); } } ObjectName = LoDConsole.ReadLine("Which item do you want to consume?", "Consume", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); ObjectName = strArray[1]; index = 2; while (index < strArray.Length) { ObjectName = string.Concat(ObjectName, " ", strArray[index]); index++; //LoDConsole.WriteLine(WordWrap("item is {0}", item); } ObjectName = ObjectName.Trim(); } LoDConsole.WriteLine(WordWrap(ConsumeItem(ObjectName))); } else LoDConsole.WriteLine("Your inventory is empty"); } #endregion #region Sleep else if (CommandContains(PlayerCommand, "sleep") || CommandContains(PlayerCommand, "sleep in") || CommandContains(PlayerCommand, "go to sleep")) { int index = 0; string bedItem = string.Empty; if (PlayerCommand.ToLower() == "sleep in" || PlayerCommand.ToLower() == "sleep") { bedItem = LoDConsole.ReadLine("Who do you want to sleep in?", "Give Item", string.Empty); } else if (PlayerCommand.ToLower().Split(' ').Length > 2 && PlayerCommand.ToLower().Split(' ')[0] == "sleep" && PlayerCommand.ToLower().Split(' ')[1] == "in") { string[] strArray = PlayerCommand.Split(' '); bedItem = strArray[2]; index = 3; while (index < strArray.Length) { bedItem = string.Concat(bedItem, " ", strArray[index]); index++; //LoDConsole.WriteLine(WordWrap("item is {0}", item); } bedItem = bedItem.Trim(); } //LoDConsole.WriteLine("Trying to sleep in {0}", bedItem); Rest(bedItem); } #endregion #region Map else if ((CommandContains(PlayerCommand, "map"))) { DrawMap(); } #endregion #region Time else if (CommandContains(PlayerCommand, "time")) { TimeSpan ts = TimeSpan.FromMinutes(WorldState.WorldTime); LoDConsole.WriteLine("The time is " + ts.ToString("hh':'mm")); } #endregion #region Music else if (PlayerCommand.ToLower() == "music browse") { Music("browse"); } else if (PlayerCommand.ToLower() == "music start") { Music("start"); } else if (PlayerCommand.ToLower() == "music stop") { Music("stop"); } #endregion #region Control else if (PlayerCommand.ToLower() == "clear") { LoDConsole.Clear(); LoDConsole.WriteLine(WordWrap(CurrentRoom.Description)); } else if (PlayerCommand.ToLower() == "main menu" || PlayerCommand.ToLower() == "mainmenu") { //Run the main menu screen lock (myLock) { stopTime = 0; } //Pause the clock DrawMainMenu(); lock (myLock) { stopTime = 1; } //Start the clock //ThisFloor = world[Player.CurrentPos[2]]; CurrentRoom = GetRoomInfo(Player.CurrentPos); LoDConsole.WriteLine(WordWrap(CurrentRoom.Description)); } else if (CommandContains(PlayerCommand, "save")) { string success = SaveGame(); LoDConsole.WriteLine(WordWrap(string.Concat("Save ", success))); } else if (PlayerCommand.ToLower() == "quit" || PlayerCommand.ToLower() == "exit") { LoDConsole.WriteLine("Quitting game"); QuitGame(); } #endregion #region Easter Eggs else if (CommandContains(PlayerCommand, "typical")) { LoDConsole.WriteLine("I know right?\n"); } #endregion #region Debugging else if (DebugEnabled == true) { if (CommandContains(PlayerCommand, "getpos")) { LoDConsole.WriteLine("Row {0}, Col {1}, Level {2}", Char.ConvertFromUtf32(Player.CurrentPos[0] + 65), (Player.CurrentPos[1] + 1).ToString(), (Player.CurrentPos[2] + 1).ToString()); } else if (CommandContains(PlayerCommand, "movepos")) { SaveWorld(); string[] Command = PlayerCommand.Split(' '); bool fail = false; int[] NewCoods = new int[3]; int Row; if (Int32.TryParse(Command[1], out Row)) NewCoods[0] = Row; else { char ThisChar = Command[1].ToUpper().ToCharArray()[0]; int temp = (int)Convert.ToChar(ThisChar); temp = temp - 65; NewCoods[0] = temp; } int Col; if (Int32.TryParse(Command[2], out Col)) NewCoods[1] = Col - 1; else fail = true; int Floor; if (Int32.TryParse(Command[3], out Floor)) NewCoods[2] = Floor - 1; else fail = true; if (!fail) { Player.CurrentPos[0] = NewCoods[0]; Player.CurrentPos[1] = NewCoods[1]; Player.CurrentPos[2] = NewCoods[2]; CurrentRoom = GetRoomInfo(Player.CurrentPos); LoDConsole.WriteLine(CurrentRoom.Description); EventTrigger("moveinto"); } else LoDConsole.WriteLine("Command Failed"); } else LoDConsole.WriteLine(WordWrap("Command not found, type help for a list of valid commands")); } else LoDConsole.WriteLine(WordWrap("Command not found, type help for a list of valid commands")); } catch (Exception ex) { string FileName = DateTime.Now.ToString(@"dd-MM-yyyy HHmmss"); LoDConsole.WriteLine(WordWrap("\nYou have encountered an error.\nThe game engine was not able to handle the command you entered.")); LoDConsole.WriteLine(WordWrap("\nAn error report has been created in .\\Errors\\" + FileName + ".txt\nPlease submit this to the developer")); if (!Directory.Exists(".\\Errors")) Directory.CreateDirectory(".\\Errors"); using (StreamWriter file = new System.IO.StreamWriter(@".\Errors\" + FileName + ".txt", true)) { file.WriteLine("---Legend-Of-Drongo---"); file.WriteLine(""); file.WriteLine("Error logged at {0}", DateTime.Now.ToString(@"dd-MM-yyyy HH:mm:ss")); file.WriteLine(""); file.WriteLine("Player Location: Row {0}, Col {1}, Level {2}\n\n", Char.ConvertFromUtf32(Player.CurrentPos[0] + 65), (Player.CurrentPos[1] + 1), (Player.CurrentPos[2] + 1)); file.WriteLine("Command Entered: {0}\n\n", PlayerCommand); file.WriteLine(""); file.WriteLine(""); Random rng = new Random(); int output = rng.Next(1, 3); switch (output) { case 1: file.WriteLine("The stacktrace output can be scary, do not say the words out loud as you may summon a demon!"); break; case 2: file.WriteLine("The stacktrace output can be scary, some say it can read your very soul!"); break; case 3: file.WriteLine("The stacktrace output can be scary, don't believe it's lies about being sentient!"); break; } file.WriteLine("Error Message: {0}", ex.Message); file.WriteLine("Stacktrace:"); file.WriteLine(ex.StackTrace); file.WriteLine(""); file.WriteLine(""); file.WriteLine("End of line..."); } } #endregion #region Level Up int XP = Player.XP; int Level = Player.Level; if (XP >= XPNeeded(Level)) LevelUp(Level + 1); #endregion #region GameOver if (Player.HPBonus <= 0) { if (Player.CurrentPos[2] == 0) { lock (myLock) { stopTime = 0; } LoDConsole.WriteLine("\n\n Your adventure has come to an end :("); Thread.Sleep(5000); DrawMainMenu(); lock (myLock) { stopTime = 1; } ThisFloor = world[Player.CurrentPos[2]]; CurrentRoom = ThisFloor.CurrentFloor[Player.CurrentPos[0], Player.CurrentPos[1]]; LoDConsole.WriteLine(WordWrap(CurrentRoom.Description)); } else { LoDConsole.WriteLine("\n\n You have died, but this is not the end..."); Thread.Sleep(5000); LoDConsole.Clear(); LoDConsole.WriteLine(WordWrap("\n\n\tYou fall through darkness and smoke\n\tuntil you feel your feet softly make contact with ground")); Player.HPBonus = 60; world[(Player.CurrentPos[2])] = ThisFloor; Player.CurrentPos[0] = 1; Player.CurrentPos[1] = 1; //set coodinates of afterlife Player.CurrentPos[2] = 0; ThisFloor = world[0]; CurrentRoom = GetRoomInfo(Player.CurrentPos); EventTrigger("moveinto"); } } #endregion //LoDConsole.DrawEnvironment(CurrentRoom); }
public static bool IsItemName(itemInfo Item, string Name) { //will return true if name matches item name or interaction name bool itemFound = false; int index = 0; if (Name.ToLower() == Item.Name.ToLower()) itemFound = true; if (Item.InteractionName != null) { while (itemFound == false && index < Item.InteractionName.Count) { if (Name.ToLower() == Item.InteractionName[index].ToLower()) itemFound = true; index++; } } return itemFound; }
public static void SellItem(itemInfo ItemSold, string Vendor) { int index = 0; bool vendorFound = false; if (CurrentRoom.Civilians != null) { while (index < CurrentRoom.Civilians.Count) { if (Vendor.ToLower() == CurrentRoom.Civilians[index].name.ToLower()) { vendorFound = true; if (CurrentRoom.Civilians[index].willBuy == true && (CurrentRoom.Civilians[index].MerchantType == "All" || ItemSold.Class.Contains(CurrentRoom.Civilians[index].MerchantType))) { int cost = -1; if (ItemSold.Value == 0) //Item is worthless { string response = LoDConsole.ReadLine(ItemSold.Name + " is not worth anything. Do you want to give it away?", "Item", "Yes"); if (response.ToLower() == "yes" || response.ToLower() == "y" || response.ToLower() == "hell yeah") { cost = 0; } } else if (CurrentRoom.Civilians[index].Money == 0) //Merchant has no money to buy { string response = LoDConsole.ReadLine(CurrentRoom.Civilians[index].name + " does not have any money. Do you want to give it as a gift?", "Item", "Yes"); if (response.ToLower() == "yes" || response.ToLower() == "y" || response.ToLower() == "hell yeah") { cost = 0; } } else if (CurrentRoom.Civilians[index].Money < ItemSold.Value) //Merchant doesn't have enough money to buy { string temp = CurrentRoom.Civilians[index].name + " only has " + CurrentRoom.Civilians[index].Money + " gold. Do you want to sell " + ItemSold.Name + " for " + CurrentRoom.Civilians[index].Money + " gold?"; LoDConsole.Write("\n>"); string response = LoDConsole.ReadLine(temp, "Item", "Yes"); if (response.ToLower() == "yes" || response.ToLower() == "y" || response.ToLower() == "hell yeah") { cost = CurrentRoom.Civilians[index].Money; } } else //Merchant will buy at face value { LoDConsole.WriteLine(WordWrap(string.Concat("Sucessfully sold ", ItemSold.Name, " to ", Vendor, " for ", ItemSold.Value, " gold coins."))); cost = ItemSold.Value; } CivilianProfile Civy = CurrentRoom.Civilians[index]; if (Civy.inventory == null) Civy.inventory = new List<itemInfo>(); ItemSold.Value = ItemSold.Value + (((ItemSold.Value / 100) * 10) + 10); Civy.inventory.Add(ItemSold); Civy.Money = Civy.Money - cost; Player.Money = Player.Money + cost; if (Civy.Money > 0) Civy.Money = 0; //technically shouldn't happen but whatever CurrentRoom.Civilians[index] = Civy; int Counter = 0; bool itemfound = false; while (itemfound == false && Counter < Player.inventory.Count) { if (ItemSold.Name == Player.inventory[Counter].Name) { Player.inventory.RemoveAt(Counter); itemfound = true; Player.invspace = Player.invspace + 1; } Counter++; } } else LoDConsole.WriteLine(WordWrap(string.Concat(Vendor, " will not buy items of that type from you"))); } index++; } if (vendorFound == false) LoDConsole.WriteLine(WordWrap(string.Concat(Vendor, " does not appear to be in the local area"))); } else LoDConsole.WriteLine("There is nobody here willing to trade"); }
public static itemInfo GainXPfromItem(itemInfo ItemUsed) { if (ItemUsed.XP > 0) Player.XP = Player.XP + ItemUsed.XP; ItemUsed.XP = 0; return ItemUsed; }
public static void GiveItem(string ItemName, string NPC) { int index; bool NPCFound = false; bool GivingMoney = false; int MoneyAmount = 0; itemInfo ItemGiven = new itemInfo(); if (CurrentRoom.Civilians != null || CurrentRoom.Enemy != null || CurrentRoom.items != null) { int n; if (ItemName.Split(' ').Length >= 2 && (ItemName.Split(' ')[1].ToLower() == "gold" || ItemName.Split(' ')[1].ToLower() == "money" || ItemName.Split(' ')[1].ToLower() == "coins") && (Int32.TryParse(ItemName.Split(' ')[0], out n))) //Player is giving gold { if (n <= Player.Money) { GivingMoney = true; MoneyAmount = n; } else MoneyAmount = -1; } else { for (index = 0; index < Player.inventory.Count; index++) { if (IsItemName(Player.inventory[index], ItemName)) { ItemGiven = Player.inventory[index]; Player.inventory.RemoveAt(index); Player.invspace++; GivingMoney = false; } } } index = 0; while (CurrentRoom.Civilians != null && index < CurrentRoom.Civilians.Count && !NPCFound && (ItemGiven.Name != null || GivingMoney)) { if (NPC.ToLower() == CurrentRoom.Civilians[index].name.ToLower()) { NPCFound = true; string temp; if (!GivingMoney) temp = "Do you want to give " + ItemGiven.Name + " as a gift to " + CurrentRoom.Civilians[index].name + "? "; else temp = "Do you want to give " + ItemName + " as a gift to " + CurrentRoom.Civilians[index].name + "? "; string response = LoDConsole.ReadLine(temp, "Item", "Yes"); if (response.ToLower() == "yes" || response.ToLower() == "y" || response.ToLower() == "hell yeah") { if (!GivingMoney) { CivilianProfile Civy = CurrentRoom.Civilians[index]; if (Civy.inventory == null) Civy.inventory = new List<itemInfo>(); Civy.inventory.Add(ItemGiven); CurrentRoom.Civilians[index] = Civy; } else { CivilianProfile Civy = CurrentRoom.Civilians[index]; Civy.Money = Civy.Money + MoneyAmount; CurrentRoom.Civilians[index] = Civy; Player.Money = Player.Money - MoneyAmount; } LoDConsole.WriteLine(WordWrap(string.Concat("\nYou have given ", ItemName, " to ", NPC))); int val; if (!GivingMoney && CurrentRoom.Events != null) { if (ItemName.ToLower() == CurrentRoom.Civilians[index].Donation.ToLower()) EventTrigger("donate", NPC); } else if (GivingMoney == true && CurrentRoom.Events != null) { if (Int32.TryParse(CurrentRoom.Civilians[index].Donation, out val)) { if (MoneyAmount >= val) EventTrigger("donate", NPC); } } } else { LoDConsole.WriteLine(WordWrap(string.Concat("\nYou did not give ", ItemName, " to ", NPC))); Player.inventory.Add(ItemGiven); Player.invspace--; } } index++; } if (!NPCFound && GivingMoney == true) //Check to see if player is trying to bribe an enemy { if (CurrentRoom.Enemy != null ) { index = 0; while (index < CurrentRoom.Enemy.Count) { if (CurrentRoom.Enemy[index].name.ToLower() == NPC.ToLower()) { PayOff(CurrentRoom.Enemy[index].name, MoneyAmount); index = CurrentRoom.Enemy.Count + 1; NPCFound = true; } index++; } } if (!NPCFound) LoDConsole.WriteLine(WordWrap(string.Concat("Could not find ", NPC, " here"))); } if (!NPCFound && !GivingMoney && !string.IsNullOrEmpty(ItemName)) //Check to see if player is trying to use an item { if (CurrentRoom.items != null) { index = 0; while (index < CurrentRoom.items.Count) { if (IsItemName(CurrentRoom.items[index],NPC)) { Player.inventory.Add(ItemGiven); //Give the player his item back as he is not going down the gifting path Player.invspace--; UseItem(ItemName, NPC); index = CurrentRoom.items.Count + 1; NPCFound = true; } index++; } } } else if (!GivingMoney && MoneyAmount == -1) LoDConsole.WriteLine(WordWrap(string.Concat("You do not have ", ItemName))); else if (string.IsNullOrEmpty(ItemGiven.Name) && !GivingMoney) LoDConsole.WriteLine(WordWrap(string.Concat("Could not find ", ItemName, " in your inventory"))); } else LoDConsole.WriteLine("There is nobody here to give items to"); }
public static void ExamineItem(string Objectname) { int index; itemInfo invItem = new itemInfo(); if (CurrentRoom.items != null) foreach (itemInfo Item in CurrentRoom.items) { if (IsItemName(Item, Objectname)) invItem = Item; } if (Player.inventory != null) foreach (itemInfo Item in Player.inventory) { if (IsItemName(Item, Objectname)) invItem = Item; } for (index = 0; index < 5; index++) //Then check the players armor { if (Player.ArmorWorn[index].Name != null) if (IsItemName(Player.ArmorWorn[index], Objectname)) invItem = Player.ArmorWorn[index]; } if (IsItemName(Player.WeaponHeld, Objectname)) invItem = Player.WeaponHeld; //Then check their weapon held if (invItem.Name != null) { if (invItem.Class == "Food" || invItem.Class == "Drink") { LoDConsole.WriteLine(WordWrap(string.Concat("Name: ", invItem.Name))); LoDConsole.WriteLine(WordWrap(string.Concat("Item Type: ", invItem.Class))); LoDConsole.WriteLine(WordWrap(string.Concat("Health Boost: ", invItem.HPmod))); LoDConsole.WriteLine(WordWrap(string.Concat("Value: ", invItem.Value))); LoDConsole.WriteLine(WordWrap(string.Concat(invItem.Examine))); } else if (invItem.Class == "Weapon") { LoDConsole.WriteLine(WordWrap(string.Concat("Name: ", invItem.Name))); LoDConsole.WriteLine(WordWrap(string.Concat("Item Type: ", invItem.Class))); LoDConsole.WriteLine(WordWrap(string.Concat("Base Damage: ", invItem.AttackMod))); LoDConsole.WriteLine(WordWrap(string.Concat("Defense Modifier: ", invItem.DefenseMod))); LoDConsole.WriteLine(WordWrap(string.Concat("Value: ", invItem.Value))); LoDConsole.WriteLine(WordWrap(string.Concat(invItem.Examine))); } else if (invItem.Class.Contains("Armor")) { LoDConsole.WriteLine(WordWrap(string.Concat("Name: ", invItem.Name))); LoDConsole.WriteLine(WordWrap(string.Concat("Item Type: ", invItem.Class))); LoDConsole.WriteLine(WordWrap(string.Concat("Defense Modifier: ", invItem.DefenseMod))); LoDConsole.WriteLine(WordWrap(string.Concat("Value: ", invItem.Value))); LoDConsole.WriteLine(WordWrap(string.Concat(invItem.Examine))); } else if (invItem.Class == "Bed") { LoDConsole.WriteLine(WordWrap(string.Concat("Name: ", invItem.Name))); LoDConsole.WriteLine(WordWrap(string.Concat("Item Type: ", invItem.Class))); LoDConsole.WriteLine(WordWrap(string.Concat("Value: ", invItem.Value))); LoDConsole.WriteLine(WordWrap(string.Concat(invItem.Examine))); } else if (invItem.Class == "Readable") LoDConsole.WriteLine(WordWrap(string.Concat("I think I may be supposed to read this"))); else if (invItem.Class == "Interactive Item") LoDConsole.WriteLine(WordWrap(string.Concat("I think I'm supposed to use ", invItem.Name, " on something"))); else LoDConsole.WriteLine(WordWrap(string.Concat(invItem.Name, " remains a mystery, but you could probably sell it for ", invItem.Value, " gold."))); } else LoDConsole.WriteLine(WordWrap("Item not found in your intentory")); }
public static void Combat(itemInfo WeaponUsed, string enemy) { int NumOfFighters = 0; int Fortitude; Random RNG = new Random(); int index; NumOfFighters = CurrentRoom.Enemy.Count + 1; //LoDConsole.WriteLine(WordWrap("There are ", ," people in the room", NumOfFighters); List<Fighter> ThisFight = new List<Fighter>(); Fighter TempFighter = new Fighter(); TempFighter.name = Player.name; TempFighter.HP = Player.HPBonus; TempFighter.Weapon = WeaponUsed; TempFighter.AttackMod = (WeaponUsed.AttackMod + (Player.Strength - (0.5 * Player.DaysSinceSleep))); TempFighter.DefenseMod = (Player.ArmorBonus + Player.Resitence); TempFighter.isAlive = true; TempFighter.initiative = RNG.Next((Player.Speed - Convert.ToInt32(Math.Round((0.5 * Player.DaysSinceSleep)))), 100); //Use players speed bonus TempFighter.ID = 99; TempFighter.Behaviour = string.Empty; TempFighter.Team = 99; ThisFight.Add(TempFighter); for (index = 0; index < CurrentRoom.Enemy.Count; index++) { TempFighter.name = CurrentRoom.Enemy[index].name; TempFighter.HP = CurrentRoom.Enemy[index].HPBonus; TempFighter.DefenseMod = CurrentRoom.Enemy[index].armor + CurrentRoom.Enemy[index].Weapon.DefenseMod; TempFighter.AttackMod = CurrentRoom.Enemy[index].Weapon.AttackMod; TempFighter.Weapon = CurrentRoom.Enemy[index].Weapon; TempFighter.isAlive = true; TempFighter.initiative = RNG.Next(0, 100); //Roll 1d100 to decide initiative TempFighter.ID = index; TempFighter.Behaviour = CurrentRoom.Enemy[index].Behaviour; TempFighter.Team = CurrentRoom.Enemy[index].Team; ThisFight.Add(TempFighter); } index = 0; while (index < (NumOfFighters - 1)) //Sort fighters into highest initiative first { if (ThisFight[index].initiative < ThisFight[index + 1].initiative) { TempFighter = ThisFight[index]; ThisFight[index] = ThisFight[index + 1]; ThisFight[index + 1] = TempFighter; index = 0; } else { index++; } } double BaseAttack = 0; index = 0; while (index < ThisFight.Count && Player.HPBonus > 0 && CurrentRoom.Enemy != null && CurrentRoom.Enemy.Count != 0) { if (ThisFight[index].name == Player.name) //players turn { BaseAttack = RNG.Next(1, 6); if (BaseAttack == 1 || BaseAttack == 2) { //bad attack LoDConsole.WriteLine(WordWrap(string.Concat("You attack enemy ", enemy, " with your ", Player.WeaponHeld.Name, "\n", Player.WeaponHeld.BadHit))); } else if (BaseAttack == 3 || BaseAttack == 4) { //Medium Weak Attack LoDConsole.WriteLine(WordWrap(string.Concat("You attack enemy ", enemy, " with your ", Player.WeaponHeld.Name, "\n", Player.WeaponHeld.MedHit))); } else if (BaseAttack == 5 || BaseAttack == 6) { //Critical Attack LoDConsole.WriteLine(WordWrap(string.Concat("You attack enemy ", enemy, " with your ", Player.WeaponHeld.Name, "\n", Player.WeaponHeld.GoodHit))); } BaseAttack = BaseAttack * ThisFight[index].AttackMod; int Counter = 0; bool GaveHit = false; while (CurrentRoom.Enemy != null && Counter < ThisFight.Count && GaveHit == false && CurrentRoom.Enemy.Count != 0) { if (ThisFight[Counter].name.ToLower() == enemy.ToLower()) { EnemyProfile ThisEnemy = CurrentRoom.Enemy[ThisFight[Counter].ID]; ThisEnemy.PayOff = 0; //Do not allow the player to bribe the enemy after attacking them Fortitude = RNG.Next(1, 100); if (Fortitude > ThisEnemy.armor) ThisEnemy.HPBonus = ThisEnemy.HPBonus - BaseAttack; else ThisEnemy.HPBonus = ThisEnemy.HPBonus - Math.Ceiling((double)(BaseAttack / 110) * ThisEnemy.armor); if (ThisEnemy.HPBonus < 0) //if the enemy has been killed { LoDConsole.WriteLine(); if (CurrentRoom.Enemy[ThisFight[Counter].ID].DeathMessage == null) { LoDConsole.WriteLine(WordWrap(string.Concat("With this hit you kill the enemy ", CurrentRoom.Enemy[ThisFight[Counter].ID].name))); } else { LoDConsole.WriteLine(WordWrap(CurrentRoom.Enemy[ThisFight[Counter].ID].DeathMessage)); } if (CurrentRoom.items == null) CurrentRoom.items = new List<itemInfo>(); CurrentRoom.items.Add(ThisEnemy.Weapon); itemInfo newItem = new itemInfo(); newItem.Name = string.Concat(ThisEnemy.name, "'s body"); newItem.Class = "Object"; newItem.Examine = string.Concat("The slashed and torn body of enemy ", ThisEnemy.name); newItem.CanPickUp = false; newItem.InteractionName = new List<string>(); newItem.InteractionName.Add("body"); newItem.InteractionName.Add("corpse"); newItem.InteractionName.Add("enemy"); newItem.InteractionName.Add(string.Concat(ThisEnemy.name, "'s body")); newItem.InteractionName.Add(ThisEnemy.name); CurrentRoom.items.Add(newItem); if (ThisEnemy.Money != 0) LoDConsole.WriteLine("\nYou take {0} gold coins from {1}'s corpse", ThisEnemy.Money.ToString(), enemy); Player.Money = Player.Money + ThisEnemy.Money; //take money from enemy GainXPfromEnemy(ThisEnemy); //Take XP NumOfFighters = NumOfFighters - 1; SaveWorld(); EventTrigger("killenemy", ThisEnemy.name); CurrentRoom.Enemy.RemoveAt(ThisFight[Counter].ID); if (CurrentRoom.Enemy.Count != 0) { //Remove the fighter ThisFight.RemoveAt(Counter); } else { EventTrigger("killallenemies"); //if (CurrentRoom.Enemy != null) CurrentRoom.Enemy.Clear(); } } else CurrentRoom.Enemy[ThisFight[Counter].ID] = ThisEnemy; GaveHit = true; } Counter++; } } else //enemies turn { int EnemyTarget = FindEnemyTarget(ThisFight, index); //Find enemy based on this enemies behaviour BaseAttack = RNG.Next(1, 3); string target = ThisFight[EnemyTarget].name; if (ThisFight[EnemyTarget].ID == 99) target = "you"; LoDConsole.WriteLine(WordWrap(string.Concat(ThisFight[index].name, " attacks ", target, " with their ", ThisFight[index].Weapon.Name))); if (BaseAttack == 1) { //bad attack BaseAttack = BaseAttack * ThisFight[index].AttackMod; LoDConsole.WriteLine(WordWrap(string.Concat(ThisFight[index].Weapon.BadHit))); } else if (BaseAttack == 2) { //Medium Attack BaseAttack = BaseAttack * ThisFight[index].AttackMod; LoDConsole.WriteLine(WordWrap(string.Concat(ThisFight[index].Weapon.MedHit))); } else if (BaseAttack == 3) { //Strong Attack BaseAttack = BaseAttack * ThisFight[index].AttackMod; LoDConsole.WriteLine(WordWrap(string.Concat(ThisFight[index].Weapon.GoodHit))); } if (ThisFight[EnemyTarget].ID == 99) { Fortitude = RNG.Next(1, 100); if (Fortitude > ThisFight[EnemyTarget].DefenseMod) Player.HPBonus = Player.HPBonus - BaseAttack; else Player.HPBonus = Player.HPBonus - Math.Ceiling((double)(BaseAttack / 110) * Player.ArmorBonus); Player.HPBonus = Math.Round((double)Player.HPBonus, 2); if (Player.HPBonus < 0) { if (CurrentRoom.Enemy[ThisFight[index].ID].KillMessage != null) { LoDConsole.WriteLine(WordWrap(string.Concat("\n", CurrentRoom.Enemy[ThisFight[index].ID].KillMessage))); } else { LoDConsole.WriteLine(WordWrap(string.Concat("\n\n", CurrentRoom.Enemy[ThisFight[index].ID].name, " has killed you with their ", CurrentRoom.Enemy[ThisFight[index].ID].Weapon.Name))); } NumOfFighters = NumOfFighters - 1; } } else { EnemyProfile ThisEnemy = CurrentRoom.Enemy[ThisFight[EnemyTarget].ID]; ThisEnemy.PayOff = 0; //Do not allow the player to bribe the enemy after attacking them Fortitude = RNG.Next(1, 100); if (Fortitude > ThisEnemy.armor) ThisEnemy.HPBonus = ThisEnemy.HPBonus - BaseAttack; else ThisEnemy.HPBonus = ThisEnemy.HPBonus - Math.Ceiling((double)(BaseAttack / 110) * ThisEnemy.armor); if (ThisEnemy.HPBonus < 0) //if the enemy has been killed { LoDConsole.WriteLine(); if (CurrentRoom.Enemy[ThisFight[EnemyTarget].ID].DeathMessage == null) { LoDConsole.WriteLine(WordWrap(string.Concat("With this hit ", ThisFight[index].name, " kills the enemy ", CurrentRoom.Enemy[ThisFight[EnemyTarget].ID].name))); } else { LoDConsole.WriteLine(WordWrap(CurrentRoom.Enemy[ThisFight[EnemyTarget].ID].DeathMessage)); } if (CurrentRoom.items == null) CurrentRoom.items = new List<itemInfo>(); CurrentRoom.items.Add(ThisEnemy.Weapon); itemInfo newItem = new itemInfo(); newItem.Name = string.Concat(ThisEnemy.name, "'s body"); newItem.Class = "Object"; newItem.Examine = string.Concat("The slashed and torn body of enemy ", ThisEnemy.name); newItem.CanPickUp = false; newItem.InteractionName = new List<string>(); newItem.InteractionName.Add("body"); newItem.InteractionName.Add("corpse"); newItem.InteractionName.Add("enemy"); newItem.InteractionName.Add(string.Concat(ThisEnemy.name, "'s body")); newItem.InteractionName.Add(ThisEnemy.name); CurrentRoom.items.Add(newItem); //Player should not get money/xp if an enemy kills another enemy? //Player.Money = Player.Money + ThisEnemy.Money; //take money from enemy //Player.XP = Player.XP + ThisEnemy.XP; //Take XP NumOfFighters = NumOfFighters - 1; SaveWorld(); EventTrigger("killenemy", ThisEnemy.name); CurrentRoom.Enemy.RemoveAt(ThisFight[EnemyTarget].ID); if (CurrentRoom.Enemy.Count != 0) { //Remove the fighter ThisFight.RemoveAt(EnemyTarget); } else { EventTrigger("killallenemies"); //if (CurrentRoom.Enemy != null) CurrentRoom.Enemy.Clear(); } } else CurrentRoom.Enemy[ThisFight[EnemyTarget].ID] = ThisEnemy; } } //Thread.Sleep(1500); LoDConsole.WriteLine(""); index++; } }
public static Event EventAction(Event thisEvent) { if (thisEvent.Triggered == false) { thisEvent.Triggered = true; if (thisEvent.Action.ToLower() == "unlockroom") //unlock { if (thisEvent.Coodinates != null) { ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].CanMove = true; } } else if (thisEvent.Action.ToLower() == "lockroom") //lock { if (thisEvent.Coodinates != null) { ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].CanMove = false; } } else if (thisEvent.Action.ToLower() == "unlockbuilding") //unlock { if (thisEvent.Coodinates != null) { ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building.CanMove = true; } } else if (thisEvent.Action.ToLower() == "lockbuilding") //lock { if (thisEvent.Coodinates != null) { ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building.CanMove = false; } } else if (thisEvent.Action.ToLower() == "lockin") { if (!CurrentRoom.LockedIn) CurrentRoom.LockedIn = true; else CurrentRoom.LockedIn = false; SaveWorld(); } else if (thisEvent.Action.ToLower() == "kill all enemies") //kill all { //do some other things if (CurrentRoom.Enemy != null) { if (CurrentRoom.items == null) CurrentRoom.items = new List<itemInfo>(); foreach (EnemyProfile ThisEnemy in CurrentRoom.Enemy) { CurrentRoom.items.Add(ThisEnemy.Weapon); itemInfo newItem = new itemInfo(); newItem.Name = string.Concat(ThisEnemy.name, "'s body"); newItem.Class = "Object"; newItem.Examine = string.Concat("The slashed and torn body of enemy ", ThisEnemy.name); newItem.CanPickUp = false; newItem.InteractionName = new List<string>(); newItem.InteractionName.Add("body"); newItem.InteractionName.Add("corpse"); newItem.InteractionName.Add("enemy"); newItem.InteractionName.Add(string.Concat(ThisEnemy.name, "'s body")); newItem.InteractionName.Add(ThisEnemy.name); CurrentRoom.items.Add(newItem); GainXPfromEnemy(ThisEnemy); } EventTrigger("killallenemies"); CurrentRoom.Enemy.Clear(); //Overwrite all enemies } } else if (thisEvent.Action.ToLower() == "remove all npcs") //remove all npcs { CurrentRoom.Civilians.Clear(); SaveWorld(); } else if (thisEvent.Action.ToLower() == "remove all items") //remove all npcs { CurrentRoom.items.Clear(); SaveWorld(); } else if (thisEvent.Action.ToLower() == "change description" || thisEvent.Action.ToLower() == "custom description") //change description { if (thisEvent.Coodinates[2] != Player.CurrentPos[2]) //If change is not on this floor { Floor TempFloor; TempFloor = world[thisEvent.Coodinates[2]]; if (!thisEvent.ApplyToBuilding) { if (thisEvent.Action.ToLower() == "change description") TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].AltDescription; else TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = thisEvent.EventValue; } else if (thisEvent.ApplyToBuilding == true && TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building.BuildingName != null) { roomInfo TempRoom = new roomInfo(); DataTypes dt = new DataTypes(); TempRoom = dt.BuildingIntoRoom(TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building); if (thisEvent.Action.ToLower() == "change description") TempRoom.Description = TempRoom.AltDescription; else TempRoom.Description = thisEvent.EventValue; TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building = dt.RoomIntoBuilding(TempRoom); } world[thisEvent.Coodinates[2]] = TempFloor; } else if (Player.CurrentPos[0] != thisEvent.Coodinates[0] || Player.CurrentPos[1] != thisEvent.Coodinates[1]) //Change is not in this cell { if (!thisEvent.ApplyToBuilding) { if (thisEvent.Action.ToLower() == "change description") ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].AltDescription; else ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = thisEvent.EventValue; } else if (thisEvent.ApplyToBuilding == true && ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building.BuildingName != null) { roomInfo TempRoom = new roomInfo(); DataTypes dt = new DataTypes(); TempRoom = dt.BuildingIntoRoom(ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building); if (thisEvent.Action.ToLower() == "change description") TempRoom.Description = TempRoom.AltDescription; else TempRoom.Description = thisEvent.EventValue; ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building = dt.RoomIntoBuilding(TempRoom); } } else { if ((!thisEvent.ApplyToBuilding && !Player.InBuilding) || (thisEvent.ApplyToBuilding && Player.InBuilding)) //Applying to the non-building area the player is in { if (thisEvent.Action.ToLower() == "change description") CurrentRoom.Description = CurrentRoom.AltDescription; else CurrentRoom.Description = thisEvent.EventValue; } else if (!thisEvent.ApplyToBuilding && Player.InBuilding == true) //Applies to current cell but player is in building { if (thisEvent.Action.ToLower() == "change description") ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].AltDescription; else ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = thisEvent.EventValue; } else if (thisEvent.ApplyToBuilding == true && Player.InBuilding == false) //Applies to building in current Cell { roomInfo TempRoom = new roomInfo(); DataTypes dt = new DataTypes(); TempRoom = dt.BuildingIntoRoom(ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building); if (thisEvent.Action.ToLower() == "change description") TempRoom.Description = TempRoom.AltDescription; else TempRoom.Description = thisEvent.EventValue; ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building = dt.RoomIntoBuilding(TempRoom); } } SaveWorld(); CurrentRoom = GetRoomInfo(Player.CurrentPos); //retreive new room info } else if (thisEvent.Action.ToLower() == "change location") //change floor { bool newFloor = false; if (thisEvent.Coodinates[2] != Player.CurrentPos[2]) newFloor = true; //If the player is changing floors //ThisEvent will remain bool untriggered as will allow multiple re-use //Thread.Sleep(5000); world[Player.CurrentPos[2]] = ThisFloor; //save floor to list. Player.CurrentPos[0] = thisEvent.Coodinates[0]; Player.CurrentPos[1] = thisEvent.Coodinates[1]; //set players position to start of new room Player.CurrentPos[2] = thisEvent.Coodinates[2]; ThisFloor = world[Player.CurrentPos[2]]; //retreive new floor if (!thisEvent.ApplyToBuilding) Player.InBuilding = false; else Player.InBuilding = true; CurrentRoom = GetRoomInfo(Player.CurrentPos); //retreive new room info //else if (!string.IsNullOrEmpty(ThisFloor.CurrentFloor[Player.CurrentPos[0], Player.CurrentPos[1]].Building.BuildingName)) //move player into building. //{ // DataTypes dt = new DataTypes(); // CurrentRoom = dt.BuildingIntoRoom(ThisFloor.CurrentFloor[Player.CurrentPos[0],Player.CurrentPos[1]].Building); //} LoDConsole.Clear(); //clear the screen LoDConsole.WriteLine(WordWrap(CurrentRoom.Description)); if (newFloor == true && ThisFloor.FloorSong != null && File.Exists(ThisFloor.FloorSong)) { MusicPlayer.SoundLocation = ThisFloor.FloorSong; Music("Start"); } } else if (thisEvent.Action.ToLower() == "change objective") { Player.Objective = thisEvent.EventValue; LoDConsole.WriteLine("\nYour current objective has changed."); } /* else if (thisEvent.Action.ToLower() == "custom description") { CurrentRoom.Description = thisEvent.EventValue; SaveWorld(); } */ else if (thisEvent.Action.ToLower() == "output text") { LoDConsole.WriteLine(""); LoDConsole.WriteLine(WordWrap(thisEvent.EventValue)); } else if (thisEvent.Action == "spawnItems") { if (CurrentRoom.items == null) CurrentRoom.items = new List<itemInfo>(); foreach (itemInfo Item in thisEvent.Items) { CurrentRoom.items.Add(Item); } SaveWorld(); } else if (thisEvent.Action == "spawnNPC") { if (CurrentRoom.Civilians == null) CurrentRoom.Civilians = new List<CivilianProfile>(); foreach (CivilianProfile NPC in thisEvent.NPCs) { CurrentRoom.Civilians.Add(NPC); } SaveWorld(); } else if (thisEvent.Action == "spawnEnemy") { if (CurrentRoom.Enemy == null) CurrentRoom.Enemy = new List<EnemyProfile>(); foreach (EnemyProfile Enemy in thisEvent.Enemies) { CurrentRoom.Enemy.Add(Enemy); } SaveWorld(); } else if (thisEvent.Action == "giveXP") { int n; if (int.TryParse(thisEvent.EventValue, out n)) Player.XP = Player.XP + n; } else if (thisEvent.Action == "EndCredits") { Console.ReadKey(); EndCredits(); } else thisEvent.Triggered = false; //If an event is re-usable allow it to be triggered again if (thisEvent.Triggered == true && thisEvent.ReUsable == true) thisEvent.Triggered = false; if (thisEvent.Coodinates != null && thisEvent.Coodinates[0] == Player.CurrentPos[0] && thisEvent.Coodinates[1] == Player.CurrentPos[1] && thisEvent.Coodinates[2] == Player.CurrentPos[2]) CurrentRoom = GetRoomInfo(Player.CurrentPos); } return thisEvent; }
public static void EquipItem(string PlayerCommand) { int index; string item = string.Empty; if (PlayerCommand.ToLower() == "equip") { LoDConsole.WriteLine(WordWrap("Specify an item to equip:\n")); for (index = 0; index < Player.inventory.Count; index++) { if (Player.inventory[index].Class == "Weapon" || Player.inventory[index].Class.Contains("Armor")) { LoDConsole.WriteLine(WordWrap(Player.inventory[index].Name)); } } item = LoDConsole.ReadLine("Which item would you like to equip?", "Equip Item", string.Empty); } else { string[] strArray = PlayerCommand.Split(' '); for (index = 1; index < strArray.Length; index++) { item = string.Concat(item, " ", strArray[index]); } } item = item.Trim(); bool itemFound = false; itemInfo tempItem = new itemInfo(); for (index = 0; index < Player.inventory.Count && !itemFound; index++) { if (IsItemName(Player.inventory[index], item)) { itemFound = true; if (Player.inventory[index].Class == "Weapon") { Player.ArmorBonus = Player.ArmorBonus - Player.WeaponHeld.DefenseMod; tempItem = Player.WeaponHeld; Player.WeaponHeld = Player.inventory[index]; Player.inventory[index] = tempItem; Player.ArmorBonus = Player.ArmorBonus + Player.WeaponHeld.DefenseMod; LoDConsole.WriteLine(WordWrap(string.Concat("You have equipped ", item, " as your current weapon"))); LoDConsole.WriteLine(WordWrap(string.Concat("Your old weapon ", Player.inventory[index].Name, " has been been placed in your inventory."))); } else if (Player.inventory[index].Class.Contains("Armor")) { //LoDConsole.WriteLine(WordWrap("You cannot equip armor at this time"); string armorType = Player.inventory[index].Class; int armorPOS = 0; itemFound = true; if (armorType == "Armor-Helmet") armorPOS = 0; else if (armorType == "Armor-Chest") armorPOS = 1; else if (armorType == "Armor-Gloves") armorPOS = 2; else if (armorType == "Armor-Legs") armorPOS = 3; else if (armorType == "Armor-Boots") armorPOS = 4; if (Player.ArmorWorn[armorPOS].Name != null) //armor of that type is already being worn { tempItem = Player.ArmorWorn[armorPOS]; Player.ArmorWorn[armorPOS] = Player.inventory[index]; Player.inventory[index] = tempItem; LoDConsole.WriteLine(WordWrap(string.Concat("You have equipped ", item, " as your ", armorType.Split('-')[1], " armor"))); LoDConsole.WriteLine(WordWrap(string.Concat("Your old armor ", Player.inventory[index].Name, " has been been placed in your inventory."))); Player.ArmorBonus = Player.ArmorBonus - tempItem.DefenseMod; Player.ArmorBonus = Player.ArmorBonus + Player.ArmorWorn[armorPOS].DefenseMod; } else { Player.ArmorWorn[armorPOS] = Player.inventory[index]; Player.ArmorBonus = Player.ArmorBonus + Player.inventory[index].DefenseMod; Player.inventory.RemoveAt(index); //remove item from inventory as it isn't replacing anything Player.invspace = Player.invspace + 1; LoDConsole.WriteLine(WordWrap(string.Concat("You have equipped ", item, " as your ", armorType.Split('-')[1], " armor"))); } if (Player.ArmorBonus > 100) Player.ArmorBonus = 100; } else LoDConsole.WriteLine(WordWrap(string.Concat("You cannot equip ", item))); } } if (itemFound == false) { LoDConsole.WriteLine(WordWrap("Item not found in your inventory, use 'inventory' to see items you possess")); } }
public static void BuyItem(string itemName, string vendor) { itemInfo item = new itemInfo(); int index = 0; int counter = 0; if (CurrentRoom.Civilians.Count != 0) { bool itemFound = false; bool vendorFound = false; while (itemFound == false && index < CurrentRoom.Civilians.Count) { if (CurrentRoom.Civilians[index].inventory != null && CurrentRoom.Civilians[index].name.ToLower() == vendor.ToLower() && CurrentRoom.Civilians[index].willSell == true) { vendorFound = true; if (CurrentRoom.Civilians[index].willSell == true) { while (itemFound == false && counter < CurrentRoom.Civilians[index].inventory.Count) { if (IsItemName(CurrentRoom.Civilians[index].inventory[counter], itemName)) { item = CurrentRoom.Civilians[index].inventory[counter]; if (Player.Money >= item.Value) { Player.Money = Player.Money - item.Value; Player.inventory.Add(item); Player.invspace = Player.invspace - 1; LoDConsole.WriteLine(WordWrap(string.Concat("You have successfully purchased ", itemName, " for ", item.Value, " gold coins"))); CurrentRoom.Civilians[index].inventory.RemoveAt(counter); } else LoDConsole.WriteLine(WordWrap(string.Concat(itemName, " costs ", item.Value, " gold coins and you only have ", Player.Money, ". You cannot afford this"))); itemFound = true; } else counter++; } } else LoDConsole.WriteLine(WordWrap(string.Concat(vendor, "is not willing to sell anything to you"))); } index++; } if (itemFound == false && vendorFound == true) LoDConsole.WriteLine(WordWrap(string.Concat("The merchant does not seem to be selling ", itemName))); else if (itemFound == false && vendorFound == false) LoDConsole.WriteLine(WordWrap(string.Concat(vendor, " is not willing to sell anything to you."))); } else LoDConsole.WriteLine("There are no people in the area to buy from"); }