//
//  MyScriptTask.h
//  nochange
//
//  Created by mac on 2024/7/23.
//

#ifndef MyScriptTask_h
#define MyScriptTask_h

#import <Foundation/Foundation.h>
#import <mach/mach_time.h>
#import "MyAdServer.h"

typedef struct {
    int64_t _id;
    int type;
    NSString *appId;
    NSString *idfa;
    FixedPoint *btnLoc;
    NSString *adId;
    bool ad;
} ScriptTask;

typedef void (^ScriptRunOverCallback)(NSString* res);
typedef void (^ScriptReplaceCallback)(NSMutableString *newScript);

#define SCRIPT_START_TPL @"start.tpl.lua"
#define SCRIPT_START @"start.lua"
#define SCRIPT_TOUCH_BTN_TPL @"touch_btn.tpl.lua"
#define SCRIPT_TOUCH_BTN @"touch_btn.lua"
#define SCRIPT_TOUCH_AD_TPL @"touch_ad.tpl.lua"
#define SCRIPT_TOUCH_AD @"touch_ad.lua"
#define SCRIPT_KILL_ALL_TPL @"kill_all.tpl.lua"
#define SCRIPT_KILL_ALL @"kill_all.lua"


@interface MyScriptTask : NSObject
{
    
}

@property (nonatomic, assign) int64_t currentId;
@property (strong, nonatomic) NSTimer *timer;


- (int) enqueue:(id)item;
- (id) dequeue;
- (void) run;
- (void) stop;
- (void) start;
- (void) adClosed: (ScriptTask *)task;
- (BOOL) isRun;
- (void) saveAdTaskLog: (AdTaskLogData *)data;

- (int) runAdTouchScript: (ScriptTask *) taskData;

- (NSString*) statusStr;
- (NSString*) appid;
- (void) loadIncrCount;
- (void) completeTask;
+(instancetype)sharedInstance;


@end

#endif /* MyScriptTask_h */
