package org.drools.games.wumpus.server;

import org.drools.games.wumpus.ShootCommand;
import org.drools.games.wumpus.Hero;
import org.drools.games.wumpus.Arrow;
import org.drools.games.wumpus.Direction;
import org.drools.games.wumpus.Wumpus;
import org.drools.games.wumpus.Cell;
import org.drools.games.wumpus.HearScream;

dialect "mvel"

rule "Wumpus Killed" agenda-group "Shoot" when
    $a  : Arrow()
    $w  : Wumpus(row == $a.row, col == $a.col, alive == true )
    $c  : Cell(row == $a.row, col == $a.col )
then
    retract( $a );
    insert( new HearScream() );
    modify( $w ) { alive = false };
end

rule "Cave Boundary, Remove Arrow" agenda-group "Shoot"  when
     $a : Arrow()
     not Cell(row == $a.row, col == $a.col )
then
    retract ( $a );
end

rule "Move Arrow Up" agenda-group "Shoot"  when
     $a :  Arrow( direction == Direction.UP)    
then
    modify( $a ) { row = $a.row + 1 };
end   

rule "Move Arrow Down" agenda-group "Shoot"  when
     $a :  Arrow( direction == Direction.DOWN)    
then
    modify( $a ) { row = $a.row - 1 };
end   

rule "Move Arrow Left" agenda-group "Shoot"  when
     $a :  Arrow( direction == Direction.LEFT)    
then
    modify( $a ) { col = $a.col - 1 };
end    

rule "Move Arrow Right" agenda-group "Shoot" when
     $a :  Arrow( direction == Direction.RIGHT)
then
    modify( $a ) { col = $a.col + 1 };
end  

