409 cl <- thisClient |
409 cl <- thisClient |
410 let m = readInt_ n |
410 let m = readInt_ n |
411 if not $ isMaster cl then |
411 if not $ isMaster cl then |
412 return [Warning $ loc "You're not the room master!"] |
412 return [Warning $ loc "You're not the room master!"] |
413 else if m < 2 || m > cMaxTeams then |
413 else if m < 2 || m > cMaxTeams then |
414 return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/maxteams: specify number from 2 to 8"]] |
414 return [Warning $ loc "/maxteams: specify number from 2 to 8"] |
415 else |
415 else |
416 return [ModifyRoom (\r -> r{teamsNumberLimit = m})] |
416 return [ModifyRoom (\r -> r{teamsNumberLimit = m})] |
417 |
417 |
418 handleCmd_inRoom ["FIX"] = serverAdminOnly $ |
418 handleCmd_inRoom ["FIX"] = serverAdminOnly $ |
419 return [ModifyRoom (\r -> r{isSpecial = True})] |
419 return [ModifyRoom (\r -> r{isSpecial = True})] |
455 |
455 |
456 handleCmd_inRoom ["CALLVOTE", "KICK"] = do |
456 handleCmd_inRoom ["CALLVOTE", "KICK"] = do |
457 cl <- thisClient |
457 cl <- thisClient |
458 rm <- thisRoom |
458 rm <- thisRoom |
459 return |
459 return |
460 [AnswerClients [sendChan cl] ["CHAT", nickServer, |
460 [Warning $ |
461 if isJust $ masterID rm then |
461 if isJust $ masterID rm then |
462 loc "/callvote kick: This is only allowed in rooms without a room master." |
462 loc "/callvote kick: This is only allowed in rooms without a room master." |
463 else |
463 else |
464 loc "/callvote kick: You need to specify a nickname." |
464 loc "/callvote kick: You need to specify a nickname." |
465 ]] |
465 ] |
466 |
466 |
467 handleCmd_inRoom ["CALLVOTE", "KICK", nickname] = do |
467 handleCmd_inRoom ["CALLVOTE", "KICK", nickname] = do |
468 (thisClientId, rnc) <- ask |
468 (thisClientId, rnc) <- ask |
469 cl <- thisClient |
469 cl <- thisClient |
470 rm <- thisRoom |
470 rm <- thisRoom |
471 maybeClientId <- clientByNick nickname |
471 maybeClientId <- clientByNick nickname |
472 let kickId = fromJust maybeClientId |
472 let kickId = fromJust maybeClientId |
473 let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId |
473 let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId |
474 |
474 |
475 if isJust $ masterID rm then |
475 if isJust $ masterID rm then |
476 return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote kick: This is only allowed in rooms without a room master."]] |
476 return [Warning $ loc "/callvote kick: This is only allowed in rooms without a room master."] |
477 else |
477 else |
478 if isJust maybeClientId && sameRoom then |
478 if isJust maybeClientId && sameRoom then |
479 startVote $ VoteKick nickname |
479 startVote $ VoteKick nickname |
480 else |
480 else |
481 return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote kick: No such user!"]] |
481 return [Warning $ loc "/callvote kick: No such user!"] |
482 |
482 |
483 |
483 |
484 handleCmd_inRoom ["CALLVOTE", "MAP"] = do |
484 handleCmd_inRoom ["CALLVOTE", "MAP"] = do |
485 -- Display list of available maps for voting |
485 -- Display list of available maps for voting |
486 cl <- thisClient |
486 cl <- thisClient |
499 rm <- thisRoom |
499 rm <- thisRoom |
500 |
500 |
501 if Map.member roomSave $ roomSaves rm then |
501 if Map.member roomSave $ roomSaves rm then |
502 startVote $ VoteMap roomSave |
502 startVote $ VoteMap roomSave |
503 else |
503 else |
504 return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote map: No such map!"]] |
504 return [Warning $ loc "/callvote map: No such map!"] |
505 |
505 |
506 |
506 |
507 handleCmd_inRoom ["CALLVOTE", "PAUSE"] = do |
507 handleCmd_inRoom ["CALLVOTE", "PAUSE"] = do |
508 cl <- thisClient |
508 cl <- thisClient |
509 rm <- thisRoom |
509 rm <- thisRoom |
510 |
510 |
511 if isJust $ gameInfo rm then |
511 if isJust $ gameInfo rm then |
512 startVote VotePause |
512 startVote VotePause |
513 else |
513 else |
514 return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote pause: No game in progress!"]] |
514 return [Warning $ loc "/callvote pause: No game in progress!"] |
515 |
515 |
516 handleCmd_inRoom ["CALLVOTE", "PAUSE", _] = handleCmd_inRoom ["CALLVOTE", "PAUSE"] |
516 handleCmd_inRoom ["CALLVOTE", "PAUSE", _] = handleCmd_inRoom ["CALLVOTE", "PAUSE"] |
517 |
517 |
518 handleCmd_inRoom ["CALLVOTE", "NEWSEED"] = do |
518 handleCmd_inRoom ["CALLVOTE", "NEWSEED"] = do |
519 startVote VoteNewSeed |
519 startVote VoteNewSeed |
520 |
520 |
521 handleCmd_inRoom ["CALLVOTE", "NEWSEED", _] = handleCmd_inRoom ["CALLVOTE", "NEWSEED"] |
521 handleCmd_inRoom ["CALLVOTE", "NEWSEED", _] = handleCmd_inRoom ["CALLVOTE", "NEWSEED"] |
522 |
522 |
523 handleCmd_inRoom ["CALLVOTE", "HEDGEHOGS"] = do |
523 handleCmd_inRoom ["CALLVOTE", "HEDGEHOGS"] = do |
524 cl <- thisClient |
524 cl <- thisClient |
525 return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote hedgehogs: Specify number from 1 to 8."]] |
525 return [Warning $ loc "/callvote hedgehogs: Specify number from 1 to 8."] |
526 |
526 |
527 |
527 |
528 handleCmd_inRoom ["CALLVOTE", "HEDGEHOGS", hhs] = do |
528 handleCmd_inRoom ["CALLVOTE", "HEDGEHOGS", hhs] = do |
529 cl <- thisClient |
529 cl <- thisClient |
530 let h = readInt_ hhs |
530 let h = readInt_ hhs |
531 |
531 |
532 if h > 0 && h <= cHogsPerTeam then |
532 if h > 0 && h <= cHogsPerTeam then |
533 startVote $ VoteHedgehogsPerTeam h |
533 startVote $ VoteHedgehogsPerTeam h |
534 else |
534 else |
535 return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote hedgehogs: Specify number from 1 to 8."]] |
535 return [Warning $ loc "/callvote hedgehogs: Specify number from 1 to 8."] |
536 |
536 |
537 handleCmd_inRoom ["CALLVOTE", _] = handleCmd_inRoom ["CALLVOTE"] |
537 handleCmd_inRoom ["CALLVOTE", _] = handleCmd_inRoom ["CALLVOTE"] |
538 handleCmd_inRoom ["CALLVOTE", _, _] = handleCmd_inRoom ["CALLVOTE"] |
538 handleCmd_inRoom ["CALLVOTE", _, _] = handleCmd_inRoom ["CALLVOTE"] |
539 |
539 |
540 handleCmd_inRoom ("VOTE" : m : p) = do |
540 handleCmd_inRoom ("VOTE" : m : p) = do |
541 cl <- thisClient |
541 cl <- thisClient |
542 let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing |
542 let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing |
543 if isJust b then |
543 if isJust b then |
544 voted (p == ["FORCE"]) (fromJust b) |
544 voted (p == ["FORCE"]) (fromJust b) |
545 else |
545 else |
546 return [AnswerClients [sendChan cl] ["CHAT", nickServer, |
546 return [Warning $ |
547 if (p == ["FORCE"]) then |
547 if (p == ["FORCE"]) then |
548 loc "/force: Please use 'yes' or 'no'." |
548 loc "/force: Please use 'yes' or 'no'." |
549 else |
549 else |
550 loc "/vote: Please use 'yes' or 'no'." |
550 loc "/vote: Please use 'yes' or 'no'." |
551 ]] |
551 ] |
552 |
552 |
553 |
553 |
554 handleCmd_inRoom ["SAVE", stateName, location] = serverAdminOnly $ do |
554 handleCmd_inRoom ["SAVE", stateName, location] = serverAdminOnly $ do |
555 return [ModifyRoom $ \r -> r{roomSaves = Map.insert stateName (location, mapParams r, params r) (roomSaves r)}] |
555 return [ModifyRoom $ \r -> r{roomSaves = Map.insert stateName (location, mapParams r, params r) (roomSaves r)}] |
556 |
556 |