https://github.com/bingus-dev/guess-the-card
Computer magic trick
https://github.com/bingus-dev/guess-the-card
card-trick lua magic
Last synced: about 1 year ago
JSON representation
Computer magic trick
- Host: GitHub
- URL: https://github.com/bingus-dev/guess-the-card
- Owner: bingus-dev
- Created: 2024-08-26T20:30:44.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-27T14:11:27.000Z (almost 2 years ago)
- Last Synced: 2025-03-17T15:26:06.862Z (about 1 year ago)
- Topics: card-trick, lua, magic
- Language: Lua
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The Computer will Guess Your Card
This Lua code will guess your card. Only 1% can beat! Impossible to figure out.
> this is a joke
## Usage
```
lua guess-the-card.lua
```
Also compatable with LuaJIT
```
luajit guess-the-card.lua
```
## Code
```lua
-- made by @btd2010
function read()
return io.read()
end
local acceptableValue = false
local faceValue = "None"
local suitValue = "None"
while not acceptableValue do
os.execute("clear")
print("I will guess your card. Enter a number according to the chart below..")
print(
"""
- 11: Ace
- 12: King
- 13: Queen
- 14: Jack
- 1-10: Face value
"""
)
local readValue = read()
local readNum = tonumber(readValue)
if readNum ~= nil then
if readNum >= 1 and readNum <= 14 then
acceptableValue = true
if readNum == 1 then faceValue = "One" end
if readNum == 2 then faceValue = "Two" end
if readNum == 3 then faceValue = "Three" end
if readNum == 4 then faceValue = "Four" end
if readNum == 5 then faceValue = "Five" end
if readNum == 6 then faceValue = "Six" end
if readNum == 7 then faceValue = "Seven" end
if readNum == 8 then faceValue = "Eight" end
if readNum == 9 then faceValue = "Nine" end
if readNum == 10 then faceValue = "Ten" end
if readNum == 11 then faceValue = "Ace" end
if readNum == 12 then faceValue = "King" end
if readNum == 13 then faceValue = "Queen" end
if readNum == 14 then faceValue = "Jack" end
end
end
end
acceptableValue = false
while not acceptableValue do
os.execute("clear")
print("I will guess your card. Enter the suit of your card..")
print(
"""
- 1: Spades
- 2: Clubs
- 3: Hearts
- 4: Diamonds
"""
)
local readValue = read()
local readNum = tonumber(readValue)
if readNum ~= nil then
if readNum >= 1 and readNum <= 4 then
acceptableValue = true
if readNum == 1 then suitValue = "Spades" end
if readNum == 2 then suitValue = "Clubs" end
if readNum == 3 then suitValue = "Hearts" end
if readNum == 4 then suitValue = "Diamonds" end
end
end
end
print("Is your card...")
print("a " .. faceValue .. " of " .. suitValue .. "?")
os.exit(0)
```