- Inherits From:
- NSObject
- Conforms To:
- ICCountryProtocol
- NSCoding
- Declared In:
- ICCountry.h
AccessorsPlayer
- - name
- - game
- - selected
- - setSelected:
Armies
- - player
- - pick
- - isOwnedBy:
- - isOwnedByCurrentPlayer
Neighbors
- - canAssignArmies
- - assignArmies:
- - armies
- - tiredArmies
- - reserveArmies
- - setReserveArmies:
- - sortByArmies:
Attacking
- - neighbors
- - ownedNeighbors
- - unownedNeighbors
- - mostVulnerableNeighbor
- - isAdjacentTo:
- - threat
- - calculateThreat
- - sortByThreat:
Attack Paths
- - canAttack
- - attack:attacksPerClick:untilLossesExceed:withDice:advanceArmies:
- - currentCountryAttackSelfAttacksPerClick:untilLossesExceed:withDice:advanceArmies:
Attack Paths
- - attackPath
- - calculateAttackPath
- - armiesAlongAttackPath
- - sortByArmiesAlongAttackPath:
- - customInfo
- (int)armies
The number of armies in the country.
- (int)armiesAlongAttackPath
The countries along the most optimum attack path from a country owned by the current player to this country.
- (void)assignArmies:(int)count
Takes count armies from the country's owner and places them in the country. If these armies are being fortified from another country, increments tiredArmies by count. If the player's unallocatedArmies value is 0, proceeds to the next phase of the turn or game.
- (BOOL)attack:(ICCountry *)country attacksPerClick:(ICAttackCount)attacksPerClick untilLossesExceed:(int)lossesExceedValue withDice:(int)diceToRoll advanceArmies:(BOOL)advanceArmies
Launches an attack on country.
The attacksPerClick value controls how many attacks will be performed, and can be AttackOnce
, AttackUntilLossesExceed
, or AttackUntilWinOrLose
. If AttackUntilLossesExceed
is specified, then attacks will continue until lossesExceedValue armies have been lost. Otherwise, the value of lossesExceedValue is ignored.
The diceToRoll value determines how many dice to roll, and can be 1, 2, or 3. The more dice that are rolled, the more risky the attack.
In the event of a victory, if advanceArmies is YES
armies are automatically advanced to the conquered country. Otherwise, the player receives an advanceArmiesFrom:to: message.
Returns whether country was conquered.
- (NSMutableArray *)attackPath
The countries along the most optimum attack path from a country owned by the current player to this country.
- (void)calculateAttackPath
Sets attackPath to the countries along the most optimum attack path from a country owned by the current player to this country.
- (void)calculateThreat
Sets the country's threat level to the number of adjacent enemy countries, plus the number of armies in those countries, minus the number of armies in this country.
- (BOOL)canAssignArmies
Returns whether the country is owned by the current player and the player has armies to place.
- (BOOL)canAttack
Returns whether the game's currentCountry is adjacent to this country and this country is not owned by the game's currentPlayer.
- (void)currentCountryAttackSelfAttacksPerClick:(ICAttackCount)attacksPerClick untilLossesExceed:(int)lossesExceedValue withDice:(int)diceToRoll advanceArmies:(BOOL)advanceArmies
This convenience method calls:
[[game currentCountry] attack: self
attacksPerClick: attacksPerClick
untilLossesExceed: lossesExceedValue
withDice: diceToRoll
advanceArmies: advanceArmies];
- (NSMutableDictionary *)customInfo
This dictionary can be used by players to store information on each country. You can rely on this data being preserved from turn to turn, even if the game is saved and restored. This dictionary is shared by all players, so be sure to use unique keys (i.e. "<playername><keyname>") to avoid clobbering values added by other players.
- (ICGame *)game
The game object, which handles the game state.
- (BOOL)isAdjacentTo:(ICCountry *)country
Returns whether country is adjacent to this country.
- (BOOL)isOwnedBy:(ICPlayer *)value
Returns whether the country is owned by the player value.
- (BOOL)isOwnedByCurrentPlayer
Returns whether the country is owned by the current player.
- (ICCountry *)mostVulnerableNeighbor
Returns the unowned adjacent country with the fewest number of armies. If all adjacent countries are owned by the same player as this country, returns nil.
- (NSString *)name
The non-localized name of the country. For the localized name, use description.
- (NSMutableArray *)neighbors
The countries that are adjacent to this country.
- (NSMutableArray *)ownedNeighbors
Returns the adjacent countries that are owned by the same player as this country.
- (void)pick
Players send pick to a country when picking countries. Removes the country from the game's unallocatedCountries, sets the player of the country to the game's currentPlayer. If there are more unallocated countries, tells the next player to pick a country. Otherwise, sends donePickingCountries to the game.
- (ICPlayer *)player
The player who owns this country.
- (int)reserveArmies
The number of armies to be used for defense.
- (BOOL)selected
Returns whether this country is selected.
- (void)setReserveArmies:(int)value
Sets the number of armies to be used for defense. At the beginning of the turn, this message is sent with value equal to armies times the value returned by the player's armiesToReserveForDefense method.
- (void)setSelected:(BOOL)value
Sets whether this country is selected. If the country's owner is not a computer player, tells the current country view to display the country as selected.
- (int)sortByArmies:(ICCountry *)country
Returns NSOrderedAscending
if this country has more armies than country, NSOrderedDescending
if it has fewer, or NSOrderedSame
if they have the same number.
- (int)sortByArmiesAlongAttackPath:(ICCountry *)country
Returns NSOrderedAscending
if this country has fewer armies along the attack path than country, NSOrderedDescending
if it has more, or NSOrderedSame
if they have the same number.
- (int)sortByThreat:(ICCountry *)country
Returns NSOrderedAscending
if this country has a lower threat than country, NSOrderedDescending
if it has a higher threat. If the countries have the same threat level, randomly returns NSOrderedAscending
or NSOrderedDescending
.
- (int)threat
Returns the stored threat level of this country. To calculate the threat level, send the calculateThreat message.
- (int)tiredArmies
The number of armies that have been fortified into this country from another country during this turn. Tired armies cannot be fortified to another country.
- (NSMutableArray *)unownedNeighbors
Returns the adjacent countries that are not owned by the same player as this country.