many bugfix

This commit is contained in:
Olivier Gagnon
2021-12-03 14:12:32 -05:00
parent d852649f2b
commit 49a545f00e
67 changed files with 549 additions and 486 deletions

View File

@@ -224,7 +224,9 @@ export class Gang {
if (AllGangs[otherGang].territory <= 0) return;
const territoryGain = calculateTerritoryGain(thisGang, otherGang);
AllGangs[thisGang].territory += territoryGain;
if (AllGangs[thisGang].territory > 1) AllGangs[thisGang].territory = 1;
AllGangs[otherGang].territory -= territoryGain;
if (AllGangs[thisGang].territory < 0) AllGangs[thisGang].territory = 0;
if (thisGang === gangName) {
this.clash(true); // Player won
AllGangs[otherGang].power *= 1 / 1.01;
@@ -237,7 +239,9 @@ export class Gang {
if (AllGangs[thisGang].territory <= 0) return;
const territoryGain = calculateTerritoryGain(otherGang, thisGang);
AllGangs[thisGang].territory -= territoryGain;
if (AllGangs[otherGang].territory < 0) AllGangs[otherGang].territory = 0;
AllGangs[otherGang].territory += territoryGain;
if (AllGangs[otherGang].territory > 1) AllGangs[otherGang].territory = 1;
if (thisGang === gangName) {
this.clash(false); // Player lost
} else if (otherGang === gangName) {

View File

@@ -114,6 +114,8 @@ export function NetscriptSingularity(
if (player.hasGangWith(facname)) {
const res = [];
for (const augName in Augmentations) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const aug = Augmentations[augName];
if (!aug.isSpecial) {
res.push(augName);
@@ -953,7 +955,7 @@ export function NetscriptSingularity(
// if the player is in a gang and the target faction is any of the gang faction, fail
if (player.inGang() && AllGangs[name] !== undefined) {
workerScript.log("workForFaction", () => `Faction '${name}' does not offer work at the moment.`);
return;
return false;
}
if (!player.factions.includes(name)) {

View File

@@ -669,8 +669,13 @@ export interface GangOtherInfoObject {
* @public
*/
export interface GangOtherInfo {
/** Stock Symbol */
[key: string]: GangOtherInfoObject[];
"Slum Snakes": GangOtherInfoObject;
Tetrads: GangOtherInfoObject;
"The Syndicate": GangOtherInfoObject;
"The Dark Army": GangOtherInfoObject;
"Speakers for the Dead": GangOtherInfoObject;
NiteSec: GangOtherInfoObject;
"The Black Hand": GangOtherInfoObject;
}
/**
@@ -1235,12 +1240,11 @@ export interface TIX {
*/
export interface Singularity {
/**
* Take university class.
* SF4.1 - Take university class.
*
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
*
* This function will automatically set you to start taking a course at a university.
* If you are already in the middle of some “working” action (such as working at a
@@ -1257,12 +1261,11 @@ export interface Singularity {
universityCourse(universityName: string, courseName: string): boolean;
/**
* Workout at the gym.
* SF4.1 - Workout at the gym.
*
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
* This function will automatically set you to start working out at a gym to train
* a particular stat. If you are already in the middle of some “working” action
@@ -1279,11 +1282,10 @@ export interface Singularity {
gymWorkout(gymName: string, stat: string): boolean;
/**
* Travel to another city.
* SF4.1 - Travel to another city.
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
*
* This function allows the player to travel to any city. The cost for using this
* function is the same as the cost for traveling through the Travel Agency.
@@ -1294,11 +1296,10 @@ export interface Singularity {
travelToCity(city: string): boolean;
/**
* Purchase the TOR router.
* SF4.1 - Purchase the TOR router.
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
*
* This function allows you to automatically purchase a TOR router. The cost for
* purchasing a TOR router using this function is the same as if you were to
@@ -1309,11 +1310,10 @@ export interface Singularity {
purchaseTor(): boolean;
/**
* Purchase a program from the dark web.
* SF4.1 - Purchase a program from the dark web.
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
*
* This function allows you to automatically purchase programs. You MUST have a
* TOR router in order to use this function. The cost of purchasing programs
@@ -1330,11 +1330,10 @@ export interface Singularity {
purchaseProgram(programName: string): boolean;
/**
* Check if the player is busy.
* SF4.1 - Check if the player is busy.
* @remarks
* RAM cost: 0.5 GB
*
* Singularity - Level 1
*
* Returns a boolean indicating whether or not the player is currently performing an
* action. These actions include working for a company/faction, studying at a univeristy,
@@ -1345,11 +1344,10 @@ export interface Singularity {
isBusy(): boolean;
/**
* Stop the current action.
* SF4.1 - Stop the current action.
* @remarks
* RAM cost: 1 GB
*
* Singularity - Level 1
*
* This function is used to end whatever action the player is currently performing.
* The player will receive whatever money/experience/etc. he has earned from that action.
@@ -1369,11 +1367,10 @@ export interface Singularity {
stopAction(): boolean;
/**
* Upgrade home computer RAM.
* SF4.2 - Upgrade home computer RAM.
* @remarks
* RAM cost: 3 GB
*
* Singularity - Level 2
*
* This function will upgrade amount of RAM on the players home computer. The cost is
* the same as if you were to do it manually.
@@ -1385,11 +1382,10 @@ export interface Singularity {
upgradeHomeRam(): boolean;
/**
* Upgrade home computer cores.
* SF4.2 - Upgrade home computer cores.
* @remarks
* RAM cost: 3 GB
*
* Singularity - Level 2
*
* This function will upgrade amount of cores on the players home computer. The cost is
* the same as if you were to do it manually.
@@ -1401,11 +1397,10 @@ export interface Singularity {
upgradeHomeCores(): boolean;
/**
* Get the price of upgrading home RAM.
* SF4.2 - Get the price of upgrading home RAM.
* @remarks
* RAM cost: 1.5 GB
*
* Singularity - Level 2
*
* Returns the cost of upgrading the players home computer RAM.
*
@@ -1414,11 +1409,10 @@ export interface Singularity {
getUpgradeHomeRamCost(): number;
/**
* Get the price of upgrading home cores.
* SF4.2 - Get the price of upgrading home cores.
* @remarks
* RAM cost: 1.5 GB
*
* Singularity - Level 2
*
* Returns the cost of upgrading the players home computer cores.
*
@@ -1427,11 +1421,10 @@ export interface Singularity {
getUpgradeHomeCoresCost(): number;
/**
* Work for a company.
* SF4.2 - Work for a company.
* @remarks
* RAM cost: 3 GB
*
* Singularity - Level 2
*
* This function will automatically set you to start working at the company
* at which you are employed. If you are already in the middle of some “working”
@@ -1458,11 +1451,10 @@ export interface Singularity {
workForCompany(companyName?: string): boolean;
/**
* Apply for a job at a company.
* SF4.2 - Apply for a job at a company.
* @remarks
* RAM cost: 3 GB
*
* Singularity - Level 2
*
* This function will automatically try to apply to the specified company
* for a position in the specified field. This function can also be used to
@@ -1480,11 +1472,10 @@ export interface Singularity {
applyToCompany(companyName: string, field: string): boolean;
/**
* Get company reputation.
* SF4.2 - Get company reputation.
* @remarks
* RAM cost: 1 GB
*
* Singularity - Level 2
*
* This function will return the amount of reputation you have at the specified company.
* If the company passed in as an argument is invalid, -1 will be returned.
@@ -1495,11 +1486,10 @@ export interface Singularity {
getCompanyRep(companyName: string): number;
/**
* Get company favor.
* SF4.2 - Get company favor.
* @remarks
* RAM cost: 1 GB
*
* Singularity - Level 2
*
* This function will return the amount of favor you have at the specified company.
* If the company passed in as an argument is invalid, -1 will be returned.
@@ -1510,11 +1500,10 @@ export interface Singularity {
getCompanyFavor(companyName: string): number;
/**
* Get company favor gain.
* SF4.2 - Get company favor gain.
* @remarks
* RAM cost: 0.75 GB
*
* Singularity - Level 2
*
* This function will return the amount of favor you will gain for the specified
* company when you reset by installing Augmentations.
@@ -1525,11 +1514,10 @@ export interface Singularity {
getCompanyFavorGain(companyName: string): number;
/**
* List all current faction invitations.
* SF4.2 - List all current faction invitations.
* @remarks
* RAM cost: 3 GB
*
* Singularity - Level 2
*
* Returns an array with the name of all Factions you currently have oustanding invitations from.
*
@@ -1538,11 +1526,10 @@ export interface Singularity {
checkFactionInvitations(): string[];
/**
* Join a faction.
* SF4.2 - Join a faction.
* @remarks
* RAM cost: 3 GB
*
* Singularity - Level 2
*
* This function will automatically accept an invitation from a faction and join it.
*
@@ -1552,11 +1539,10 @@ export interface Singularity {
joinFaction(faction: string): boolean;
/**
* Work for a faction.
* SF4.2 - Work for a faction.
* @remarks
* RAM cost: 3 GB
*
* Singularity - Level 2
*
* This function will automatically set you to start working for the specified faction.
* Obviously, you must be a member of the faction or else this function will fail. If
@@ -1584,11 +1570,10 @@ export interface Singularity {
workForFaction(faction: string, workType: string): boolean;
/**
* Get faction reputation.
* SF4.2 - Get faction reputation.
* @remarks
* RAM cost: 1 GB
*
* Singularity - Level 2
*
* This function returns the amount of reputation you have for the specified faction.
*
@@ -1598,11 +1583,10 @@ export interface Singularity {
getFactionRep(faction: string): number;
/**
* Get faction favor.
* SF4.2 - Get faction favor.
* @remarks
* RAM cost: 1 GB
*
* Singularity - Level 2
*
* This function returns the amount of favor you have for the specified faction.
*
@@ -1612,11 +1596,10 @@ export interface Singularity {
getFactionFavor(faction: string): number;
/**
* Get faction favor gain.
* SF4.2 - Get faction favor gain.
* @remarks
* RAM cost: 0.75 GB
*
* Singularity - Level 2
*
* This function returns the amount of favor you will gain for the specified
* faction when you reset by installing Augmentations.
@@ -1627,11 +1610,10 @@ export interface Singularity {
getFactionFavorGain(faction: string): number;
/**
* Donate to a faction.
* SF4.3 - Donate to a faction.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* Attempts to donate money to the specified faction in exchange for reputation.
* Returns true if you successfully donate the money, and false otherwise.
@@ -1643,11 +1625,10 @@ export interface Singularity {
donateToFaction(faction: string, amount: number): boolean;
/**
* Create a program.
* SF4.3 - Create a program.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function will automatically set you to start working on creating the
* specified program. If you are already in the middle of some “working” action
@@ -1678,11 +1659,10 @@ export interface Singularity {
createProgram(program: string): boolean;
/**
* Commit a crime.
* SF4.3 - Commit a crime.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function is used to automatically attempt to commit crimes.
* If you are already in the middle of some working action (such
@@ -1706,11 +1686,10 @@ export interface Singularity {
commitCrime(crime: string): number;
/**
* Get chance to successfully commit a crime.
* SF4.3 - Get chance to successfully commit a crime.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function returns your chance of success at commiting the specified crime.
*
@@ -1720,11 +1699,10 @@ export interface Singularity {
getCrimeChance(crime: string): number;
/**
* Get stats related to a crime.
* SF4.3 - Get stats related to a crime.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* Returns the stats of the crime.
*
@@ -1734,11 +1712,10 @@ export interface Singularity {
getCrimeStats(crime: string): CrimeStats;
/**
* Get a list of owned augmentation.
* SF4.3 - Get a list of owned augmentation.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function returns an array containing the names (as strings) of all Augmentations you have.
*
@@ -1748,11 +1725,10 @@ export interface Singularity {
getOwnedAugmentations(purchased?: boolean): string[];
/**
* Get a list of augmentation available from a faction.
* SF4.3 - Get a list of augmentation available from a faction.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* Returns an array containing the names (as strings) of all Augmentations
* that are available from the specified faction.
@@ -1763,11 +1739,10 @@ export interface Singularity {
getAugmentationsFromFaction(faction: string): string[];
/**
* Get the pre-requisite of an augmentation.
* SF4.3 - Get the pre-requisite of an augmentation.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function returns an array with the names of the prerequisite Augmentation(s) for the specified Augmentation.
* If there are no prerequisites, a blank array is returned.
@@ -1778,12 +1753,11 @@ export interface Singularity {
getAugmentationPrereq(augName: string): string[];
/**
* @deprecated
* Get the price and reputation of an augmentation.
* SF4.3 - Get the price and reputation of an augmentation.
* @deprecated use getAugmentationPrice getAugmentationRepCost
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function returns an array with two elements that gives the cost for
* the specified Augmentation. The first element in the returned array is the
@@ -1799,11 +1773,10 @@ export interface Singularity {
getAugmentationCost(augName: string): [number, number];
/**
* Get price of an augmentation.
* SF4.3 - Get price of an augmentation.
* @remarks
* RAM cost: 2.5 GB
*
* Singularity - Level 3
*
* @param augName - Name of Augmentation.
* @returns Price of the augmentation.
@@ -1811,11 +1784,10 @@ export interface Singularity {
getAugmentationPrice(augName: string): number;
/**
* Get reputation requirement of an augmentation.
* SF4.3 - Get reputation requirement of an augmentation.
* @remarks
* RAM cost: 2.5 GB
*
* Singularity - Level 3
*
* @param augName - Name of Augmentation.
* @returns Reputation requirement of the augmentation.
@@ -1823,11 +1795,10 @@ export interface Singularity {
getAugmentationRepReq(augName: string): number;
/**
* Purchase an augmentation
* SF4.3 - Purchase an augmentation
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function will try to purchase the specified Augmentation through the given Faction.
*
@@ -1840,11 +1811,10 @@ export interface Singularity {
purchaseAugmentation(faction: string, augmentation: string): boolean;
/**
* Get the stats of an augmentation.
* SF4.3 - Get the stats of an augmentation.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function returns augmentation stats.
*
@@ -1854,11 +1824,10 @@ export interface Singularity {
getAugmentationStats(name: string): AugmentationStats;
/**
* Install your purchased augmentations.
* SF4.3 - Install your purchased augmentations.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function will automatically install your Augmentations, resetting the game as usual.
*
@@ -1867,13 +1836,12 @@ export interface Singularity {
installAugmentations(cbScript?: string): void;
/**
* @deprecated
* Returns an object with the Players stats.
* SF4.1 - Returns an object with the Players stats.
* @deprecated use getPlayer
*
* @remarks
* RAM cost: 0.5 GB
*
* Singularity - Level 1
*
* @example
* ```ts
@@ -1885,35 +1853,32 @@ export interface Singularity {
getStats(): PlayerSkills;
/**
* @deprecated
* Returns an object with various information about your character.
* SF4.1 - Returns an object with various information about your character.
* @deprecated use getPlayer
*
* @remarks
* RAM cost: 0.5 GB
*
* Singularity - Level 1
*
* @returns Object with various information about your character.
*/
getCharacterInformation(): CharacterInfo;
/**
* Hospitalize the player.
* SF4.1 - Hospitalize the player.
* @remarks
* RAM cost: 0.25 GB
*
* Singularity - Level 1
*
* @returns The cost of the hospitalization.
*/
hospitalize(): number;
/**
* Soft reset the game.
* SF4.3 - Soft reset the game.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* This function will perform a reset even if you dont have any augmentation installed.
*
@@ -1922,11 +1887,10 @@ export interface Singularity {
softReset(cbScript: string): void;
/**
* Go to a location.
* SF4.3 - Go to a location.
* @remarks
* RAM cost: 5 GB
*
* Singularity - Level 3
*
* Move the player to a specific location.
*
@@ -1936,22 +1900,20 @@ export interface Singularity {
goToLocation(locationName: string): boolean;
/**
* Get the current server.
* SF4.1 - Get the current server.
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
*
* @returns Name of the current server.
*/
getCurrentServer(): string;
/**
* Connect to a server.
* SF4.1 - Connect to a server.
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
*
* Run the connect HOSTNAME command in the terminal. Can only connect to neighbors.
*
@@ -1960,44 +1922,40 @@ export interface Singularity {
connect(hostname: string): boolean;
/**
* Run the hack command in the terminal.
* SF4.1 - Run the hack command in the terminal.
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
*
* @returns Amount of money stolen by manual hacking.
*/
manualHack(): Promise<number>;
/**
* Run the backdoor command in the terminal.
* SF4.1 - Run the backdoor command in the terminal.
* @remarks
* RAM cost: 2 GB
*
* Singularity - Level 1
*
* @returns True if the installation was successful.
*/
installBackdoor(): Promise<void>;
/**
* Check if the player is focused.
* SF4.2 - Check if the player is focused.
* @remarks
* RAM cost: 0.1 GB
*
* Singularity - Level 2
*
* @returns True if the player is focused.
*/
isFocused(): void;
/**
* Set the players focus.
* SF4.2 - Set the players focus.
* @remarks
* RAM cost: 0.1 GB
*
* Singularity - Level 2
*/
setFocus(focus: boolean): void;
}
@@ -4273,8 +4231,7 @@ export interface NS extends Singularity {
getServerMinSecurityLevel(host: string): number;
/**
* @deprecated
* DEPRECATED
* @deprecated useless
* @remarks
* RAM cost: 0.1 GB
* Returns the base security level of the target server. This is the security
@@ -4291,8 +4248,7 @@ export interface NS extends Singularity {
getServerBaseSecurityLevel(host: string): number;
/**
* @deprecated
* DEPRECATED
* @deprecated use getServerMaxRam / getServerUsedRam
* @remarks
* RAM cost: 0.1 GB
*

View File

@@ -110,6 +110,7 @@ function LogWindow(props: IProps): React.ReactElement {
}
useEffect(() => {
updateLayer();
const id = setInterval(rerender, 1000);
return () => clearInterval(id);
}, []);