package Organisms2.g4;

import Organisms2.*;
import java.awt.Color;

abstract public class Group4Wrapper implements IFCPlayer {
    Entity entity;
    Color _my_color = new Color(1.0f,1.0f,0f);
    Color _my_sending_color = new Color(0.5f,0.5f,0f);
    Color _my_receiving_color = new Color(0.6f,0.6f,0.4f);

    public void register( Organisms2 g, int key ) throws Exception {
    }

    public String name() throws Exception {
        return "Tequila";
    }

    public Color color() throws Exception {
        if ( entity.sending() )
            return _my_sending_color;
        if ( entity.listening() )
            return _my_receiving_color;
        return _my_color;
    }

    public boolean interactive() throws Exception {
        return false;
    }

    public Move move( boolean[] foodpresent, int[] enemypresent, 
                      int foodleft, int energyleft  ) throws Exception {

        int ret = entity.move( foodpresent, enemypresent, foodleft, energyleft );
        switch ( ret )
        {
        case Entity.EAST | Entity.MOVE:
            return new Move( _CEAST );

        case Entity.WEST | Entity.MOVE:
            return new Move( _CWEST );

        case Entity.SOUTH | Entity.MOVE:
            return new Move( _CSOUTH );

        case Entity.NORTH | Entity.MOVE:
            return new Move( _CNORTH );

        case Entity.EAST | Entity.CLONE:
            return new Move( _CREPRODUCE, _CEAST, entity.cloneAttr() );

        case Entity.WEST | Entity.CLONE:
            return new Move( _CREPRODUCE, _CWEST, entity.cloneAttr() );

        case Entity.SOUTH | Entity.CLONE:
            return new Move( _CREPRODUCE, _CSOUTH, entity.cloneAttr() );

        case Entity.NORTH | Entity.CLONE:
            return new Move( _CREPRODUCE, _CNORTH, entity.cloneAttr() );

        default:
            return new Move( _CSTAYPUT );
        }
    }

    public int externalState() {
        return entity.talk();
    }
}
