Skip to content

Commit

Permalink
refactor: added conversion destroyedShips from and to Nim
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 5eebe4b7c1a76bee4dc20cd227d23e85dfd96e09e09b4d18f17b39350c43e232
  • Loading branch information
thindil committed Aug 7, 2023
1 parent 5582921 commit 83c68c2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/statistics.adb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ package body Statistics is
To_String(Source => Game_Stats.Killed_Mobs(I).Index)),
Amount => Game_Stats.Killed_Mobs(I).Amount);
end loop Get_Killed_Mobs_Loop;
elsif Name = "destroyedShips" then
Get_Destroyed_Ships_Loop :
for I in
Game_Stats.Destroyed_Ships.First_Index ..
Game_Stats.Destroyed_Ships.Last_Index loop
Nim_List(I - 1) :=
(Index =>
New_String
(Str =>
To_String(Source => Game_Stats.Destroyed_Ships(I).Index)),
Amount => Game_Stats.Destroyed_Ships(I).Amount);
end loop Get_Destroyed_Ships_Loop;
end if;
Get_Ada_Game_Stats_List
(N => New_String(Str => Name), Stats_List => Nim_List);
Expand Down Expand Up @@ -193,6 +205,17 @@ package body Statistics is
To_Unbounded_String(Source => Value(Item => Mob.Index)),
Amount => Mob.Amount));
end loop Set_Killed_Mobs_Loop;
elsif Name = "destroyedShips" then
Game_Stats.Destroyed_Ships.Clear;
Set_Destroyed_Ships_Loop :
for Mob of Nim_List loop
exit Set_Destroyed_Ships_Loop when Strlen(Item => Mob.Index) = 0;
Game_Stats.Destroyed_Ships.Append
(New_Item =>
(Index =>
To_Unbounded_String(Source => Value(Item => Mob.Index)),
Amount => Mob.Amount));
end loop Set_Destroyed_Ships_Loop;
end if;
end Set_Game_Stats_List;

Expand Down

0 comments on commit 83c68c2

Please sign in to comment.