private int status = 4;// 0-day,5-night,6-killer,10-detective
private boolean firstRound = true;
private int[] killerIndices, detectiveIndices;
private int victimIndex, examIndex, executionIndex;
private int killerCount, detectiveCount, testmentCount;
private String[] statusComment = { "杀人游戏", "天亮了,死的是", "发言", "投票,处决", "处决后",
"天黑了", "杀手睁眼", "选择被杀", "有人被杀了,杀手闭眼", "警察睁眼", "警察验人", "警察外推", "警察闭眼" };
private JLabel temp, temp2;
if (status < statusComment.length - 1)
status++;
else
status = 1;// 更新状态
temp.setText("^_^");// clear
switch (status) {
case 1:// daybreak, who died?
if (!firstRound) {
name[victimIndex] += "(dead)";
playerList.setSelectedIndex(victimIndex);
}
if (testmentCount > 0) {
testmentCount--;
temp.setText("留第"
+ String.valueOf(killerCount - testmentCount) + "个遗言");
} else
temp.setText("没有遗言");
break;
case 2:// accuse and defend
break;
case 3:// vote, execute
break;
case 4:// after execution
executionIndex = playerList.getSelectedIndex();
name[executionIndex] += "(executed)";
playerList.clearSelection();
playerList.setSelectedIndex(executionIndex);
if (testmentCount > 0) {
testmentCount--;
temp.setText("留第"
+ String.valueOf(killerCount - testmentCount) + "个遗言");
} else
temp.setText("没有遗言");
break;
case 6:// killer time
if (!firstRound)
playerList.setSelectedIndices(killerIndices);
else
temp.setText("确认匪友");
break;
case 7:// select kill
if (firstRound)
killerIndices = playerList.getSelectedIndices();
playerList.clearSelection();
break;
case 8:// someone killed
victimIndex = playerList.getSelectedIndex();
break;
case 9:// detective time
playerList.clearSelection();
if (!firstRound)
playerList.setSelectedIndices(detectiveIndices);
else
temp.setText("确认警友");
break;
case 10:// detective select a suspect
if (firstRound)
detectiveIndices = playerList.getSelectedIndices();
playerList.clearSelection();
break;
case 11:// detective choose the next suspect
examIndex = playerList.getSelectedIndex();
check(examIndex, killerIndices);//exam the suspect for this round
break;
case 12:// detective hide
firstRound = false;
break;
}
temp2.setText(String.valueOf(status) + statusComment[status]);
pk pub杀人游戏流程如上,杀手数和警察数自定。有人想编的话拿去用。