-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathBattleSystem.cs
93 lines (83 loc) · 2.24 KB
/
BattleSystem.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
namespace Console_Monsters;
public class BattleSystem
{
// TEMP FOR DEVELOPMENT, YES VERY MESSY, PLEASE FIX
public static FireLizard FireLizard { get; set; } = new();
public static Turtle Turtle { get; set; } = new();
public static MonsterBase PlayerMonster { get; set; } = Turtle;
public static MonsterBase OpponentMonster { get; set; } = FireLizard;
public static MonsterBase? AttackingMonster { get; set; }
public static MonsterBase? DefendingMonster { get; set; }
public static void Battle()
{
bool playerTurn = true;
bool battleOver = false;
if (OpponentMonster.SpeedStat > PlayerMonster.SpeedStat)
{
playerTurn = false;
}
DrawStats(playerTurn);
while (!battleOver)
{
if (playerTurn)
{
AttackingMonster = PlayerMonster;
DefendingMonster = OpponentMonster;
if (PlayerMonster.CurrentHP <= 0)
{
Console.Clear();
Console.WriteLine("Player Lost");
battleOver = true;
}
else
{
ConsoleHelper.PressToContinue();
MoveBase playerMove = MoveBase.GetRandomMove();
PlayerMonster.CurrentEnergy -= playerMove.EnergyTaken;
OpponentMonster.CurrentHP -= (int)playerMove.FinalDamage;
playerTurn = false;
DrawStats(playerTurn);
}
}
if (!playerTurn)
{
AttackingMonster = OpponentMonster;
DefendingMonster = PlayerMonster;
if (OpponentMonster.CurrentHP <= 0)
{
Console.Clear();
Console.WriteLine("CPU Lost");
battleOver = true;
}
else
{
ConsoleHelper.PressToContinue();
MoveBase opponentMove = MoveBase.GetRandomMove();
OpponentMonster.CurrentEnergy -= opponentMove.EnergyTaken;
PlayerMonster.CurrentHP -= (int)opponentMove.FinalDamage;
playerTurn = true;
DrawStats(playerTurn);
}
}
}
static void DrawStats(bool playerTurn)
{
//TEMP
Console.SetCursorPosition(63, 34);
Console.WriteLine($"HP:{PlayerMonster.CurrentHP} Energy:{PlayerMonster.CurrentEnergy} ");
Console.SetCursorPosition(102, 13);
Console.WriteLine($"HP:{OpponentMonster.CurrentHP} Energy:{OpponentMonster.CurrentEnergy} ");
Console.SetCursorPosition(35, 5);
string turn;
if (playerTurn)
{
turn = "Player Turn";
}
else
{
turn = "CPU Turn ";
}
Console.WriteLine(turn);
}
}
}