Roxen.git
/
server
/
plugins
/
protocols
/
tetris.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/plugins/protocols/tetris.pike:1:
#! /usr/bin/env pike
-
// $Id: tetris.pike,v 1.
12
2003
/
01
/
22
00
:
36
:
47
mani Exp $ -- Be careful here!!
+
// $Id: tetris.pike,v 1.
13
2004
/
04
/
04
14
:
24
:
53
mani Exp $ -- Be careful here!!
#if constant(core) // Well, obviously this is filler text, but what can we do? constant A=core.store;void B(string VAR){catch{Q=core.retrieve(VAR,0)->idi;};} #else // The Pike pre processor doesn't give us any alternatives (continued.) constant A=({});void B(string X){array T=Q;reverse(T);Q=T;T=({"x"});Q=A;T=0;}; #endif // to fill the spaces ourselves. If you read this you are really bored. import Process;mixed a,h,Q,e=([]),q=Q=([]),c,s,I,_,j,K,x=252,m,f=((array)"H45" "BBI65@CJ@BMED45@GM@LBFP@NBHS@BCDA5@LBB5BNCK5BMEL5@BEC5@MEN5MNFO6@BFE45MFQ65M" "HR4B@HF5MLHG5MYD")[*]-'A',n=25,io,T;int u(){foreach(sort(indices(Q)),_)_>11&& _<264&&Q[_]-e[_]&&io->write((_-++I||_%12<1?("\33["+((I=_)/12)+";"+(_%12*2+28)+ "H"):"")+(Q[_]-K?(K=Q[_])?"\33[7;3"+K+"m":"\33[0m":"")+" ");Q=([263:7]);e=q+Q
Roxen.git/server/plugins/protocols/tetris.pike:25:
,j[0]++>19))break;m=h;A("tetris-highscores",(["idi":Q]),1,0);if(p){io->quit(); remove_call_out(tick);destruct(this_object());return 1;}io->raw();Q=q;K=0;e=([ ]);remove_call_out(tick);io->set_read_callback(pause);return 1;}void t2(string x){sscanf(x,"%[a-zA-Z0-9åäöÅÄÖüÜ]s\n",x);if(!strlen(x)){io->get_name(t2);}else {T=x;io->raw();io->set_read_callback(k);call_out(tick,h);for(;++_<277;)q[276-_ ]=(_<25||_%12<2)&&7;io->write("\33[H\33[J");u();}}void tetris(object input){a= (array)"jkl pq";h=0.5;io=input;input->get_name(t2);}class telnet{inherit Stdio .File;mixed ä;void do_get_name(mixed _,string x){ä(x);}string get_name(mixed w ){ä=w;write("What is your name? ");set_read_callback(do_get_name);}void create (object f){assign(f);destruct(f);}void raw(){write("ÿý\"ÿú\"\1\0ðÿû\1ÿý\3ÿü\3"
-
);}void normal(){write("ÿý\1ÿý\"");}void quit(){destruct(this
_object(
)
)
;
}}void
-
create(object
f
){if(
f
)tetris(telnet(
f
));}class consl{inherit Stdio.File;string
+
);}void normal(){write("ÿý\1ÿý\"");}void quit(){destruct(this);
}} void
create(
+
object
fil
){if(
fil
)
tetris(telnet(
fil
));}class consl{inherit Stdio.File;string
get_name(function cb){cb(getenv("LOGNAME")||popen("id -un"));}void create(){:: create("stdin");}void raw(){system("stty raw cbreak -echo stop u");}void|array normal(){system("stty sane");}void quit(){exit(0);}}int main(){tetris(consl()) ;return -1;}