Macro.add('ConnectionExecute',{
    handler  : function () {
        const _executeData = this.args[0];
        for(const [_capturedKey, _captureValue] of Object.entries(_executeData.capturedVars)){
            State.setVar(_capturedKey,_captureValue);
        }

        if(_executeData.duration)
            State.variables.time.minutes += _executeData.duration;
        jQuery(this.output).wiki(_executeData.content);
    }
});

setup.connectionExecute = function(connectedLocation:ConnectedLocation):string{
    if(connectedLocation.destination){
        const from = State.variables.location.locationIdentifier;
        const destination = connectedLocation.destination;
        const duration = connectedLocation.duration;
        const tags = connectedLocation.tags ?? [];
        const travelRequest = new LocationTravelRequest(destination,from,duration,tags);
        setup.travel(travelRequest);
        return;
    }

    if(connectedLocation.content){
        var html = document.createElement('div');
        $(html).wiki(connectedLocation.content);
        return html.innerHTML;
    }

    return '';
}

    
    

