コード例 #1
0
ファイル: NPC.cs プロジェクト: pareion/tamagotchi
 internal void addQuest(Quest q)
 {
     quests.Add(q);
 }
コード例 #2
0
ファイル: AreaHandler.cs プロジェクト: pareion/tamagotchi
        internal Player Ferrington(Player play)
        {
            try_again:
            Console.Clear();
            player = play;
            Area area = new Area("Ferrington", 1);
            NPC npc = new NPC("Merchant");
            NPC npc2 = new NPC("King's Diplomat");
            Item a = IC.CreateAtkItem("Steel sword", Item.equipment.weapon, 20, 5, 100);
            a.Price = 200;
            npc.addItem(a);
            Item b = IC.CreateHPItem("HP potion 20", Item.equipment.potion, 20, 0);
            b.Price = 5;
            npc.addItem(b);
            Item c = IC.CreateArmorItem("Armor potion 20 ", Item.equipment.potion, 20, 0);
            c.Price = 20;
            npc.addItem(c);

            Quest quest = new Quest("The Goblin cave", "Some goblins are rampaging the trade roads, go hunt 8 goblins down and the rest might flee!", 8, 0, "money 100", false, false);
            Quest quest2 = new Quest("Find the source of the corruption", "Main Quest The king is looking for a hero who will undertake the task, of finding and repelling the corruption", 1, 0, "money 300", false, false);
            Quest quest3 = new Quest("The Sorcerer", "Find the Sorcerer to stop the corruption", 1, 0, "money 300", false, false);

            npc.addQuest(quest);
            npc2.addQuest(quest2);
            npc2.addQuest(quest3);

            area.setNPC(npc);
            area.setNPC2(npc2);
            player.Area = area;
            Console.Clear();
            Console.WriteLine("You approach the huge city you see a couple of guards standing watch.\n" +
                                "You slowly approach them, they sceptically look at you and you little \n" +
                                "monster, but let you through anyways. Inside the huge city you spot a \n" +
                                "castle straight ahead, to your left you find a bunch of houses \n" +
                                "To your right you spot a merchant so fat he would fall over if you \n" +
                                "touched him. You pass him and go around the town and spot another \n" +
                                "gate leading to Orexdale");
            Console.WriteLine();
            Console.WriteLine("You are in " + area.Name + " level " + area.Level);
            Console.WriteLine(player.stats());
            Console.WriteLine();
            Console.WriteLine("1 Talk to the Merchant");
            Console.WriteLine("2 Talk to the Kings Diplomat");
            Console.WriteLine("3 Go to the The Fery (castle)");
            Console.WriteLine("4 Go to the Eirin (level 1)");
            Console.WriteLine("5 Go to the Orexdale (level 3)");
            Console.WriteLine("6 Save your progress");
            int choice = 0;
            try
            {
                choice = int.Parse(Console.ReadLine());
            }
            catch (Exception)
            {
                goto try_again;
            }

            switch (choice)
            {
                case 1:
                trader:
                    Console.Clear();
                    Console.WriteLine("1. Do you wanna buy something?");
                    Console.WriteLine("2. Do you need a quest?");
                    Console.WriteLine("3. Return to the area");
                    Console.WriteLine();

                    int choice2 = 0, choice3 = 0;

                    try
                    {
                        choice2 = int.Parse(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        goto trader;
                    }
                    switch (choice2)
                    {
                        case 1:
                        trader2:
                            Console.Clear();
                            Console.WriteLine("Your money: " + player.Money);
                            Console.WriteLine();
                            Console.WriteLine("*** Displaying items ***");
                            int b2;
                            for (int i = 0; i < area.Npc.Selling.Count; i++)
                            {
                                b2 = i + 1;
                                Console.WriteLine("Item: " + b2 + " " + area.Npc.Selling[i].Name);
                            }
                            try
                            {
                                Console.WriteLine("What item do you want to buy?");
                                Console.WriteLine("Type 0 if you don't want to buy anything");
                                choice3 = int.Parse(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                goto trader2;
                            }
                            if (choice3 != 0)
                            {
                                if (area.Npc.Selling[choice2 + 1].Price <= player.Money)
                                {
                                    player.Inventory.Add(area.Npc.Selling[choice2 + 1]);
                                    player.Money -= area.Npc.Selling[choice2 + 1].Price;
                                }
                                else
                                {
                                    Console.WriteLine("You can't afford it!");
                                    Console.WriteLine();
                                    Console.WriteLine("Press enter to continue");
                                    Console.ReadLine();
                                    Console.Clear();
                                }

                            }
                            goto trader;
                        case 2:
                        quests:
                            Console.Clear();
                            area.Npc.displayQuests();
                            Console.WriteLine();
                            Console.WriteLine("Are you up for one of the challenges?");
                            Console.WriteLine("Type 0 if you wanna return to the menu");
                            Console.WriteLine("Else type 1");
                            int choice4;
                            try
                            {
                                choice4 = int.Parse(Console.ReadLine());
                            }
                            catch (Exception)
                            {
                                goto quests;
                            }
                            switch (choice4)
                            {
                                case 0:
                                    goto trader;
                                default:
                                    if (player.checkQuest(area.Npc.Quests[choice4 - 1]))
                                    {
                                        Console.Clear();
                                        Console.WriteLine("The quest: " + area.Npc.Quests[choice4 - 1].Name + " has been added to your questlog!");
                                        player.Questlog.Add(area.Npc.Quests[choice4 - 1]);
                                        Console.WriteLine();
                                        Console.WriteLine("Press enter to continue");
                                        Console.ReadLine();
                                    }
                                    else
                                    {
                                        player.completeQuest(area.Npc.Quests[choice4 - 1], null);
                                        Console.WriteLine("You'r either on the quest or finished it");
                                        Console.WriteLine();
                                        Console.WriteLine("Press enter to continue");
                                        Console.ReadLine();
                                    }
                                    break;
                            }
                            break;
                        case 3:
                            goto try_again;
                    }
                    goto trader;
                case 2:
                diplomat:
                    Console.Clear();
                    area.Npc2.displayQuests();
                    int choice5 = 0;
                    try
                    {
                        choice5 = int.Parse(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        goto diplomat;
                    }
                    switch (choice5)
                    {
                        case 0:
                            goto diplomat;
                        default:
                            switch (choice5)
                            {
                                case 1:
                                    if (player.checkQuest(area.Npc2.Quests[0]))
                                    {
                                        Console.Clear();
                                        Console.WriteLine("The quest: " + area.Npc2.Quests[0].Name + " has been added to your questlog!");
                                        player.Questlog.Add(area.Npc2.Quests[0]);
                                        Console.WriteLine();
                                        Console.WriteLine("Press enter to continue");
                                        Console.ReadLine();
                                    }
                                    else
                                    {
                                        player.completeQuest(area.Npc2.Quests[0], null);
                                        Console.WriteLine("You'r either on the quest or finished it");
                                        Console.WriteLine();
                                        Console.WriteLine("Press enter to continue");
                                        Console.ReadLine();
                                    }
                                    break;
                                case 2:
                                    if (player.completedQuest(area.Npc2.Quests[0]))
                                    {
                                        if (player.checkQuest(area.Npc2.Quests[1]))
                                        {
                                            Console.Clear();
                                            Console.WriteLine("The quest: " + area.Npc2.Quests[1].Name + " has been added to your questlog!");
                                            player.Questlog.Add(area.Npc2.Quests[1]);
                                            Console.WriteLine();
                                            Console.WriteLine("Press enter to continue");
                                            Console.ReadLine();
                                        }
                                        else
                                        {
                                            player.completeQuest(area.Npc2.Quests[1], null);
                                            Console.WriteLine("You'r either on the quest or finished it");
                                            Console.WriteLine();
                                            Console.WriteLine("Press enter to continue");
                                            Console.ReadLine();
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("You need to complete 'Find the source of the corruption' before starting it");
                                        Console.WriteLine();
                                        Console.WriteLine("Press enter to continue");
                                        Console.ReadLine();
                                    }

                                    break;
                                default:
                                    break;
                            }

                            break;
                    }
                    goto try_again;
                case 3:
                    player = The_Fery(player);
                    break;
                case 4:
                    player = Eirin(player);
                    break;
                case 5:
                    player = Orexdale(player);
                    break;
                case 6:
                    return player;

            }
            return player;
        }
コード例 #3
0
ファイル: AreaHandler.cs プロジェクト: pareion/tamagotchi
        internal Player WitchHut(Player play)
        {
            try_again:
            Console.Clear();
            player = play;
            Area area = new Area("WitchHut", 1);
            NPC npc = new NPC("Witch Doctor");
            Quest q1 = new Quest("Learning Brewing", "Go find 20 herbs for the Witch Doctor", 20, 0, "herbs 20", false, false);

            npc.addQuest(q1);
            area.setNPC(npc);
            player.Area = area;

            Console.Clear();
            Console.WriteLine("As you walk towards the hut a witch steps outside and looks at you and you wonder whether to \n" +
                                "confront her or go back");
            Console.WriteLine();
            Console.WriteLine(player.stats());
            Console.WriteLine();
            Console.WriteLine("1 Go to Pladósh (level 3)");
            Console.WriteLine("2 Talk to the " + npc.Name);
            Console.WriteLine("3 Save your progress");
            int choice = 0;

            try
            {
                choice = int.Parse(Console.ReadLine());
            }
            catch (Exception)
            {
                goto try_again;
            }

            switch (choice)
            {
                case 1:
                    player = Pladósh(player);
                    break;
                case 2:
                Witch:
                    Console.Clear();
                    Console.WriteLine("As you walk towards the witch she stares at you and let out a little squek before she asks you");
                    Console.WriteLine();
                    Console.WriteLine("1. Do you wanna brew something?");
                    Console.WriteLine("2. Or head back where you came from?");
                    int choice2;
                    try
                    {
                        choice2 = int.Parse(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        goto Witch;
                    }
                    switch (choice2)
                    {
                        case 1:
                            bool questCompleted = false;
                            foreach (var item in player.Questlog)
                            {
                                if (item.Name == q1.Name && item.Completed && item.Rewarded)
                                {
                                    questCompleted = true;
                                }
                            }
                            if (questCompleted)
                            {
                                PotionMenu();
                                goto Witch;
                            }
                            else
                            {
                                Console.WriteLine("Before you start brewing you have to do a quest for me");
                                Console.WriteLine();
                                Console.WriteLine("Press 1 to accept the quest");
                                int choice3;
                                try
                                {
                                    choice3 = int.Parse(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    goto Witch;
                                }
                                switch (choice3)
                                {
                                    case 1:
                                        Console.Clear();
                                        area.Npc.displayQuests();
                                        if (player.checkQuest(area.Npc.Quests[choice3 - 1]))
                                        {
                                            Console.Clear();
                                            Console.WriteLine("The quest: " + area.Npc.Quests[choice3 - 1].Name + " has been added to your questlog!");
                                            player.Questlog.Add(area.Npc.Quests[choice3 - 1]);
                                            player.updateQuests(null, null, null, player.Herbs, 0, 0);
                                            Console.WriteLine();
                                            Console.WriteLine("Press enter to continue");
                                            Console.ReadLine();
                                        }
                                        else
                                        {
                                            if (player.completeQuest(area.Npc.Quests[choice3 - 1], null))
                                            {
                                                player.Herbs -= 20;
                                            }
                                            else
                                                Console.WriteLine("You'r either on the quest or finished it");
                                            Console.WriteLine();
                                            Console.WriteLine("Press enter to continue");
                                            Console.ReadLine();
                                        }
                                        break;
                                    default:
                                        goto Witch;
                                }
                            }
                            goto Witch;
                        case 2:
                            goto try_again;
                    }
                    break;
                case 3:
                    return player;

            }
            return player;
        }
コード例 #4
0
ファイル: Player.cs プロジェクト: pareion/tamagotchi
        internal bool completeQuest(Quest quest, Area area)
        {
            bool completed = false;
            foreach (var item in questlog)
            {
                if (item.Name == quest.Name)
                {
                    if (item.Progress >= item.GoalValidator)
                    {
                        if (!item.Rewarded)
                        {
                            string[] str = quest.Reward.Split(' ');

                            switch (str[0])
                            {
                                case "herbs":
                                    herbs += int.Parse(str[1]);
                                    break;
                                case "metal":
                                    metal += int.Parse(str[1]);
                                    break;
                                case "money":
                                    money += int.Parse(str[1]);
                                    break;
                            }
                            item.Rewarded = true;
                            completed = true;
                            Console.WriteLine("You have been rewarded with "+str[0] + " "+str[1]);
                        }
                    }
                }
            }
            return completed;
        }
コード例 #5
0
ファイル: Player.cs プロジェクト: pareion/tamagotchi
 internal bool completedQuest(Quest quest)
 {
     foreach (var item in questlog)
     {
         if (item.Name == quest.Name)
         {
             return item.Rewarded;
         }
     }
     return false;
 }
コード例 #6
0
ファイル: Player.cs プロジェクト: pareion/tamagotchi
 /// <summary>
 /// Returns false if the quest is in the questlog already otherwise returns true
 /// </summary>
 /// <param name="quest"></param>
 /// <returns></returns>
 internal bool checkQuest(Quest quest)
 {
     foreach (var item in questlog)
     {
         if (item.Name == quest.Name)
         {
             return false;
         }
     }
     return true;
 }