我有以下数据结构;
Array ( [0] => Array ([suit] => c [rank] => A )
[1] => Array ( [suit] => d [rank] => A ) )
我想测试这些卡片是否是某些值并显示适当的消息;
if (
(($hand[0]['rank'] == "A") && ($hand[1]['rank'] == "A"))
|| (($hand[0]['rank'] == "K") && ($hand[1]['rank'] == "K"))
|| (($hand[0]['rank'] == "Q") && ($hand[1]['rank'] == "Q"))
|| (($hand[0]['rank'] == "A") && ($hand[1]['rank'] == "K"))
|| (($hand[0]['rank'] == "K") && ($hand[1]['rank'] == "A"))
) {
echo "Action: Raise pre-flop. Re-raise if already raised.<br />\n";
}
if (
(($hand[0]['rank'] == "7") && ($hand[1]['rank'] == "7"))
|| (($hand[0]['rank'] == "A") && ($hand[1]['rank'] == "J") && ($hand[0]['suit'] == $hand[1]['suit']))
|| (($hand[0]['rank'] == "J") && ($hand[1]['rank'] == "Q") && ($hand[0]['suit'] == $hand[1]['suit']))
|| (($hand[0]['rank'] == "10") && ($hand[1]['rank'] == "J") && ($hand[0]['suit'] == $hand[1]['suit']))
) {
echo "Action: Worth a call pre-flop (provided no-one has raised).<br />\n";
}
我通过删除一些条件简化了 IF。
任何人都可以提出更好的方法吗?