我想在C#中做壟斷,但是,我面臨一個未知的租金問題。該計劃應該將規定的租金添加到一個玩家,並從其他玩家中扣除,但這隻有時纔有效。其他時間,每個球員的金額保持不變。壟斷 - 租金沒有被轉移到其他玩家
if (type[roll] == "Land")
{
if (owned[roll] == "Unowned")
{
DialogResult dialogResult = MessageBox.Show("You have landed on " + name[roll] + ". This property costs $" + cost[roll] + ". Would you like to purchase it?", "Purchase Property?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
int deduct = Convert.ToInt32(cost[roll]);
if (player == true)
{
money1 -= deduct;
p1owned[roll] = "Owned";
}
else if (player == false)
{
money2 -= deduct;
p2owned[roll] = "False";
}
parking += deduct;
owned[roll] = "Owned";
}
}
else
{
if (player == true && p2owned[roll] == "Owned")
{
money2 += Convert.ToInt32(rent[roll]);
money1 -= Convert.ToInt32(rent[roll]);
}
else if (player == false && p1owned[roll] == "Owned")
{
money1 += Convert.ToInt32(rent[roll]);
money2 -= Convert.ToInt32(rent[roll]);
}
}
}
在這種情況下,變量播放器與什麼有關? – miguelarcilla
在else塊的開始處設置一個斷點並進行調試。 – Seano666
'player','money1','money2','roll'是什麼? –