/*-*-c++-*-*/

/* Originally written by Karl.  Julian changed some formatting 2/3/96
   And added some comments.
 */

import java.awt.*;
import embossRect;
import constants;

public class scoreboard{
  String myname;
  int score;
  int lastscore;
  int lines;
  int lastlines;
  
  int xoff, yoff;
  
  embossRect boardframe;
  embossRect infoframe;
  
  public int grid[][];
  
  scoreboard(int x, int y){

    xoff = x;
    yoff = y;
    
    score = 0;
    lines = 0;
    lastscore = 0;
    lastlines = 0;
    
    boardframe = new embossRect(xoff,yoff,114,204,2,constants.DEBOSS);
    infoframe = new embossRect(xoff,yoff+206,114,50,2,constants.DEBOSS);
    
    grid = new int [10][20];
  }
  
  public void setName(String name){
    myname = name;
  }
  
  public void setScore(int s){
    lastscore = score;
    score = s;
  }
  
  public void setLines(int lin){
    lastlines = lines;
    lines = lin;
  }
  
  public void setBoard(scoreboard board){
    setScore(board.score);
    setLines(board.lines);
    setName(board.myname);
    
    for (int i = 0; i < 10; i ++){
      for (int j = 0; j < 20; j ++){
	grid[i][j] = board.grid[i][j];
      }
    }
  }
  
  public void drawYourself(Graphics g){
    g.setColor(constants.NULL_COLOR);
    g.drawString("Score: " + lastscore, xoff+10, yoff+236);
    g.drawString("Lines: " + lastlines, xoff+10, yoff+251);
    
    g.setColor(constants.BLACK);
    if (myname != null) {
      g.drawString(myname, xoff + 10, yoff + 221);
    }
    g.drawString("Score: " + score, xoff+10, yoff+236);
    g.drawString("Lines: " + lines, xoff+10, yoff+251);
    
    for (int i = 0; i < 10; i ++){
      for (int j = 0; j < 20; j ++){
	switch (grid[i][j]){
	case 0:
	  g.setColor(constants.NULL_COLOR);
	  break;
	case 1:
	  g.setColor(constants.BLUE_NORMAL);
	  break;
	case 2:
	  g.setColor(constants.RED_NORMAL);
	  break;
	case 3:
	  g.setColor(constants.GREEN_NORMAL);
	  break;
	case 4:
	  g.setColor(constants.YELLOW_NORMAL);
	  break;
	case 5:
	  g.setColor(constants.PURPLE_NORMAL);
	  break;
	case 6:
	  g.setColor(constants.ORANGE_NORMAL);
	  break;
	case 7:
	  g.setColor(constants.LTBLUE_NORMAL);
	  break;
	}
	g.fillRect(xoff + (i * 11)+2, yoff + (j * 10)+2, 10, 9);
      }
    }
  }
}



