package kamiworldserver.comm;

import kamiworldserver.elem.KamiUser;

public class KamiCommand {

    private KamiUser ku_Caller;
    private int nID;
    Object[] aFields;

    //
    // Constructor
    public KamiCommand() {
        nID = -1;
        aFields = new Object[32];
    }

    public void setID(int i) {
        nID = i;
    }

    public int getID() {
        return nID;
    }

    public void set(int i, Object o) {
        aFields[i] = o;
    }

    public Object get(int i) {
        return aFields[i];
    }

    public void setCaller(KamiUser ku) {
        ku_Caller = ku;
    }

    public KamiUser getCaller() {
        return ku_Caller;
    }

    // =========================================================================
    // Misc.
    //
    public void clear() {
        byte i = 0;
        while (i < aFields.length) {
            aFields[i] = null;
            ++i;
        }
    }
    @Override
    public KamiCommand clone() {
        KamiCommand kc = new KamiCommand();
        kc.setCaller(ku_Caller);
        kc.setID(nID);
        byte i = 0;
        while (i < aFields.length) {
            kc.set(i, aFields[i]);
            ++i;
        }
        return kc;
    }

    @Override
    public String toString() {
        String s = "" + getID() + "[";
        byte i = 0;
        while (i < aFields.length) {
            if (aFields[i] == null) {
                return s + "]";
            }
            s += aFields[i] + ",";
            ++i;
        }
        return s + "]";
    }
}
