Skip to content
Snippets Groups Projects

Feature/publish game

Merged EVEN PIERRE requested to merge feature/publish-game into develop
Compare and
6 files
+ 250
4
Preferences
Compare changes
Files
6
package com.barreoblique.core.gameplay.publishsystem;
import com.barreoblique.core.gameplay.DataRef;
import com.barreoblique.core.gameplay.testsystem.TestResult;
import com.barreoblique.core.gameplay.testsystem.TestSession;
import com.barreoblique.core.timesystem.TimeHandler;
import com.barreoblique.database.dtos.ContractDto;
import com.barreoblique.database.enums.TestType;
import java.util.HashMap;
public class PublishGameAlgorithm {
private final float BASE = 100f;
private final float DAY_MALUS = 25f;
private final TestSession testSession;
private final DataRef<ContractDto> chosenContract;
private PublishResult _publishedResults = null;
public PublishGameAlgorithm(TestSession session, DataRef<ContractDto> chosenContract){
this.testSession = session;
this.chosenContract = chosenContract;
}
public void calculate(){
HashMap<TestType, Float> results = new HashMap<>();
for(TestResult result : testSession.getResults()){
results.put(result.getFeedback().get().getType(), BASE - Math.abs(result.getFeedback().get().getLvlOffset()));
}
float dayMalus = DAY_MALUS * (TimeHandler.Get().getDay() - chosenContract.get().getGameDuration());
_publishedResults = new PublishResult(results, dayMalus);
}
public PublishResult getResults() { return _publishedResults; }
public TestSession getTestSession() {
return testSession;
}
}