Data/Planet.m

00001 //
00002 //  Planet.m
00003 //  MacTrek
00004 //
00005 //  Created by Aqua on 23/04/2006.
00006 //  Copyright 2006 Luky Soft. All rights reserved.
00007 //
00008 
00009 #import "Planet.h"
00010 
00011 @implementation Planet
00012 
00013 - (id) init {
00014     self = [super init];
00015     if (self != nil) {
00016         flags = 0;                                                      // State information
00017         owner = nil;
00018         name = @"??";
00019         position.x = -1000;
00020         position.y = -1000;
00021         name = @"??";
00022         armies = 0;
00023         info = 0;                                                       // Teams which have info on planets    
00024         orbit = 0;
00025         planetId = -1;
00026     }
00027     return self;
00028 }
00029 
00030 - (id)initWithPlanetId:(int)id {
00031     self = [self init];
00032     if (self != nil) {
00033         planetId = id;
00034     }
00035     return self;
00036 }
00037 
00038 - (int)planetId {
00039     return planetId;
00040 }
00041 
00042 - (NSString*) nameWithArmiesIndicator {
00043     char hasArmies = ' ';
00044     if (armies > 4) {
00045         hasArmies = '+';
00046     }
00047     return [NSString stringWithFormat:@"%c%@", hasArmies, name];
00048 }
00049 
00050 - (NSString*) name {
00051     return name;
00052 }
00053 
00054 - (NSString*) abbreviation {
00055     if ([name length] > 3) {
00056         return [[name substringWithRange:NSMakeRange(0,3)] uppercaseString];
00057     }
00058     return name;
00059 }
00060 
00061 - (bool) needsDisplay {
00062     return needsDisplay;
00063 }
00064 
00065 - (Team*) owner {
00066     return owner;
00067 }
00068 
00069 - (void) setOwner: (Team*) team {
00070     owner = team;
00071 }
00072 
00073 - (int)  info {
00074     return info;
00075 }
00076 
00077 - (void) setInfo: (int) newInfo {
00078     info = newInfo;
00079 }               
00080 
00081 - (int)  flags {
00082     return flags;
00083 }
00084 
00085 - (int)  armies {
00086     return armies;
00087 }
00088 
00089 - (void) setName:(NSString *)newName {
00090     [name release];
00091     name = newName;
00092     [name retain];
00093 }
00094 
00095 - (void) setFlags: (int) newFlags {
00096     flags = newFlags;
00097 }
00098 
00099 - (void) setArmies: (int) newArmies {
00100     armies = newArmies;
00101 }
00102 
00103 - (void) setNeedsDisplay: (bool) redraw {
00104     needsDisplay = redraw;
00105 }
00106 
00107 // fixed size 1200 by 1200 game pix (30x30 view pix)
00108 - (NSSize) size {
00109     return NSMakeSize(1200, 1200);
00110 }
00111 
00112 @end

Generated on Sat Aug 26 21:14:10 2006 for MacTrek by  doxygen 1.4.7