make wizards start randomly rotated
This commit is contained in:
parent
0f5101f7bb
commit
ddbdc0a6e5
3 changed files with 8 additions and 5 deletions
|
@ -23,6 +23,7 @@ import Server.Communication.Send
|
|||
import Server.Log
|
||||
import Server.Types
|
||||
import Server.Util
|
||||
import System.Random (randomRIO)
|
||||
|
||||
-- | function for translating 'ClientMessage's into server actions
|
||||
handleMessage
|
||||
|
@ -76,9 +77,10 @@ handleMessage stateContainer readerContainer msg = do
|
|||
ClientRequestWizard -> do
|
||||
let arena = rcMap readerContainer
|
||||
initPos <- rollInitPosition arena
|
||||
initRot <- randomRIO (0, 2 * pi)
|
||||
now <- liftIO getCurrentTime
|
||||
uuid <- nextRandom
|
||||
let freshWizard = newWizard initPos
|
||||
let freshWizard = newWizard initPos initRot
|
||||
STM.atomically $ do
|
||||
currentPlayers <- STM.readTMVar (scPlayers stateContainer)
|
||||
void $ STM.swapTMVar (scPlayers stateContainer) $
|
||||
|
|
|
@ -184,8 +184,8 @@ sendUpdate curLevel stateContainer tileMap player = do
|
|||
leftLine row = cos leftBound * row
|
||||
rightLine row = sin rightBound * row
|
||||
correctionLeft = if wizardRot < pi / 2 || wizardRot >= 2 * pi
|
||||
then floor
|
||||
else ceiling
|
||||
then ceiling
|
||||
else floor
|
||||
correctionRight = if wizardRot < pi / 2 || wizardRot >= 2 * pi
|
||||
then ceiling
|
||||
else floor
|
||||
|
|
|
@ -25,11 +25,12 @@ removeIfExists fileName = removeFile fileName `catch` handleExists
|
|||
|
||||
newWizard
|
||||
:: Position
|
||||
-> Float
|
||||
-> Wizard
|
||||
newWizard pos =
|
||||
newWizard pos rot =
|
||||
Wizard
|
||||
{ wizardWands = []
|
||||
, wizardRot = 0
|
||||
, wizardRot = rot
|
||||
, wizardPos = pos
|
||||
, wizardMana = 100
|
||||
, wizardHealth = 100
|
||||
|
|
Loading…
Reference in a new issue