Cities are now top-down view of metro maps in ascii

This commit is contained in:
Olivier Gagnon 2021-03-07 16:14:08 -05:00
parent dabb5016fc
commit 6cd6f28820
4 changed files with 235 additions and 12 deletions

@ -233,6 +233,7 @@ export let CONSTANTS: IMap<any> = {
ASCII ASCII
* Travel Agency now displays a world map * Travel Agency now displays a world map
* Cities are now top view of metro station maps
Netscript Netscript
* softReset is a new netscript function that performs a soft reset * softReset is a new netscript function that performs a soft reset

@ -15,9 +15,15 @@ export class City {
*/ */
name: CityName; name: CityName;
constructor(name: CityName, locations: LocationName[]=[]) { /**
* Metro map ascii art
*/
asciiArt: string;
constructor(name: CityName, locations: LocationName[]=[], asciiArt: string='') {
this.name = name; this.name = name;
this.locations = locations; this.locations = locations;
this.asciiArt = asciiArt;
} }
addLocation(loc: LocationName): void { addLocation(loc: LocationName): void {

@ -40,6 +40,181 @@ Cities[CityName.NewTokyo] = new City(CityName.NewTokyo);
Cities[CityName.Sector12] = new City(CityName.Sector12); Cities[CityName.Sector12] = new City(CityName.Sector12);
Cities[CityName.Volhaven] = new City(CityName.Volhaven); Cities[CityName.Volhaven] = new City(CityName.Volhaven);
Cities[CityName.Aevum].asciiArt = `
[aevum police headquarters] 26
o
I \\ [bachman & associates]
\\ 56 B
x \\ [summit university]
\\ \\ 28
\\ [snap fitness gym] x o--L------------
K \\ /
\\ \\ P
x 58 \\ / [travel agency]
\\ 94 95 o
90 x 59 o------o |
\\ / \\ | 98 102 103
o--------N------x----o 93 96 o-----+------------o o----o
\\ | \\ /
[hospital] \\ 61 [ecorp] x 31 99 o-F-o 101
o |
| o---E-- | [fulcrum tech.]
x 62 / A [aerocorp]
[crush fitness gym] | / |
| / |
o--------D------+--o o
| |\\ [rho construction]
H [netlink tech.] | J
| | \\
| 34 x \\
[clarke inc.] C | \\ [world stock exchange]
| | \\
| | o-M-------Q--------o
[galactic cybersystems] G 35 x
| [watchdog security]
|
67 o
[the slums] O `
Cities[CityName.Chongqing].asciiArt = `
|
75 o
\\
o 76
7 | |
| + 77
[world stock exchange] F |
\\ o 78 [kuaigong international]
\\ /
38 o----x--x------x------A---------
/ 39 | 41
37 o + 79 o--x--x-C-0
/ | /
/ x-----+-----x-----0 [hospital]
[solaris space system] B |
| + 80
| |
34 o E [travel agency]
|
|
x 82
[the slums] D `
Cities[CityName.Ishima].asciiArt = `
o 59
o o |
[storm tech.] | | G [world stock exchange]
| | 28 |
23 o--C------o--------+----x----o |
/ / 25 | 27 \\ x 57
/ / | \\ |
/ / | \\ |
o 22 o | \\| 29/56
| | o
| [hospital] D / \\ 3 2 1
o | / \\ o-------x------o
/ o / \\ /
48 o / 55 x \\ /
\\ / / x
\\ / [nova medical] / 4/30 \\
49 x A \\
/ \\ / \\
/ \\ [travel agency] F o 31
/ \\ 51 /
/ o----B------x-----o
o 50 52
[omega soft.]
[the slums] E `
Cities[CityName.NewTokyo].asciiArt = `
o
\\
\\ [defcomm]
\\
o--x---A--x--o [travel agency]
7 8 10 G
[vitalife] o 12 [global pharmaceuticals]
|
o--D-x----x-------x-C-+--------x--x-B-x---x-o
21 22 23 \\ 24 25 26 27
\\
[noodle bar] x 14
\\
\\
[hospital] o 15 [world stock exchange]
|
o--x--E--x-----x-----x---+---x----x--H--x-o
|
|
o 17
F [the slums]
`
Cities[CityName.Sector12].asciiArt = `
78 o 97
o [icarus microsystems] /
N [powerhouse gym] o I
1 | | /
o-----+---x----o 4 A [alpha ent.] o-------o /
| 3 \\ | \\ /
| \\ | [iron gym] x 95
(79) x \\ | / \\
| o-E----+----x----J--o 10 / o----T--o
| | 8 \\ 94 x
80 x [city hall] | x 11 / [world stock exchange]
| | \\ /
| C [cia] \\ /
Q [hospital] | F P [universal energy]
| o [deltaone] \\ /
| 35 o---------x 13/92/36
L [megacorp] 33 / / \\
| o------------o 34 / \\
(29) | / [carmichael sec.] D \\
o-----+-----x------o / O [rothman university]
| 31 32 [nsa] M
| /
B [blade industries] H
| / [four sigma]
| [joe's guns] /
| /
85 o--G--------K--------S-------o 88 [the slums] R
[foodnstuff] [travel agency] `
Cities[CityName.Volhaven].asciiArt = `
[omnia cybersystems]
17 66 68
o o------G-------o
\\ / \\
\\ o 65 o 69
[syscore sec.] H | |
\\ | | [millenium fitness gym]
\\ | 21 22 23 24 | 26
o----+--x--x----x---x---+-----x-------D-----o
19 | | 28
| F [omnitek inc.]
[hospital] J 63 o
| / 72
3 | 5 6 / 9
o--------+----x-----x----+----------M-------o
/ | |
/ 61 x [helios labs] B [world stock exchange]
[travel agency] L | |
/ | o
/ E [nwo] / 75
/ [computek] | /
/ A-------o------I-----o
1 o | |
| [zb] o 77
[lexocorp] C
|
o
57
[the slums] K `
// Then construct all locations, and add them to the cities as we go. // Then construct all locations, and add them to the cities as we go.
for (const metadata of LocationsMetadata) { for (const metadata of LocationsMetadata) {
const loc = constructLocation(metadata); const loc = constructLocation(metadata);

@ -17,18 +17,59 @@ type IProps = {
export class LocationCity extends React.Component<IProps, any> { export class LocationCity extends React.Component<IProps, any> {
render() { render() {
const locationButtons = this.props.city.locations.map((locName) => { const thiscity = this;
return ( const topprop = this.props
<li key={locName}>
<StdButton onClick={this.props.enterLocation.bind(this, locName)} text={locName} /> function LocationLetter(location: string) {
</li> if (location)
) return <span key={location} className='tooltip' style={{color: 'blue', whiteSpace: 'nowrap', margin: '0px', padding: '0px', cursor: 'pointer'}} onClick={topprop.enterLocation.bind(thiscity, location)}>
}); X
</span>
return <span>*</span>
}
const locationLettersRegex = /[A-Z]/g;
const letterMap: any = {'A': 0,'B': 1,'C': 2,'D': 3,'E': 4,'F': 5,'G': 6,
'H': 7,'I': 8,'J': 9,'K': 10,'L': 11,'M': 12,'N': 13,'O': 14,
'P': 15,'Q': 16,'R': 17,'S': 18,'T': 19,'U': 20,'V': 21,'W': 22,
'X': 23,'Y': 24,'Z': 25}
let locI = 0;
function lineElems(s: string) {
let elems: any[] = [];
let matches: any[] = [];
let match: any;
while ((match = locationLettersRegex.exec(s)) !== null) {
matches.push(match);
}
if (matches.length === 0) {
elems.push(s);
return elems;
}
let parts: any[] = [];
for(let i = 0; i < matches.length; i++) {
const startI = i === 0 ? 0 : matches[i-1].index+1;
const endI = matches[i].index;
elems.push(s.slice(startI, endI))
const locationI = letterMap[s[matches[i].index]];
elems.push(LocationLetter(thiscity.props.city.locations[locationI]))
locI++;
}
elems.push(s.slice(matches[matches.length-1].index+1))
return elems;
}
let elems: any[] = [];
const lines = this.props.city.asciiArt.split('\n');
for(const i in lines) {
elems.push(<pre key={i}>{lineElems(lines[i])}</pre>)
}
return ( return (
<ul> <>
{locationButtons} {elems}
</ul> </>
) )
} }
} }