Exemplo n.º 1
0
        public override Var Parse(Scope scope)
        {
            Scope   hackedScope = new Scope();
            VarList argList     = new VarList();

            hackedScope.Variables         = argList;
            argList.StringVars["_parent"] = scope.Variables;
            argList.Meta = GetHackMeta();
            int index = 0;

            foreach (var t in _arguments)
            {
                index = t.AppendArguments(argList, index, hackedScope);
            }
            Var callVar = _caller.Parse(scope);

            if (callVar == null)
            {
                return(null);
            }

            CallData callData = new CallData
            {
                NumArgs = argList.DoubleVars,
                StrArgs = argList.StringVars,
                VarArgs = argList.OtherVars
            };

            return(callVar.Call(callData));
        }
Exemplo n.º 2
0
    public void Action(object obj)
    {
        var names_scope = new Scope();

        scope.Union(Core.FactionNames(obj));
        scope.Union(Core.TraitsNames(obj));
        scope.Intersect(Core.CultureNames(obj));

        var fallback_names = new Scope();

        scope.Union(Core.FactionNames(obj));
        scope.Union(Core.TraitsNames(obj));
        fallback_names.Weight(Core.SimilarTraits(Core.TraitsNames(obj)));

        var second_name = new Scope();

        {
            var husband_name = new Var <string>();
            if (Core.SexIs(Sexes.Female) && Core.FamilyStatus(Family.Married))
            {
                husband_name.Value = Core.HusbandName(obj);
            }
            var family_name = new Var <string>();
            if (Core.HasFamily(obj) && !husband_name)            // ! husband_name.HasValue()
            {
                family_name.Value = Core.FamilyName();
            }
            var random_name = new Var <string>(Core.NewName, Core.CultureSecondNames);
            if (!husband_name && !family_name)
            {
                random_name.Call();
            }

            second_name.Union(husband_name);
            second_name.Union(family_name);
            second_name.Union(random_name);
        }

        Core.SetName(
            Core.Concat(
                Core.RandomFrom(
                    names_scope,
                    Core.MostWeigth(
                        fallback_names,
                        Core.NewName(
                            Core.CultureNames(obj),
                            "Error name")
                        )
                    ),
                " ",
                Core.SingleFrom(
                    second_name,
                    "Error name"
                    )
                )
            );
    }
Exemplo n.º 3
0
        public Var Parse(Var left, Var right)
        {
            Var metaMethod = Meta.LR_Get(left, right, _op.Name, $"left={left.Type}", $"right={right.Type}");

            return(metaMethod?.Call(new CallData(left, right)));
        }
Exemplo n.º 4
0
        public virtual Var Set(Var key, Var val)
        {
            Var callFunc = Funky.Meta.Get(this, "set", $"key({key.Type})", $"value({val.Type})");

            return(callFunc != null?callFunc.Call(new CallData(this, (VarString)key, val)) : val);
        }
Exemplo n.º 5
0
        public virtual Var Get(Var key)
        {
            Var callFunc = Funky.Meta.Get(this, "get", $"key({key.Type})");

            return(callFunc?.Call(new CallData(this, (VarString)key)));
        }