-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeapon.cs
More file actions
85 lines (74 loc) · 2.65 KB
/
Weapon.cs
File metadata and controls
85 lines (74 loc) · 2.65 KB
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
using System;
using System.Threading;
namespace EternityRPG
{
public class Weapon : Item
{
public Weapon(string playerClass, int weaponType) => GetWeapon(playerClass, weaponType);
private void GetWeapon(string playerClass, int weaponType)
{
switch (weaponType)
{
case 1:
switch (playerClass)
{
case "warrior":
Title = "Crystal Sword";
Damage = 90;
Cost = 3100;
break;
case "archer":
Title = "Poisoned Bow";
Damage = 80;
Cost = 3200;
break;
case "mage":
Title = "Staff of Pain";
Damage = 70;
Cost = 3050;
break;
}
break;
case 2:
switch (playerClass)
{
case "warrior":
Title = "Dark Sword";
Damage = 150;
Cost = 6700;
break;
case "archer":
Title = "Bloody Bow";
Damage = 155;
Cost = 6650;
break;
case "mage":
Title = "Staff of Light";
Damage = 185;
Cost = 6900;
break;
}
break;
}
}
public override void Buy(Player player, Item[] inventory, int choice)
{
if (player.Gold >= Cost)
{
player.Gold -= Cost;
Use(player, inventory, choice);
Print.Text($"\t\t\t {Title} purchased and equipped\n", ConsoleColor.DarkCyan);
}
else Print.Text("not enough gold".PadLeft(41, ' ') + "\n", ConsoleColor.DarkRed);
Thread.Sleep(2000);
}
public override void Use(Player player, Item[] inventory, int choice)
{
//turning all weapon to false before buying new one
for (int i = 0; i < inventory.Length; i++)
inventory[i].WeaponIsBought = false;
//equipping new one
inventory[choice - 1].WeaponIsBought = true;
}
}
}