//
//  SFSBuddyVariable.m
//  SFS2X
//
//  Original development by Infosfer Game Technologies Ltd. | http://www.infosfer.com.
//
//  Maintained and developed by A51 Integrated.
//  Copyright 2012 A51 Integrated | http://a51integrated.com. All rights reserved.
//

#import "SFSBuddyVariable.h"
#import "VariableType.h"
#import "ISFSObject.h"
#import "SFSArray.h"
#import "SFSObject.h"
#import "SFSException.h"

NSString * const SFSBuddyVariable_OFFLINE_PREFIX = @"$";

@implementation SFSBuddyVariable

@dynamic isOffline;


/**
 @param name the name of the variable
 @param value the variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )
 @param type (optional -1) it's usually not necessary to pass this parameter as the variable value is auto-detected
 */
+(id)variableWithName:(NSString *)name value:(id)value type:(NSInteger)type
{
    SFSBuddyVariable* bVar = [[SFSBuddyVariable alloc] initWithName:name value:value type:type];
    return bVar;
}

/**
 @param name the name of the variable
 @param value the variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )
 */
+(id)variableWithName:(NSString *)name value:(id)value
{
    SFSBuddyVariable* bVar = [[SFSBuddyVariable alloc] initWithName:name value:value type:-1];
    return bVar;
}


+(id<BuddyVariable>)fromSFSArray:(id <ISFSArray>)sfsa
{
    SFSBuddyVariable *var = [[SFSBuddyVariable alloc] initWithName:[sfsa getUtfString:0] value:[sfsa getElementAt:2] type:[sfsa getByte:1]];
    
    return var;
}

-(BOOL)isOffline
{	
	return [_name characterAtIndex:0] == '$';
}



@end
