
#import "HighScoreTesterController.h"
#import <daymisckit/daymisckit.h>
#import <gamekit/gamekit.h>

@implementation HighScoreTesterController

- init
{	// set up an animator to periodically update the high score slot display
	[super init];
	animator = [[Animator alloc] initChronon:1.0
			adaptation:0.0   target:self
			action:@selector(updateSlot:) autoStart:YES eventMask:0];
	return self;
}

- trapPause:sender
{ // so we can update our interface when pausing is done
	id aString = [[DAYString alloc] initString:"The game is currently "];
	[aString cat:[pauseMenuCell title]];
	[aString cat:"d."];
	[pauseMonitor setStringValue:[aString stringValue]];
	return [gameBrain pauseGame:sender];
}

- nextLevelWithoutCheat:sender
{
	[gameBrain nextLevel];
	[self updateSlot:self];
    return self;
}

- sendScore:sender
{
	[scoreKeeper addToScore:[scoreText intValue]];
	[self updateSlot:self];
    return self;
}

- updateSlot:sender
{	// display the values of the slot in the Matrix.
	id theSlot = [gameBrain currentHighScoreSlot]; // get info from GameBrain
	[[slotMatrix findCellWithTag:0]
			setStringValue:[[theSlot startTime] stringValue]];
	[[slotMatrix findCellWithTag:1]
			setStringValue:[[theSlot endTime] stringValue]];
	[[slotMatrix findCellWithTag:2]
			setStringValue:[[theSlot elapsedTime] stringValue]];
	[[slotMatrix findCellWithTag:3] setStringValue:[theSlot playerName]];
	[[slotMatrix findCellWithTag:4] setStringValue:[theSlot userName]];
	[[slotMatrix findCellWithTag:5] setStringValue:[theSlot machineName]];
	[[slotMatrix findCellWithTag:6] setIntValue:[theSlot startLevel]];
	[[slotMatrix findCellWithTag:7] setIntValue:[theSlot endLevel]];
	[[slotMatrix findCellWithTag:8] setIntValue:[theSlot finalScore]];
	[cheatSwitch setState:[gameBrain playerCheated]];
    return self;
}


@end
