Skip to content

Commit a188126

Browse files
committed
Add full passenger parsing
1 parent 8f0cc7a commit a188126

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

socha-backend/Starter.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,17 @@ static void ExecuteCommunationLoop(NetworkStream stream)
199199
var curNode = s.Fieldarray[x].ChildNodes[y];
200200
if (!Enum.TryParse(curNode.Name, out FieldType ft))
201201
throw new Exception("Cant parse this field type " + curNode.Name);
202+
Direction? dirOut = null;
203+
int? passengers = null;
204+
if (ft == FieldType.passenger)
205+
{
206+
if (!Enum.TryParse(curNode.Attributes["direction"].Value, out Direction dir))
207+
throw new Exception($"Cant parse this field types direction {curNode.Name}, {curNode.Attributes["direction"]?.Value}");
208+
dirOut = dir;
209+
passengers = Convert.ToInt32(curNode.Attributes["passenger"].Value);
210+
}
202211
var fieldCoords = centerCoords + Cache.segOffsets[y][x].RotateByDir(s.Direction);
203-
gameState.Board.SetField(fieldCoords, new Field(ft, y == 2, fieldCoords, gameState.Board));
212+
gameState.Board.SetField(fieldCoords, new Field(ft, y == 2, fieldCoords, gameState.Board, dirOut, passengers));
204213
}
205214
}
206215

0 commit comments

Comments
 (0)