-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cs
123 lines (107 loc) · 3.86 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
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
using Generic_Text_Based_RPG_Epic_Edition.BaseClasses;
using System;
using System.Collections.Generic;
namespace Generic_Text_Based_RPG_Epic_Edition
{
public class Player
{
public static Random Rand { get; set; } = new Random();
public string Name { get; set; }
public int Coins { get; set; } = 0;
public int MaxHealth { get; set; } = 10;
public int Health { get; set; } = 10; // Default Health = 10
public int Strength { get; set; } = 1; // Default Damage = 1
public int Defense { get; set; } = 1;
public Weapon CurrentWeapon { get; set; }
public List<Item> Inventory { get; set; }
public int ArmorValue { get; set; } = 0;
public int Potion { get; set; } = 5;
public int LastNextLevel { get; set; } = 10;
public int NextLevel { get; set; } = 10;
public int Level { get; set; } = 1;
public int XP { get; set; } = 0;
public int Mods { get; set; } = 0;
/* public static implicit operator Player(SavePlayer sp)
{
Player p = new();
p.Name = sp.Name;
p.Coins = sp.Coins;
p.MaxHealth = sp.MaxHealth;
p.Health = sp.Health;
p.Strength = sp.Strength;
p.Defense = sp.Defense;
p.CurrentWeapon = sp.CurrentWeapon;
p.Inventory = sp.Inventory;
p.ArmorValue = sp.ArmorValue;
p.Potion = sp.Potion;
p.LastNextLevel = sp.LastNextLevel;
p.NextLevel = sp.NextLevel;
p.Level = sp.Level;
p.XP = sp.XP;
p.Mods = sp.Mods;
return p;
}*/
public int GetHealth()
{
int upper = 2 * Mods + 5;
int lower = Mods + 2;
return Rand.Next(lower, upper + 1);
}
public int GetPower()
{
int upper = 2 * Mods + 5;
int lower = Mods + 3;
return Rand.Next(lower, upper + 1);
}
public int GetDefense()
{
double upper = 1 * ((Mods + 1) / 2) + 3;
double lower = Mods + 0.5;
return Rand.Next((int)lower, (int)upper + 1);
}
public int CoinCalc()
{
if (Level > 3)
return (int)(Rand.Next(10, 50) + ((Math.Log(Level) / Math.Sin(3) + 1) * (Level + Rand.Next(1, 3))));
else
return (int)((Math.Log(Level) / Math.Sin(3) + 1) * (Level + Rand.Next(1, 3)));
}
public bool LevelCheck(int newxp)
{
int nextLevelCalc;
XP += newxp;
NextLevel -= newxp;
if (NextLevel <= 0)
{
while (NextLevel <= 0)
{
nextLevelCalc = ((5 * (Level + 1) ^ 3) / 4);
NextLevel += nextLevelCalc;
LastNextLevel += nextLevelCalc;
LevelUp();
}
return true;
}
return false;
}
public void LevelUp()
{
Console.WriteLine("You leveled up to level " + (Level + 1) + "!");
Level += 1;
int tempstrength = Rand.Next(1, 2);
int temphealth = Rand.Next(2, 4);
int temppotion = Rand.Next(3, 5);
int tempdefense = Rand.Next(0, 2);
Console.WriteLine("+" + tempstrength + " Damage," + " +" + temphealth + " Max Health," + " +" + temppotion + " Potions," + " +" + tempdefense + " Defense");
Strength += tempstrength;
MaxHealth += temphealth;
Health += temphealth;
Potion += temppotion;
Defense += tempdefense;
if (NextLevel > 0)
{
Console.WriteLine("You need " + NextLevel + " XP to get to the next level.");
}
}
}
}