/*
By Dale Swanson
2004 02 12
Some Pirate Game Or Something
*/
#include
#include
#include
#include
int day, money, saving, debt;
int cargo, cap;
int place;
int ships[256][10];
int worth;
int chol[8];
int pri[8][11];
double cha[8][11];
int car[8];
int sale[7][4][5];
int ran(int b, int a)
{
int c;
c=rand() % (a-b+1)+b;
return c;
}
void display()
{
int x,y,z;
cout<<"\n\n\n";
cout<<"\n\n";
cout<<"Place - "<>x;
if (x<8 and x>0)
{
cout<<"\nHow much?\n";
cin>>y;
cout<<"\n1-Buy, 2-Sell\n";
cin>>z;
if (z==1)
{
if ((pri[x][place] * y) > money)
{
cout<<"You Don't Have The Money";
goto no;
}
else if (cargo + y > cap)
{
cout<<"You Don't Have The Space";
goto no;
}
else
{
money = money - (pri[x][place] * y);
car[x] = car[x] + y;
cargo = cargo + y;
}
}
else if (z==2)
{
if (car[x]>day>>money>>saving>>debt>>cap;
}
void speed()
{
int x, y, z;
ships[0][1] = 100;
for (x=1; x < ships[0][0] + 1; x++)
{
if (ships[0][1] > ships[x][5])
{
ships[0][1] = ships[x][5];
}
}
}
int combat(int x, int y)
{
int a, b, c, xx, yy, zz;
cout<<"\n\n\n***Combat***\n\n\n";
a = ran(1, y);
b = ran(1, ships[0][0]);
c = ran(1, ships[b][3]);
if (a > c)
{
cout<<"\n\n\n***Defeat***\n\n\n";
if (ships[0][0] == 1)
{
ships[b][4] = ships[b][4] / 3;
for (zz=1; zz < 8; zz++)
{
car[zz] = 0;
cargo = 0;
}
}
else
{
cap = cap - ships[b][2];
for (xx=b; xx < ships[0][0]; xx++);
{
for (yy=1; yy < 8; yy++)
{
ships[xx][yy] = ships[xx+1][yy];
}
}
ships[0][0]--;
speed();
if (cargo > cap)
{
for (zz = 7; cargo > cap; zz--)
{
car[zz] = 0;
}
}
}
}
else
{
cout<<"\n\n\n***Victory***\n\n\n";
money = money + ran(1, pow(x + y, 2));
money = money + 500;
}
return 0;
}
void pirate()
{
int a, b, c, x, y, z;
cout<<"\n\n\n\n\n*******************************\n\nYou've Come Across Another Ship\n\n*******************************\n\n";
a = ran(1, 6) + ran(1, 6) + 5;
b = ran(5, 150);
cout<<"Ships Speed "<>x;
if (a > ships[0][1])
{
x = 1;
}
if (x==1)
{
if (ran(1, b) > 20 and a > ships[0][1])
{
combat(a, b);
}
}
else
if (a > ships[0][1])
{
cout<<"\nYou Can't Attack A Faster Ship\n";
}
else
{
combat(a, b);
}
}
void taxes()
{
int x, y, z;
cout<<"\n\n\n***Tax Time***\n\n\n";
x = money + saving;
cout<<"\nTaxable Assests - "<>xx;
if (xx < 1 or xx > 10)
{
goto noship;
}
d = (50 / ships[0][1]) * (abs((xx - place) / 2) + 1);
d++;
if (d * 15 > money)
{
cout<<"You Need More Money";
goto noship;
}
place = xx;
for (e=0; e < d; e++)
{
day++;
debt = (debt * 1.0138) / 1;
saving = (saving * 1.00138) / 1;
money = money - 15;
yy = ran(1, 50);
if (day % 25 == 0)
{
taxes();
}
if (yy==25)
{
pirate();
}
for (a=1; a < 6; a++)
{
for (b=1; b < 4; b++)
{
z = ran(((sale[a][b][3] / 1000) * (-1)), sale[a][b][3] / 1000);
sale[a][b][3] = sale[a][b][3] + z;
}
}
for (c=1; c < ships[0][0]; c++)
{
ships[c][4] = ships[c][4] - (ships[c][4] / 100);
}
for (x=1; x<8; x++)
{
for (y=1; y<11; y++)
{
cha[x][y] = ((pri[x][y] / 100) + 1) * (ran(-1, 1) / 1);
//pri[x][y]++;
pri[x][y] = pri[x][y] + cha[x][y];
if (pri[x][y] < pow(2, x) * 10)
{
pri[x][y] = pow(2, x) * 10;
}
}
}
}
noship:
cout<<"\n";
}
void bank()
{
int x, y, z;
cout<<"\n\n\n";
cout<<"Day - "<>x;
if (x==1)
{
if (debt > (money + saving + 5) * 3)
{
cout<<"You Owe Too Much";
goto bankno;
}
else
{
cout<<"\nHow Much?\n";
cin>>y;
if (y < 1)
{
goto bankno;
}
debt = debt + y;
money = money + y;
cout<<"Now You Owe "<>y;
if (y > money or y < 1)
{
cout<<"You Don't Have The Money\n";
goto bankno;
}
else
{
debt = debt - y;
money = money - y;
cout<<"You Still Owe "<>y;
if (y > money or y < 1)
{
cout<<"You Don't Have The Money\n";
goto bankno;
}
else
{
saving = saving + y;
money = money - y;
cout<<"You Have "<>y;
if (y > saving or y < 1)
{
cout<<"You Don't Have That Much\n";
goto bankno;
}
else
{
saving = saving - y;
money = money + y;
cout<<"You Have "<>x;
if (x==1)
{
cout<<"Stats Are Estimates On A 1-10 Scale, Speed.Cargo.Defence";
cout<<"\n\n1 - Cutter 4.1.1, 2 - Schooner 9.3.2, 3 - Caravel 3.4.4, 4 - Galleon 4.8.6 5 - Frigate 6.5.8\n";
for (s = 1; s < 6; s++)
{
for (m = 1; m < 4; m++)
{
cout<<"Ship Type "<~~>s>>m;
if (s==0 and m==0)
{
goto nobs;
}
else if (s > 5 or m > 3)
{
goto nobs;
}
else if(sale[s][m][3] > money)
{
cout<<"\n\nYou Don't Have The Money\n";
goto nobs;
}
else
{
cout<<"\n\nAre You Sure You Want To Buy Ship Type "<~~~~>w;
if (w != 138)
{
goto nobs;
}
else
{
money = money - sale[s][m][3];
cap = cap + sale[s][m][1];
ships[ships[0][0] + 1][1] = s;
ships[ships[0][0] + 1][2] = sale[s][m][1];
ships[ships[0][0] + 1][3] = sale[s][m][2];
ships[ships[0][0] + 1][4] = (sale[s][m][3] / 3);
ships[ships[0][0] + 1][5] = sale[s][m][4];
ships[0][0]++;
speed();
}
}
}
else if (x==2)
{
cout<<"\n\n";
if (ships[0][0] < 0)
{
goto nobs;
}
for (y=1; y <= ships[0][0]; y++)
{
cout<<"Ship Number "<>z;
if (z==0)
{
goto nobs;
}
else if (ships[z][2] > cap - cargo)
{
cout<<"\nYou Need To Sell Some Cargo First\n";
}
else if (z < 1 or z > ships[0][0])
{
goto nobs;
}
else
{
cout<<"Are You Sure You Want To Sell Ship Number "<>a;
if (a!=138)
{
goto nobs;
}
else
{
money = money + ships[z][4];
cap = cap - ships[z][2];
for (b=z; b < ships[0][0]; b++);
{
for (c=1; c < 8; c++)
{
ships[b][c] = ships[b+1][c];
}
}
ships[0][0]--;
speed();
}
}
}
nobs:
cout<<"\n";
}
void cargohold()
{
unsigned x, y, z;
x=0;
y=0;
z=0;
cout<<"\n\n\n";
cout<<"You Have Onboard\n";
cout<<"1-Iron - "<>x;
if (x<8 and x>0)
{
cout<<"\nHow Much To Transfer?\n";
cin>>y;
cout<<"\n1-Take Out Of Hold, 2-Put In Hold\n";
cin>>z;
if (z==1)
{
if (cargo + y > cap)
{
cout<<"You Don't Have The Space";
goto noc;
}
else
{
car[x] = car[x] + y;
chol[x] = chol[x] - y;
cargo = cargo - y;
}
}
else if (z==2)
{
if (car[x] cap)
{
cout<<"No Room";
goto noc;
}
else
{
car[x] = car[x] - y;
cargo = cargo + y;
chol[x] = chol[x] + y;
}
}
else
{
goto noc;
}
}
noc:
cout<<"\n";
}
void gamble()
{
int x, y, z;
cout<<"\n\n\nWelcome\n";
cout<<"The rules are simple, enter your bet, then pick a number, 1-3.\nOne number will win, one will draw, and one will lose.\n";
cout<<"Enter Your Bet, then your number 1-3\n";
cin>>x>>y;
if (x > money or x > 500)
{
cout<<"\nToo Much Money, Cap Is 500";
goto nobet;
}
z = ran(1, 3);
if (y==z)
{
cout<<"\n\n\n***You Win***\n\n\n";
money = money + x;
}
else if (y==ran(1, 3))
{
cout<<"\nDraw\n";
}
else
{
cout<<"\n\n\n***You Lose***\n\n\n";
money = money - x;
}
nobet:
cout<<"\n";
}
void start()
{
int x, y, z;
cout<<"\n\n\nWelcome To Pirate, By Dale Swanson\n\n\n";
cout<<"This game is pretty pointless, basicly just a way for me to work on my C++ skills.\nIt dosn't have any graphics, but that shouldn't be too bad.\n\n\n";
cout<<"\n\nInstuctions\n\n";
cout<<"\nIn this game you are a merchant in the 1700's, you buy and sell stuff.\nThere are 7 things you can buy, they range in price, and there are 10 places you can buy and sell them.\nThe prices for stuff will be more or less depending on where you are.\n";
cout<<"You start with nothing, no ship or money, you will need to take a loan from the bank, then buy a ship, I recomend you take out 10,000, and buy the cheapest ship.\nThen ship out, travel around a bit and get a feel for the prices of stuff.\n";
cout<<"If you end up in a menu you don't want to be in usally 0 is the key to getting out, even if it dosn't get you out you won't buy/sell anything if you put that as th amount.\n";
cout<<"Buy stuff when it is cheap, sell it when it is expensive.\nThe farther away you go the longer it takes to get there, and it cost money per day to operate your ship.\nThe main thing you need to watch is your debt, from the loan, pay that off quickly.\n";
cout<<"There is also a chance of you coming across another ship, if you do you may attack it or it may attack you.\nThe faster ship always has the option of if there will be a fight.\nIf you lose, you will lose all cargo, if you win you will get some money.\n";
cout<<"You have a cargo hold in your home city, which can store an unlimited amount of stuff, so you can take advantage of deals.\nA feature which I'm still working on a bit is the fleet, you can buy as many ships as you want to have more cargo room.\n";
cout<<"Your fleet will only move as fast as your slowest ship, so you may want to sell off outdated ships.\nAlso your defence will not stack up, each ship will keep it's own.\nIf you get into a fight and you have a fleet your ship is picked at random.\n";
cout<<"If you lose a fight and you have a fleet, you will lose the ship that lost, plus you may lose cargo (this is what I'm still working on, so it's a temp system right now).\n\n";
cout<<"\nThere really isn't a goal as of now, just get a lot of money I guess. Also these instructions may not be up to date, as I will add more stuff, but probably won't feel like explaining it all here, nothing too big.\n";
cout<<"\n\nStuff I plan to add: Some kind of taxes, a much better system for losing when you have a fleet, and maybe give the pirates fleets, and you fight until one has one ship left.\n";
cout<<"Some more stuf: Names for the cities, I'm not sure if they will all be port towns (I guess they should).\nProbably some random tinkering with pirates, and interest rates, since they are to two main enemys in the game.\n";
cout<<"I may add some kind of point, or goal to this game, like some big pirate boss with a huge fleet that keeps demanding money, they you can fight him when you feel ready.\nI may add a way to gamble, I always liked that, like in the first Zelda\n";
cout<<"I'll probably rework the whole distance system, so that the distances match the names I end up giving them.\n";
}
int main()
{
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
place=1;
int cho;
int x, y, z;
start();
for (x=1; x < 8; x++)
{
z = pow(3, (x + 2));
z = z + 5;
for (y=1; y < 11; y++)
{
pri[x][y] = ran (z, z * 2);
cha[x][y] = ran ((-1) * ((z / 100) + 1), (z / 100) + 1);
//pri[x][y] = ran(z, z*2);
//cha[x][y] = ran( (-1) * ((z/35) + 1), ((z/35) + 1));
car[x] = 0;
chol[x] = 0;
}
}
x=1;
y=1;
sale[x][y][1] = 50;
sale[x][y][2] = 10;
sale[x][y][3] = 5000;
sale[x][y][4] = 10;
y++;
sale[x][y][1] = 65;
sale[x][y][2] = 17;
sale[x][y][3] = 10000;
sale[x][y][4] = 9;
y++;
sale[x][y][1] = 85;
sale[x][y][2] = 25;
sale[x][y][3] = 17000;
sale[x][y][4] = 13;
y=1;
x++;
sale[x][y][1] = 45;
sale[x][y][2] = 15;
sale[x][y][3] = 14000;
sale[x][y][4] = 23;
y++;
sale[x][y][1] = 55;
sale[x][y][2] = 17;
sale[x][y][3] = 19000;
sale[x][y][4] = 23;
y++;
sale[x][y][1] = 65;
sale[x][y][2] = 20;
sale[x][y][3] = 21000;
sale[x][y][4] = 22;
y=1;
x++;
sale[x][y][1] = 85;
sale[x][y][2] = 20;
sale[x][y][3] = 14000;
sale[x][y][4] = 8;
y++;
sale[x][y][1] = 110;
sale[x][y][2] = 35;
sale[x][y][3] = 22000;
sale[x][y][4] = 9;
y++;
sale[x][y][1] = 150;
sale[x][y][2] = 45;
sale[x][y][3] = 28000;
sale[x][y][4] = 8;
y=1;
x++;
sale[x][y][1] = 145;
sale[x][y][2] = 50;
sale[x][y][3] = 29000;
sale[x][y][4] = 9;
y++;
sale[x][y][1] = 185;
sale[x][y][2] = 85;
sale[x][y][3] = 38000;
sale[x][y][4] = 10;
y++;
sale[x][y][1] = 245;
sale[x][y][2] = 110;
sale[x][y][3] = 55000;
sale[x][y][4] = 12;
y=1;
x++;
sale[x][y][1] = 85;
sale[x][y][2] = 75;
sale[x][y][3] = 28000;
sale[x][y][4] = 15;
y++;
sale[x][y][1] = 95;
sale[x][y][2] = 115;
sale[x][y][3] = 49000;
sale[x][y][4] = 16;
y++;
sale[x][y][1] = 115;
sale[x][y][2] = 175;
sale[x][y][3] = 78000;
sale[x][y][4] = 18;
begin://*****The Begining*****
display();
cout<<"\n?";
cin>>cho;
if (cho==1)
{
buy();
}
else if (cho==2)
{
buyship();
}
else if (cho==3)
{
bank();
}
else if (cho==4)
{
ship();
}
else if (cho==5)
{
if (place==1)
{
cargohold();
}
}
else if (cho==6)
{
if (place==1)
{
gamble();
}
}
else if (cho==0)
{
goto ended;
}
else if (cho==138)
{
cheat();
}
else
{
cout<<"Try Again";
goto begin;
}
goto begin;
ended:
cout<<"\n\n\nGoodbye.\n\n\n";
return 0;
}
~~