Implement core game functionality with AppRoot, SaveClient, PlayerRepository, and LevelRepository classes
This commit is contained in:
6
game/services/LevelService.cs
Normal file
6
game/services/LevelService.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Mr.BrickAdventures.game.services;
|
||||
|
||||
public sealed class LevelService
|
||||
{
|
||||
|
||||
}
|
1
game/services/LevelService.cs.uid
Normal file
1
game/services/LevelService.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b2tsi3cjnh5xq
|
32
game/services/SaveService.cs
Normal file
32
game/services/SaveService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Mr.BrickAdventures.data;
|
||||
using Mr.BrickAdventures.game.repositories;
|
||||
|
||||
namespace Mr.BrickAdventures.game.services;
|
||||
|
||||
public sealed class SaveService
|
||||
{
|
||||
private readonly PlayerRepository _players;
|
||||
private readonly LevelRepository _levels;
|
||||
private readonly SaveClient _save;
|
||||
|
||||
public SaveService(PlayerRepository players, LevelRepository levels, SaveClient save) {
|
||||
_players = players; _levels = levels; _save = save;
|
||||
}
|
||||
|
||||
|
||||
public bool TryLoad() {
|
||||
if (!_save.TryLoad(out var p, out var l)) return false;
|
||||
_players.Load(p);
|
||||
_levels.Load(l);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Save() => _save.Save(_players.Export(), _levels.Export());
|
||||
public bool Exists() => _save.Exists();
|
||||
|
||||
public void NewGame() {
|
||||
_players.Load(new PlayerState { Coins = 0, Lives = 3 });
|
||||
_levels.Load(new LevelState { Current = 0, Unlocked = [0], Completed = [] });
|
||||
Save();
|
||||
}
|
||||
}
|
1
game/services/SaveService.cs.uid
Normal file
1
game/services/SaveService.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dxqkxlkkivxog
|
6
game/services/SkillService.cs
Normal file
6
game/services/SkillService.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Mr.BrickAdventures.game.services;
|
||||
|
||||
public sealed class SkillService
|
||||
{
|
||||
|
||||
}
|
1
game/services/SkillService.cs.uid
Normal file
1
game/services/SkillService.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dim21hs12wdi5
|
Reference in New Issue
Block a user