-
Notifications
You must be signed in to change notification settings - Fork 0
/
Politician.cs
98 lines (95 loc) · 2.58 KB
/
Politician.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Win538Electors
{
internal abstract class Politician
{
protected int funds;
protected int campaigners;
protected int donators;
protected int electorsWon;
protected List<string> latestAction;
protected int turnTicker;
protected Campaign campaign;
// Getters
public int GetFunds()
{
return funds;
}
public int GetCampaigners()
{
return campaigners;
}
public int GetDonators()
{
return donators;
}
public int GetElectors()
{
return electorsWon;
}
public int GetCampaignCost(string type)
{
return campaign.GetCampaignCost(type);
}
public List<string> GetLatestAction()
{
return latestAction;
}
public int GetTurnTicker()
{
return turnTicker;
}
// Setters
public void SetFundsIncrease(int increase)
{
funds += increase;
}
public void SetFundsPurchase(int price)
{
funds = funds - price;
}
public void SetCampaigners()
{
campaigners += 1;
}
public void SetDonators()
{
donators += 1;
}
public void SetElectors(int electors)
{
electorsWon += electors;
}
public void UpdateCampaignCost(string type, int change)
{
campaign.SetCampaignCost(type, change);
}
public void SetLatestAction(string action)
{
latestAction.Insert(0, action);
}
public void SetTurnTicker() // This tracks the amount of turns have occured, used to display in action log.
{
turnTicker += 1;
}
// Constructors
public Politician()
{
funds = 10000;
campaigners = 0;
donators = 1;
electorsWon = 0;
campaign = new Campaign(); // Composition instead of inheritence: https://code-maze.com/csharp-composition-vs-inheritance/
turnTicker = 0;
latestAction = new List<string>();
}
// Methods
public abstract void TurnTaken(Dictionary<string, int> statePolling, string[] states, Dictionary<string, int> campaignCosts);
public abstract void SaveGame();
public abstract void LoadGame();
}
}