]>
Commit | Line | Data |
---|---|---|
5b25ff5f | 1 | |
2 | /* | |
3 | nethackify | |
4 | tries to write text ala nethack | |
5 | ||
6 | cat /etc/motd/ | nethackify | |
7 | /exec -o nethackify "good morning :)" | |
8 | ||
9 | gurkan@linuks.mine.nu | |
10 | */ | |
11 | ||
12 | #include <stdio.h> | |
13 | #include <string.h> | |
14 | #include <stdlib.h> | |
15 | #include <sys/time.h> | |
16 | ||
17 | char *normal ="ABCDEFGHIKLMNOPQRTUVWZbdeghjklmnoqwy:;01678"; | |
18 | char *nethack1="^P(|||C||||||CFCP|J/V/|cccni||nrccvv.,C|o/3"; | |
7fa98a96 | 19 | char *nethack2="?b?)F-(-?<_??\(?(F??\?/??|??????r???????\(???o"; |
5b25ff5f | 20 | char *nethack3=" [ [L \\ "; |
21 | char *nethack4=" [ \\ "; | |
22 | char *nethack5=" _ \\ "; | |
23 | ||
24 | int myrandom(float max) | |
25 | { | |
26 | return ((int)(max*rand()/(RAND_MAX+1.0))); | |
27 | } | |
28 | ||
29 | void nethackify(char* str) | |
30 | { | |
31 | int i,c; | |
32 | for(i=0; i<strlen(str); i++) { | |
33 | for(c=0; c<strlen(normal); c++) { | |
34 | if(normal[c]==str[i]) { | |
35 | if (myrandom(3)>0) { | |
36 | switch(myrandom(5)) { | |
37 | case 4: if(nethack5[c]!=' ') str[i]=nethack5[c]; | |
38 | case 3: if(nethack4[c]!=' ') str[i]=nethack4[c]; | |
39 | case 2: if(nethack3[c]!=' ') str[i]=nethack3[c]; break; | |
40 | case 1: if(nethack2[c]!=' ') str[i]=nethack2[c]; break; | |
41 | case 0: str[i]=nethack1[c]; break; | |
42 | default: break; | |
43 | } | |
44 | } | |
45 | } | |
46 | } | |
47 | printf("%c",str[i]); | |
48 | } | |
49 | ||
50 | printf(" "); | |
51 | } | |
52 | ||
53 | int main(int argc, char **argv) | |
54 | { | |
43263c0e | 55 | int i,c, ch; |
5b25ff5f | 56 | struct timeval tv; |
5b25ff5f | 57 | |
58 | srand((gettimeofday(&tv,NULL),tv.tv_usec)); | |
59 | if (argc==1) { | |
43263c0e | 60 | while((ch = getchar()) != EOF) { |
5b25ff5f | 61 | for(c=0; c<strlen(normal); c++) { |
43263c0e | 62 | if(normal[c]==ch) { |
5b25ff5f | 63 | switch(myrandom(5)) { |
43263c0e MG |
64 | case 4: if(nethack5[c]!=' ') ch=nethack5[c]; |
65 | case 3: if(nethack4[c]!=' ') ch=nethack4[c]; | |
66 | case 2: if(nethack3[c]!=' ') ch=nethack3[c]; break; | |
67 | case 1: if(nethack2[c]!=' ') ch=nethack2[c]; break; | |
68 | case 0: ch=nethack1[c]; break; | |
5b25ff5f | 69 | default: break; |
70 | } | |
71 | } | |
72 | } | |
43263c0e | 73 | printf("%c",ch); |
5b25ff5f | 74 | } |
5b25ff5f | 75 | } else { |
76 | for(i=1; i<argc; i++) { | |
77 | nethackify(argv[i]); | |
78 | } | |
79 | printf("\n"); | |
80 | } | |
81 | ||
82 | return 0; | |
83 | } |