-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
52 lines (42 loc) · 1.02 KB
/
Player.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
using System.Globalization;
public class Player
{
public int CurrentHitPoints = 15;
public int Potions = 0;
public Location Location;
public Weapon CurrentWeapon = World.WeaponByID(1);
public int MaximumHitPoints = 15;
public string Name;
public Player(Location location )
{
this.Location = location;
}
public bool TryMoveTo(Location newLocation)
{
if (newLocation != null)
{
Location = newLocation;
return true;
}
return false;
}
public void Potion()
{
if (this.Potions > 0)
{
this.CurrentHitPoints += 5;
if(CurrentHitPoints > 15)
{
CurrentHitPoints = MaximumHitPoints;
}
}
else
{
Console.WriteLine("You have no potions to use");
}
}
public void ResetHP()
{
this.CurrentHitPoints = MaximumHitPoints;
}
}