gameServer/EngineInteraction.hs
changeset 10017 de822cd3df3a
parent 9690 6a1748b71df2
child 10040 4ac87acbaed9
equal deleted inserted replaced
10015:4feced261c68 10017:de822cd3df3a
    40         check Nothing = (B.empty, B.empty, Nothing)
    40         check Nothing = (B.empty, B.empty, Nothing)
    41         check (Just msgs) = let (a, b) = (filter isLegal msgs, filter isNonEmpty a) in (encode a, encode b, lft a)
    41         check (Just msgs) = let (a, b) = (filter isLegal msgs, filter isNonEmpty a) in (encode a, encode b, lft a)
    42         encode = B.pack . Base64.encode . BW.unpack . B.concat
    42         encode = B.pack . Base64.encode . BW.unpack . B.concat
    43         isLegal m = (B.length m > 1) && (flip Set.member legalMessages . B.head . B.tail $ m)
    43         isLegal m = (B.length m > 1) && (flip Set.member legalMessages . B.head . B.tail $ m)
    44         lft = foldr l Nothing
    44         lft = foldr l Nothing
    45         l m n = let m' = B.head $ B.tail m; tst = flip Set.member in 
    45         l m n = let m' = B.head $ B.tail m; tst = flip Set.member in
    46                       if not $ tst timedMessages m' then n
    46                       if not $ tst timedMessages m' then n
    47                         else if '+' /= m' then Just Nothing else Just . Just . B.pack . Base64.encode . BW.unpack $ m
    47                         else if '+' /= m' then Just Nothing else Just . Just . B.pack . Base64.encode . BW.unpack $ m
    48         isNonEmpty = (/=) '+' . B.head . B.tail
    48         isNonEmpty = (/=) '+' . B.head . B.tail
    49         legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtghbc12345" ++ slotMessages
    49         legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtghbc12345" ++ slotMessages
    50         slotMessages = "\128\129\130\131\132\133\134\135\136\137\138"
    50         slotMessages = "\128\129\130\131\132\133\134\135\136\137\138"