package com.statox.robotz;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import org.w3c.dom.Text;


public class LostActivity extends Activity {
    public final static String MSG_LVL = "com.statox.robotz.playAgain.level";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lost);

        /* get the score */
        Intent intent = getIntent();
        int score = intent.getIntExtra(BoardActivity.MSG_SCORE, 1);
        int highscore = 0;
        /* getting the previous highscore */
        /*SharedPreferences prefs = this.getSharedPreferences("highscore", Context.MODE_PRIVATE);
        int highscore = prefs.getInt("highscore", 0); //0 is the default value
*/
        /* save the score if highscore */
  /*      if (score > highscore) {
            SharedPreferences.Editor editor = prefs.edit();
            editor.putInt("highscore", score);
            editor.commit();
        }
*/
        /* output the results */
        ((TextView) findViewById(R.id.textViewScore)).setText("Score: " + score);
        ((TextView) findViewById(R.id.textViewHighScore)).setText("Previous HighScore: " + highscore);

    }

    /* Start a new game
     * Launch the Board activity (no need to give a level since the default value is 1)
     */
    public void playAgain (View view) {
        // launch the BoardActivity
        Intent intent = new Intent(this, BoardActivity.class);
        startActivity(intent);
    }
}

@@ -797,34 +797,8 @@
 1);%0A
-        int highscore = 0;
 %0A   
@@ -847,18 +847,16 @@
         
-/*
 SharedPr
@@ -1014,18 +1014,169 @@
 t value%0A
-*/
+%0A        /* String to display the results */%0A        String scoreString = %22Score: %22 + score;%0A        String highScoreString = %22Highscore: %22 + highscore;%0A
 %0A       
@@ -1212,18 +1212,16 @@
 re */%0A  
-/*
       if
@@ -1374,24 +1374,145 @@
 or.commit();
+%0A%0A            scoreString= %22New High score !%22;%0A            highScoreString = %22Previous: %22 + highscore + %22 New: %22 + score;
 %0A        %7D%0A*
@@ -1510,18 +1510,16 @@
       %7D%0A
-*/
 %0A       
@@ -1606,33 +1606,27 @@
 setText(
-%22Score: %22 + score
+scoreString
 );%0A     
@@ -1690,42 +1690,23 @@
 ext(
-%22Previous HighScore: %22 + highscore
+highScoreString
 );%0A%0A

handle highscores