This is Score.m in view mode; [Download] [Up]
// Score.m
// Project: Cribbage
// Stephan Wacker
// 93-09-26
#import "Score.h"
#import "HumanPlayer.h"
#import "Cribbage.h"
#import "LocalizableStrings.h"
#import "cribbage.h"
static int score_value[] =
{
2, // SC_FIFTEEN,
2, // SC_PAIR,
6, // SC_PAIR_ROYAL,
12, // SC_DBL_PAIR_ROYAL,
3, // SC_RUN,
8, // SC_DBL_RUN,
15, // SC_TRIPLE_RUN,
16, // SC_QUADRUPLE_RUN,
4, // SC_4RUN,
10, // SC_DBL_4RUN,
5, // SC_5RUN,
4, // SC_4FLUSH,
5, // SC_5FLUSH,
1, // SC_NOBS
};
@implementation Score
- awakeFromNib
{
[self disablePanel];
return self;
}
- window
{
return [total window];
}
- disablePanel
{
[[total window] setTitle: STR_SCORE_PANEL_TITLE];
return self;
}
- enablePanel: (const char *) title
{
[[[total window] setTitle: title] makeKeyAndOrderFront: nil];
return self;
}
- doScoring: (char *) what for: aPlayer
{
player = aPlayer;
sprintf( local_buf, "Score %s %s", [aPlayer possessivePronoun], what );
msg( LOCAL_BUF );
[self clear];
[self enablePanel: LOCAL_BUF];
return self;
}
- add: sender
{
id cell = [sender selectedCell];
int tag = [cell tag];
int value = score_value[tag];
id field = [values findCellWithTag: tag];
int oldValue = [field intValue];
[field setIntValue: value + oldValue];
[self addTotal: value];
return self;
}
- addTotal: (int) value
{
[total setIntValue: value + [total intValue]];
return self;
}
- cancel: sender
{
return [self clear];
}
- clear
{
[[values cellList] makeObjectsPerform: @selector(setStringValue:)
with: (id) ZERO_STRING];
[total setIntValue: 0];
return self;
}
- ok: sender
{
[self disablePanel];
[player manualScore: [total intValue]];
return self;
}
- explain: sender
{
[[NXApp delegate] explainPreviousScore];
return self;
}
- help: sender
{
[[NXApp delegate] explainCurrentScore];
return self;
}
@end // Score
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.