fork(1) download
  1. //Dark Woods by Freakazoitt
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. //опять линуксоиды
  6. //#include <unistd.h>
  7. //#define Sleep(ms) sleep((ms)/1000)
  8. #define sleep
  9. #define scan_s
  10. #define random
  11.  
  12. int main(void)
  13. {
  14. // сразу дается нош на 1 атаку
  15. char k="z";
  16. int g=0,a=1,d=0,i=0,m=0;
  17. int x=0,d1=0,d2=0,d3=0,d4=0,d5=0,kills=0,buy=0,m_loot=0,m_attack=0;
  18. printf("Dark Woods by Freakazoitt\n\ncommand list: \n w - work in mines for gold \n i - look stats \n b - buy items \n m - kill monsters \n q - quit \n u - kill boss ");
  19. d=d1+d2+d3+d4+d5;
  20. scan_s("%c",&k);
  21. switch(k)
  22. {
  23. case 'w': // работать в шахте
  24. printf("started to work in mines");
  25. sleep(60000);
  26. {
  27. printf("finished work in mines");
  28. }
  29. g=g+1; // заработал 1 gold
  30. printf("earned 1 gold");
  31. break;
  32. case 'i': // инфа о персонаже
  33. printf("class: mercenary\n");
  34. printf("attack: ",a);
  35. printf("\ndefence:",d);
  36. printf("\nweapon: ","nife");
  37. printf("\nmoney: ",g);
  38. printf("\nmonsters killed",kills);
  39. break;
  40.  
  41. case 'b': // купить
  42. printf("\nshop items list\n\n weapons: \n d - dagger +2 attack, cost 3 gold \n a - axe +4 attack, cost 5 gold \n s - sword +6 attack, cost 8 gold \n p - enchanted pike +10 attack, cost 10 gold \n\n");
  43. printf("armor: \n i - leather jacket +1 defence, cost 1 gold \n b - leather gloves +1 defencr, cost 1 gold \n l - studded boots +1 defence, cost 2 gold \n c - chainmail +3 defence, replasing leather jacket, cost 3 gold \n h - steel helmet +2 defence, cost 4 gold \n g - iron face mask +1 defence, 2 gold");
  44. scan_s("%c",&buy); // покупка
  45. switch(buy)
  46. {
  47. case 'd':
  48. printf("You bought dagger +2 attack for 3 gold coins");
  49. a=2; // атака
  50. g=g-3; // минус зотото
  51. break;
  52. case 'a':
  53. printf("You bought axe +4 attack for 5 gold coins"); // axe на 4 атака
  54. a=4;
  55. g=g-5; // 5 gold
  56. break;
  57. case 's': //
  58. printf("You bought sword +6 attack for 8 gold coins");
  59. a=6;
  60. g=g-8; // 8 gold
  61. break;
  62. case 'p': //
  63. printf("You bought enchanted pike +8 attack for 15 gold coins");
  64. a=10;
  65. g=g-15;
  66.  
  67. break;
  68. case 'i': // leather jacket +1 defence
  69. printf("You bought leather jacket +1 defence for 1 gold coin");
  70. d1=1; g=g-1;
  71. break;
  72. case 'b': // perchatki +1 defence
  73. printf("You bought leather gloves +1 defence for 1 gold coin");
  74. d2=1; g=g-1;
  75. break;
  76. case 'l': // sapogi s plastinami +1 defence
  77. printf("You bought studded leather boots +1 defence for 2 gold coins");
  78. d3=1; g=g-2;
  79. break;
  80. case 'c': // chainmale 7gold +3 defence, zamenyaet leather jacket
  81. printf("You bought chainmail +3 defence for 3 gold coins. Replaced leather jacket.");
  82. d1=3; g=g-3;
  83. break;
  84. case 'h': // stalnoj shlem 7g
  85. printf("You bought steel helmet +2 defence for 4 gold coins");
  86. d5=2; g=g-4;
  87. break;
  88. case 'g': // защитные очки
  89. printf("You bought iron face mask +1 defence for 2 gold coins");
  90. d4=1; g=g-2;
  91. break;
  92. }
  93.  
  94. case 'm': // hunting on monster
  95. {
  96. int p;
  97. printf("You are going into the dark woods. Choose monster to attack: \n r -rat \n w -wolf \n g - goblin \n o -undead \n t - giant poison toad");
  98. scan_s("%c",&p);
  99. switch(p)
  100. {
  101. case 'r': // rat
  102. m_attack=1;
  103. m_loot=1;
  104. break;
  105. case 'w': // wolf
  106. m_attack=2;
  107. m_loot=2;
  108. break;
  109. case 'g': // goblin
  110. m_attack=4;
  111. m_loot=3;
  112. break;
  113. case 'o': // undead
  114. m_attack=8;
  115. m_loot=5;
  116. d4=2;
  117. printf("You picked up undead skin");
  118. break;
  119. case 't': // zhaba
  120. m_attack=10;
  121. m_loot=6;
  122. a=12;
  123. printf("You picked up poison");
  124. break;
  125. x=(a+d);
  126.  
  127. if (x>0)
  128. {
  129. printf("You won \n gained ",m_loot,"gold");
  130. g=g+m_loot;
  131. k=k+1;
  132. }
  133. else
  134. {
  135. printf("You loose");
  136. sleep(60000);
  137. printf("Find better equipment and try again");
  138. }
  139.  
  140. break;
  141. }
  142. break;
  143. }
  144.  
  145. case 'u': // final quest
  146. {
  147. printf("Fihting against final boss - evil mage Boratur");
  148. x=(a+d)*(random(1,5)-15*random(1,5));
  149.  
  150. if (x>0) { printf("You won! \n Game over: You won"); }
  151. else { printf("You loose!");
  152. sleep(60000);
  153. return 0;
  154. break;
  155. }
  156. return 0;
  157. }
  158. }
  159. }
Runtime error #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
Dark Woods by Freakazoitt

command list: 
 w - work in mines for gold 
 i - look stats 
 b - buy items 
 m - kill monsters 
 q - quit 
 u - kill boss