-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShop.cs
160 lines (150 loc) · 5.64 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using System;
using static System.Console;
namespace Generic_Text_Based_RPG_Epic_Edition
{
public class Shop
{
static int ArmorMod { get; set; }
static int WeaponMod { get; set; }
static int DiffMod { get; set; }
public static void RunShop(Player player)
{
int potionPlayer = 20 + 10 * DiffMod;
int armorPlayer = 100 * (ArmorMod + 1);
int weaponPlayer = 100 * (WeaponMod + 1);
int diffPlayer = 300 + 100 * player.Mods;
while (true)
{
Clear();
WriteLine("=====================");
WriteLine(" Shop ");
WriteLine("=====================");
WriteLine("Coins: " + player.Coins);
WriteLine("=====================");
//WriteLine("(W)eapon: $" + weaponPlayer);
WriteLine("(A)rmor $" + armorPlayer);
WriteLine("(P)otions: $" + potionPlayer);
WriteLine("(D)ifficulty Mod: $" + diffPlayer);
WriteLine("(I)nventory");
WriteLine("(S)tats");
WriteLine("=====================");
WriteLine("(E)xit");
WriteLine("Save and (Q)uit");
WriteLine("=====================");
string input = ReadKey(true).Key.ToString().ToLower();
if (input == "p")
{
TryBuy("potion", potionPlayer, player);
}
/*else if (input == "w")
{
TryBuy("weapon", weaponPlayer, player);
}*/
else if (input == "a")
{
TryBuy("armor", armorPlayer, player);
}
else if (input == "d")
{
TryBuy("diff", diffPlayer, player);
}
else if (input == "s")
{
StatsScreen(player);
}
else if (input == "i")
Inventory(player);
else if (input == "e")
{
break;
}
else if (input == "q")
{
SaveVarStorage saveVarStorage = new();
SaveManager.SaveGame(saveVarStorage);
Environment.Exit(0);
}
}
}
static void TryBuy(string item, int cost, Player player)
{
if (player.Coins >= cost)
{
if (item == "potion")
player.Potion++;
else if (item == "weapon")
player.CurrentWeapon.Damage++;
else if (item == "armor")
player.ArmorValue++;
else if (item == "diff")
player.Mods++;
player.Coins -= cost;
}
else
{
Clear();
WriteLine("You don't have enough coins.");
ReadKey(true);
}
}
static void Inventory(Player player)
{
while (true)
{
Clear();
WriteLine("=====================");
WriteLine(" Inventory ");
WriteLine("=====================");
WriteLine("Potions: " + player.Potion);
WriteLine("=====================");
WriteLine("Slot 1:");
WriteLine("Slot 2:");
WriteLine("Slot 3:");
WriteLine("Slot 4:");
WriteLine("Slot 5:");
WriteLine("Slot 6:");
WriteLine("Slot 7:");
WriteLine("Slot 8:");
WriteLine("Slot 9:");
WriteLine("Slot 10:");
WriteLine("=====================");
WriteLine(" (B)ack ");
WriteLine("=====================");
string input = ReadKey(true).Key.ToString().ToLower();
if (input == "b")
break;
}
}
static void StatsScreen(Player player)
{
while (true)
{
Clear();
WriteLine("=====================");
WriteLine(" Player Stats ");
WriteLine("=====================");
WriteLine("Player Name: " + player.Name);
WriteLine("Coins: " + player.Coins);
WriteLine("Current Health: " + player.Health);
WriteLine("Strength: " + player.Strength);
WriteLine("Defense: " + player.Defense);
WriteLine("=====================");
WriteLine("Current Weapon: " + player.CurrentWeapon.Name);
WriteLine("Weapon Strength: " + player.CurrentWeapon.Damage);
WriteLine("Armor Defense: " + player.ArmorValue);
WriteLine("=====================");
WriteLine("Level: " + player.Level);
WriteLine("XP: " + player.XP);
WriteLine("Next Level: " + player.NextLevel);
WriteLine("=====================");
WriteLine("Difficulty Mods: " + player.Mods);
WriteLine("=====================");
WriteLine(" (B)ack ");
WriteLine("=====================");
string input = ReadKey(true).Key.ToString().ToLower();
if (input == "b")
break;
}
}
}
}