public Player(string name, int level, int job) { _name = name; _level = level; _job = job; _inventory = new Inventory(this, 20); _questLog = new QuestLog(); }
protected void ShowStartQuest(QuestLog questLog) { bool exit = false; while (!exit) { Console.WriteLine("Start a Quest"); Console.WriteLine("Type 'done' when finished starting quests."); int questId = GetIntInput("Enter a questId> ", "done"); if (questId > 0) { if (!questLog.HasStarted(questId)) { if (!questLog.HasCompleted(questId)) { questLog.StartQuest(questId); Console.WriteLine("Quest {0} has been started.", questId); } else { Console.WriteLine("Quest has already been completed."); } } else { Console.WriteLine("Quest has already been started."); } } else if (questId == -1) { exit = true; } else { Console.WriteLine("Invalid quest Id."); } Console.WriteLine(); } }
protected void ShowQuestMenu(QuestLog questLog) { bool exit = false; while (!exit) { byte selection = ShowMenu("Show Quests", "Start a Quest", "Abandon a Quest", "Complete a Quest", "Return to Player Menu"); switch (selection) { case 1: ListQuests(questLog); Console.WriteLine(); break; case 2: ShowStartQuest(questLog); Console.WriteLine(); break; case 3: ShowAbandonQuest(questLog); Console.WriteLine(); break; case 4: ShowCompleteQuest(questLog); Console.WriteLine(); break; case 5: exit = true; break; } } }
protected void ShowCompleteQuest(QuestLog questLog) { if (questLog.StartedQuests.Length == 0) { Console.WriteLine("No quests have been started."); Console.WriteLine(); return; } bool exit = false; while (!exit) { ListQuests(questLog); Console.WriteLine(); Console.WriteLine("Complete a Quest"); Console.WriteLine("Type 'done' when finished completing quests."); int questId = GetIntInput("Enter a questId> ", "done"); if (questId > 0) { if (!questLog.HasCompleted(questId)) { if (questLog.HasStarted(questId)) { questLog.CompleteQuest(questId); Console.WriteLine("Quest {0} has been completed.", questId); } else { Console.WriteLine("Quest has not been started."); } } else { Console.WriteLine("Quest has already been completed."); } } else if (questId == -1) { exit = true; } else { Console.WriteLine("Invalid quest Id."); } } Console.WriteLine(); }
protected void ShowAbandonQuest(QuestLog questLog) { bool exit = false; while (!exit) { if (questLog.StartedQuests.Length == 0) { Console.WriteLine("No quests have been started."); Console.WriteLine(); return; } ListQuests(questLog); Console.WriteLine(); Console.WriteLine("Adbandon a Quest"); Console.WriteLine("Type 'done' when finished abandoning quests."); int questId = GetIntInput("Enter a questId> ", "done"); if (questId > 0) { if (questLog.HasStarted(questId)) { questLog.AbandonQuest(questId); Console.WriteLine("Quest {0} has been abandoned.", questId); } else { Console.WriteLine("Quest has not been started."); } } else if (questId == -1) { exit = true; } else { Console.WriteLine("Invalid quest Id."); } } Console.WriteLine(); }
protected void ListQuests(QuestLog questLog) { int[] startedQuests = questLog.StartedQuests; int[] completedQuests = questLog.CompletedQuests; Console.WriteLine("Quest Log"); if (startedQuests.Length > 0) { Console.WriteLine("In-Progress"); Console.WriteLine(string.Join(", ", startedQuests)); Console.WriteLine(); } else { Console.WriteLine("No quests are in progress."); } if (completedQuests.Length > 0) { Console.WriteLine("Completed"); Console.WriteLine(string.Join(", ", completedQuests)); } else { Console.WriteLine("No quests have been completed."); } }