1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "gfCTotalScoreLevel.h"

#include <fsCore/fsIFile.h>
#include <fsCore/fsPoint.h>
#include <fsCore/fsIResourceNamePathAdjuster.h>
#include <fsCore/src/fsCResourceName.h>
#include <fsCore/src/fsCAppSettings.h>

#include "src/gfCHogEntityFactory.h"


fsS32 fsCTotalScoreLevel::silhouetteItemeScoreGet() const
{
	return mSilhoutteCount * fsCAppCoreMain::instanceGet()->settingsGet()->s32GetWithDefault("silhouetteItemScore", 0);
}

fsS32 fsCTotalScoreLevel::bonusItemeScoreGet() const
{
	return mBonusCount * fsCAppCoreMain::instanceGet()->settingsGet()->s32GetWithDefault("bonusItemScore", 0);
}

fsS32 fsCTotalScoreLevel::sceneItemeScoreGet() const
{
	return mLevelSettings->s32GetWithDefault("numHogItems", 0) * fsCAppCoreMain::instanceGet()->settingsGet()->
		s32GetWithDefault("sceneItemScore", 0);
}

fsS32 fsCTotalScoreLevel::noHintsUsedScoreGet() const<--- The member function 'fsCTotalScoreLevel::noHintsUsedScoreGet' can be static.
{
	return fsCAppCoreMain::instanceGet()->settingsGet()->s32GetWithDefault("noHintsUsedScore", 0);
}

fsBool fsCTotalScoreLevel::miniGameLevel()
{
	return fsStr::npos != levelFilenameGet().find("_");
}

fsS32 fsCTotalScoreLevel::scoreGet()
{
	if (miniGameLevel())
	{
		return fsCAppCoreMain::instanceGet()->settingsGet()->s32GetWithDefault("miniGameCompletionScore", 0);
	}
	return sceneItemeScoreGet() + silhouetteItemeScoreGet() + bonusItemeScoreGet();
}

std::map<fsStr, fsS32>& fsCTotalScoreLevel::classifiedSilhouettesGet()
{
	return mClassification;
}

void
fsCTotalScoreLevel::silhouetteItemClassify(const fsStr& pEntityName)
{
	for (auto& key : mClassification)
	{
		if (fsStr::npos != pEntityName.find(key.first))
		{
			++key.second;
		}
	}
}

void fsCTotalScoreLevel::silhouetteItemAndBonusItemCountsCalculate(const fsStr& pLevelPath, const fsStr& pLevelFolder)
{
	fsStr folderName {pLevelPath};
	if (fsStr::npos == folderName.find(fsIResourceNamePathAdjuster::mPathSeparator))
	{
		folderName = pLevelPath + "/" + folderName;
	}
	fsStr coordsFileData = fsIFile::strGetFromFile(fsCResourceName(
		folderName + "/" + fsIResourceNamePathAdjuster::mLayersFolder + "coords.txt",
		fsCResourceName::eRES_LOCATION_ASSETS));

	fsStr entName = coordsFileData.chomp(",");
	const fsBool correctlyFormattedFile = fsStr::npos != coordsFileData.find(",") && fsStr::npos != coordsFileData.
		find("\n");

	if (correctlyFormattedFile)
	{
		while (!entName.emptyGet())
		{
			fsPoint entPos;
			entPos.x = coordsFileData.chomp(",").toS32();
			entPos.y = coordsFileData.chomp("\n").toS32();

			if (0 == entName.find(gfCHogEntityFactory::bonusPickablePrefix))
			{
				++mBonusCount;
			}
			else if (0 == entName.find(gfCHogEntityFactory::bonusSilhouettePickablePrefix))
			{
				++mSilhoutteCount;
				silhouetteItemClassify(entName);
			}
			entName = coordsFileData.chomp(",");
		}
	}
}

fsCTotalScoreLevel::fsCTotalScoreLevel(const fsStr& pLevelPath, const fsStr& pLevelFolder):
	gfCLevelSequencerLevelComponent(pLevelPath, pLevelFolder),
	mSilhoutteCount(0),
	mBonusCount(0)
{
	mClassification.insert(std::pair<fsStr, fsS32>("-end-", 0));
	mClassification.insert(std::pair<fsStr, fsS32>("-insect-", 0));
	mClassification.insert(std::pair<fsStr, fsS32>("-bird-", 0));

	silhouetteItemAndBonusItemCountsCalculate(pLevelPath, pLevelFolder);
}

fsCTotalScoreLevel::~fsCTotalScoreLevel()
{
}