add a bunch of behind the scene wiring

This commit is contained in:
Your Name
2023-06-16 12:24:00 -04:00
parent d0cb1c5a51
commit f5af453af1
15 changed files with 673 additions and 555 deletions

View File

@ -1,3 +1,3 @@
import { Myrian } from "./Myrian";
export let myrian = new Myrian();
export const myrian = new Myrian();

View File

@ -1,5 +1,13 @@
import { DefaultWorld } from "./World";
export class Myrian {
world: string[][];
resources: number;
constructor() {
this.world = DefaultWorld;
this.resources = 0;
console.log(this);
}
}

12
src/Myrian/World.ts Normal file
View File

@ -0,0 +1,12 @@
const e = ''; // empty
const c = 'c'; // core
const b = 'b'; // battery
const d = 'd'; // depleted
export const DefaultWorld = [
[b, b, b, b, b],
[e, e, e, e, e],
[e, e, c, e, e],
[e, e, e, e, e],
[b, b, b, d, d],
];

View File

@ -1,10 +1,14 @@
import React, { useEffect, useState } from "react";
import Container from "@mui/material/Container";
import PersonIcon from '@mui/icons-material/Person';
import { Box } from "@mui/system";
import { Paper, Typography } from "@mui/material";
import BatteryFullIcon from '@mui/icons-material/BatteryFull';
import { useRerender } from "src/ui/React/hooks";
import { Myrian } from "../Myrian";
import PersonIcon from '@mui/icons-material/Person';
import BatteryFullIcon from '@mui/icons-material/BatteryFull';
import Battery20Icon from '@mui/icons-material/Battery20';
import FavoriteIcon from '@mui/icons-material/Favorite';
const width = 30;
@ -14,8 +18,12 @@ const iterator = (i: number): number[] => {
return Array(i).fill(0)
}
const Cell = (): React.ReactElement => {
const x = 20;
interface ICellProps {
tile: string;
}
const Cell = ({ tile }: ICellProps): React.ReactElement => {
const x = 50;
const sx = {
display: 'block',
color: 'white',
@ -23,11 +31,19 @@ const Cell = (): React.ReactElement => {
}
return <div style={{
width: x + 'px', height: x + 'px', margin: '0px', padding: '0px'
}}>{Math.random() > 0.5 ? <PersonIcon sx={sx} /> : <BatteryFullIcon sx={sx} />}</div>
}}>
{tile === '' && <div />}
{tile === 'b' && <BatteryFullIcon sx={sx} />}
{tile === 'd' && <Battery20Icon sx={sx} />}
{tile === 'c' && <FavoriteIcon sx={sx} />}
</div>
}
export function MyrianRoot(): React.ReactElement {
console.log(new Date());
interface IProps {
myrian: Myrian;
}
export function MyrianRoot({ myrian }: IProps): React.ReactElement {
const [render, setRerender] = useState(false);
const rerender = () => setRerender((old) => !old);
useEffect(() => {
@ -37,9 +53,15 @@ export function MyrianRoot(): React.ReactElement {
return (
<Container maxWidth="lg" disableGutters sx={{ mx: 0 }}>
<Paper sx={{ display: 'flex', flexDirection: 'column', m: 0, p: 0 }}>
{iterator(height).map(() => <Box sx={{ display: 'flex', flexDirection: 'row' }}>{iterator(width).map(() => <Cell />)}</Box>)}
</Paper>
<Box sx={{ display: 'flex', flexDirection: 'column', m: 0, p: 0 }}>
{iterator(myrian.world.length).map((_, j) =>
<Box sx={{ display: 'flex', flexDirection: 'row' }}>
{iterator(myrian.world[j].length).map((_, i) =>
<Cell key={i + '' + j + '' + myrian.world[j][i]} tile={myrian.world[j][i]} />)
}
</Box>)
}
</Box>
</Container>
);
}

View File

@ -325,6 +325,17 @@ const stanek = {
acceptGift: RamCostConstants.StanekAcceptGift,
} as const;
const myr = {
ianInteract: 5.9,
ianMove: 3.4,
ianGetTask: 1.1,
ianCancelTask: 1.2,
ianEnter: 0.2,
ianLeave: 0.2,
ianBuild: 4.1,
ianApplyPowerup: 10.9,
}
// UI API
const ui = {
getTheme: 0,
@ -426,6 +437,7 @@ export const RamCosts: RamCostTree<NSFull> = {
stanek,
ui,
grafting,
myr,
sprintf: 0,
vsprintf: 0,

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
import { Myr as IMyrian } from "@nsdefs";
import { InternalAPI } from "src/Netscript/APIWrapper";
import { helpers } from "../Netscript/NetscriptHelpers";
import { Player as player } from "../Player";
import { SleeveMyrianWork } from "../PersonObjects/Sleeve/Work/SleeveMyrianWork";
export function NetscriptMyrian(): InternalAPI<IMyrian> {
return {
@ -18,7 +21,13 @@ export function NetscriptMyrian(): InternalAPI<IMyrian> {
(sleeveId) => { throw new Error("Unimplemented"); },
ianEnter:
(ctx) =>
(sleeveId?) => { throw new Error("Unimplemented"); },
(sleeveId?) => {
const id = sleeveId === undefined ? undefined : helpers.number(ctx, "sleeveId", sleeveId);
if (id === undefined) return false; // skip player handling for now.
// handle sleeve entering the myrian.
player.sleeves[id].startWork(new SleeveMyrianWork());
return true;
},
ianLeave:
(ctx) =>
(sleeveId?) => { throw new Error("Unimplemented"); },

View File

@ -0,0 +1,29 @@
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../../../utils/JSONReviver";
import { Sleeve } from "../Sleeve";
import { Work, WorkType } from "./Work";
import { calculateIntelligenceBonus } from "../../formulas/intelligence";
export const isSleeveMyrianWork = (w: Work | null): w is SleeveMyrianWork =>
w !== null && w.type === WorkType.MYRIAN;
export class SleeveMyrianWork extends Work {
type: WorkType.MYRIAN = WorkType.MYRIAN;
process(sleeve: Sleeve, cycles: number) { }
APICopy() {
return { type: WorkType.MYRIAN as "MYRIAN" };
}
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveRecoveryWork", this);
}
/** Initializes a RecoveryWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveMyrianWork {
return Generic_fromJSON(SleeveMyrianWork, value.data);
}
}
constructorsForReviver.SleeveMyrianWork = SleeveMyrianWork;

View File

@ -12,6 +12,7 @@ import { SleeveSynchroWork } from "./SleeveSynchroWork";
import { SleeveBladeburnerWork } from "./SleeveBladeburnerWork";
import { SleeveInfiltrateWork } from "./SleeveInfiltrateWork";
import { SleeveSupportWork } from "./SleeveSupportWork";
import { SleeveMyrianWork } from "./SleeveMyrianWork";
export const applySleeveGains = (sleeve: Sleeve, shockedStats: WorkStats, mult = 1): void => {
applyWorkStatsExp(sleeve, shockedStats, mult);
@ -43,6 +44,7 @@ export enum WorkType {
BLADEBURNER = "BLADEBURNER",
INFILTRATE = "INFILTRATE",
SUPPORT = "SUPPORT",
MYRIAN = "MYRIAN",
}
export type SleeveWork =
@ -54,4 +56,5 @@ export type SleeveWork =
| SleeveSynchroWork
| SleeveBladeburnerWork
| SleeveInfiltrateWork
| SleeveSupportWork;
| SleeveSupportWork
| SleeveMyrianWork;

View File

@ -57,6 +57,8 @@ function getWorkDescription(sleeve: Sleeve, progress: number): string {
"This sleeve is currently attempting to infiltrate synthoid communities to generate additional contracts and operations.\nThis activity is less efficient the more sleeves are assigned to it.\n\n" +
`Progress: ${formatPercent(progress)}`
);
case WorkType.MYRIAN:
return "This sleeve is currently in The Myrian."
}
}

View File

@ -123,6 +123,7 @@ const tasks: {
["Perform Bladeburner Actions"]: (sleeve: Sleeve) => ITaskDetails;
["Shock Recovery"]: (sleeve: Sleeve) => ITaskDetails;
["Synchronize"]: (sleeve: Sleeve) => ITaskDetails;
["In The Myrian"]: (sleeve: Sleeve) => ITaskDetails;
} = {
"------": (): ITaskDetails => {
return { first: ["------"], second: () => ["------"] };
@ -217,6 +218,9 @@ const tasks: {
Synchronize: (): ITaskDetails => {
return { first: ["------"], second: () => ["------"] };
},
["In The Myrian"]: (): ITaskDetails => {
return { first: ["------"], second: () => ["------"] };
}
};
const canDo: {
@ -230,6 +234,7 @@ const canDo: {
["Perform Bladeburner Actions"]: (sleeve: Sleeve) => boolean;
["Shock Recovery"]: (sleeve: Sleeve) => boolean;
["Synchronize"]: (sleeve: Sleeve) => boolean;
["In The Myrian"]: (sleeve: Sleeve) => boolean;
} = {
"------": () => true,
"Work for Company": (sleeve: Sleeve) => possibleJobs(sleeve).length > 0,
@ -241,6 +246,7 @@ const canDo: {
"Perform Bladeburner Actions": () => !!Player.bladeburner,
"Shock Recovery": (sleeve: Sleeve) => sleeve.shock > 0,
Synchronize: (sleeve: Sleeve) => sleeve.sync < 100,
["In The Myrian"]: (sleeve: Sleeve) => true,
};
function getABC(sleeve: Sleeve): [string, string, string] {
@ -282,6 +288,8 @@ function getABC(sleeve: Sleeve): [string, string, string] {
return ["Shock Recovery", "------", "------"];
case WorkType.SYNCHRO:
return ["Synchronize", "------", "------"];
case WorkType.MYRIAN:
return ["In The Myrian", "------", "------"];
}
}

View File

@ -798,26 +798,26 @@ function createNewUpdateText() {
() =>
dialogBoxCreate(
"New update!\n" +
"Please report any bugs/issues through the GitHub repository " +
"or the Bitburner subreddit (reddit.com/r/bitburner).\n\n" +
CONSTANTS.LatestUpdate,
"Please report any bugs/issues through the GitHub repository " +
"or the Bitburner subreddit (reddit.com/r/bitburner).\n\n" +
CONSTANTS.LatestUpdate,
),
1000,
);
}
function createBetaUpdateText() {
setTimeout(
() =>
dialogBoxCreate(
"You are playing on the beta environment! This branch of the game " +
"features the latest developments in the game. This version may be unstable.\n" +
"Please report any bugs/issues through the github repository (https://github.com/bitburner-official/bitburner-src/issues) " +
"or the Bitburner subreddit (reddit.com/r/bitburner).\n\n" +
CONSTANTS.LatestUpdate,
),
1000,
);
// setTimeout(
// () =>
// dialogBoxCreate(
// "You are playing on the beta environment! This branch of the game " +
// "features the latest developments in the game. This version may be unstable.\n" +
// "Please report any bugs/issues through the github repository (https://github.com/bitburner-official/bitburner-src/issues) " +
// "or the Bitburner subreddit (reddit.com/r/bitburner).\n\n" +
// CONSTANTS.LatestUpdate,
// ),
// 1000,
// );
}
function download(filename: string, content: string): void {

View File

@ -971,6 +971,9 @@ type SleeveSupportTask = { type: "SUPPORT" };
/** @public */
type SleeveSynchroTask = { type: "SYNCHRO" };
/** @public */
type SleeveMyrianTask = { type: "MYRIAN" };
/** Object representing a sleeve current task.
* @public */
export type SleeveTask =
@ -982,7 +985,8 @@ export type SleeveTask =
| SleeveInfiltrateTask
| SleeveRecoveryTask
| SleeveSupportTask
| SleeveSynchroTask;
| SleeveSynchroTask
| SleeveMyrianTask;
/** Object representing a port. A port is a serialized queue.
* @public */
@ -2704,7 +2708,7 @@ export interface Myr {
/**
* Interact with an object in The Myrian.
* @remarks
* RAM cost: 5.9 GB
f
*
* The effect is different depending on the object.
* Interacting with an enemy will attack it.
@ -2719,7 +2723,7 @@ export interface Myr {
/**
* Move a sleeve in the Myrian.
* @remarks
* RAM cost: 3.4 GB
f
*
* The target tile must be 1 tile away from the sleeves current tile.
*
@ -2730,7 +2734,7 @@ export interface Myr {
/**
* Get that sleeves current task in the Myrian.
* @remarks
* RAM cost: 1.1 GB
f
*
*
* @returns The task currently being performed.
@ -2740,7 +2744,7 @@ export interface Myr {
/**
* Cancel a sleeves current Myrian task.
* @remarks
* RAM cost: 1.2 GB
f
*
* @returns true if a task was cancelled.
*/
@ -2749,7 +2753,7 @@ export interface Myr {
/**
* Makes the player or a sleeve enter The Myrian.
* @remarks
* RAM cost: 0.2 GB
f
*
* @returns true if the person is now in The Myrian.
*/
@ -2758,7 +2762,7 @@ export interface Myr {
/**
* Makes the player or a sleeve leave The Myrian.
* @remarks
* RAM cost: 0.2 GB
f
*
* Sleeves must be 1 tile away from the core.
*
@ -2769,7 +2773,7 @@ export interface Myr {
/**
* Build an entity in The Myrian.
* @remarks
* RAM cost: 4.1 GB
f
*
* Sleeves must be 1 tile away from the target tile and the player must have enough resources to build the entity.
*
@ -2780,7 +2784,7 @@ export interface Myr {
/**
* Apply a Myrian powerup to a sleeve.
* @remarks
* RAM cost: 10.9 GB
f
*
* Must have at least 1 powerup to apply.
*
@ -4677,6 +4681,12 @@ export interface NS {
*/
readonly grafting: Grafting;
/**
* Namespace for myrian functions. Contains spoilers.
* @remarks RAM cost: 0 GB
*/
readonly myr: Myr;
/**
* Arguments passed into the script.
*

View File

@ -344,30 +344,30 @@ const Engine: {
Player.lastUpdate = Engine._lastUpdate;
Engine.start(); // Run main game loop and Scripts loop
const timeOfflineString = convertTimeMsToTimeElapsedString(time);
setTimeout(
() =>
AlertEvents.emit(
<>
<Typography>Offline for {timeOfflineString}. While you were offline:</Typography>
<ul>
<li>
<Typography>
Your scripts generated <Money money={offlineHackingIncome} />
</Typography>
</li>
<li>
<Typography>Your Hacknet Nodes generated {hacknetProdInfo}</Typography>
</li>
<li>
<Typography>
You gained <Reputation reputation={offlineReputation} /> reputation divided amongst your factions
</Typography>
</li>
</ul>
</>,
),
250,
);
// setTimeout(
// () =>
// AlertEvents.emit(
// <>
// <Typography>Offline for {timeOfflineString}. While you were offline:</Typography>
// <ul>
// <li>
// <Typography>
// Your scripts generated <Money money={offlineHackingIncome} />
// </Typography>
// </li>
// <li>
// <Typography>Your Hacknet Nodes generated {hacknetProdInfo}</Typography>
// </li>
// <li>
// <Typography>
// You gained <Reputation reputation={offlineReputation} /> reputation divided amongst your factions
// </Typography>
// </li>
// </ul>
// </>,
// ),
// 250,
// );
} else {
// No save found, start new game
FormatsNeedToChange.emit();

View File

@ -79,6 +79,7 @@ import { useRerender } from "./React/hooks";
import { ScriptFilePath } from "src/Paths/ScriptFilePath";
import { TextFilePath } from "src/Paths/TextFilePath";
import { MyrianRoot } from "../Myrian/ui/MyrianRoot";
import { myrian } from "../Myrian/Helpers";
const htmlLocation = location;
@ -300,7 +301,7 @@ export function GameRoot(): React.ReactElement {
break;
}
case Page.Myrian: {
mainPage = <MyrianRoot />;
mainPage = <MyrianRoot myrian={myrian} />;
break;
}
case Page.Stats: {