This game is an allegory for Judaism.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(){
char Action[10];
int Damage;
int HP = 50;
int EHP = 35;
int EDamage;
printf("\nYou are in a battle with a monster, please take an action.\n");
while(HP > 0 && EHP > 0){
printf("\nYour HP is: %d\nYour last hit did %d Damage.\nAction: ", HP, Damage);
fgets(Action, sizeof(Action), stdin);
Action[strcspn(Action, "\n")] = 0; //This section takes out the newline character.
for(int i = 0; i < strlen(Action); i++){ //This section is the part which makes the string upper case.
Action[i] = toupper(Action[i]);
}
if(strcmp(Action, "ATTACK") ==0){
Damage=rand() % 20 + 0;//This picks the damage randomly.
printf("\nYou hit the enemy for: %d Damage.\n", Damage);
EHP=EHP - Damage;
}
else if(strcmp(Action, "RUN") ==0){
printf("\nYou Got Away!\n");
break;
}
else{
printf("\nYou did nothing.\n");
EDamage=rand() % 20 + 0;
HP= HP - EDamage;
printf("\nYou were hit for: %d Damage.\n", EDamage);
}
EDamage=rand() % 20 + 0; //This picks the enemy damage randomly.
printf("\nYou were hit for: %d Damage.\n", EDamage);
HP=HP - EDamage;
}
if(HP > EHP && HP > 0){
printf("\nYOU WON!\n");
}
else if(HP > EHP && HP < 0){
printf("\nYou won but didn\'t survive...\n");
}
else if(HP < EHP && HP < 0){
printf("\nYou died...\n");
}
else if(HP < EHP && HP > 0){
printf("\nAt least you survived???\n");
}
else{
printf("\nWell folks it\'s a strange one out there and we\'re not really sure of what happened.\n");
}
return 0;}