ig.module(
    'game.entities.buttonnext'
)

.requires(
    'game.entities.button'
)

.defines(function(){
    
// Confirm an action.
EntityButtonnext = EntityButton.extend({
    
    animSheet: new ig.AnimationSheet( 'media/arrow_right.png', 42.5, 44 ),
    size: {x: 42.5, y:44}, // Size of sprite.
    parent_dialogue_box: null,
    id: -1,

    init: function( x, y, settings ) {
        this.parent( x, y, settings );
        
        this.addAnim( 'focus', 1, [1] ); // 1x1.
        this.addAnim( 'unfocus', 1, [0] ); // 1x1.

        this.id = settings.id;
    },

    mouseCollision: function() {
        this.parent();
    },
    
    action: function() {
        if(this.id === 0)
            ig.game.createGame();

        if(this.id === 2)
            ig.game.startGame();

        if(this.id === 1)
            ig.game.joinGame();

        if(this.id === 3) {
            ig.game.gamesocket.send(
            'joinGame',
            {
                key: ig.game.inputb.value
            }
            );
        }
        /*if(ig.game.name_input.value !== ""
        && ig.game.question_input.value !== "") {
            ig.game.gamesocket.send('msg', {name:ig.game.name_input.value, msg:ig.game.question_input.value});
            ig.game.name_input.value = "";
            ig.game.question_input.value = "";
        }*/
    },
})
});