It looks like you're new here. If you want to get involved, click one of these buttons!

I have an idea for card games, their are very little tutorials on gard games for LUA.

If I can complete this card game, I could build on it, change the game by changing the rules, changing the amount of cards dealt and so fourth.

The Card game here is written in python, and I would like to change it to LUA programming Language.

The code isnt to long so as not to give it to much trouble. First here is the Logic of the Game.

```
- - BlackJack Planning Phase
- - Dealer Cards
- - Player Cards
- - Deal the Cards
- - Display the Cards
- - Sum of the Dealer
- - Sum of the Player
- - Compare the sum of the Cards, D vs. P
- - The Rules
- - if P cards sum is > 21 = Bust
- - if P cards sum is < 21 = Option : Hit or Stay
- - if Option P Stay compare of, D vs. P
- - if P sum is < 21 && and > D sum then P Wins !
- - if P sum is < D sum then P loses !
```

This is from a Youtube Video (22min long)

- - Code a Game of BlackJack withPython

- -

Now here is the Code (Written in Python) :...

~~~~~~~

```
- - Dealer Cards (This should be a Table )
dealer_cards [ ]
- - Player Cards (This should be a Table )
```

```
- - Deal the Cards (where len = length of string)
- - (Display the Cards)
while len(dealer_cards) ~= 2
dealer_cards.append(math.random(1,11))
if len(dealer_cards) ==2
```

```
- - Player Cards (Display the Cards)
while len(playler_cards) ~= 2
player_cards.append(math.random(1,11))
if len(player_cards) ==2
```

```
- - Sum of the Dealer Cards
If sum(dealer_cards) ==21
print(“Dealer has 21 and Wins”)
elif sum(dealer_cards) > 21
```

- Sum of the Player Cards

while sum(player_cards) < 21

action taken = str(input(“Do you want to stay or Hit ? ))

If action taken == “hit” :

player_cards.append(math.random(1,11))

print(“You now have a total of” + str(sum(player_cards))

”From these Cards, player_cards)

else:

print(“The Dealer has a total of ” + str(sum(dealer_cards)) +

“with”, dealer_cards)

print(“You now have a total of” + str(sum(player_cards)) +

“with”, player_cards)

If sum(dealer_cards) > sum(player_cards):

print(“Dealer Wins”)

else:

print(“You Win !”)

break

If sum(player_cards) > 21

print(“You Busted, Dealer Wins”)

elif sum(player_cards) == 21:

print(“You Win”)

~~~~~~~~~~

- Sum of the Player Cards

## Comments

@kendog400 There are plenty of card game examples on the forum. Do a forum search to see what you can find.

@kendog400 Here's a start for your card game. Some code to create a deck of cards. You can alter this to create what you want.

Thank You....

@kendog400 Here's a version based on what you show above. It's a total waste of Codea's capabilities, but it can be done. Press "h" for hit, "s" for stay, and "a" to play again. It's in portrait mode and you should slide the output window all the way up to show all of the print statements. I think it runs without errors, but I didn't test it that well.

EDIT: Made minor change for dealer.