Типа готовый GuessMyNumber. Угадайка от 1 до 50 с 4 уровнями сложности.
This commit is contained in:
83
main.cpp
Normal file
83
main.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
using std::cout; using std::endl; using std::cin; using std::string; typedef unsigned int unint;
|
||||
|
||||
int main() {
|
||||
|
||||
//переменные
|
||||
int compwin=0, urwin=0, maxtimes, times=1, rng, usercount=101; string yn = "y";
|
||||
const char *RAZD = "------------------"; unint dif; bool debug;
|
||||
char const *TOOCOLD = "hell bro TOO COLD"; char const *TOOHOT = "yo brodie dat SO HOT";
|
||||
enum difficult {EASY = 1, HARD = 2, NIGHTMARE = 3, FEDYA = 4};
|
||||
|
||||
//заглавие
|
||||
cout << RAZD << "\n" << RAZD << endl; cout << "ayyyy lmao welcome do Doka 3!" << endl;
|
||||
cout << "CHOOSE UR DESTINY.\n1.EASY gives u 10 tries.\n2.HARD - 6 tries.\n3.NIGHTMARE - 3 tries.\n4.BROOO DON'T TYPE FEDYA" << endl;
|
||||
cin >> dif;
|
||||
|
||||
//выбор уровня сложности из пеоечисления
|
||||
switch (dif) {
|
||||
case EASY:
|
||||
cout << "DADDY PLZ DON'T BEAT ME!" << endl; maxtimes = 10; break;
|
||||
case HARD:
|
||||
cout << "U WANNA PLAY? LET'S PLAY!" << endl; maxtimes = 6; break;
|
||||
case NIGHTMARE:
|
||||
cout << "U'LL NEVER WIN." << endl; maxtimes = 3; break;
|
||||
case FEDYA:
|
||||
cout << "DeLongia Software ebat'" << endl; maxtimes = 1; break;
|
||||
default:
|
||||
cout << "invalid parameter (you are invalid too brodie.)" << endl; return 0;
|
||||
}
|
||||
|
||||
//дебаг вкл-выкл
|
||||
cout << "need a debug option? (0/1)" << endl;
|
||||
cin >> debug; if (debug==true) {cout << "freaking cheater." << endl;}
|
||||
cout << "I've generated number from 1 to 50. Can u guess it? ";
|
||||
|
||||
//ТЕЛО ИГРЫ
|
||||
while (yn=="y") {
|
||||
//рандомайзер
|
||||
cout << "wut r u waitin' 4? type ur number:" << endl;
|
||||
srand(static_cast<unint>(time(0)));
|
||||
rng = (rand() % 50) + 1;
|
||||
|
||||
//дебаг-опция выводит верный ответ и счёт после каждого прокрута
|
||||
if (debug==true) {cout << "rng:" << rng << "\ncompscore:" << compwin << "\nuserscore:" << urwin << endl;}
|
||||
|
||||
//тело угадайки
|
||||
while (usercount != rng)
|
||||
{
|
||||
cin >> usercount;
|
||||
if (usercount>rng) {if (usercount-rng>=5) {cout << TOOCOLD << endl;} else {cout << TOOHOT << endl;}}
|
||||
if (usercount<rng) {if (rng-usercount>=5) {cout << TOOCOLD << endl;} else {cout << TOOHOT << endl;}}
|
||||
if ((usercount==rng) or (maxtimes==times)) {break;}
|
||||
++times;
|
||||
};
|
||||
|
||||
//итоги раунда
|
||||
if ((times==1) and (usercount==rng)) {++urwin; cout << "DAMMIT M8 U GUESSED IT FROM " << times << "st TIME!" << endl;}
|
||||
else if ((times<=maxtimes) and (usercount==rng)) {++urwin; cout << "sheee not bad u guessed it from " << times << " time!" << endl;}
|
||||
else {++compwin ;cout << "damn u lost." << endl;}
|
||||
//прекол (только на уровне сложности ФЕДЯ)
|
||||
if (maxtimes==1) {cout << "fedya also found u and took ur ass." << endl;}
|
||||
|
||||
//предложение нового раунда
|
||||
cout << "wanna play another time? (y/n)" << endl;
|
||||
times = 1;
|
||||
cin >> yn;
|
||||
}
|
||||
|
||||
//СТАТИСТИКА ПРИ ЗАВЕРШЕНИИ ИГРЫ
|
||||
cout << "SOME STATS OF UR SESSION:" << endl;
|
||||
//только на уровне сложности ФЕДЯ
|
||||
if (maxtimes==1) {cout << "fedya took ur ass " << compwin << " times.\nu r saved ur anus " << urwin << " times." << endl;}
|
||||
//в остальных случаях
|
||||
else {cout << "I'm won " << compwin << " times.\nu won me " << urwin << " times." << endl;}
|
||||
|
||||
//компьютер респектует или лошит игрока
|
||||
if (compwin>urwin) {cout << "fuckyeah go back home lamer, u need some training." << endl;}
|
||||
else {cout << "well, dat was not bad how u beat me." << endl;}
|
||||
return 1488;
|
||||
}
|
||||
Reference in New Issue
Block a user