ICCountry


Inherits From:
NSObject
Conforms To:
ICCountryProtocol
NSCoding
Declared In:
ICCountry.h


Class Description

ICCountry represents one country in the game.


Method Types

Accessors
- name
- game
- selected
- setSelected:
Player
- player
- pick
- isOwnedBy:
- isOwnedByCurrentPlayer
Armies
- canAssignArmies
- assignArmies:
- armies
- tiredArmies
- reserveArmies
- setReserveArmies:
- sortByArmies:
Neighbors
- neighbors
- ownedNeighbors
- unownedNeighbors
- mostVulnerableNeighbor
- isAdjacentTo:
- threat
- calculateThreat
- sortByThreat:
Attacking
- canAttack
- attack:attacksPerClick:untilLossesExceed:withDice:advanceArmies:
- currentCountryAttackSelfAttacksPerClick:untilLossesExceed:withDice:advanceArmies:
Attack Paths
- attackPath
- calculateAttackPath
- armiesAlongAttackPath
- sortByArmiesAlongAttackPath:
Attack Paths
- customInfo

Instance Methods

armies

- (int)armies

The number of armies in the country.


armiesAlongAttackPath

- (int)armiesAlongAttackPath

The countries along the most optimum attack path from a country owned by the current player to this country.


assignArmies:

- (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.


attack:attacksPerClick:untilLossesExceed:withDice:advanceArmies:

- (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.


attackPath

- (NSMutableArray *)attackPath

The countries along the most optimum attack path from a country owned by the current player to this country.


calculateAttackPath

- (void)calculateAttackPath

Sets attackPath to the countries along the most optimum attack path from a country owned by the current player to this country.


calculateThreat

- (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.


canAssignArmies

- (BOOL)canAssignArmies

Returns whether the country is owned by the current player and the player has armies to place.


canAttack

- (BOOL)canAttack

Returns whether the game's currentCountry is adjacent to this country and this country is not owned by the game's currentPlayer.


currentCountryAttackSelfAttacksPerClick:untilLossesExceed:withDice:advanceArmies:

- (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];


customInfo

- (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.


game

- (ICGame *)game

The game object, which handles the game state.


isAdjacentTo:

- (BOOL)isAdjacentTo:(ICCountry *)country

Returns whether country is adjacent to this country.


isOwnedBy:

- (BOOL)isOwnedBy:(ICPlayer *)value

Returns whether the country is owned by the player value.


isOwnedByCurrentPlayer

- (BOOL)isOwnedByCurrentPlayer

Returns whether the country is owned by the current player.


mostVulnerableNeighbor

- (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.


name

- (NSString *)name

The non-localized name of the country. For the localized name, use description.


neighbors

- (NSMutableArray *)neighbors

The countries that are adjacent to this country.


ownedNeighbors

- (NSMutableArray *)ownedNeighbors

Returns the adjacent countries that are owned by the same player as this country.


pick

- (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.


player

- (ICPlayer *)player

The player who owns this country.


reserveArmies

- (int)reserveArmies

The number of armies to be used for defense.


selected

- (BOOL)selected

Returns whether this country is selected.


setReserveArmies:

- (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.


setSelected:

- (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.


sortByArmies:

- (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.


sortByArmiesAlongAttackPath:

- (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.


sortByThreat:

- (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.


threat

- (int)threat

Returns the stored threat level of this country. To calculate the threat level, send the calculateThreat message.


tiredArmies

- (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.


unownedNeighbors

- (NSMutableArray *)unownedNeighbors

Returns the adjacent countries that are not owned by the same player as this country.


Version 1.1 Copyright ©2003 by KavaSoft. All Rights Reserved.