{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE FlexibleInstances #-} module Object where import Affection as A import Control.Monad (when) import Data.Ecstasy import Data.Maybe import Linear -- internal imports import Types import Object.Computer import Object.Copier instance ObjectAction ObjType ObjState where objectAction dt t@ObjCopier s ent = copierObjectAction dt t s ent objectAction dt t@ObjComputer s ent = computerObjectAction dt t s ent objectAction _ _ _ _ = return () objectTransition t@ObjCopier s pa ent aent = copierObjectTransition t s pa ent aent objectTransition t@ObjComputer s pa ent aent = computerObjectTransition t s pa ent aent objectTransition _ _ _ _ _ = return unchanged instance ActionTime ObjType ObjState where actionTime ObjCopier "copying" = 5 actionTime ObjComputer "off" = 0 actionTime ObjComputer "on" = 20 actionTime ObjComputer "hack" = 20 actionTime o s = A.log Error (show o ++ ": " ++ s ++ ": has not a time") 0