我昨天在这里的用户写了这段代码,但我无法理解它。我通过交易功能的第 9 行理解了所有内容,它从 52 个数字中创建了一张随机卡,但在下一行我不明白这是做什么的。有人可以解释一下这段代码的作用,以便我可以修改它并扩展它吗?
//Creates the deck
var Ace = 1;
var Face = 10;
var deck = [Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Face, Face, Face];
/*Creates a deal function that can deal cards to each player.
Use object_name.property_name = deal() to call this function.*/
var deal = function () {
var randomcard = Math.ceil(Math.random() * 52) + 1;
return deck[Math.floor(randomcard % 13)];
};