|
1 | 1 | using System.Diagnostics; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Runtime.InteropServices; |
4 | | -using System.Linq; |
| 2 | +using System.Net.NetworkInformation; |
5 | 3 | using Serilog; |
6 | 4 |
|
7 | 5 | namespace C7Engine { |
8 | | - using System; |
9 | 6 | using System.Threading.Tasks; |
10 | 7 | using C7GameData; |
11 | 8 |
|
@@ -39,7 +36,7 @@ internal static async Task AdvanceTurn() { |
39 | 36 | //at the same place in the order. Confirmed this is what Civ3 does. |
40 | 37 | UnitInteractions.ClearWaitQueue(); |
41 | 38 |
|
42 | | - SpawnBarbarians(gameData); |
| 39 | + BarbarianInteractions.SpawnBarbarians(gameData); |
43 | 40 |
|
44 | 41 | gameData.turn++; |
45 | 42 | foreach (Player player in gameData.players) { |
@@ -109,42 +106,6 @@ private static async Task<bool> PlayPlayerTurns(GameData gameData, bool firstTur |
109 | 106 | return false; |
110 | 107 | } |
111 | 108 |
|
112 | | - private static void SpawnBarbarians(GameData gameData) { |
113 | | - Player barbPlayer = gameData.players.Find(player => player.isBarbarians); |
114 | | - |
115 | | - // A random 5% of camps will spawn a unit each turn. Shuffle the |
116 | | - // camps to make this random. |
117 | | - int barbariansToSpawn = (int)Math.Ceiling(GameData.rng.Next(gameData.map.barbarianCamps.Count) / 20.0); |
118 | | - List<int> tileIndicies = Enumerable.Range(0, gameData.map.barbarianCamps.Count).ToList(); |
119 | | - GameData.rng.Shuffle<int>(CollectionsMarshal.AsSpan(tileIndicies)); |
120 | | - |
121 | | - for (int i = 0; i < barbariansToSpawn; ++i) { |
122 | | - Tile tile = gameData.map.barbarianCamps[tileIndicies[i]]; |
123 | | - |
124 | | - // Its a 3:1 ratio of advanced to basic barbarians. |
125 | | - UnitPrototype unitType = GameData.rng.Next(100) < 25 ? gameData.barbarianInfo.advancedBarbarian : gameData.barbarianInfo.basicBarbarian; |
126 | | - // Give costal camps a chance to spawn a boat. |
127 | | - if (tile.NeighborsWater() && GameData.rng.Next(100) < 20) { |
128 | | - unitType = gameData.barbarianInfo.barbarianSeaUnitProto; |
129 | | - } |
130 | | - |
131 | | - MapUnit newUnit = unitType.GetInstance(gameData); |
132 | | - newUnit.location = tile; |
133 | | - newUnit.owner = barbPlayer; |
134 | | - newUnit.nationality = barbPlayer.civilization; |
135 | | - // TODO: make this a conscript. |
136 | | - newUnit.experienceLevelKey = gameData.defaultExperienceLevelKey; |
137 | | - newUnit.experienceLevel = gameData.defaultExperienceLevel; |
138 | | - newUnit.hitPointsRemaining = 3; |
139 | | - |
140 | | - tile.unitsOnTile.Add(newUnit); |
141 | | - gameData.mapUnits.Add(newUnit); |
142 | | - barbPlayer.units.Add(newUnit); |
143 | | - |
144 | | - log.Debug("New barbarian of type {type} added at {tile}", unitType.name, tile); |
145 | | - } |
146 | | - } |
147 | | - |
148 | 109 | ///Eventually we'll have a game year or month or whatever, but for now this provides feedback on our progression |
149 | 110 | public static int GetTurnNumber() { |
150 | 111 | return EngineStorage.gameData.turn; |
|
0 commit comments