game.Score Class Reference

This Class is responsible for all the stuff that ha something todo with score. More...

Collaboration diagram for game.Score:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Score ()
 The constructor.
void addToHighScore (int score2)
 To add something to the High Score.
void addPoints (int deletedRows)
 Add some points depending on the number of removed rows if a stone was dropped.
int getScore ()

Static Public Member Functions

static void updateScore ()
 Updatescore draws the Score in the sidebar.

Package Attributes

int lvloffset = 0
 to determin wether a levelup is to do or not.

Private Member Functions

void getSavedHighScore ()
 Load the saved HighScore.
void SaveHighScore ()
 Save the HighScore.

Private Attributes

final String HIGH_SCORE_NAME = "HighScoreName"
final String HIGH_SCORE_POINTS = "HighScorePoints"
final int HIGH_SCORE_LENGTH = 5
Preferences tetrisPreferences

Static Private Attributes

static int score
 The Number of Points the player has achieved.
static List< EntryhighScore = new ArrayList<Entry>()
 A List of Entry to hold the HighScore.

Classes

class  DroppEventListener
 This Subclass is used to listen to the DroppEvent without trashing the initial class too much. More...
class  Entry
 A subclass that represents an entry in the HighScore table. More...
class  EntryComparator
 To keep the standards in comparing. More...
class  GameOverEventListener
 This Subclass is used to listen to the GameOverEvent without trashing the initial class too much. More...


Detailed Description

This Class is responsible for all the stuff that ha something todo with score.

Author:
Team Solid Sun

Constructor & Destructor Documentation

game.Score.Score (  ) 

The constructor.

It is loading the saved HighScore.

References game.Score.getSavedHighScore(), and game.Score.score.

00160                        {
00161                 getSavedHighScore();
00162                 DroppEvent.addDroppListener(new DroppEventListener());
00163                 GameOverEvent.addGameOverListener(new GameOverEventListener());
00164                 score = 0;
00165         }


Member Function Documentation

void game.Score.addToHighScore ( int  score2  ) 

To add something to the High Score.

caution! This method will respect the HIGH_SCORE_LENGTH so if your Score is to low it will simply not appear on that list.

Parameters:
score2 The Value that will be added
See also:
highScore

References game.Score.HIGH_SCORE_LENGTH, and game.Score.highScore.

Referenced by game.Score.GameOverEventListener.gameOver().

00177                                                {
00178                 highScore.add(new Entry("", score2));
00179                 Collections.sort(highScore, new EntryComparator());
00180 
00181                 highScore.remove(HIGH_SCORE_LENGTH);
00182         }

void game.Score.addPoints ( int  deletedRows  ) 

Add some points depending on the number of removed rows if a stone was dropped.

Parameters:
deletedRows The number of deleted the curently rows.

References game.Score.lvloffset, and game.Score.score.

Referenced by game.Score.DroppEventListener.dropped().

00191                                                {
00192                 int velocity = 10;
00193                 score += Math.pow(3, deletedRows - 1);
00194                 if ((score - lvloffset) > velocity) {
00195                         engine.JavaRenderer.getTime().lvlup();
00196                         lvloffset += velocity;
00197                 }
00198         }

int game.Score.getScore (  ) 

Returns:
The score

References game.Score.score.

Referenced by game.Score.GameOverEventListener.gameOver().

00203                               {
00204                 return score;
00205         }

static void game.Score.updateScore (  )  [static]

Updatescore draws the Score in the sidebar.

References game.Score.highScore, and game.Score.score.

Referenced by game.Score.DroppEventListener.dropped(), and game.Score.GameOverEventListener.gameOver().

00211                                          {
00212                 JPanel sidebar = Window.getSidebarScore();
00213                 Graphics g = sidebar.getGraphics();
00214 
00215                 Dimension size = sidebar.getSize();
00216 
00217                 g.clearRect(0, 0, size.width, size.height);
00218 
00219                 g.drawRect(10, 10, size.width - 20, size.height - 20);
00220 
00221                 g.drawString("Punkte: " + score, 20, (size.height / 20) + 10);
00222 
00223                 for (int i = 0; i < highScore.size(); i++) {
00224                         g.drawString("Platz " + (i + 1) + " : " + highScore.get(i).points,
00225                                         20, (size.height / 20) + 30 + i * 17);
00226                 }
00227         }

void game.Score.getSavedHighScore (  )  [private]

Load the saved HighScore.

References game.Score.HIGH_SCORE_LENGTH, game.Score.HIGH_SCORE_NAME, game.Score.HIGH_SCORE_POINTS, game.Score.highScore, and game.Score.tetrisPreferences.

Referenced by game.Score.Score().

00232                                          {
00233                 Entry cur;
00234                 String curName;
00235                 int curScore;
00236 
00237                 for (int i = 0; i < HIGH_SCORE_LENGTH; i++) {
00238                         curName = tetrisPreferences.get(HIGH_SCORE_NAME + i, "Player");
00239                         curScore = tetrisPreferences.getInt(HIGH_SCORE_POINTS + i, 0);
00240                         cur = new Entry(curName, curScore);
00241                         highScore.add(cur);
00242                 }
00243         }

void game.Score.SaveHighScore (  )  [private]

Save the HighScore.

References game.Score.HIGH_SCORE_LENGTH, game.Score.HIGH_SCORE_NAME, game.Score.HIGH_SCORE_POINTS, game.Score.highScore, game.Score.Entry.name, game.Score.Entry.points, and game.Score.tetrisPreferences.

Referenced by game.Score.GameOverEventListener.gameOver().

00248                                      {
00249                 Entry cur;
00250                 for (int i = 0; (i < HIGH_SCORE_LENGTH) && (i < highScore.size()); i++) {
00251                         cur = highScore.get(i);
00252                         tetrisPreferences.put(HIGH_SCORE_NAME + i, cur.name);
00253                         tetrisPreferences.putInt(HIGH_SCORE_POINTS + i, cur.points);
00254                 }
00255         }


Member Data Documentation

int game.Score.score [static, private]

int game.Score.lvloffset = 0 [package]

to determin wether a levelup is to do or not.

Referenced by game.Score.addPoints().

List<Entry> game.Score.highScore = new ArrayList<Entry>() [static, private]

final String game.Score.HIGH_SCORE_NAME = "HighScoreName" [private]

final String game.Score.HIGH_SCORE_POINTS = "HighScorePoints" [private]

final int game.Score.HIGH_SCORE_LENGTH = 5 [private]

Preferences game.Score.tetrisPreferences [private]

Initial value:

 Preferences
                        .userNodeForPackage(getClass())

Referenced by game.Score.getSavedHighScore(), and game.Score.SaveHighScore().


The documentation for this class was generated from the following file:

Generated on Mon Jul 28 19:03:06 2008 for SolidJavaTetris by  doxygen 1.5.5