mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 09:42:53 +02:00
Add achievements to base game
- Add a script to generate achievement data from Steamworks API - Add achievements page with a link in sidebar - Calculate achievements (1/min) with an engine counter - Store achievements with a timestamp on unlocked in the PlayerObject - Add a script to generate monochrome icons from Steam icons - Add toast when unlocking an achievement
This commit is contained in:
@@ -35,6 +35,7 @@ import { CityName } from "../../Locations/data/CityNames";
|
||||
import { MoneySourceTracker } from "../../utils/MoneySourceTracker";
|
||||
import { Reviver, Generic_toJSON, Generic_fromJSON } from "../../utils/JSONReviver";
|
||||
import { ISkillProgress } from "../formulas/skill";
|
||||
import { PlayerAchievement } from '../../Achievements/Achievements';
|
||||
|
||||
export class PlayerObject implements IPlayer {
|
||||
// Class members
|
||||
@@ -75,6 +76,7 @@ export class PlayerObject implements IPlayer {
|
||||
sleevesFromCovenant: number;
|
||||
sourceFiles: IPlayerOwnedSourceFile[];
|
||||
exploits: Exploit[];
|
||||
achievements: PlayerAchievement[];
|
||||
lastUpdate: number;
|
||||
totalPlaytime: number;
|
||||
|
||||
@@ -243,6 +245,7 @@ export class PlayerObject implements IPlayer {
|
||||
takeDamage: (amt: number) => boolean;
|
||||
travel: (to: CityName) => boolean;
|
||||
giveExploit: (exploit: Exploit) => void;
|
||||
giveAchievement: (achievementId: string) => void;
|
||||
queryStatFromString: (str: string) => number;
|
||||
getIntelligenceBonus: (weight: number) => number;
|
||||
getCasinoWinnings: () => number;
|
||||
@@ -467,6 +470,7 @@ export class PlayerObject implements IPlayer {
|
||||
this.scriptProdSinceLastAug = 0;
|
||||
|
||||
this.exploits = [];
|
||||
this.achievements = [];
|
||||
|
||||
this.init = generalMethods.init;
|
||||
this.prestigeAugmentation = generalMethods.prestigeAugmentation;
|
||||
@@ -557,6 +561,7 @@ export class PlayerObject implements IPlayer {
|
||||
this.gotoLocation = generalMethods.gotoLocation;
|
||||
this.canAccessResleeving = generalMethods.canAccessResleeving;
|
||||
this.giveExploit = generalMethods.giveExploit;
|
||||
this.giveAchievement = generalMethods.giveAchievement;
|
||||
this.getIntelligenceBonus = generalMethods.getIntelligenceBonus;
|
||||
this.getCasinoWinnings = generalMethods.getCasinoWinnings;
|
||||
this.hasAugmentation = augmentationMethods.hasAugmentation;
|
||||
|
||||
@@ -64,6 +64,7 @@ import React from "react";
|
||||
import { serverMetadata } from "../../Server/data/servers";
|
||||
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
||||
import { calculateClassEarnings } from "../formulas/work";
|
||||
import { achievements } from "../../Achievements/Achievements";
|
||||
|
||||
export function init(this: IPlayer): void {
|
||||
/* Initialize Player's home computer */
|
||||
@@ -2632,6 +2633,15 @@ export function giveExploit(this: IPlayer, exploit: Exploit): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function giveAchievement(this: IPlayer, achievementId: string): void {
|
||||
const achievement = achievements[achievementId];
|
||||
if (!achievement) return;
|
||||
if (!this.achievements.map(a => a.ID).includes(achievementId)) {
|
||||
this.achievements.push({ ID: achievementId, unlockedOn: new Date().getTime() });
|
||||
SnackbarEvents.emit(`Unlocked Achievement: "${achievement.Name}"`, 'success', 2000);
|
||||
}
|
||||
}
|
||||
|
||||
export function getIntelligenceBonus(this: IPlayer, weight: number): number {
|
||||
return calculateIntelligenceBonus(this.intelligence, weight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user