using DTLib.Extensions;

namespace Mlaumcherb.Client.Avalonia.классы;

public class GameArguments : ArgumentsWithPlaceholders
{
    private static readonly string[] _initial_arguments =
    [
        "--width", "${resolution_width}",
        "--height", "${resolution_height}",
    ];
    
    private static readonly string[] _enabled_features =
    [
    ];
    
    public GameArguments(GameVersionDescriptor d)
    {
        _raw_args.AddRange(_initial_arguments);
        
        if (d.minecraftArguments is not null)
        {
            _raw_args.AddRange(d.minecraftArguments.SplitToList(' ', quot: '"'));
        }
        else if (d.arguments is not null)
        {
            foreach (var av in d.arguments.game)
            {
                if(Rules.Check(av.rules, _enabled_features))
                {
                    foreach (var arg in av.value)
                    {
                        // if(!_raw_args.Contains(arg))
                            _raw_args.Add(arg);
                    }
                }
            }
        }
        else throw new Exception("no game arguments specified in descriptor");
    }
}
