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