Compare commits

...

5 Commits

5 changed files with 238 additions and 151 deletions

View File

@ -1,3 +1,19 @@
Version 1.4.2 by ~jan6, 2020
added a terminal bell on the start of each turn, to notify players
Version 1.4.1 by ~jan6, 2020
restored original stats,
moved modded stats to separate file (rename to common.h use)
fixed text overflow bug caused by extending company names in 1.4.0,
the bug pushed 5th company (Eridani) off-screen,
because of too long lines wrapping around
Version 1.4.0 released 2020 by ~jan6
jan6@tilde.ninja and jan6@envs.net

View File

@ -1,64 +0,0 @@
/*
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License v2 for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program;
*/
#define OFFMAP '-' /* space character */
#define SPACE '.' /* space character */
#define NEWCO '+' /* new company character */
#define STAR '*' /* star character */
#define BLACKHOLE '@' /* black hole character */
#define NUMCO 5 /* number of companies (don't change) */
#define INIT_CO_COST 90 /* initial company start cost */
#define FOUNDER_BONUS 10 /* founder gets this much stock */
#define NUMMOVES 6 /* number of moves options a player gets */
#define MAXPLAYERS 4 /* total number of players a game can have */
#define STARCOST 251 /* company's price increase near star */
#define BLACKHOLECOST -250 /* price increase near black hole */
#define NEWCOCOST 101 /* company's price increase near new co */
#define Mx 12 /* x dimension of map */
#define My 10 /* y dimension of map */
/* macros to look at surrounding spaces on the map: */
#define iscompany(c) ((c)>='A'&&(c)<='Z')
#define ripe(c) ((c)==STAR||(c)==NEWCO)
#define co_near(move) (iscompany(up_obj(move))||iscompany(down_obj(move))||iscompany(left_obj(move))||iscompany(right_obj(move)))
#define s_or_bh(c) ((c)==SPACE||(c)==BLACKHOLE)
/* player and company structures: */
typedef struct {
char name[100];
int holdings[NUMCO];
long int svalue; /* stock value -- not always accurate!! */
long int cash;
int ishuman;
} PLAYER;
typedef struct {
char name[100];
int price;
int size;
int potential;
int risk; /* value related to chance of being swallowed by Black Hole */
int netpot; /* potential - risk */
} COMPANY;

1
common.h Symbolic link
View File

@ -0,0 +1 @@
common.h.modded

67
common.h.modded Normal file
View File

@ -0,0 +1,67 @@
/*
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License v2 for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program;
*/
#define OFFMAP '?' /* space character */
#define SPACE '`' /* space character */
#define NEWCO '+' /* new company character */
#define STAR '*' /* star character */
#define BLACKHOLE '@' /* black hole character */
#define END_PERCENT 45 /* end when this much of the map is full */
#define INIT_CASH 600 /* initial player cash */
#define SPLIT_PRICE 300 /* when stocks split 2-1 */
#define NUMCO 5 /* number of companies (don't change) */
#define INIT_CO_COST 9 /* initial company start cost */
#define FOUNDER_BONUS 5 /* founder gets this much stock */
#define NUMMOVES 6 /* number of moves options a player gets */
#define MAXPLAYERS 4 /* total number of players a game can have */
#define STARCOST 26 /* company's price increase near star */
#define BLACKHOLECOST -25 /* price increase near black hole */
#define NEWCOCOST 10 /* company's price increase near new co */
#define Mx 12 /* x dimension of map */
#define My 10 /* y dimension of map */
/* macros to look at surrounding spaces on the map: */
#define iscompany(c) ((c)>='A'&&(c)<='Z')
#define ripe(c) ((c)==STAR||(c)==NEWCO)
#define co_near(move) (iscompany(up_obj(move))||iscompany(down_obj(move))||iscompany(left_obj(move))||iscompany(right_obj(move)))
#define s_or_bh(c) ((c)==SPACE||(c)==BLACKHOLE)
/* player and company structures: */
typedef struct {
char name[100];
int holdings[NUMCO];
long int svalue; /* stock value -- not always accurate!! */
long int cash;
int ishuman;
} PLAYER;
typedef struct {
char name[100];
int price;
int size;
int potential;
int risk; /* value related to chance of being swallowed by Black Hole */
int netpot; /* potential - risk */
} COMPANY;

