-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shop.cs
104 lines (95 loc) · 3.49 KB
/
Shop.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
using System;
namespace Helvete
{
public class Shop
{
public static void LoadShop(Player p)
{
RunShop(p);
}
public static void RunShop(Player p)
{
int potionPrice;
int armorPrice;
int weaponPrice;
int diffPrice;
while(true)
{
potionPrice = 20 + 10 * p.modifier;
armorPrice = 100 * (p.armor + 1);
weaponPrice = 100 * (p.weapon);
diffPrice = 300 + 100 * p.modifier;
Console.Clear();
Console.WriteLine(" Shop ");
Console.WriteLine("===========================");
Console.WriteLine("(W)eapon: $" + weaponPrice);
Console.WriteLine("(A)rmor: $" + armorPrice);
Console.WriteLine("(P)otion: $" + potionPrice);
Console.WriteLine("(D)ifficulty: $" + diffPrice);
Console.WriteLine("===========================");
Console.WriteLine("| (E)xit |");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(p.name + "'s Stats ");
Console.WriteLine("===========================");
Console.WriteLine("Coins: " + p.coins);
Console.WriteLine("Health: " + p.health);
Console.WriteLine("Weapon: " + p.weapon);
Console.WriteLine("Armor: " + p.armor);
Console.WriteLine("Potions: " + p.potion);
Console.WriteLine("Difficulty Modifiers: " + p.modifier);
Console.WriteLine("===========================");
//Wait for input
string input = Console.ReadLine().ToLower();
if(input == "w" || input == "weapon")
{
Buy("weapon", weaponPrice, p);
}
else if(input == "a" || input == "armor")
{
Buy("armor", armorPrice, p);
}
else if (input == "p" || input == "potion")
{
Buy("potion", potionPrice, p);
}
else if (input == "d" || input == "difficulty")
{
Buy("difficulty", diffPrice, p);
}
else if(input == "e" || input == "exit")
{
break;
}
static void Buy(string item, int price, Player p)
{
if(p.coins >= price)
{
if(item == "weapon")
{
p.weapon++;
}
else if(item == "armor")
{
p.armor++;
}
else if(item == "potion")
{
p.potion++;
}
else if(item == "difficulty")
{
p.modifier++;
}
p.coins -= price;
}
else
{
Console.WriteLine("You don't have enough coins!");
Console.ReadKey();
}
}
}
}
}
}