insert players at end of list (preserve index numbers)

This commit is contained in:
Jonathan Lamothe
2019-09-28 01:46:28 -04:00
parent 767c9b9221
commit ac92182b20
3 changed files with 8 additions and 7 deletions

View File

@@ -149,7 +149,7 @@ addPlayer s = fromMaybe s $ do
pos = cps^.cpsPosition
player = newPlayer num name pos
Just $ s & database.dbPlayers
%~ (player:)
%~ (++[player])
-- | Awards the goal and assists to the players
recordGoalAssists :: ProgState -> ProgState

View File

@@ -182,7 +182,8 @@ selectPlayerPrompt pStr callback = Prompt
& cpsName .~ sStr
& cpsSuccessCallback .~ do
modify $ progMode .~ mode
callback (Just 0)
pIndex <- pred . length <$> gets (view $ database.dbPlayers)
callback $ Just pIndex
& cpsFailureCallback .~ do
modify $ progMode .~ mode
callback Nothing