-
Notifications
You must be signed in to change notification settings - Fork 9
/
GameEntity.m
46 lines (43 loc) · 1.22 KB
/
GameEntity.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// GameEntity.m
// Connect5
//
// Created by Mohammed Eldehairy on 10/9/13.
// Copyright (c) 2013 Mohammed Eldehairy. All rights reserved.
//
#import "GameEntity.h"
@implementation GameEntity
-(id)initWithCoder:(NSCoder *)aDecoder
{
if(self = [super init])
{
self.graph = [aDecoder decodeObjectForKey:@"graph"];
self.score =[aDecoder decodeObjectForKey:@"score"];
self.nextCellsToAdd = [aDecoder decodeObjectForKey:@"NextCellsToAdd"];
}
return self;
}
-(void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:self.graph forKey:@"graph"];
[aCoder encodeObject:self.score forKey:@"score"];
[aCoder encodeObject:self.nextCellsToAdd forKey:@"NextCellsToAdd"];
}
-(id)copyWithZone:(NSZone *)zone
{
GameEntity *copy = [[GameEntity alloc] init];
if(copy)
{
[copy setGraph:[self.graph copyWithZone:zone]];
[copy setScore:[self.score copyWithZone:zone]];
NSMutableArray *CopyArray = [NSMutableArray array];
for(GraphCell *cell in _nextCellsToAdd)
{
GraphCell *copyGCell = [cell copyWithZone:zone];
[CopyArray addObject:copyGCell];
}
[copy setNextCellsToAdd:CopyArray];
}
return copy;
}
@end