66
common.h.orig Normal file
View File

@ -0,0 +1,66 @@
/*
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License v2 for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program;
*/
#define OFFMAP '-' /* space character */
#define SPACE '.' /* space character */
#define NEWCO '+' /* new company character */
#define STAR '*' /* star character */
#define BLACKHOLE '@' /* black hole character */
#define END_PERCENT 55 /* end when this much of the map is full */
#define INIT_CASH 6000 /* initial player cash */
#define SPLIT_PRICE 3000 /* when stocks split 2-1 */
#define NUMCO 5 /* number of companies (don't change) */
#define INIT_CO_COST 100 /* initial company start cost */
#define FOUNDER_BONUS 5 /* founder gets this much stock */
#define NUMMOVES 5 /* number of moves options a player gets */
#define MAXPLAYERS 4 /* total number of players a game can have */
#define STARCOST 500 /* company's price increase near star */
#define BLACKHOLECOST -500 /* price increase near black hole */
#define NEWCOCOST 100 /* company's price increase near new co */
#define Mx 12 /* x dimension of map */
#define My 10 /* y dimension of map */
/* macros to look at surrounding spaces on the map: */
#define iscompany(c) ((c)>='A'&&(c)<='Z')
#define ripe(c) ((c)==STAR||(c)==NEWCO)
#define co_near(move) (iscompany(up_obj(move))||iscompany(down_obj(move))||iscompany(left_obj(move))||iscompany(right_obj(move)))
#define s_or_bh(c) ((c)==SPACE||(c)==BLACKHOLE)
/* player and company structures: */
typedef struct {
char name[100];
int holdings[NUMCO];
long int svalue; /* stock value -- not always accurate!! */
long int cash;
int ishuman;
} PLAYER;
typedef struct {
char name[100];
int price;
int size;
int potential;
int risk; /* value related to chance of being swallowed by Black Hole */
int netpot; /* potential - risk */
} COMPANY;

View File

