class LobbyBar extends Phaser.Scene {

    constructor ()
    {
        super({ key: 'LobbyBar', active: true });
    }
    
    preload()
    {
    }

    create (data)
    {
        this.parent = data.scene;
        this.vDelta = data.vDelta;

        this.abX = 625;
        this.abY = 658;
        
        if(this.vDelta == 0)
        {
            this.animBalance = new AnimatedAmount(this, this.abX, this.abY, data.fontBet, true);
            this.animBalance.setScale(1.0);

            this.bmTxtBalance = this.add.bitmapText(this.abX, 570, 'barLetters', 'BALANCE');
            this.bmTxtBalance.setScale(0.5);
        }
        else
        {
            this.animBalance = new AnimatedAmount(this, this.abX, this.abY + 540 +  this.vDelta, data.fontBet, true);
            this.animBalance.setScale(1.0);

            this.bmTxtBalance = this.add.bitmapText(this.abX, this.abY + 280 +  this.vDelta, 'barLetters', 'BALANCE');
            this.bmTxtBalance.setScale(1.0);
        }

        this.animBalance.setOrigin(0.5);

        this.bmTxtBalance.setOrigin(0.5);
        this.bmTxtBalance.letterSpacing = -10;
        
        this.scene.sleep();
    }
    
    onOrientationChange(v)
    {
        this.vDelta = v;

        if(this.vDelta == 0)
        {
            this.animBalance.setPosition(this.abX, this.abY + this.vDelta);
            this.animBalance.setScale(1.0);

            this.bmTxtBalance.setPosition(this.abX, 570);
            this.bmTxtBalance.setScale(0.5);
        }
        else
        {
            this.animBalance.setPosition(this.abX, this.abY + 465 + this.vDelta);
            this.animBalance.setScale(1.75);

            this.bmTxtBalance.setPosition(this.abX, this.abY + 280 + this.vDelta);
            this.bmTxtBalance.setScale(1.0);
        }
    }

    updateBalance(v)
    {
        if(v == this.animBalance.value())
        {
            return;
        }

        this.animBalance.reset(v);
    }

    update(time, delta) 
    {
        this.animBalance.update(delta, this.parent.gameSocket.getBalance());
    }
}
