-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBattleTurnHandler.cs
More file actions
55 lines (48 loc) · 1.53 KB
/
BattleTurnHandler.cs
File metadata and controls
55 lines (48 loc) · 1.53 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
using System.Collections;
using System.Collections.Generic;
public class BattleTurnHandler
{
public int PlayerActions { get; private set; }
public int EnemyActions { get; private set; }
public bool IsPlayerFirst { get; }
private Stat playerSpeed;
private Stat enemySpeed;
private int playerBonus = 0;
private int enemyBonus = 0;
public BattleTurnHandler(Stat playerSpeed, Stat enemySpeed)
{
this.playerSpeed = playerSpeed;
this.enemySpeed = enemySpeed;
IsPlayerFirst = playerSpeed.GetValue() >= enemySpeed.GetValue();
}
public void CalculatePlayerActions()
{
playerBonus += playerSpeed.GetValue() - enemySpeed.GetValue();
if (playerBonus < 0) playerBonus = 0;
int bonusActions = playerBonus / enemySpeed.GetValue();
if (bonusActions > 0)
{
playerBonus -= bonusActions * enemySpeed.GetValue();
}
PlayerActions = 1 + bonusActions;
}
public void CalculateEnemyActions()
{
enemyBonus += enemySpeed.GetValue() - playerSpeed.GetValue();
if (enemyBonus < 0) enemyBonus = 0;
int bonusActions = enemyBonus / playerSpeed.GetValue();
if (bonusActions > 0)
{
enemyBonus -= bonusActions * playerSpeed.GetValue();
}
EnemyActions = 1 + bonusActions;
}
public void UsePlayerAction()
{
PlayerActions--;
}
public void UseEnemyAction()
{
EnemyActions--;
}
}