-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
52 lines (40 loc) · 1.37 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--[[----------------------------------------------
Vocabulary and logic
----------------------------------------------]]--
voc = { 'piedra', 'papel', 'tijeras', 'lagarto', 'spock' }
who =
{
tijeras = { papel = 'Tijeras cortan papel',
lagarto = 'Tijeras decapitan al lagarto'},
papel = { piedra = 'Papel cubre a piedra',
spock = 'Papel desautoriza a Spock'},
piedra = { lagarto = 'Piedra aplasta a lagarto',
tijeras = 'Piedra aplasta las tijeras'},
lagarto = { spock = 'Lagarto envenena a Spock',
papel = 'Lagarto se come el papel'},
spock = { tijeras = 'Spock destroza las tijeras',
piedra = 'Spock vaporiza la piedra'}
}
--[[----------------------------------------------
Main activity
----------------------------------------------]]--
math.randomseed( os.time() )
print ( 'Choose one: \n' ..
'\tPiedra\n' ..
'\tPapel\n' ..
'\tTijeras\n' ..
'\tLagarto\n' ..
'\tSpock' )
user = string.lower ( io.read( '*line' ) )
cpu = math.random ( 0, 4 )
cpu = voc [ cpu ]
if user == cpu then
print 'Empate'
else
if who [ cpu ][ user ] ~= nil then
print ( who [ cpu ] [ user ] )
else
print ( who [ user ] [ cpu ] )
end
end
io.read( "*line" )