-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
129 lines (116 loc) · 4.21 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Game
{
class Program
{
public static Random rnd = new Random();
public static List<EnemyModel> enemies = new List<EnemyModel>();
public static Player player;
public static Shop shop;
static void Main(string[] args)
{
RunGame();
}
private static void RunGame()
{
Console.WriteLine("WELCOME!");
InitializeGame.Initialize();
do
{
MainMenu(player);
} while (player.Level < 10);
WonGame();
}
public static void MainMenu(Player player)
{
int userChoice;
bool parseSuccessful;
do
{
Console.WriteLine("\nSelect an action from the menu: ");
Console.WriteLine($"1. take {player.Name} adventuring");
Console.WriteLine($"2. show details about {player.Name}");
Console.WriteLine("3. Open backpack");
Console.WriteLine("4. Visit shop");
PrintDesign.WriteLineInRed("5. Play with GodMode");
PrintDesign.WriteLineInRed("6. Exit game");
Console.Write("\nChoice: ");
parseSuccessful = int.TryParse(Console.ReadLine(), out userChoice);
if (userChoice <= 0)
{
Console.Clear();
PrintDesign.WriteLineInRed("Chosen number to small, pick a number between 1 and 4 in the menu");
}
else if (userChoice > 4)
{
Console.Clear();
PrintDesign.WriteLineInRed("Chosen number to big, pick a number between 1 and 4 in the menu");
}
else if (parseSuccessful == false) // denna behövs egentligen inte då ints default är 0, men varför inte :)
{
Console.Clear();
PrintDesign.WriteLineInRed("Something went wrong with your input. Pick a number between 1 and 4 in the menu");
}
MenuAction(userChoice);
} while (userChoice < 0 || userChoice > 6 || parseSuccessful == false);
}
public static void MenuAction(int choice)
{
switch (choice)
{
case 1:
if(rnd.Next(1,11) == 10)
{
Console.WriteLine("You walk by without seeing any enemies!");
Console.Clear();
}
else
{
Battle.StartFight(player, enemies[rnd.Next(enemies.Count)]); // skickar med spelaren och en random vald fiende i listan
}
break;
case 2:
player.PlayerInfo();
break;
case 3:
if(Player.backpack.Count == 0)
{
Console.Clear();
PrintDesign.WriteLineInRed("Backpack is currently empty!");
}
else
{
PrintDesign.PrintBackpack(Player.backpack);
}
break;
case 4:
shop.ShopMenu(player);
break;
case 5:
player.GodMode();
break;
case 6:
Exit();
break;
default:
break;
}
}
public static void WonGame()
{
Console.Clear();
Console.WriteLine("You won the game!");
Console.WriteLine("Thank you for playing!!");
Environment.Exit(0);
}
public static void Exit()
{
Console.Clear();
PrintDesign.WriteLineInGreen("Thank you for playing! See you next time");
Environment.Exit(0);
}
}
}