easter egg implemented, discover a hidden surprise on the map
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
abad327b3f
commit
26aa5fa679
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ghost-telemetry-frontend",
|
||||
"version": "0.1.11",
|
||||
"version": "0.1.12",
|
||||
"author": "Uncle f4tso <f4ts0@ghostchain.io>",
|
||||
"license": "GPL-3.0",
|
||||
"description": "Ghost Telemetry frontend",
|
||||
|
@ -25,6 +25,88 @@ interface MapState {
|
||||
left: number;
|
||||
}
|
||||
|
||||
const funnyLocations = [
|
||||
[-68.7700, 38.0100],
|
||||
[-66.7700, 38.0100],
|
||||
[-64.7700, 38.0100],
|
||||
[-62.7700, 38.0100],
|
||||
[-60.7700, 38.0100],
|
||||
[-68.7700, 36.0100],
|
||||
[-68.7700, 34.0100],
|
||||
[-68.7700, 32.0100],
|
||||
[-68.7700, 30.0100],
|
||||
[-66.7700, 30.0100],
|
||||
[-64.7700, 30.0100],
|
||||
[-62.7700, 30.0100],
|
||||
[-60.7700, 30.0100],
|
||||
[-60.7700, 34.0100],
|
||||
[-60.7700, 36.0100],
|
||||
[-60.7700, 38.0100],
|
||||
|
||||
[-54.7700, 38.0100],
|
||||
[-54.7700, 36.0100],
|
||||
[-54.7700, 34.0100],
|
||||
[-54.7700, 32.0100],
|
||||
[-54.7700, 30.0100],
|
||||
[-50.7700, 38.0100],
|
||||
[-50.7700, 36.0100],
|
||||
[-50.7700, 34.0100],
|
||||
[-50.7700, 32.0100],
|
||||
[-50.7700, 30.0100],
|
||||
[-54.7700, 34.0100],
|
||||
[-53.7700, 34.0100],
|
||||
[-52.7700, 34.0100],
|
||||
[-51.7700, 34.0100],
|
||||
[-50.7700, 34.0100],
|
||||
|
||||
[-44.7700, 38.0100],
|
||||
[-42.7700, 38.0100],
|
||||
[-40.7700, 38.0100],
|
||||
[-38.7700, 38.0100],
|
||||
[-36.7700, 38.0100],
|
||||
[-44.7700, 36.0100],
|
||||
[-36.7700, 36.0100],
|
||||
[-44.7700, 34.0100],
|
||||
[-36.7700, 34.0100],
|
||||
[-44.7700, 32.0100],
|
||||
[-36.7700, 32.0100],
|
||||
[-44.7700, 30.0100],
|
||||
[-36.7700, 30.0100],
|
||||
[-44.7700, 30.0100],
|
||||
[-42.7700, 30.0100],
|
||||
[-40.7700, 30.0100],
|
||||
[-38.7700, 30.0100],
|
||||
[-36.7700, 30.0100],
|
||||
|
||||
[-30.7700, 38.0100],
|
||||
[-28.7700, 38.0100],
|
||||
[-26.7700, 38.0100],
|
||||
[-24.7700, 38.0100],
|
||||
[-22.7700, 38.0100],
|
||||
[-30.7700, 36.0100],
|
||||
[-30.7700, 34.0100],
|
||||
[-28.7700, 34.0100],
|
||||
[-26.7700, 34.0100],
|
||||
[-24.7700, 34.0100],
|
||||
[-22.7700, 34.0100],
|
||||
[-22.7700, 32.0100],
|
||||
[-22.7700, 30.0100],
|
||||
[-24.7700, 30.0100],
|
||||
[-26.7700, 30.0100],
|
||||
[-28.7700, 30.0100],
|
||||
[-30.7700, 30.0100],
|
||||
|
||||
[-18.7700, 38.0100],
|
||||
[-16.7700, 38.0100],
|
||||
[-14.7700, 38.0100],
|
||||
[-12.7700, 38.0100],
|
||||
[-10.7700, 38.0100],
|
||||
[-14.7700, 36.0100],
|
||||
[-14.7700, 34.0100],
|
||||
[-14.7700, 32.0100],
|
||||
[-14.7700, 30.0100],
|
||||
]
|
||||
|
||||
export class WorldMap extends React.Component<MapProps, MapState> {
|
||||
public state: MapState = {
|
||||
filter: null,
|
||||
@ -36,6 +118,7 @@ export class WorldMap extends React.Component<MapProps, MapState> {
|
||||
|
||||
public unknowns: Map<Types.NodeName, RandomLatLon> = new Map<Types.NodeName, RandomLatLon>();
|
||||
public offsets: Map<Types.NetworkId, LocationOffsets> = new Map<Types.NetworkId, LocationOffsets>();
|
||||
public usedFunnyIndexes: Set<number> = new Set<number>;
|
||||
|
||||
public usedLeftPositions: Set<number> = new Set<number>();
|
||||
public usedTopPositions: Set<number> = new Set<number>();
|
||||
@ -60,23 +143,36 @@ export class WorldMap extends React.Component<MapProps, MapState> {
|
||||
<div className="Map-container">
|
||||
<div className="Map">
|
||||
{nodes.map(node => {
|
||||
let isRealPoint = true;
|
||||
let { lat, lon } = node;
|
||||
const focused = filter == null || filter(node);
|
||||
|
||||
if (lat == null || lon == null) {
|
||||
// Skip nodes with unknown location
|
||||
isRealPoint = false;
|
||||
const unknown = this.unknowns.get(node.name);
|
||||
if (unknown) {
|
||||
lat = unknown.lat as Types.Latitude;
|
||||
lon = unknown.lon as Types.Longitude;
|
||||
} else {
|
||||
lat = parseFloat((Math.random() * 22.0315 + 27.2936).toFixed(4)) as Types.Latitude;
|
||||
lon = parseFloat((Math.random() * 21.2696 - 55.9863).toFixed(4)) as Types.Longitude;
|
||||
if (this.usedFunnyIndexes.size >= funnyLocations.length) {
|
||||
lat = parseFloat((Math.random() * 31.4630 - 37.4840).toFixed(4)) as Types.Latitude;
|
||||
lon = parseFloat((Math.random() * 49.2187 - 40.3147).toFixed(4)) as Types.Longitude;
|
||||
} else {
|
||||
let index = 0;
|
||||
while (this.usedFunnyIndexes.has(index)) {
|
||||
index = Math.floor(Math.random() * funnyLocations.length)
|
||||
}
|
||||
const point = funnyLocations[index];
|
||||
lat = point.at(1) as Types.Latitude;
|
||||
lon = point.at(0) as Types.Longitude;
|
||||
this.usedFunnyIndexes.add(index);
|
||||
}
|
||||
this.unknowns.set(node.name, { lat, lon });
|
||||
}
|
||||
}
|
||||
|
||||
const position = this.pixelPosition(node.networkId, lat, lon);
|
||||
const position = this.pixelPosition(node.networkId, lat, lon, isRealPoint);
|
||||
|
||||
return (
|
||||
<Location
|
||||
@ -97,6 +193,7 @@ export class WorldMap extends React.Component<MapProps, MapState> {
|
||||
id: Maybe<Types.NetworkId>,
|
||||
lat: Types.Latitude,
|
||||
lon: Types.Longitude,
|
||||
isRealPoint: boolean,
|
||||
): LocationPosition {
|
||||
const { state, offsets, usedLeftPositions, usedTopPositions } = this;
|
||||
|
||||
@ -130,8 +227,10 @@ export class WorldMap extends React.Component<MapProps, MapState> {
|
||||
leftOffset = Math.floor(Math.random() * 12) - 6;
|
||||
}
|
||||
|
||||
if (isRealPoint) {
|
||||
left += leftOffset;
|
||||
top += topOffset;
|
||||
}
|
||||
|
||||
offsets.set(id, { leftOffset, topOffset });
|
||||
usedLeftPositions.add(left);
|
||||
|
Loading…
Reference in New Issue
Block a user