Reputation: 86
I am making a game that consists of players trying to capture space stations in a Risk (board game) type format. In order to tell who owns what station I have set up a multidimensional bool
array like so.
bool[,] stationOwners =
new bool[3, 5]
{
//S0 S1 S2 S3 S4
{true, false, false, false, false}, //blue player
{false, false, true, false, false}, //red player
{false, false, false, true, false} //green player
};
The rows represent a player while a column represents a specific station on the map. Now the issue I am running into is trying calculate each players income, each station has its own set income value int[] stationIncome = new int[5] {3,2,3,3,2};
Also players have their own variable to store their income int[] playerMoney = new int[3] {0,0,0};
How I am looking for what player owns which stations is through a for loop inside a method
public void playerTurnStart(int ID)
{
for(int x = 0; x > 4; x++)
{
if (stationOwners[ID, x] == true)
{
playerMoney[ID] += stationIncome[x];
}
}
lblPlayerMoney.Text = playerMoney[ID].ToString();
}
The integer ID
is tied to what players turn it is. I then make a label on my form equal to the income. The problem is that the players income remains at zero no matter who's turn it is. Is there anyone who could look over this code and see if I missed anything?
Upvotes: 0
Views: 222
Reputation: 1092
The most obvious thing is your for
loop is incorrect.
for(int x = 0; x > 4; x++)
needs to be
for(int x = 0; x < 4; x++)
Starting at x = 0
means the condition x > 4
will never be true.
Upvotes: 3