-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCombatManager.cs
More file actions
127 lines (114 loc) · 3.31 KB
/
Copy pathCombatManager.cs
File metadata and controls
127 lines (114 loc) · 3.31 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
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
using System.Runtime.CompilerServices;
using TTRPG_manager;
public static class CombatManager
{
public static int turn = 0; // Tracks the number of complete rounds of combat
public static bool isPlayersTurn = false;
public static bool isEnemiesTurn = false;
public static bool isAmbush = false;
public static int totalTurns = 0; // Tracks the number of individual actions taken
public static void NextTurn()
{
AppConfig config = ConfigManager.LoadConfig();
if (config.Parties.Count == 0) { return; }
// Reduce skill cooldowns for the active party
foreach (Character character in config.Parties[config.selectedPartyIndex].Members)
{
character.actionTaken = false;
foreach (Skill skill in character.Skills)
{
skill.Cooldown = Math.Min(skill.BaseCooldown, skill.Cooldown+1);
}
}
if (!isPlayersTurn && !isEnemiesTurn)
{
StartCombat();
}
// Manage turn progression
if (isEnemiesTurn)
{
isPlayersTurn = true;
isEnemiesTurn = false;
if (!isAmbush)
{
EndRound();
}
}
else if (isPlayersTurn)
{
isPlayersTurn = false;
isEnemiesTurn = true;
if (isAmbush)
{
EndRound();
}
}
totalTurns++;
ConfigManager.SaveConfig(config);
}
private static void EndRound()
{
// Check if the combat began with an ambush to decide who acts first in the new round
if (isAmbush)
{
isEnemiesTurn = true;
isPlayersTurn = false;
}
else
{
isPlayersTurn = true;
isEnemiesTurn = false;
}
turn++; // Only increment the round counter after both have had their turn
}
public static void ResetTurn()
{
turn = 0;
totalTurns = 0;
isPlayersTurn = false;
isEnemiesTurn = false;
isAmbush = false;
}
public static void Ambush()
{
isAmbush = true;
isEnemiesTurn = true;
isPlayersTurn = false;
}
public static void StartCombat()
{
ResetTurn();
// Determine if it should start as an ambush or not
if (isAmbush)
{
isEnemiesTurn = true;
}
else
{
isPlayersTurn = true; // Players start normally
}
}
public static void EndCombat()
{
// Clean up combat state, potentially calculate rewards or outcomes
AppConfig config = ConfigManager.LoadConfig();
if (config.Parties.Count == 0) { return; }
foreach (Character character in config.Parties[config.selectedPartyIndex].Members)
{
foreach (Skill skill in character.Skills)
{
skill.Cooldown = skill.BaseCooldown; // Reset all skill cooldowns to zero
}
}
ResetTurn();
ConfigManager.SaveConfig(config);
}
public static bool IsCombatOver()
{
// Placeholder logic to determine if combat should end
return false; // Actual implementation needed
}
public static void changeParty()
{
}
}