gpt4 book ai didi

Javascript 二十一点游戏

转载 作者:搜寻专家 更新时间:2023-11-01 04:38:08 27 4
gpt4 key购买 nike

<分区>

我正在为我的类(class)开发 JavaScript 二十一点游戏。到目前为止,我有一种方法可以为牌组、闲家和庄家创建筹码。另一个创建套牌,一个将每张卡片创建为一个对象。另一个人洗牌,一个人从牌堆中分发牌,另一个人将这些牌添加到其他牌堆中。我试图让一些显示器在我完成它之前看看到目前为止发生了什么,但对于我的生活我什么也得不到。我已经盯着它看了几个小时,并且完全希望它是一些愚蠢的语法错误。如果有人能帮我看看这个并告诉我为什么我的显示器不显示,我将不胜感激。随意复制和修改。

<html>

<head>
<script type="text/javascript">

function stack()
{
this.cards = new Array();

this.makeDeck = createDeck();
this.shuffle = shuffle();
this.deal = dealHand();
this.addCard = AddCard();
this.combine = Combine();
this.cardCount = CardCount();
}

function createDeck()
{
var ranks = new Array("Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King");
var suits = new Array("Clubs", "Diamonds", "Hearts", "Spades");

var count = ranks.length * suits.length;
count = parseInt(count);

this.cards = new Array(count);

for (s = 0; s < suits.length; s++)
{
for (r = 0; r < ranks.length; r++)
{
this.cards[s * ranks.length + r] = new card(ranks[r], suits[s]);
}
}
}

function card (inrank, insuit)
{
this.suit = insuit;
this.rank = inrank;
}

function shuffle(n)
{
var i, j, k;
var temp;

for (i = 0; i < n; i++)
for (j = 0; j < this.cards.length; j++)
{
k = Math.floor(Math.random() * this.cards.length);
temp = this.cards[j];
this.cards[j] = this.cards[k];
this.cards[k] = temp;
}

function dealHand()
{
return this.cards.shift();
}

function addCard(card)
{
this.cards.push(card);
}

function newGame()
{
var deck = new stack();
var player = new stack();
var dealer = new stack();

deck.makeDeck;
deck.shuffle;
player.addCard(deck.deal);
player.addCard(deck.deal);
dealer.addCard(deck.deal);
dealer.addCard(deck.deal);

display();
document.write("here");
}

function display()
{
document.display.player_card_1.value ="here"; //player.cards.card[0].rank + " of " + player.cards.card[0].suit;
//document.display.player_card_1_val.value = player.cards.card[0].value;
}

</script>
<style type="text/css">
input {
background:transparent
}
</style>


</head>

<body>
<script type="text/javascript">

</script>
<table bgcolor="#33CC33">
<tr>
<td style="font:14pt bold">Your cards</td>
<td></td>
<td style="font:14pt bold">Dealer's cards</td>
<td></td>
</tr>
<tr>
<td><input type="text" readonly="readonly" value="" name="player_card_1"></td>
<td><input type="text" readonly="readonly" value="" name="p_card_1_val"></td>
<td><input type="password" readonly="readonly" value="" name="dealer_card_1"></td>
<td><input type="password" readonly="readonly" value="" name="d_card_1_val"></td>
</tr>
<tr>
<td><input type="text" readonly="readonly" value="" name="player_card_2"></td>
<td><input type="text" readonly="readonly" value="" name="p_card_2_val"></td>
<td><input type="text" readonly="readonly" value="" name="dealer_card_2"></td>
<td><input type="text" readonly="readonly" value="" name="d_card_2_val"></td>
</tr>
<tr>
<td><input type="text" readonly="readonly" value="" name="player_card_3"></td>
<td><input type="text" readonly="readonly" value="" name="p_card_3_val"></td>
<td><input type="text" readonly="readonly" value="" name="dealer_card_3"></td>
<td><input type="text" readonly="readonly" value="" name="d_card_3_val"></td>
</tr>
<tr>
<td><input type="text" readonly="readonly" value="" name="player_card_4"></td>
<td><input type="text" readonly="readonly" value="" name="p_card_4_val"></td>
<td><input type="text" readonly="readonly" value="" name="dealer_card_4"></td>
<td><input type="text" readonly="readonly" value="" name="d_card_4_val"></td>
</tr>
<tr>
<td><input type="text" readonly="readonly" value="" name="player_card_5"></td>
<td><input type="text" readonly="readonly" value="" name="p_card_5_val"></td>
<td><input type="text" readonly="readonly" value="" name="dealer_card_5"></td>
<td><input type="text" readonly="readonly" value="" name="d_card_5_val"></td>
</tr>
<tr>
<td><input type="text" readonly="readonly" value="Total"></td>
<td><input type="text" readonly="readonly" value=""></td>
<td><input type="text" readonly="readonly" value="Total"></td>
<td><input type="text" readonly="readonly" value=""></td>
</tr>
</table>
<br>
<form name="buttons" action="">
<input type="button" value="Deal" name="deal" onclick="newGame()">
<input type="button" value="Hit" name="hit">
<input type="button" value="Stand" name="stand">
</form>

</body>

</html>

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com