作者papermaster (纸大师)
看板MacDev
标题[闲聊] 刚刚无聊写的一段code
时间Thu May 17 22:32:00 2012
最近脸书都被Diablo洗版
稍早看到朋友用别的语言贴了一个登入失败的逻辑在酸
所以我也用OC写了一个XD
编译应该可以过
但是你要先找到header file XDDDD
#import "DiabloIII.h"
@interface DiabloIIILoginCheck : NSObject {
BOOL mCanPlay;
}
-(BOOL)doChkAccountWithUid:(NSString*)uid
andPwd:(NSString*)pwd forError:(NSError**)error;
-(BOOL)canPlay;
@end
@implementation DiabloIIILoginCheck
-(id)init {
[self initWithUid:nil andPwd:nil forError:nil];
return self;
}
-(id)initWithUid:(NSString*)uid
andPwd:(NSString*)pwd forError:(NSError**)error {
self = [super init];
if(self) {
mCanPlay = [self doChkAccountWithUid:uid
andPwd:pwd forError:(NSError**)error];
}
return self;
}
-(BOOL)doChkAccountWithUid:(NSString*)uid
andPwd:(NSString*)pwd forError:(NSError**)error {
BOOL result = NO;
DiabloIII *diii = [DiabloIII getInstance];
if(![diii loginWithUid:uid andPwd:pwd]) {
*error = [NSError errorWithDomain:@"ERROR"
code:12 userInfo:nil];
goto EXIT;
}
switch ([diii getServer]) {
case ASIA:
*error = [NSError errorWithDomain:@"ERROR"
code:3007 userInfo:nil];
break;
case AMERICA:
*error = [NSError errorWithDomain:@"ERROR"
code:33 userInfo:nil];
break;
case EUROPE:
*error = [NSError errorWithDomain:@"ERROR"
code:3003 userInfo:nil];
break;
}
EXIT:
return result;
}
-(BOOL)canPlay {
return mCanPlay;
}
@end
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.163.211.62