Esempio n. 1
0
        public bool Evaluate(EventContext context, Game game)
        {
            //No children means its never true.  Used in CHILDREN_WELLDRESS_PRESTIGE_MOD.
            if (context.CurrentCharacter.Children.Count == 0)
                return false;

            for (int i = 0; i < context.CurrentCharacter.Children.Count; ++i)
            {
                context.PushScope(context.CurrentCharacter.Children[i]);
                if (!requirements.Evaluate(context, game))
                {
                    //We've found a child that doesn't the requirements.  This is a failure
                    context.PopScope();
                    return false;
                }
                context.PopScope();
            }
            return true;
        }
Esempio n. 2
0
        public double Evaluate(Game game, EventContext context, Weights weights)
        {
            //TODO: Start with random index.
            // TODO: Should we be doing some average here instead of just stopping
            // at the first one that works?
            for (int i = 0; i < context.CurrentCharacter.Children.Count; ++i)
            {
                Character character = context.CurrentCharacter.Children[i];
                context.PushScope(character);
                if (requirements.Evaluate(context, game))
                {
                    double result = operation.Evaluate(game, context, weights);

                    //AnyChild stops after a single interation.
                    context.PopScope();
                    return result;
                }
                context.PopScope();
            }
            return 0.0;
        }
Esempio n. 3
0
 public bool Evaluate(EventContext context, Game game)
 {
     context.PushScope(context.GetScopedObjectByName(scopeName));
     bool result = logic.Evaluate(context, game);
     context.PopScope();
     return result;
 }
Esempio n. 4
0
        public bool Evaluate(EventContext context, Game game)
        {
            //No children means its never true.
            if (context.CurrentCharacter.Children.Count == 0)
                return false;

            //TODO: start with a random child index.
            for(int i = 0; i < context.CurrentCharacter.Children.Count; ++i)
            {
                context.PushScope(context.CurrentCharacter.Children[i]);
                if(requirements.Evaluate(context, game))
                {
                    //We've found a child that meets the requirements.
                    context.PopScope();
                    return true;
                }
                context.PopScope();
            }
            return false;
        }
Esempio n. 5
0
        public void Execute(EventResults result, Game game, EventContext context)
        {
            Character tellingCharacter = context.GetScopedObjectByName("ROOT") as Character;
            InformationInstance informationInstance = tellingCharacter.ChooseInformationAbout(type, context.GetScopedObjectByName(about) as Character);
            bool isNewInformation = context.CurrentCharacter.AddInformation(informationInstance);
            context.PushScope(informationInstance);
            operation.Execute(result, game, context);
            context.PopScope();

            result.AddObservableInfo(informationInstance, overhearChance, tellingCharacter);

            if (isNewInformation)
            {
                game.Log(context.CurrentCharacter.Name + " learned an information.");
                informationInstance.ExecuteOnTold(context.CurrentCharacter, game, context.CurrentCharacter.CurrentRoom);
            }
        }
Esempio n. 6
0
        public void Execute(EventResults result, Game game, EventContext context)
        {
            //TODO: Start with random index.
            for(int i = 0; i < context.CurrentCharacter.Children.Count; ++i)
            {
                Character character = context.CurrentCharacter.Children[i];
                context.PushScope(character);
                if (requirements.Evaluate(context, game))
                {
                    operation.Execute(result, game, context);

                    //AnyChild stops after a single interation.
                    context.PopScope();
                    return;
                }
                context.PopScope();
            }
        }
Esempio n. 7
0
 public void Execute(EventResults result, Game game, EventContext context)
 {
     context.PushScope(context.GetScopedObjectByName(scopeName));
     operation.Execute(result, game, context);
     context.PopScope();
 }
Esempio n. 8
0
 public double Evaluate(Game game, EventContext context, Weights weights)
 {
     context.PushScope(context.GetScopedObjectByName(scopeName));
     double result = operation.Evaluate(game, context, weights);
     context.PopScope();
     return result;
 }
Esempio n. 9
0
 public void Execute(EventResults result, Game game, EventContext context)
 {
     foreach (var character in context.CurrentCharacter.CurrentRoom.GetCharacters(context.CurrentCharacter))
     {
         context.PushScope(character);
         if (requirements.Evaluate(context, game))
         {
             operation.Execute(result, game, context);
         }
         context.PopScope();
     }
 }
Esempio n. 10
0
 public double Evaluate(Game game, EventContext context, Weights weights)
 {
     double result = 0.0;
     foreach (var character in context.CurrentCharacter.CurrentRoom.GetCharacters(context.CurrentCharacter))
     {
         context.PushScope(character);
         if (requirements.Evaluate(context, game))
         {
             result += operation.Evaluate(game, context, weights);
         }
         context.PopScope();
     }
     return result;
 }
Esempio n. 11
0
 public void Execute(EventResults result, Game game, EventContext context)
 {
     Character chosen = context.CurrentCharacter.ChooseCharacter(game.FilterCharacters(requirements, context), operation, context, scopeName);
     context.PushScope(chosen, scopeName);
     operation.Execute(result, game, context);
     context.PopScope();
 }
Esempio n. 12
0
        private double EvaluateChangedModifiers(Character character, EventContext context, Game game)
        {
            context.PushScope(character);
            List<PrestigeModifier> addedModifiers = new List<PrestigeModifier>();
            List<PrestigeModifier> removedModifiers = new List<PrestigeModifier>();
            game.GetChangedModifiers(context, addedModifiers, removedModifiers);

            double result = 0.0;
            if (addedModifiers.Count > 0 || removedModifiers.Count > 0)
            {
                foreach (var added in addedModifiers)
                {
                    result += added.DailyChange;
                }
                foreach (var removed in removedModifiers)
                {
                    result -= removed.DailyChange;
                }

            }
            context.PopScope();
            return result * 100.0 * 10.0;
        }
Esempio n. 13
0
 public Character[] FilterCharacters(ILogic requirements, EventContext context)
 {
     List<Character> matchingCharacters = new List<Character>();
     foreach (Character character in this.AllCharacters)
     {
         context.PushScope(character);
         if (requirements.Evaluate(context, this))
         {
             matchingCharacters.Add(character);
         }
         context.PopScope();
     }
     return matchingCharacters.ToArray();
 }