@ -1,5 +1,5 @@
/*
** starlanes v1.3.0 (29-Mar-1997) -- a space-age stock trading game
** starlanes v1.4.0 (29-Mar-1997) -- a space-age stock trading game
**
** Copyright (C) 1997 Brian "Beej" Hall
** with modifications by David Barnsdale 2004 and by ~jan6 2020
@ -94,14 +94,14 @@
/* misc stuff: */
#define INIT_CO_COST 100 /* initial company start cost */
#define INIT_CASH 6000 /* initial player cash */
#define SPLIT_PRICE 3000 /* when stocks split 2-1 */
//#define INIT_CO_COST 100 /* initial company start cost */
//#define INIT_CASH 6000 /* initial player cash */
//#define SPLIT_PRICE 3000 /* when stocks split 2-1 */
/* #define NUMMOVES 5 number of different moves a player gets */
//#define NUMMOVES 5 /* number of different moves a player gets */
#define END_PERCENT 55 /* end when this much of the map is full */
//#define END_PERCENT 55 /* end when this much of the map is full */
#define DEF_LINES 25 /* default number of lines on screen */
#define DEF_COLUMNS 80 /* default number of columns on screen */
@ -161,8 +161,8 @@ void usage(void);
char placemove(); */
/* global variables */
char *VERSION = "1.3.0";
char *VERSION_DATE = "1-June-2004";
char *VERSION = "1.4.1";
char *VERSION_DATE = "13-February-2020";
char *ident = "$Id: starlanes.c 1.2.2 29-Mar-1997 beej@ecst.csuchico.edu $";
@ -174,8 +174,8 @@ int MAPY = My; /* y dimension of map */
int LINES; /* lines in screen */
int COLUMNS; /* columns in screen */
char *map; /* pointer to the map data */
//char *mapc; /* copy of map for ai */
char *map; /* pointer to the map data *//*
char *mapc; /* copy of map for ai */
PLAYER *pl; /* pointer to array of players */
COMPANY *co; /* pointer to array of companies */
int numplayers,turn; /* number of players, whose turn it is */
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
else
usage();
break;
default:usage();
default: usage();
}
/* initscr */
@ -251,6 +251,7 @@ int main(int argc, char *argv[])
//ai_buy_sell(pl,co,turn,map,Difficulty);
//}
turn = (++turn)%numplayers;
fprintf(stderr,"\x07");
}
} while (!done);
@ -315,10 +316,10 @@ void initialize(void)
for(i=0;i<NUMCO;i++) {
switch(i) {
case 0: strcpy(co[i].name, "Altar & Stairway, Ltd.");break;
case 1: strcpy(co[i].name, "Beatles & Juice Co.");break;
case 2: strcpy(co[i].name, "Capella Fright, Ltd.");break;
case 1: strcpy(co[i].name, "Beatles & Juice Co. ");break;
case 2: strcpy(co[i].name, "Capella Fright, Ltd. ");break;
case 3: strcpy(co[i].name, "Denebola Dice Shippers");break;
case 4: strcpy(co[i].name, "Eridani Expert Export");break;
case 4: strcpy(co[i].name, "Eridani Expert Export ");break;
}
co[i].size = co[i].price = 0;
}
@ -329,8 +330,7 @@ void initialize(void)
pl[i].name[0] = '\0';
pl[i].ishuman=1;
pl[i].cash = INIT_CASH;
for(j=0;j<NUMCO;j++)
pl[i].holdings[j] = 0;
for(j=0;j<NUMCO;j++) pl[i].holdings[j] = 0;
}
/* create the windows: */
@ -468,16 +468,16 @@ void showmap(void)
for(i=0;i<MAPY;i++)
for(j=0;j<MAPX;j++) {
switch(map[j+i*MAPX]) {
case SPACE: attrs = MAP_SPACE;break;
case STAR: attrs = MAP_STAR;break;
case NEWCO: attrs = MAP_NEWCO;break;
case SPACE : attrs = MAP_SPACE;break;
case STAR : attrs = MAP_STAR;break;
case NEWCO : attrs = MAP_NEWCO;break;
case BLACKHOLE: attrs = MAP_BLACKHOLE;break;
case 'A': attrs = CO_A;break;
case 'B': attrs = CO_B;break;
case 'C': attrs = CO_C;break;
case 'D': attrs = CO_D;break;
case 'E': attrs = CO_E;break;
default: attrs = A_NORMAL;
default : attrs = A_NORMAL;
}
wattron(mapwin,attrs);
mvwaddch(mapwin,i+1,j*3+2,map[j+i*MAPX]);
@ -496,16 +496,16 @@ void drawmap(int loc, char c)
int attrs;
switch(c) {
case SPACE: attrs = MAP_SPACE;break;
case STAR: attrs = MAP_STAR;break;
case NEWCO: attrs = MAP_NEWCO;break;
case SPACE : attrs = MAP_SPACE;break;
case STAR : attrs = MAP_STAR;break;
case NEWCO : attrs = MAP_NEWCO;break;
case BLACKHOLE: attrs = MAP_BLACKHOLE;break;
case 'A': attrs = CO_A;break;
case 'B': attrs = CO_B;break;
case 'C': attrs = CO_C;break;
case 'D': attrs = CO_D;break;
case 'E': attrs = CO_E;break;
default: attrs = A_NORMAL;
default : attrs = A_NORMAL;
}
wattron(mapwin,attrs);
mvwaddch(mapwin,loc/MAPX+1,(loc%MAPX)*3+2,c);
@ -522,7 +522,7 @@ void show_coinfo(void)
werase(coinfo);
wattron(coinfo,COINFO_TITLE);
mvwprintw(coinfo,0,0," %-19s %5s %8s ","Company","Price","Holdings");
mvwprintw(coinfo,0,0," %-22s %5s %8s","Company","Price","Holdings");
wattroff(coinfo,COINFO_TITLE);
wmove(coinfo,2,0);
@ -541,6 +541,7 @@ void show_coinfo(void)
wattroff(coinfo,attrs);
wprintw(coinfo,"$%-4d ",co[i].price);
/*if (pl[turn].holdings[i] == 0) wattron(coinfo,A_BLINK);*/
// wprintw(coinfo,"%-5d\n\n\r",pl[turn].holdings[i]);
wprintw(coinfo,"%-5d\n\n\r",pl[turn].holdings[i]);
/*if (pl[turn].holdings[i] == 0) wattroff(coinfo,A_BLINK);*/
gotco = 1;
@ -628,8 +629,7 @@ int get_move(void)
} while(c<1 || c>NUMMOVES);
echo();
for(i=0;i<NUMMOVES;i++)
mvwaddch(mapwin,move[i]/MAPX+1,(move[i]%MAPX)*3+2,SPACE);
for(i=0;i<NUMMOVES;i++) mvwaddch(mapwin,move[i]/MAPX+1,(move[i]%MAPX)*3+2,SPACE);
wnoutrefresh(mapwin);
return move[c-1];
@ -781,7 +781,7 @@ void do_merge(int *c1, int *c2, int *o1, int *o2)
wnoutrefresh(mapwin); /* show the players what's up */
merge_announce(cb,cs);
xaction_announce(cb,cs); /*annouces and executes the transactions */
xaction_announce(cb,cs); /* annouces and executes the transactions */
if (co[cb].price > SPLIT_PRICE)
split_announce(cb);
}
@ -950,7 +950,7 @@ void xaction_announce(int c1, int c2)
mvwprintw(general,3+i,4," %-20s ", pl[i].name);
wattroff(general,A_BOLD);
wprintw(general,"%-5d %-5d %5d ",
pl[i].holdings[c2],newshares,totalholdings);
pl[i].holdings[c2],newshares,totalholdings); //continues previous line
wattron(general,A_BOLD);
wprintw(general,"$%-5d",bonus);
wattroff(general,A_BOLD);
@ -1026,8 +1026,7 @@ void buy_sell(void)
if (cocount == 0) return; /* no companies yet */
sprintf(s," %s (Cash: $%ld) ",pl[turn].name,pl[turn].cash);
clear_general(s,0);
sprintf(s," %s (Cash: $%ld) ",pl[turn].name,pl[turn].cash); clear_general(s,0);
center(general,COLUMNS-2,1,"Arrow keys to select a company, return to trade, escape when done:");
@ -1071,22 +1070,24 @@ void buy_sell(void)
break;
case 'q':
case 'Q':
case CTRL_C:quit_yn();
case CTRL_C :
quit_yn();
wmove(general,cursor+3,strlen(co[cos[cursor]].name)+20);
wnoutrefresh(general);
break;
case KEY_UP:
case KEY_UP :
case '8':
case 'k':
case 'K': newcur = cursor?cursor-1:cocount-1;break;
case KEY_DOWN:
case KEY_DOWN :
case '5':
case 'j':
case 'J': newcur = cursor<cocount-1?cursor+1:0;break;
case KEY_RIGHT:
case 6:
case CR :
case LF : max = pl[turn].cash / co[cos[cursor]].price;
case LF :
max = pl[turn].cash / co[cos[cursor]].price;
min = -pl[turn].holdings[cos[cursor]];
sprintf(s,"Amount (%d to %d): ",min,max);
mvwprintw(general,cursor+3,40,s);