1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
# include <iostream>
# include <stdlib.h>
# include <windows.h>
using namespace std;
int main(){
long long attack, defence, eattack, edefence, life, elife, rest, erest;
long long attackp, t[2], money, moneya, account, price[2];
char attacktype, shop, weapon;
bool boughtweapon[2];
life = 100;
elife = 100;
cout << "press (s) to start:\n";
cin >> attacktype;
t[0, 1, 2] = 0;
money = 0;
price[0, 1, 2] = 30;
cout << "\nNEW GAME\n\n";
boughtweapon[0, 1, 2] = false;
while(true){
moneya = money;
if ( attacktype != 's' and attacktype != 'h' and attacktype != 'i' ){
cout << "\nUNABLE TO READ COMMAND";
break;
}
if (attacktype == 's'){
attack = rand () % 10;
attackp = attack;
if ( boughtweapon[0] = true){
erest = elife - (attackp + t [0]);
}
if ( boughtweapon[1] = true){
erest = elife - (attackp + t [1]);
}
if ( boughtweapon[2] = true){
erest = elife - (attackp + t [2]);
}
if ( boughtweapon[0, 1, 2] = false ){
erest = elife - attackp;
}
elife = erest;
eattack = rand () % 8;
rest = life - eattack;
life = rest;
cout << "Choose what kind of attack to use: stab(s), hack(h) or instantkill(i):\n";
cin >> attacktype;
cout << "You take the enemy " << attackp << " damage | " << erest << " enemy life\n";
cout << "The enemy takes you " << eattack << " damage | " << rest << " your life\n\n";
}
if (attacktype == 'h'){
attack = rand () % 15;
attackp = attack ;
if ( boughtweapon[0] = true){
erest = elife - (attackp + t [0]);
}
if ( boughtweapon[1] = true){
erest = elife - (attackp + t [1]);
}
if ( boughtweapon[2] = true){
erest = elife - (attackp + t [2]);
}
if ( boughtweapon[0, 1, 2] = false ){
erest = elife - attackp;
}
elife = erest;
eattack = rand () % 20;
rest = life - eattack;
life = rest;
cout << "stab, hack, instantkill:\n";
cin >> attacktype;
cout << "You take the enemy " << attackp << " damage | " << erest << " enemy life\n";
cout << "The enemy takes you " << eattack << " damage | " << rest << " your life\n";
}
if (attacktype == 'i'){
attack = rand () % (60 - 10);
attackp = attack;
if ( boughtweapon[0] = true){
erest = elife - (attackp + t [0]);
}
if ( boughtweapon[1] = true){
erest = elife - (attackp + t [1]);
}
if ( boughtweapon[2] = true){
erest = elife - (attackp + t [2]);
}
if ( boughtweapon[0, 1, 2] = false ){
erest = elife - attackp;
}
elife = erest;
eattack = rand() %( 60 - 10 );
rest = life - eattack;
life = rest;
cout << "stab(s), hack(h), instantkill(i) (do not use 'i' again or instant dead for YOU!!!):\n";
cin >> attacktype;
cout << "You take the enemy " << attackp << " damage | " << erest << " enemy life\n";
cout << "The enemy takes you " << eattack << " damage | " << rest << " your life\n";
}
if ( life <= 0 ){
cout << "you lost\n";
cout << "do you want to go to shop(press (S)) or pres any other button to play again\n";
cin >> shop;
money = rand () % (20 - 5) - 10;
account = money + moneya;
cout << account << "$ your money\n";
if ( shop == 'S' ){
cout << "What do you want to buy sword(+3), bow(+2) or axe(+3)\n";
cin >> weapon;
if( account < price[0] and account < price[1] and account < price[2] ){
cout << "You don't have enough money";
continue;
}
if ( account >= price[0] and account >= price[1] and account >= price[2] ) {
t[0] = 3;
t[1] = 2;
t[2] = 3;
cin >> weapon;
switch(weapon){
case 's' : attackp == attack + t[0];
boughtweapon[0] = true;
case 'b' : attackp == attack + t[1];
boughtweapon[1] = true;
case 'a' : attackp == attack + t[2];
boughtweapon[2] = true;
}
}
}
else {
elife = 100;
life = 100;
continue;
cout << "NEW GAME\n\n";
boughtweapon[0,1,2] = false;
}
elife = 100;
life = 100;
cout << endl;
}
if ( elife <= 0 ){
cout << "you win\n";
cout << "do you want to go to shop(press (S)) or press any other button to play again\n";
money = rand () % (20 - 5) + 10;
account = money + moneya;
cout << account << "$ your money\n";
cin >> shop;
if ( shop == 'S' ){
cout << "What do you want to buy sword(+3damage), bow(+2damage) or axe(+3damage)\n";
if( account < price[0] and account < price[1] and account < price[2] ){
cout << "You don't have enough money\n";
continue;
}
if ( account >= price[0] and account >= price[1] and account >= price[2] ) {
t[0] = 3;
t[1] = 2;
t[2] = 3;
cin >> weapon;
switch( weapon ){
case 's' : attackp == attack + t[0];
boughtweapon[0] = true;
case 'b' : attackp == attack + t[1];
boughtweapon[1] = true;
case 'a' : attackp == attack + t[2];
boughtweapon[2] = true;
}
}
}
else {
elife = 100;
life = 100;
continue;
cout << "NEW GAME\n\n";
boughtweapon[0,1,2] = false;
}
elife = 100;
life = 100;
cout << endl;
}
if ( attacktype == 'i' ){
cout << "I told you so!\nYou lost! -10$ \n";
account = account - 10;
cout << account << "$ your money\n\n";
cout << "NEW GAME\n\n";
continue;
}
}
return 0;
}
|