Пример #1
0
        public ParseErrorExpression Merge(RichPresenceBuilder from)
        {
            if (!String.IsNullOrEmpty(from.DisplayString))
            {
                DisplayString = from.DisplayString;
            }

            _conditionalDisplayStrings.AddRange(from._conditionalDisplayStrings);

            foreach (var kvp in from._valueFields)
            {
                ValueField field;
                if (!_valueFields.TryGetValue(kvp.Key, out field))
                {
                    _valueFields.Add(kvp);
                }
                else if (field.Format != kvp.Value.Format)
                {
                    return(new ParseErrorExpression("Multiple rich_presence_value calls with the same name must have the same format", field.Func));
                }
            }

            foreach (var kvp in from._lookupFields)
            {
                Lookup existing;
                if (!_lookupFields.TryGetValue(kvp.Key, out existing))
                {
                    _lookupFields.Add(kvp);
                }
                else
                {
                    var toMerge = kvp.Value;

                    if (existing.Fallback != toMerge.Fallback)
                    {
                        return(new ParseErrorExpression("Multiple rich_presence_lookup calls with the same name must have the same fallback", toMerge.Fallback ?? existing.Fallback));
                    }

                    if (existing.Entries.Count != toMerge.Entries.Count)
                    {
                        return(new ParseErrorExpression("Multiple rich_presence_lookup calls with the same name must have the same dictionary", toMerge.Func ?? existing.Func));
                    }

                    foreach (var kvp2 in existing.Entries)
                    {
                        string value;
                        if (!toMerge.Entries.TryGetValue(kvp2.Key, out value) || kvp2.Value != value)
                        {
                            return(new ParseErrorExpression("Multiple rich_presence_lookup calls with the same name must have the same dictionary", toMerge.Func ?? existing.Func));
                        }
                    }
                }
            }

            return(null);
        }
Пример #2
0
 public AchievementScriptInterpreter()
 {
     _achievements = new List <Achievement>();
     _leaderboards = new List <Leaderboard>();
     _richPresence = new RichPresenceBuilder();
 }