1
Name:
Anonymous
2010-06-29 14:04
The Challenge:
-Develop a turn based combat system that implements the following choices that occur during the player's turns:
--Fight (Straight Damage)
--Item (Use an object from a choice of your design)
--Ability (Use an ability from a choice of your design)
--Run (Flee the battle)
The Deadline:
- 2010-07-01 00:00
The rest is up to you.
90
Name:
Anonymous
2010-07-03 23:52
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, char *argv[])
{
double hp = 50;
double shp = 50;
bool turn = 0;
bool battle = 1;
int choice = 0;
double dmg = 0;
cout << "A WILD SUSSMAN appeared!\nYou are drawn into battle!\n";
while (battle) {
if (turn==0) {
cout << "What do you do?\n [1] Attack\n [2] Use Item\n [3] Use Skill\n [4] Run\n";
cin >> choice;
cout << "\n";
switch (choice) {
case (1):
dmg = round(5+(rand() % 7));
shp -= dmg;
cout << "You hit WILD SUSSMAN for " << dmg << " damage!\nWILD SUSSMAN has " << shp << " health remaining!\n\n";
turn = 1;
break;
case (2):
dmg = 5 - round(rand() % 5);
shp -= dmg;
cout << "Your quote from SICP brings WILD SUSSMAN to tears!\nYou hit him with SICP for " << dmg << " damage!\nWILD SUSSMAN has " << shp << " health remaining!\n\n";
turn = 1;
break;
case (3):
dmg = round(10*(rand() % 2));
shp -= dmg;
cout << "Your vast knoledge of Perl assists you...!\n";
if (dmg==0) {
cout << "WILD SUSSMAN's knoledge surpasses yours!\nNo damage!\n\n";
} else {
cout << "The pure beauty of your code deals " << dmg << " points of damage to WILD SUSSMAN!\nWILD SUSSMAN has " << shp << " health remaining!\n\n";
}
turn = 1;
break;
case (4):
cout << "You break into a full sprint away from WILD SUSSMAN!\n";
cout << "...\nWILD SUSSMAN jumps from above and blocks your escape!\n\n";
turn = 0;
break;
default:
cout << "Your input is invalid; try again.\n\n";
break;
}
system("Pause");
} else {
choice = (int) round(rand() % 4);
switch (choice) {
case (0):
hp -= 5;
cout << "WILD SUSSMAN performs a low-kick dealing 5 damage.\nYou have " << hp << " health left.\n\n";
turn = 0;
break;
case (1):
hp -= 6;
cout << "WILD SUSSMAN summons the progsnake, dealing 6 damage.\nYou have " << hp << " health left.\n\n";
turn = 0;
break;
case (2):
hp -= 3;
cout << "WILD SUSSMAN uses peels on you, dealing 3 damage.\nYou have " << hp << " health left.\n\n";
turn = 0;
break;
case (3):
cout << "WILD SUSSMAN flees, but is barred by the mighty progsnake!\n\n";
turn = 0;
break;
}
system("Pause");
}
if (hp<=0) {
cout << "The WILD SUSSMAN defeated you!\n\n";
battle = 0;
}
if (shp<=0) {
cout << "You defeated the WILD SUSSMAN!\n\n";
battle = 0;
}
}
system("Pause");
}