package org.drools.games.adventures

import java.util.List

import org.drools.games.adventures.Character
import org.drools.games.adventures.Room
import org.drools.games.adventures.Location

query connect( Room $x, Room $y ) 
    Door($id, $x, $y;)
    or 
    Door($id, $y, $x;)
end

query isContainedIn( Thing $x, Thing $y ) 
    Location($x, $y;)
    or 
    ( Location($z, $y;) and ?isContainedIn($x, $z;) )
end

query things(Character $char, List $things)
    $char := Character()
    Location( $char, $room; )
    $things := List() from accumulate( Location($thing, $room; thing != $char),
                                       collectList( $thing ) )      
end

query exits(Character $char, List $exits)
    $char := Character()
    Location( $char, $room; )
    $exits := List() from accumulate( connect($room, $exit;),
                                      collectList( $exit ) )      
end

query look(Character $char, Room $room, List $things, List $exits) 
   $char := Character()
   Location( $char, $room; )
   things( $char, $things; )
   exits( $char, $exits; )
end

query inventory(Character $char, List $inventory) 
    $char := Character()    
    $inventory := List() from accumulate( Holding( $char, $thing; ),
                                          collectList( $thing ) )   
end