Skip to content

Instantly share code, notes, and snippets.

@sonygod
Created January 19, 2013 02:28
Show Gist options
  • Save sonygod/4570361 to your computer and use it in GitHub Desktop.
Save sonygod/4570361 to your computer and use it in GitHub Desktop.
enumIndex Test
package ;
/**
* ...
* @author sonygod
*/
import TaskData;
using Type;
class TaskUtils {
public function convert(taskFormat:TaskFormat):TaskInfo {
var obj = { };
for (i in Reflect.fields(taskFormat)) {
var value = Reflect.field(taskFormat, Std.string(i));
Reflect.setProperty(obj, i, value);
}
var tc:Array<FunAndArgs> = obj.triggerCondition;
var target:Array<FunAndArgs> = obj.target;
var award:Array<FunAndArgs> = obj.award;
var type:UInt = obj.type;
switch(type) {
case TaskType.Main.enumIndex():
obj.type = TaskType.Main;
case TaskType.Extend.enumIndex():
obj.type = TaskType.Extend;
case TaskType.Country.enumIndex():
obj.type = TaskType.Country
case TaskType.Legion.enumIndex():
obj.type = TaskType.Legion;
case TaskType.Daily.enumIndex():
obj.type = TaskType.Daily;
case TaskType.Give.enumIndex():
obj.type = TaskType.Give;
case TaskType.Leader.enumIndex():
obj.type = TaskType.Leader;
default:
}
for (i in 0...award.length) {
var item:FunAndArgs = award[i];
}
return obj;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment