Skip to content

Commit

Permalink
Track the techs known by each player, starting with their civ's free …
Browse files Browse the repository at this point in the history
…techs
  • Loading branch information
TomWerner committed Jan 24, 2025
1 parent b0db5ff commit 49b793d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
28 changes: 28 additions & 0 deletions C7/Text/c7-static-map-save.json
Original file line number Diff line number Diff line change
Expand Up @@ -61588,6 +61588,10 @@
"y": 45
}
],
"knownTechs": [
"tech-3",
"tech-2"
],
"turnsUntilPriorityReevaluation": 0
},
{
Expand Down Expand Up @@ -61652,6 +61656,10 @@
"y": 30
}
],
"knownTechs": [
"tech-4",
"tech-2"
],
"turnsUntilPriorityReevaluation": 0
},
{
Expand Down Expand Up @@ -61712,6 +61720,10 @@
"y": 62
}
],
"knownTechs": [
"tech-6",
"tech-4"
],
"turnsUntilPriorityReevaluation": 0
},
{
Expand Down Expand Up @@ -61776,6 +61788,10 @@
"y": 48
}
],
"knownTechs": [
"tech-4",
"tech-2"
],
"turnsUntilPriorityReevaluation": 0
},
{
Expand Down Expand Up @@ -61844,6 +61860,10 @@
"y": 75
}
],
"knownTechs": [
"tech-1",
"tech-2"
],
"turnsUntilPriorityReevaluation": 0
},
{
Expand Down Expand Up @@ -61908,6 +61928,10 @@
"y": 56
}
],
"knownTechs": [
"tech-2",
"tech-4"
],
"turnsUntilPriorityReevaluation": 0
},
{
Expand Down Expand Up @@ -61968,6 +61992,10 @@
"y": 78
}
],
"knownTechs": [
"tech-4",
"tech-3"
],
"turnsUntilPriorityReevaluation": 0
}
],
Expand Down
4 changes: 4 additions & 0 deletions C7GameData/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class Player {

//Ordered list of priority data. First is most important.
public List<StrategicPriority> strategicPriorityData = new List<StrategicPriority>();

// The list of techs known by this player.
public List<ID> knownTechs = new();

public int turnsUntilPriorityReevaluation = 0;

public void AddUnit(MapUnit unit) {
Expand Down
10 changes: 10 additions & 0 deletions C7GameData/Save/SavePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class SavePlayer {

public List<TileLocation> tileKnowledge = new List<TileLocation>();

// The list of techs known by this player.
public List<ID> knownTechs = new();

public int turnsUntilPriorityReevaluation = 0;

public Player ToPlayer(GameMap map, List<Civilization> civilizations) {
Expand All @@ -26,10 +29,16 @@ public Player ToPlayer(GameMap map, List<Civilization> civilizations) {
civilization = civilization is not null ? civilizations.Find(civ => civ.name == civilization) : null,
cityNameIndex = cityNameIndex,
tileKnowledge = new TileKnowledge(),
knownTechs = knownTechs,
};
foreach (TileLocation tile in tileKnowledge) {
player.tileKnowledge.AddTileToKnown(map.tileAt(tile.x, tile.y));
}
foreach (ID techId in player.civilization.startingTechs) {
if (!player.knownTechs.Contains(techId)) {
player.knownTechs.Add(techId);
}
}
return player;
}

Expand All @@ -47,6 +56,7 @@ public SavePlayer(Player player) {
cityNameIndex = player.cityNameIndex;
tileKnowledge = player.tileKnowledge.AllKnownTiles().ConvertAll(tile => new TileLocation(tile));
turnsUntilPriorityReevaluation = player.turnsUntilPriorityReevaluation;
knownTechs = player.knownTechs;
}
}
}

0 comments on commit 49b793d

Please sign in to comment.