Skip to content

Commit a793668

Browse files
committed
fix foes sort order
1 parent cba27c2 commit a793668

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Update.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fightWithWeapon foe model =
240240
{ model
241241
| playerHealth = newHealth
242242
, room = newRoom
243-
, stackedFoes = foe :: model.stackedFoes -- Add foe to stacked list
243+
, stackedFoes = model.stackedFoes ++ [foe]
244244
, draggedCard = Nothing
245245
}
246246
else

src/View.elm

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,15 @@ onDrop target =
231231
-- Function to view stacked foes with offset
232232
viewStackedFoes : List Card -> List (Html Msg)
233233
viewStackedFoes stackedFoes =
234-
List.indexedMap
235-
(\index foe ->
236-
div
237-
[ class "stacked-foe"
238-
, style "left" (String.fromInt (index * 30) ++ "px")
239-
, style "top" (String.fromInt (index * 10) ++ "px")
240-
, style "z-index" (String.fromInt (10 + index))
241-
]
242-
[ viewCard foe False ]
243-
)
244-
stackedFoes
234+
stackedFoes
235+
|> List.reverse
236+
|> List.indexedMap
237+
(\index foe ->
238+
div
239+
[ class "stacked-foe"
240+
, style "left" (String.fromInt (index * 30) ++ "px")
241+
, style "top" (String.fromInt ((index * 10) - 20) ++ "px")
242+
, style "z-index" (String.fromInt (10 - index))
243+
]
244+
[ viewCard foe False ]
245+
)

0 commit comments

Comments
 (0)