Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
87
Task/Penneys-game/Amazing-Hopper/penneys-game.hopper
Normal file
87
Task/Penneys-game/Amazing-Hopper/penneys-game.hopper
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#include <jambo.h>
|
||||
|
||||
#define Getanuppercasecharinto(_X_) Getchar(_X_),Let( _X_ := Ucase(_X_) )
|
||||
#define Isnotvalidin(_X_) Not( Occurs in (_X_) )
|
||||
#define NOELIGEPCDESPUESDETI 0
|
||||
#define ELIGEPCDESPUESDETI 1
|
||||
|
||||
Main
|
||||
Set break
|
||||
Get total args
|
||||
If ( Is equal to '2' )
|
||||
largo=0
|
||||
Let ( largo := Get if( Argnum(2) Is less than '3', 3, Argnum(2) ) )
|
||||
OTRO="S"
|
||||
|
||||
Cursor off
|
||||
Loop
|
||||
P="", C="", S="", L=0
|
||||
Cls
|
||||
Locate(1,1), Printnl ("***** Penney's Game *****")
|
||||
|
||||
If ( Geq( Rand(1), 0.5) )
|
||||
Gosub ' Yo tiro ', Set 'NO ELIGE PC DESPUES DE TI',Gosub ' Tú tiras '
|
||||
Else
|
||||
Set 'ELIGE PC DESPUES DE TI', Gosub ' Tú tiras '
|
||||
End If
|
||||
|
||||
// a jugar:
|
||||
G="", SW=1
|
||||
Loop
|
||||
Let( G := Cat( G, Get if( Geq( Rand(1), 0.5), "T", "H" ) ) )
|
||||
Locate( 6, 1 ), Printnl( "Tiradas: ", G )
|
||||
|
||||
Continue if ( Less ( Len (G) ---Backup to 'L'---, 3) )
|
||||
|
||||
Let ( S := Right( Sub(L, Minus one 'largo') , G) )
|
||||
|
||||
If ( Eq( S, P ) )
|
||||
Set ("TU GANAS!!"), SW=0
|
||||
Else If (Eq( S, C ) )
|
||||
Set ("YO GANO!!"), SW=0
|
||||
End If
|
||||
Prnl
|
||||
Sleep(1)
|
||||
Back if( SW ) is not zero
|
||||
Printnl ( Utf8("¿Otro juego? S/* ") )
|
||||
Getchar(OTRO)
|
||||
While( Eq (OTRO, "S") )
|
||||
|
||||
Cursor on
|
||||
Else
|
||||
Printnl("Modo de uso: hopper penny.jambo <n>\ndonde \"n\" es el largo de la secuencia")
|
||||
End If
|
||||
End
|
||||
|
||||
Subrutines
|
||||
|
||||
Define ' Yo tiro '
|
||||
Locate(4,1), Print( "Yo elijo... " )
|
||||
i=largo
|
||||
Loop
|
||||
Let( C := Cat( C, Get if( Geq( Rand(1), 0.5), "T", "H" ) ) )
|
||||
--i
|
||||
Back if (i) is positive
|
||||
Printnl (C)
|
||||
|
||||
Return
|
||||
|
||||
Define ' Tú tiras, elige pc '
|
||||
Locate(3,1), Printnl ( Utf8("Tú eliges...") )
|
||||
i=largo, c=0
|
||||
Loop
|
||||
Get an uppercase char into 'c'
|
||||
Continue if ( var(c) Is not valid in ("HT") )
|
||||
Let( P:=Cat(P,c) )
|
||||
Loccol(13), Printnl(P)
|
||||
--i
|
||||
Back if (i) is positive
|
||||
|
||||
If ( elige pc )
|
||||
Let (C := P)
|
||||
[2] Get from (C)
|
||||
Set if( Is equal to ("H"), "T", "H" )
|
||||
Cput (C)
|
||||
Locate(4,1), Print( "Yo elijo... ", C )
|
||||
End If
|
||||
Return
|
||||
Loading…
Add table
Add a link
Reference in a new issue