// game test number 1
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
usingnamespace std;
int main(){
int d10 ;
int ML1 ;
int ML2 ;
int ML3 ;
int RM1 ;
int RM2 ;
int BOS ;
int WP1 ;
int rr ;
int MNS ;
cout << "You have been assigned by the Lord of Uberdark to patrol the Mines of Rodin. While patroling you run into a goblin!";
char myArray[50];
cout << " What do you want to do, run or fight the goblin? ";
cin.getline( myArray, 50, '\n');
if( !strcmp( myArray, "fight")){
srand(time(0));
d10 = rand() % 10+1;
cout << d10;
ML1 = rand() % 10+1;
cout << ML1;
if(d10 > ML1){
cout << " You defeated the goblin!" << endl << endl;}
if(d10 < ML1){
cout << " You have been defeated by the goblin! You retreat back to Uberdark to rest." << endl << endl;}
if(d10 == ML1){
cout << " You and the goblin have both been defeated by entropy!\n\n" << endl << endl;
}
if(d10 == ML1){
cout << " You get back up and rest for a while to then continue your task." << endl << endl;}
if(d10 < ML1){
cout << " You return from Uberdark well rested." << endl << endl;}
}
if( !strcmp( myArray, "run")){
srand(time(0));
rr = rand() % 14+1;
if(rr > 7){
cout << " You have successfully ran away, coward!" << endl << endl;}
if(rr < 7){
cout << " The goblin has caught up to you and beat you to the floor. You wake up later and continue to patrol." << endl << endl;}
if(rr == 7){
cout << " The goblin has caught up to you and beat you to the floor. You wake up later and continue to patrol." <<endl <<endl;}
// Part 2
{cout << " As you continue along in the mines you hear a noise. You investigate and discover the source, a room.";
cout << " Will You go through the door or leave and cancel the investigation? ";
cin.getline( myArray, 50, '\n');
if( !strcmp( myArray, "go through")){
srand(time(0));
RM1 = rand() % 20+1;
if(RM1 < 8){
cout << " You find and ancient relic as you put the relic into your rucksack you feel a power come over you.";
cout << " Your sword begins to glow blue and your armor is now...";
cout << " Ancient armor of the Gods!" << endl << endl;}
if(RM1 > 8){
cout << " You find nothing but a pile of bones and a dead rat.";
cout << " You leave the room and continue patroling." << endl <<endl;}
}
if( !strcmp( myArray, "leave")){
cout << " You walk away from the door but the sound is still there and it continues to haunt you.";}
srand(time(0));
MNS = rand() % 20+1;
if(MNS > 1){
cout << " You run into a dwarf on the walk away from the door.";
cout << " He is equipped with corrupt dwarven armor and has fierce red eyes.";
cout << " As you reach for your sword the dwarf says something.";
cout << " What are you doing petty human?";
cout << " Do you not realize that I am the Dark Lord Farron?";
cout << " You feel a dark shadow rise from the Farron.";
cout << " The dwarf suddenly vannishes.";}
if(MNS == 1){
cout << " You run into a dwarf on the walk away from the door.";
cout << " He is equipped with corrupt dwarven armor and has fierce red eyes.";
cout << " As you reach for your sword the dwarf says something.";
cout << " What are you doing petty human?";
cout << " Do you not realize that I am the Dark Lord Farron?";
cout << " You feel a dark shadow rise from the Farron.";
cout << " The dwarf suddenly vannishes.";}
system("pause");}
}
}
I don't know why but when I type "fight" in the beginning when fighting the goblin the window just closes can anyone help? It worked before but now it keeps closing when I type "fight". Plz help!
So what else you expected it to do , if you fight you either win or lose , that's it,you get out of the program as there is no loop or anything more to do when you all do is fight.