package org.drools.examples.wumpus

import org.drools.examples.wumpus.Move
import org.drools.examples.wumpus.Cell

import org.drools.examples.wumpus.Wumpus
import org.drools.examples.wumpus.Pitt
import org.drools.examples.wumpus.Gold
import org.drools.examples.wumpus.SeeGlitter
import org.drools.examples.wumpus.SmellStench
import org.drools.examples.wumpus.WumpusDeath
import org.drools.examples.wumpus.PittDeath
import org.drools.examples.wumpus.GoldWin

dialect "mvel"


rule "Wumpus Death" when
    $h  : Hero()
          Wumpus(row == $h.row, col == $h.col, alive == true )
then
    insert( new WumpusDeath() );
end

rule "Wumpus Killed" no-loop when
    $a  : Arrow()
    $w  : Wumpus(row == $a.row, col == $a.col, alive == true )
    $c  : Cell(row == $a.row, col == $a.col )        
then
    $c.setHidden( false );     
    retract( $a );
    modify( $w ) { alive = false };
end

rule "Pitt Death" when
    $h  : Hero()
          Pitt(row == $h.row, col == $h.col )
then
    insert( new PittDeath() ); 
end

rule "Gold Win" when
    $h  : Hero()
          Gold(row == $h.row, col == $h.col )
then
    insert( new GoldWin() );
end