Files
Mindustry/core/src/mindustry/service/Achievement.java
2021-06-02 11:08:08 -04:00

101 lines
2.6 KiB
Java

package mindustry.service;
import static mindustry.Vars.*;
public enum Achievement{
kill1kEnemies(SStat.unitsDestroyed, 1000),
kill100kEnemies(SStat.unitsDestroyed, 100_000),
launch100kItems(SStat.itemsLaunched, 100_000),
produce5kMin(SStat.maxProduction, 5000),
produce50kMin(SStat.maxProduction, 50_000),
win10Attack(SStat.attacksWon, 10),
win10PvP(SStat.pvpsWon, 10),
defeatAttack5Waves,
launch30Times(SStat.timesLaunched, 30),
captureBackground,
survive100Waves(SStat.maxWavesSurvived, 100),
researchAll,
shockWetEnemy,
killEnemyPhaseWall,
researchRouter,
place10kBlocks(SStat.blocksBuilt, 10_000),
destroy1kBlocks(SStat.blocksDestroyed, 1000),
overheatReactor(SStat.reactorsOverheated, 1),
make10maps(SStat.mapsMade, 10),
downloadMapWorkshop,
publishMap(SStat.mapsPublished, 1),
defeatBoss(SStat.bossesDefeated, 1),
captureAllSectors,
control10Sectors(SStat.sectorsControlled, 10),
drop10kitems,
powerupImpactReactor,
obtainThorium,
obtainTitanium,
suicideBomb,
buildGroundFactory,
issueAttackCommand,
active100Units(SStat.maxUnitActive, 100),
build1000Units(SStat.unitsBuilt, 1000),
buildAllUnits(SStat.unitTypesBuilt, 30),
buildT5,
pickupT5,
active10Polys,
dieExclusion,
drown,
fillCoreAllCampaign,
hostServer10(SStat.maxPlayersServer, 10),
buildMeltdownSpectre, //technically inaccurate
launchItemPad,
chainRouters,
circleConveyor,
becomeRouter,
create20Schematics(SStat.schematicsCreated, 20),
survive10WavesNoBlocks,
captureNoBlocksBroken,
useFlameAmmo,
coolTurret,
enablePixelation,
openWiki,
useAccelerator,
unlockAllZones,
;
private final SStat stat;
private final int statGoal;
private boolean completed = false;
public static final Achievement[] all = values();
/** Creates an achievement that is triggered when this stat reaches a number.*/
Achievement(SStat stat, int goal){
this.stat = stat;
this.statGoal = goal;
}
Achievement(){
this(null, 0);
}
public void complete(){
if(!isAchieved()){
service.completeAchievement(name());
service.storeStats();
}
}
public void checkCompletion(){
if(!isAchieved() && stat != null && stat.get() >= statGoal){
complete();
}
}
public boolean isAchieved(){
if(completed){
return true;
}
return (completed = service.isAchieved(name()));
}
}