@@ -149,8 +149,9 @@ defmodule BotManager.GameSocketHandler do
149
149
obstacles =
150
150
state . game_state . obstacles
151
151
|> Enum . map ( fn { obstacle_id , obstacle } ->
152
- { obstacle_id ,
153
- Map . take ( Map . from_struct ( obstacle ) , [
152
+ obstacle = obstacle
153
+ |> Map . from_struct ( )
154
+ |> Map . take ( [
154
155
:id ,
155
156
:shape ,
156
157
:position ,
@@ -161,27 +162,16 @@ defmodule BotManager.GameSocketHandler do
161
162
:direction ,
162
163
:is_moving ,
163
164
:name
164
- ] ) }
165
- end )
166
- |> Enum . map ( fn { obstacle_id , obstacle } ->
167
- { obstacle_id , Map . put ( obstacle , :position , % { x: obstacle . position . x , y: obstacle . position . y } ) }
168
- end )
169
- |> Enum . map ( fn { obstacle_id , obstacle } ->
170
- { obstacle_id ,
171
- Map . put (
172
- obstacle ,
173
- :vertices ,
174
- Enum . map ( obstacle . vertices . positions , fn position -> % { x: position . x , y: position . y } end )
175
- ) }
176
- end )
177
- |> Enum . map ( fn { obstacle_id , obstacle } ->
178
- { obstacle_id , Map . put ( obstacle , :direction , % { x: obstacle . direction . x , y: obstacle . direction . y } ) }
179
- end )
180
- |> Enum . map ( fn { obstacle_id , obstacle } ->
181
- { obstacle_id , Map . put ( obstacle , :shape , get_shape ( obstacle . shape ) ) }
182
- end )
183
- |> Enum . map ( fn { obstacle_id , obstacle } ->
184
- { obstacle_id , Map . put ( obstacle , :category , get_category ( obstacle . category ) ) }
165
+ ] )
166
+
167
+ obstacle = obstacle
168
+ |> Map . put ( :position , % { x: obstacle . position . x , y: obstacle . position . y } )
169
+ |> Map . put ( :vertices , Enum . map ( obstacle . vertices . positions , fn position -> % { x: position . x , y: position . y } end ) )
170
+ |> Map . put ( :direction , % { x: obstacle . direction . x , y: obstacle . direction . y } )
171
+ |> Map . put ( :shape , get_shape ( obstacle . shape ) )
172
+ |> Map . put ( :category , get_category ( obstacle . category ) )
173
+
174
+ { obstacle_id , obstacle }
185
175
end )
186
176
|> Map . new ( )
187
177
0 commit comments