-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue wih duplicate IDs by introducing the IdGen abstraction for …
…generating all IDs
- Loading branch information
Konrad Jamrozik
committed
Jun 14, 2024
1 parent
4e4fd0e
commit e437389
Showing
15 changed files
with
119 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace UfoGameLib.Lib; | ||
|
||
public class IdGen | ||
{ | ||
protected int NextId; | ||
|
||
public int Generate => NextId++; | ||
|
||
public int Value => NextId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using UfoGameLib.Lib; | ||
using UfoGameLib.State; | ||
|
||
namespace UfoGameLib.Model; | ||
|
||
public class AgentIdGen : IdGen | ||
{ | ||
public AgentIdGen(List<GameSessionTurn> turns) | ||
{ | ||
NextId = turns.Last().EndState.AllAgents.Count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Lib.Contracts; | ||
using UfoGameLib.Lib; | ||
using UfoGameLib.State; | ||
|
||
namespace UfoGameLib.Model; | ||
|
||
public class MissionIdGen : IdGen | ||
{ | ||
public MissionIdGen(List<GameSessionTurn> turns) | ||
{ | ||
Contract.Assert(turns.Any()); | ||
NextId = turns.Last().EndState.Missions.Count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Lib.Contracts; | ||
using UfoGameLib.Lib; | ||
using UfoGameLib.State; | ||
|
||
namespace UfoGameLib.Model; | ||
|
||
public class MissionSiteIdGen : IdGen | ||
{ | ||
public MissionSiteIdGen(List<GameSessionTurn> turns) | ||
{ | ||
Contract.Assert(turns.Any()); | ||
NextId = turns.Last().EndState.MissionSites.Count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters