/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package database.encoding;

import java.io.Serializable;
import woaley.Woaley;

/**
 *
 * @author Ani
 */
public class Encode implements Serializable{
    private Woaley state;
    private String code = "";

    public Encode(Woaley state) {
        this.state = state;
        encode();
    }

    private void encode(){
        encodePlayer();
        encodeContinuous();
        encodePosition();
        encodeGameTable();
    }

    private void encodePlayer(){
        code += state.getPlayer().getPlayer();
    }

    private void encodeContinuous(){
        if (state.getContinuous()){
            code += "T";
        }
        else{
            code += "F";
        }
    }

    private void encodePosition(){
        code += state.getPosition().getRow();
        code += state.getPosition().getHouse();
    }

    private void encodeGameTable(){
        for (int i=1; i<3; i++){
            for (int j=1; j<7; j++){
                code += CharacterTable.numbertable.get(state.getBoard()[i][j]);
            }
            code += CharacterTable.numbertable.get(state.getCollectors()[i]);
        }
    }

    public String getCode() {
        return code;
    }




}
