/***********************************************************************

GECCO, a platform for command and control gaming

Copyright (C) 2001 Henrik Bäärnhielm, Andreas Enblom, Niklas
Hallenfur, Karl Hasselström, Henrik Hägerström, Oskar Linde, Jing Fu
Zi and Jon Åslund

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.

***********************************************************************/

package gecco.server.automaton;

import gecco.server.core.UnitEvent;

/**
 *  This class represents a return from an automaton update call, that indicates
 *  that certain neighbours of the automaton should be inserted into the queue.
 *
 * @author     Henrik Bäärnhielm, Karl Hasselström, Henrik Hägerström
 * @created    April 23, 2001
 */
public class AutomatonReturnQueueSelective extends AutomatonReturn {

    /**
     *  Description of the Field
     */
    private long[][] timeToExecutions;


    /**
     *  Constructor for the AutomatonReturnQueueSelective object
     *
     * @param  timeToExecutionsArray  The 3x3 array with the times for each
     *      neighbour (including the automaton itself).
     */
    public AutomatonReturnQueueSelective(double[][] timeToExecutionsArray) {
        // Check array dimensions
        if (timeToExecutionsArray.length != 3) {
            throw new IllegalArgumentException("Array dimensions doesn't match, has to be 3x3!");
        }
        if (timeToExecutionsArray[0].length != 3) {
            throw new IllegalArgumentException("Array dimensions doesn't match, has to be 3x3!");
        }

        // Convert double to long
        timeToExecutions = new long[3][3];
        for (int x = 0; x < 3; x++) {
            for (int y = 0; y < 3; y++) {
                timeToExecutions[x][y] = Math.round(timeToExecutionsArray[x][y] * 1000);
            }
        }
    }


    /**
     *  Constructor for the AutomatonReturnQueueSelective object
     *
     * @param  timeToExecutionsArray  The 3x3 array with the times for each
     *      neighbour (including the automaton itself).
     * @param  unitEvent              A unit event for any units on the
     *      automaton.
     */
    public AutomatonReturnQueueSelective(double[][] timeToExecutionsArray, UnitEvent unitEvent) {
        this(timeToExecutionsArray);
        event = unitEvent;
    }


    /**
     *  Gets the TimeToExecutions attribute of the AutomatonReturnQueueSelective
     *  object
     *
     * @return    The TimeToExecutions value
     */
    public long[][] getTimeToExecutions() {
        return timeToExecutions;
    }


}
