Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<typeinfo>
#include<string>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include"class.h"
using namespace std;
int neweenmy()
{
if(rand()%100<10)
{
return 11;
}
else
{
int w=rand()%10;
return w;
}
}
int fight(int eno)
{
srand(time(NULL));
player p;
int playerexp=9;
string name;
name=p.getname();
p.fight=true;
enemy e;
e.enemyno=eno;
e.enemyskill;
while(p.fight&&e.enemykill<e.enemyno)
{
e.enemyskill= neweenmy();
if (e.enemyskill > 10) {
cout << endl << "Here comes a huge enemy!" << endl;
}
else
{
cout << endl << "enemy is attacking " << e.enemykill + 1 << endl;
}
cout << "battleing..." << endl;
sleep(2);
if (playerexp< e.enemyskill)
{
p.fight = false;
cout << "you failed the battle" << endl;
}
else
{
if (playerexp - e.enemyskill > 7) {
cout << "You superpuched the enemy!" << endl;
}
else if (playerexp - e.enemyskill > 5) {
cout << "You superkicked the enemy!" << endl;
}
else if (playerexp - e.enemyskill > 0) {
cout << "You defested the enemy!" << endl;
}
else {
cout << "You deafeated enemy, but injuries are serious" << endl;
}
e.enemykill++;
}
sleep(2);
}
if (e.enemykill == e.enemyno)
{
cout << "You have won the macth!" << endl;
}
else {
cout << "You lose the match." << endl;
}
return 0;
}
int main()
{
int inp;
cout<<"\n\n\n\nMAIN MENUE\n\n";
cout<<"1.start game\n\n";
cout<<"2.credits\n\n";
cout<<endl<<endl<<"enter your choice:";
bool check0=true;
while(check0)
{
cin>>inp;
switch(inp)
{
case 1:
{
string name ;
cout<<"enter your name to continue";
cin>>name;
player p;
p.setname(name);
string j=p.getname();
cout<< "hi";
char ans;
int x;
cout<<"\n\n\n\\nWelcome to the game\t"<<name<<"! You are in another dimension of time where you must make quick decisions to survive and progress onto the next level.\n" ;
cout<<"You see a laptop in front of you and an email pops up on the screen. Do you wish to read or not (y/n)? ";
bool check=true;
while(check)
{
cin>>ans;
if( (int)ans==121 ||(int)ans==89)
{
cout<<"\n\n\n\nThe email reads:\n\n";
cout<<"\nDare to enter be courageous in this game because every step you take has its consequences. This is the Game of 24 where you get 24 hours with two lifelines within each level.For every wrong decision, you lose one lifeline, and the game resets the day.\n";
cout<<"Regards\n";
cout<<"Charlie\n\n\n" ;
p.setexp();
cout<<"exp incresed to\n\n"<<p.getexp()<<endl;;
check=false;
break;
}
else if((int)ans==110||(int)ans==79)
{
char sure;
cout<<"ARE YOU SURE TO EXIT";
cin >> sure;
if((int)sure==121 ||(int)sure==89)
{
exit(0);
}
else if((int)ans==110||(int)ans==79)
{
cout<<"do you want to play the game";
continue;
}
else
{
continue;
}
}
else
{
cout<<"invalid input"<<endl;
cout<<"retry";
continue;
}
}
int ans2;
cout<<"You have found out the email header of Charlie and you have the knowledge to hack him and find out more about him. Do you wish to continue? \n1.Hack Charlie"<<endl<<"\n2.no"<<endl;
bool check2=true;
while(check2)
{
cin>>ans2;
switch(ans2)
{
case 1:
{
cout<<"to hack chalie you must find the you must type the LETTERS OF FOLLOING ASCII VALUEs"<< endl;
cout<<"71,65,77,69,79,70"<< endl;
string decrpt;
bool check3=true;
while(check3)
{
cin>>decrpt;
if(decrpt=="GAMEOF")
{
cout<<"well done you have craked the code";
p.incintell();
p.incstamin();
p.setexp();
check3=false;
check2=false;
}
else
{
cout<<"try again";
}
}
break;
}
case 2:
{
char sure;
cout<<"ARE YOU SURE TO EXIT";
cin >> sure;
if((int)sure==121 ||(int)sure==89)
{
exit(0);
}
else
{
continue;
}
}
default:
{
cout<<"invalid input;";
cout<<"retry";
continue;
}
}
}
bool check4=true;
while(check4)
{
char ans1;
cout<<"The software returns the IP address of Charlie, and you have an IP tracer software with which you find his location Australia (16.3014 S 145.2480 E )\n\n\n";
cout<<"\"Do you want to find Charlie and accept his challenge to play the Game of 24? (y/n)?\n\n";
cin>>ans1 ;
if( (int)ans1==121 ||(int)ans1==89)
{
p.incintell();
p.incstamin();
p.setexp();
check4=false;
int x;
cout<<"\n\n\n\nIntro of Level 1 - You are taken into the Daintree National Park, Australia, a dense rainforest, surrounded by tall trees and waterfalls.";
cout<<"After following the coordinates of Charlie’s email location, you have reached the forest office.\n\n Do you choose to \n1.Enter the forest office \n 2.stay where you are\n 3.roam around";
cin>>x;
bool check5=true;
while(check5)
{
switch(x)
{
case 1:
{
cout<<"when you enter the forest a forest officer come to forest ask what you want\n\n 1.you ask him about charlie\n\n 2.ask nothing \n\n3. you attack officer"<< endl;
cin>>x;
switch(x)
{
case 1:
{
cout<<"Enquire about Charlie but no one knows any person named Charlie in the forest department.\n\n\n\n";
p.incintell();
p.incstamin();
p.setexp();
check4=false;
check5=false;
break;}
default:
{
cout<<"no useful info gained";
}
}
break;
}
default:
{
cout<<"no useful info gained";
}
}
}
}
else if((int)ans1==110||(int)ans1==79)
{
char sure;
cout<<"ARE YOU SURE TO EXIT";
cin >> sure;
if((int)sure==121 ||(int)sure==89)
{
exit(0);
}
else if((int)ans1==110||(int)ans1==79)
{
cout<<"do you want to play the game";
continue;
}
else
{
continue;
}
}
else
{
cout<<"invalid input"<<endl;
cout<<"retry";
continue;
}
}
int ans3;
cout<<endl<<endl<<"when you come out of the forest office a van came in front of you .your are kidnapped by by some people"<<endl;
cout<<endl<<"they took you to empty ware =house";
cout<<"heard someome murmuring in the dark."<<endl;
cout<<"what must you do";
cout<<endl<<"1.you try get out of rope ";
cout<<endl<<"2. you give up hope";
bool check6=true;
while(check6)
{
cin>>ans3;
switch(ans3)
{
case 1:
{
cout<<"you got out of rope";
cout<<"but enemy saw you.three big men charging towars you."<<endl;
p.incintell();
p.incstamin();
p.setexp();
check6=false;
break;
}
default:
cout<<"no useful info gained."<<endl;
}
}
cout<<"YOU MUST ACT QUick"<<endl;
cout<<"1.attack the men"<< endl;
cout<<"2.surrender"<<endl;
int ans4;
bool check7=true;
while(check7)
{
cin>>ans3;
switch(ans3)
{
case 1:
{
cout<<"you are attacking";
fight(3);
p.incintell();
p.incstamin();
p.setexp();
check7=false;
break;
}
default:
cout<<"no useful info gained";
}
if(x==0)
{
cout<<"well done"<< endl;
}
else
{cout<<"you escaped from there"<< endl;
}
}
cout<<"you ware able to get hold of cellphone of one of the ayttckers"<< endl;
cout<<"what should you do?"<< endl;
cout<<"1.hack"<< endl;
cout<<"2.break the phone";
bool check8=true;
int ans9;
while(check8)
{
cin>>ans9;
switch(ans9)
{
case 1:
{
cout<<"you must do the ascII decrpting"<< endl;
cout<<"to hack chalie you must find the you must type the LETTERS OF FOLLOING ASCII VALUEs"<< endl;
cout<<"72,65,75,69,68"<< endl;
string decrpt1;
bool check9=true;
while(check9)
{
cin>>decrpt1;
if(decrpt1=="HACKED")
{
cout<<endl<<"well done you have craked the code"<< endl;
p.incintell();
p.incstamin();
p.setexp();
check9=false;
check8=false;
continue;
}
else
{
cout<<"incorrect dcrpytion"<<endl;
}
}
break;
}
default:
cout<<"no useful info gained"<< endl;
}
}
char ans5;
cout<<endl<<"you recived some number that are the co-ordinate of near the whare house"<<endl;
cout<<endl<<" you found the uderlayerr of their boss."<< endl;
cout<<endl<<"ARE you going to meet the BOSS(y/n)" ;
cin>>ans5;
if((int)ans5==121 ||(int)ans5==89)
{
cout<<"you have enterd the boss level. you go to the warehouse ";
cout<<" you are captured by the enemy. ";
cout<<"they took you their boss";
cout<<"the man came and told you ";
cout<<endl<<"welcome i am charlie "<<name<<" i trust your skill in hacking can bring you here.I wanted to recruit you to my organisation.But i now its to late";
cout<<"i will take over your identity and kill you instead";
cout<<"Charlie and 7 other enemy coming towards you. Chose your way"<<endl<<endl;
cout<<"1.attack"<< endl;
cout<<"2.surrender";
int ans6;
bool check9=true;
while(check9)
{
cin>>ans6;
switch(ans6)
{
case 1:
{
cout<<"but enemy saw you.three big men charging towars you."<<endl;
fight(4);
check9=false;
cout<<"youhave won the game";
break;
}
default:
{
cout<<"gameover";
}
}
}
}
break;
}
case 2:
{
cout<<"credits"<<endl;
cout<<"jacob binu mancherikalam (student) Coventry University";
}
default:
{
cout<<"invalid input";
cout<<"retry";
continue;
}
}
}
return 0;
}