Methods of Interest

Here are some methods in other objects that you may need to use in your module.  I'm providing this rather than full documentation on each of the objects in NEXTVegas, primarily because I'm lazy, and also because you won't need to use any other methods than those described below.  If you do, then you can check out each object's source code...

Global Functions

PBoss()

Returns the id of the PitBoss object.  

Dealer()

Returns the id of the current module's controlling object.  

PitBoss Instance Methods

PitBoss is the main controlling object of NEXTVegas.  It is PitBoss that creates new players, loads game modules (well, actually the Casino object does that), and handles all requests for info, preferences, etc.  You should only need these few methods in your module, the others being primarily for PitBoss's use.  

BTW, the only sound method I've used in my modules is playSound:.  The only module I've written that uses sounds that PitBoss doesn't provide is VideoPoker, and it creates its sounds itself.  I don't really know why I did it this way...  

currentPlayer
- currentPlayer

Returns the id of the current player.  NVDealer has the same instance method.

numPlayers
- (int)numPlayers

Returns the number of player files currently open.  Same as NVDealer's numPlayers instance method.

removePlayer:
- removePlayer:player

Saves  player, closes it's window, and then removes it from the PitBoss's playerList.

setCurrentPlayer:
- setCurrentPlayer:player

Makes player the current player.  Display's player's name in the Current Player text field.

addSoundFromSection:
- (int)addSoundFromSection:(char *)soundfile

Creates a new SoundEffect object for the file specified in soundfile.  Returns the index of the object in PitBoss soundEffect array, which you can use with the playSound method.  The following example show a typical use for addSoundFromSection:

					char path[MAXPATHLEN+1];
					int	aSound;
			
					if ([bundle getPath:path forResource:"mySound" ofType:"snd"]) 
					{
						aSound = [PBoss() addSoundFromSection:path];
					}

playSound:
- playSound:(int)index

Plays a default sound or one that has been added by the addSoundFromSection method.  index can be one of:

Constant	Description
NV_WINSOUND	Combination of a bowling strike and applause.
NV_LOSESOUND	Combination of "taps" and grumbling from a crowd.
NV_WARNSOUND	A gun being cocked.
NV_CHIPSOUND	Supposed to sound like a chip.
NV_REMOVECHIPSOUND	Supposed to sound like a the opposite of NV_CHIPSOUND, but exaggerated.
NV_SHUFFLESOUND	Sound of a deck of cards being shuffled.
NV_CARDSOUND	Sound of a card being dealt.

Or, index can be the integer value that was returned by the addSoundFromSection: method, as in the following:

					char path[MAXPATHLEN+1];
					int	aSound;
			
					if ([bundle getPath:path forResource:"mySound" ofType:"snd"]) 
					{
						aSound = [PBoss() addSoundFromSection:path];
					}
					
					[PBoss() playSound:aSound];

removeSound:
- removeSound:(int)index

Removes the sound specified by index from the PitBoss's sound effect array.  Only remove sounds that your module adds with PitBoss's initSoundFromSection method.  Returns self.

soundEnabled:
- (BOOL)soundEnabled

Returns YES if calls to playSound will be granted, NO if not.

appIsTerminating
- (BOOL)appIsTerminating

YES if the app is terminating, NO if it is not.

houseMin
- (int)houseMin

Returns the current house miniumum bet set through the preferences panel.  NVDealer has the instance method tableMin which returns the same value.

houseMax
- (int)houseMax

Returns the current house maximum bet set through the preferences panel.  NVDealer has the instance method tableMax which return the same value.

tableWindow
- tableWindow

Returns the id of the "Table", or the large NEXTVegas window.  NVDealer has the instance method table which returns the same value.

Player Instance Methods

The only method that you will need to call to modify a player file is the player's bank roll.  Every other method is for use by PitBoss, and your module should definately never use them, except those described below.

addToBank
- addToBank:(int)bankAmount

Adds bankAmount to player's bank.  Returns self.

amountInBank
- (int) amountInBank

Returns the amount currently in player's bank.

playerName
- (char *)playerName

Returns the player's name.

selectedChip
- (int) selectedChip

Returns the chip value currently selected in the player's window.  For example, if the player has the $25 dollar chip selected, a call to selectedChip would return the integer value 25.  If the player has the variable chip selected, which has been set to be worth $250, selectedChip would return 250.  If the player has the default chip selected, selectedChip would return the constant DEFAULT.

tag
- (int)tag

Returns the tag/position of the player.

window
- window

Returns the id of the player's window.

NVDealer Instance Methods

Check out the NVDealer source code for the methods that your controller module will inherit.   Just a couple that you might want to use are:

addDecks:toView:emptyFirst:andShuffle:
- addDecks:(int)n toView:view emptyFirst:(BOOL)willEmpty andShuffle:(BOOL)willShuffle

Adds n number of decks to CardPileView view.  If willEmpty is YES, then empties the CardPile first.  If willShuffle is YES, then shuffles the new deck before returning self. 

newDeck:forView:
- newDeck:(int)numDecks forView:cardPileView

A cover for [self addDecks:numDecks toView:cardPileView emptyFirst:YES andShuffle:YES];

say:
- say:(const char *)string

Writes string to the dealer text field at the top of the NEXTVegas table.  Your controller module could use the code:

		[self say:"Hello World!"];

which would get written to the dealer text field.  Use this whenever you want to communicate something to the players.

selectCellWithTag:forPopUpButton:
- selectCellWithTag:(int)aTag forPopUpButton:aPopUpButton

This methods just makes it easier to deal with pop up buttons from InterfaceBuilder.  It selects the cell, and sets the button's title to the title of the cell.  Its not real intuitive to select a cell in a pop up button, so I've created this mostly for myself.  Here's the code:

	- selectCellWithTag:(int)tag forPopUpButton:button
	{
		[[[button target] itemList] selectCellWithTag:tag];
		[button setTitle:[[[[button target] itemList] selectedCell] title]];
		
		return self;
	}

setUserValueForPile:aceHigh:
- setUserValueForPile:cardPile aceHigh:(BOOL)flag

Not sure how usefull this will be for people...  All it does is make the userValue field for each Card in cardPile equal to its value, except if flag is YES, it makes Aces equal to CS_KING+1.

tagOfSelectedCellInPopUpButton:
- (int)tagOfSelectedCellInPopUpButton:popUpButton

Returns the tag of the currently selected cell in the target of popUpButton.

randomIntBetween::
- (int)randomIntBetween:(int)a :(int)b

Returns a random integer between the two values a and b.

randomFloatBetween::
- (float)randomFloatBetween:(float)a :(float)b

Returns a random float between the two values a and b.

runDebug
- runDebug

When a user types [COMMAND]+[SHIFT]+[ALTERNATE]+'d', this message is sent to the current dealer object indicating that the user wants to run a debugging session.  Use it as you want.  The Blackjack module uses it to bring up a panel that allows the user to pick a player, their hand, and card number and replace it with the next card from the deck.  This allows the user to select a hand to make sure that it is interpreted correctly.