Only give the chest once

This commit is contained in:
Sam 2017-05-27 18:23:53 +01:00
parent ffa2a736ec
commit 5bdcd3474f

View File

@ -70,6 +70,7 @@ public class AlienInvasion extends SoloGame
return 0;
};
private static final String GAME_COMPLETED_STAT = "Alien Invasion Chest Given";
private final List<BeamSource> _sources = new ArrayList<>();
private final List<Location> _targets = new ArrayList<>();
@ -371,18 +372,23 @@ public class AlienInvasion extends SoloGame
// Reward title
if (score.Score == _path.size() - 1)
{
Manager.getInventoryManager().addItemToInventory(success ->
if (Manager.GetStatsManager().Get(player).getStat(GAME_COMPLETED_STAT) > 0)
{
if (success)
{
player.sendMessage(F.main("Game", "Unlocked 1 " + C.cAqua + "Omega Chest" + C.mBody + "."));
}
else
{
player.sendMessage(F.main("Game", "Failed to give you your Omega Chest, you should inform a staff member!"));
}
Manager.GetStatsManager().incrementStat(player, GAME_COMPLETED_STAT, 1);
}, player, "Omega Chest", 1);
Manager.getInventoryManager().addItemToInventory(success ->
{
if (success)
{
player.sendMessage(F.main("Game", "Unlocked 1 " + C.cAqua + "Omega Chest" + C.mBody + "."));
}
else
{
player.sendMessage(F.main("Game", "Failed to give you your Omega Chest, you should inform a staff member!"));
}
}, player, "Omega Chest", 1);
}
TrackManager trackManager = Manager.getTrackManager();
Track track = trackManager.getTrack(AlienInvasionTrack.class);