public void Explore() { bool finished = false; string choice; bool picked = false; character.DisplayStats(); while (!finished) { DisplayRoom(); Console.Write("\nWhat do you want to do?"); choice = Console.ReadLine(); picked = false; if (Utility.NotBlank(choice)) { if (Utility.WordMatch(choice, "north", picked)) { nextroom = game.rooms[currentroom].northexit; if (nextroom == -1) { Console.Write("\nYou cannot go that way.\n"); System.Threading.Thread.Sleep(600); } else { currentroom = nextroom; Console.WriteLine("OK\n"); } picked = true; } if (Utility.WordMatch(choice, "east", picked)) { nextroom = game.rooms[currentroom].eastexit; if (nextroom == -1) { Console.Write("\nYou cannot go that way.\n"); System.Threading.Thread.Sleep(600); } else { currentroom = nextroom; Console.WriteLine("OK\n"); } picked = true; } if (Utility.WordMatch(choice, "west", picked)) { nextroom = game.rooms[currentroom].westexit; if (nextroom == -1) { Console.Write("\nYou cannot go that way.\n"); System.Threading.Thread.Sleep(600); } else { currentroom = nextroom; Console.WriteLine("OK\n"); } picked = true; } if (Utility.WordMatch(choice, "south", picked)) { nextroom = game.rooms[currentroom].southexit; if (nextroom == -1) { Console.Write("\nYou cannot go that way.\n"); System.Threading.Thread.Sleep(600); } else { currentroom = nextroom; Console.WriteLine("OK\n"); } picked = true; } if (Utility.WordMatch(choice, "stay", picked)) { bool foundkeeper = false; int innprice = 0; foreach (Creature c in game.rooms[currentroom].creatures) { foreach (CreatureAttribute a in c.cattributes) { if (a.atname == "Inn") { foundkeeper = true; innprice = a.atvalue; break; } } } if (foundkeeper) { if (character.gold >= innprice) { Console.Write("\nWill you stay at the Inn for " + innprice + " gold? "); choice = Console.ReadLine(); if (Utility.WordMatch(choice, "yes", picked)) { character.gold -= innprice; character.hp = character.maxhp; character.mp = character.maxmp; Console.WriteLine("You have a hearty meal and a good nights sleep.\nYou awaken invigorated and ready to win the day!"); character.DisplayStats(); RespawnEnemies(); } else { Console.WriteLine("Away with you then!"); } } else { Console.WriteLine("You do not have enough gold to stay at this Inn"); } } else { Console.WriteLine("There is no Innkeeper here."); } picked = true; } if (Utility.WordMatch(choice, "inventory", picked)) { character.displayinv(); picked = true; } if (Utility.WordMatch(choice, "save", picked)) { saver.SaveData(character, character.name + ".character"); Console.Write("\nData Saved.\n"); character.DisplayStats(); picked = true; } if (Utility.WordMatch(choice, "equip", picked) || Utility.WordMatch(choice, "wear", picked)) { foreach (Item item in character.inventory) { if (Utility.KeyWord(choice, item.name)) { character.equip(item); } } picked = true; } if (Utility.WordMatch(choice, "inspect", picked) || Utility.WordMatch(choice, "look", picked)) { foreach (Item item in character.inventory) { if (Utility.KeyWord(choice, item.name)) { item.FullDetails(); } } picked = true; } if (Utility.WordMatch(choice, "kill", picked) || Utility.WordMatch(choice, "fight", picked)) { //check every creature in room and find the first one whos name matches foreach (Creature target in game.rooms[currentroom].creatures) { if (Utility.KeyWord(choice, target.name)) { //found a creature with this name List <Creature> opponents = new List <Creature>(); opponents.Add(target); //check each creature in room, if it is in the same faction it will assist foreach (Creature assistant in game.rooms[currentroom].creatures) { if (target.Equals(assistant)) { Console.ForegroundColor = ConsoleColor.Red; Utility.Colorize("You attack #c" + target.name); System.Threading.Thread.Sleep(50); } else { if (target.faction == assistant.faction) { Utility.Colorize("#c" + assistant.name + "#w moves to assist #c" + target.name); opponents.Add(assistant); System.Threading.Thread.Sleep(50); } else { Utility.Colorize("#c" + assistant.name + "#w doesn't give a shit."); System.Threading.Thread.Sleep(50); } } } Combat mycombat = new Combat(character, opponents); if (mycombat.Battle()) { int expgain; int goldgain; foreach (Creature o in opponents) { expgain = rng.Next(1, o.exp); goldgain = rng.Next(1, o.gold); Console.WriteLine("Gained " + expgain + " experience and " + goldgain + " gold from defeating " + o.name); character.exp += expgain; character.gold += goldgain; if (game.rooms[currentroom].creatures.Contains(o)) { game.rooms[currentroom].creatures.Remove(o); } } opponents.Clear(); Console.ForegroundColor = ConsoleColor.White; break; } } } picked = true; } if (Utility.WordMatch(choice, "stats", picked) || Utility.WordMatch(choice, "score", picked)) { Console.WriteLine("Display stats"); character.DisplayStats(); picked = true; } if (Utility.WordMatch(choice, "done", picked) || Utility.WordMatch(choice, "exit", picked)) { Console.Write("\nBe done with you!.\n"); picked = true; finished = true; } if (Utility.WordMatch(choice, "help", picked)) { Console.WriteLine("kill / fight = attack a creature"); Console.WriteLine("stats = see your current stats"); Console.WriteLine("look / inspect = take a closer look at something"); Console.WriteLine("equip / wear = wear/wield a piece of equipment"); Console.WriteLine("save = save your character"); Console.WriteLine("inventory = check your inventory"); Console.WriteLine("north/south/east/west = travel"); picked = true; } if (picked) { } else { Console.WriteLine("That did not register, please try again.\n"); } } } }
public void NewCharacter() { inventory.Clear(); weapon = null; armor = null; shield = null; SaveMaker saver = new SaveMaker(); string choice; bool picked = false; string mychar = ""; bool confirm = false; while (string.IsNullOrWhiteSpace(mychar)) { Console.Write("Welcome to Garlos, what is yon name? "); mychar = Console.ReadLine(); } name = mychar; //Character character = new Character(); reset(); Console.WriteLine("Welcome " + name + "\nYour starting stats are as follows:\n"); while (!confirm) { while (statpoints > 0) { Console.WriteLine("HP: " + hp + "/" + maxhp); Console.WriteLine("MP: " + mp + "/" + maxmp); Console.WriteLine("Strength: " + str); Console.WriteLine("Dexterity: " + dex); Console.WriteLine("Wisdom: " + wis); Console.WriteLine("Constitution: " + con); Console.WriteLine("\nYou currently have " + statpoints + " stat points to distribute\n"); Console.Write("What stat will you improve (hp gains by 5 and mp gains by 2)? "); choice = Console.ReadLine(); picked = false; if (Utility.NotBlank(choice)) { if (Utility.WordMatch(choice, "dexterity", picked)) { Console.WriteLine("You chose dexterity!"); dex += 1; picked = true; } if (Utility.WordMatch(choice, "strength", picked)) { Console.WriteLine("You chose strength!"); str += 1; picked = true; } if (Utility.WordMatch(choice, "wisdom", picked)) { Console.WriteLine("You chose wisdom!"); wis += 1; picked = true; } if (Utility.WordMatch(choice, "constitution", picked)) { Console.WriteLine("You chose constitution!"); con += 1; picked = true; } if (Utility.WordMatch(choice, "hp", picked)) { Console.WriteLine("You chose hp!"); hp += 5; maxhp += 5; picked = true; } if (Utility.WordMatch(choice, "mp", picked)) { Console.WriteLine("You chose mp!"); mp += 2; maxmp += 2; picked = true; } if (picked) { statpoints--; } else { Console.WriteLine("That did not register, please try again.\n"); } } } calcstats(); Console.WriteLine("You have finished character creation. Your final stats are as follows:\n"); Console.WriteLine("HP: " + hp + "/" + maxhp); Console.WriteLine("MP: " + mp + "/" + maxmp); Console.Write("\nStr:\t" + str + "\tDex:\t" + dex); Console.Write("\nWis:\t" + wis + "\tCon:\t" + con); Console.Write("\nAtt:\t" + attack + "\tDef:\t" + defense); picked = false; while (!picked) { Console.Write("\nIs this acceptable (y/n)?"); choice = Console.ReadLine(); if (Utility.WordMatch(choice, "yes", picked)) { startingequip(); confirm = true; picked = false; while (!picked) { Console.Write("\nWill you save (y/n)?"); choice = Console.ReadLine(); if (Utility.WordMatch(choice, "yes", picked)) { picked = true; saver.SaveData(this, name + ".character"); Console.Write("\nData Saved.\n"); DisplayStats(); } if (Utility.WordMatch(choice, "no", picked)) { picked = true; DisplayStats(); } } } if (Utility.WordMatch(choice, "no", picked)) { picked = true; reset(); } } } calcstats(); }