merge into master
This commit is contained in:
@ -2,12 +2,15 @@ package;
|
||||
|
||||
import flixel.FlxG;
|
||||
|
||||
using StringTools;
|
||||
class Highscore
|
||||
{
|
||||
#if (haxe >= "4.0.0")
|
||||
public static var songScores:Map<String, Int> = new Map();
|
||||
public static var songCombos:Map<String, String> = new Map();
|
||||
#else
|
||||
public static var songScores:Map<String, Int> = new Map<String, Int>();
|
||||
public static var songCombos:Map<String, String> = new Map<String, String>();
|
||||
#end
|
||||
|
||||
|
||||
@ -32,6 +35,23 @@ class Highscore
|
||||
}else trace('BotPlay detected. Score saving is disabled.');
|
||||
}
|
||||
|
||||
public static function saveCombo(song:String, combo:String, ?diff:Int = 0):Void
|
||||
{
|
||||
var daSong:String = formatSong(song, diff);
|
||||
var finalCombo:String = combo.split(')')[0].replace('(', '');
|
||||
|
||||
if(!FlxG.save.data.botplay)
|
||||
{
|
||||
if (songCombos.exists(daSong))
|
||||
{
|
||||
if (getComboInt(songCombos.get(daSong)) < getComboInt(finalCombo))
|
||||
setCombo(daSong, finalCombo);
|
||||
}
|
||||
else
|
||||
setCombo(daSong, finalCombo);
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveWeekScore(week:Int = 1, score:Int = 0, ?diff:Int = 0):Void
|
||||
{
|
||||
|
||||
@ -64,6 +84,14 @@ class Highscore
|
||||
FlxG.save.flush();
|
||||
}
|
||||
|
||||
static function setCombo(song:String, combo:String):Void
|
||||
{
|
||||
// Reminder that I don't need to format this song, it should come formatted!
|
||||
songCombos.set(song, combo);
|
||||
FlxG.save.data.songCombos = songCombos;
|
||||
FlxG.save.flush();
|
||||
}
|
||||
|
||||
public static function formatSong(song:String, diff:Int):String
|
||||
{
|
||||
var daSong:String = song;
|
||||
@ -76,6 +104,23 @@ class Highscore
|
||||
return daSong;
|
||||
}
|
||||
|
||||
static function getComboInt(combo:String):Int
|
||||
{
|
||||
switch(combo)
|
||||
{
|
||||
case 'SDCB':
|
||||
return 1;
|
||||
case 'FC':
|
||||
return 2;
|
||||
case 'GFC':
|
||||
return 3;
|
||||
case 'MFC':
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getScore(song:String, diff:Int):Int
|
||||
{
|
||||
if (!songScores.exists(formatSong(song, diff)))
|
||||
@ -84,6 +129,14 @@ class Highscore
|
||||
return songScores.get(formatSong(song, diff));
|
||||
}
|
||||
|
||||
public static function getCombo(song:String, diff:Int):String
|
||||
{
|
||||
if (!songCombos.exists(formatSong(song, diff)))
|
||||
setCombo(formatSong(song, diff), '');
|
||||
|
||||
return songCombos.get(formatSong(song, diff));
|
||||
}
|
||||
|
||||
public static function getWeekScore(week:Int, diff:Int):Int
|
||||
{
|
||||
if (!songScores.exists(formatSong('week' + week, diff)))
|
||||
@ -98,5 +151,9 @@ class Highscore
|
||||
{
|
||||
songScores = FlxG.save.data.songScores;
|
||||
}
|
||||
if (FlxG.save.data.songCombos != null)
|
||||
{
|
||||
songCombos = FlxG.save.data.songCombos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user