Created
October 11, 2010 08:57
-
-
Save wookay/620238 to your computer and use it in GitHub Desktop.
장기 유닛 테스트
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TestJanggi.m | |
// JanggiNorm | |
// | |
// Created by Woo-Kyoung Noh on 13/09/10. | |
// Copyright 2010 factorcat. All rights reserved. | |
// | |
#import "TestJanggi.h" | |
#import "JanggiManager.h" | |
#import "JangUnit.h" | |
#import "UnitTest.h" | |
#import "JanggiPan.h" | |
#import "GeometryExt.h" | |
#import "Logger.h" | |
@implementation TestJanggi | |
-(void) test_janggi { | |
JangUnit* choGung = [JangUnit unitWithName:@"초궁"]; | |
assert_equal(NATION_CHO, choGung.nation); | |
assert_equal(GIMUL_GUNG, choGung.gimul); | |
assert_equal(CGPointZero, choGung.position); | |
[JANGMAN.board putUnit:choGung]; | |
assert_equal(JANGGI_PAN_RECT.size, JANGMAN.pan.gridSize); | |
assert_false([JANGMAN.board hasUnitAt:CGPointMake(5, 9)]); | |
[JANGMAN.board setPosition:choGung To:CGPointMake(5,9)]; | |
assert_true([JANGMAN.board hasUnitAt:CGPointMake(5, 9)]); | |
assert_equal(8, [JANGMAN.board movablePositions:choGung].count); | |
[JANGMAN.board move:choGung To:CGPointMake(5,10)]; | |
assert_equal(3, [JANGMAN.board movablePositions:choGung].count); | |
assert_equal(false, CGRectHasPoint(HAN_GUNG_RECT, choGung.position)); | |
assert_equal(true, CGRectHasPoint(CHO_GUNG_RECT, choGung.position)); | |
assert_equal(true, CGRectHasPoint(CHO_GUNG_RECT, CGPointMake(5, 9))); | |
assert_equal(CGPointMake(5,10), choGung.position); | |
assert_equal(0, [JANGMAN.board targetablePositions:choGung].count); | |
assert_equal(false, [JANGMAN.board enemyCouldJanggun:choGung]); | |
JangUnit* hanZol = [JangUnit unitWithName:@"한병"]; | |
hanZol.position = CGPointMake(5, 9); | |
[JANGMAN.board putUnit:hanZol]; | |
assert_equal(true, [JANGMAN.board enemyCouldJanggun:choGung]); | |
assert_equal(1, [JANGMAN.board targetablePositions:choGung].count); | |
assert_equal(0, [JANGMAN.board movablePositions:choGung].count); | |
assert_equal(4, [JANGMAN.board movablePositions:hanZol].count); | |
assert_equal(1, [JANGMAN.board targetablePositions:hanZol].count); | |
[JANGMAN.board popUnit:CGPointMake(5, 9)]; | |
JangUnit* hanMa = [JangUnit unitWithName:@"한마"]; | |
hanMa.position = CGPointMake(7, 9); | |
[JANGMAN.board putUnit:hanMa]; | |
assert_equal(5, [JANGMAN.board movablePositions:hanMa].count); | |
assert_equal(1, [JANGMAN.board targetablePositions:hanMa].count); | |
JangUnit* choSang = [JangUnit unitWithName:@"초상"]; | |
choSang.position = CGPointMake(5, 6); | |
[JANGMAN.board putUnit:choSang]; | |
assert_equal(1, [JANGMAN.board targetablePositions:choSang].count); | |
assert_equal(0, [JANGMAN.board movablePositions:choSang].count); | |
JangUnit* hanCha = [JangUnit unitWithName:@"한차"]; | |
hanCha.position = CGPointMake(5, 5); | |
[JANGMAN.board putUnit:hanCha]; | |
assert_equal(12, [JANGMAN.board movablePositions:hanCha].count); | |
assert_equal(1, [JANGMAN.board targetablePositions:hanCha].count); | |
[JANGMAN.board move:hanCha To:CGPointMake(5,4)]; | |
JangUnit* hanPo = [JangUnit unitWithName:@"한포"]; | |
hanPo.position = CGPointMake(5, 2); | |
[JANGMAN.board putUnit:hanPo]; | |
assert_equal(1, [JANGMAN.board movablePositions:hanPo].count); | |
assert_equal(1, [JANGMAN.board targetablePositions:hanPo].count); | |
JangUnit* choSa = [JangUnit unitWithName:@"초사"]; | |
choSa.position = CGPointMake(5, 9); | |
[JANGMAN.board putUnit:choSa]; | |
assert_equal(0, [JANGMAN.board targetablePositions:choSa].count); | |
assert_equal(1, [JANGMAN.board movablePositions:choSa].count); | |
assert_equal(0x01 , [JANGMAN matchPlayerGroup]); | |
[JANGMAN.board attack:hanCha To:choSang.position]; | |
[JANGMAN.board moveBack]; | |
[JANGMAN.board attack:hanCha To:choSang.position]; | |
log_info(@"JANGMAN panInfo %@", [JANGMAN panInfo]); | |
} | |
@end |
Author
wookay
commented
Oct 11, 2010
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment