所以我正在开发一款Chomp游戏。左下角有一个“cookies”网格和一个“poison cookie”。当玩家选择一个 cookie 时,该 cookie 上方和右侧的所有 cookie 都会被吃掉。
现在,我的程序选择了所选 cookie 左侧的所有 cookie。下面是通过鼠标单击在行和列中传递并更改每个“cookie”类型的 updateBoard 方法。我的问题是如何选择右侧而不是左侧的 cookie?
static void updateBoard(int Row, int Column){
if(gb1.arrayName1[Row][Column].getType() == 1){
gb1.arrayName1[Row][Column].setType(currentPlayer);
if(currentPlayer == Player1){
for(int i = 0; i <= Row; i++){
for(int j = 0; j <= Column; j++){
if(gb1.arrayName1[i][j].getType() != Player2){
gb1.arrayName1[i][j].setType(Player1);
}
}
}
turn.setText("Player2's turn");
currentPlayer = Player2;
}else if (currentPlayer == Player2){
for(int i= 0; i <= Row; i++){
for(int j = 0; j <= Column; j++){
if(gb1.arrayName1[i][j].getType() != Player1){
gb1.arrayName1[i][j].setType(Player2);
}
}
}
turn.setText("Player1's turn");
currentPlayer=Player1;
}
}else if(gb1.arrayName1[Row][Column].getType() == 4){
turn.setText("Poison cookie eaten, Game Over!");
}
}