Ejemplo n.º 1
0
 public double EvaluateOnTold(Character perspectiveCharacter, Character evaluateCharacter, Game game)
 {
     //The perspectiveCharacter is the character performing the query.
     //The evaluateCharacter is the character whose opinion on the information we care about.
     EventContext observeContext = new EventContext(evaluateCharacter, parameters);
     return information.OnTold.Evaluate(game, observeContext, evaluateCharacter.GetWeights(perspectiveCharacter));
 }
Ejemplo n.º 2
0
 public PlayerCharacter(MainWindow main, string name, int birthdate, Dynasty dynasty, int money, Game game, Gender gender)
     : base(name, birthdate, dynasty, money, game, gender)
 {
     this.main = main;
     notificator = new Notificator();
     notificator.Show();
 }
Ejemplo n.º 3
0
        public MainWindow(string playerName, string playerDynasty, int age)
        {
            this.FormClosed += MainWindow_FormClosed;
            InitializeComponent();
            logger = new TextBoxLogger(this);
            game = new Game(logger, NUM_PLAYERS);

            player = new PlayerCharacter(this, playerName, -Game.GetYearInTicks(age), new Dynasty(playerDynasty), 500, game, Gender.Male);
            game.AddPlayer(player);
            UpdateDate();
            UpdateStatus();

            if (Debugger.IsAttached)
            {
                restartButton.Visible = true;
                debugButton.Visible = true;
            }
            speedStep.Visible = false;
            restartButton.Visible = false;
            nextButton.Visible = false;
            playerStatusStrip.Visible = true;

            gameThread = new Thread(GameThread);
            gameThread.Start();
        }
Ejemplo n.º 4
0
 public double Calculate(EventContext context, Game game)
 {
     double result = 0.0;
     foreach(var part in parts)
     {
         result += part.Calculate(context, game);
     }
     return result;
 }
Ejemplo n.º 5
0
 public bool Evaluate(EventContext context, Game game)
 {
     for(int i = 0; i < subexpressions.Length; ++i)
     {
         if (!subexpressions[i].Evaluate(context, game))
             return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 public void GetChangedModifiers(EventContext context, Game game, List<PrestigeModifier> added, List<PrestigeModifier> removed)
 {
     foreach (var modifier in prestigeModifiers)
     {
         if (modifier.EvaluateRequirements(context, game) && !modifier.EvaluateRequirements(context.CurrentCharacter, game))
         {
             added.Add(modifier);
         }
         else if (!modifier.EvaluateRequirements(context, game) && modifier.EvaluateRequirements(context.CurrentCharacter, game))
         {
             removed.Add(modifier);
         }
     }
 }
Ejemplo n.º 7
0
 public void EvaluatePrestigeModifiers(Character character, Game game)
 {
     foreach (var modifier in prestigeModifiers)
     {
         if (modifier.EvaluateRequirements(character, game))
         {
             character.AddPrestigeModifier(modifier);
             character.PrestigeChange(modifier.DailyChange);
         }
         else
         {
             character.RemovePrestigeModifier(modifier);
         }
     }
 }
Ejemplo n.º 8
0
        public DNA CreateChildDNA(Character character, DNA father, DNA mother, Game game)
        {
            int face = SelectRandomAllowed(faceImages, character, father.Face, mother.Face, game);
            int mouth = SelectRandomAllowed(mouthImages, character, father.Mouth, mother.Mouth, game);
            int nose = SelectRandomAllowed(noseImages, character, father.Nose, mother.Nose, game);
            int eyes = SelectRandomAllowed(eyeImages, character, father.Eyes, mother.Eyes, game);
            int eyebrows = SelectRandomAllowed(eyebrowImages, character, father.Eyebrows, mother.Eyebrows, game);
            int ears = SelectRandomAllowed(earImages, character, father.Ears, mother.Ears, game);
            int hair = SelectRandomAllowed(hairImages, character, father.Hair, mother.Hair, game);
            int skinColor = SelectRandomAllowedColor(skinColors, character, father.SkinColor, mother.SkinColor, game);
            int eyeColor = SelectRandomAllowedColor(eyeColors, character, father.EyeColor, mother.EyeColor, game);
            int hairColor = SelectRandomAllowedColor(hairColors, character, father.HairColor, mother.HairColor, game);
            int shirtColor = CharacterVisualizationManager.GetRandomShirtColor(game);

            return new DNA(face, mouth, nose, eyes, eyebrows, ears, hair, skinColor, eyebrows, hairColor, shirtColor);
        }
Ejemplo n.º 9
0
        public static double GetTestValue(EventContext context, Game game, string value)
        {
            //These values must match the special cases on IsSpecialName
            if (value == "TIME")
                return game.CurrentTime;
            else if (value == "AGE")
                return context.CurrentCharacter.Age;
            else if (value == "GOLD")
                return context.CurrentCharacter.Money;

            double dValue;
            if (double.TryParse(value, out dValue))
                return dValue;

            return context.GetVariable(context.CurrentCharacter, value);
        }
Ejemplo n.º 10
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();
            }
        }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
0
        public MainWindow()
        {
            this.FormClosed += MainWindow_FormClosed;
            InitializeComponent();
            logger = new TextBoxLogger(this);
            game = new Game(logger, NUM_PLAYERS);
            UpdateDate();

            if(Debugger.IsAttached)
            {
                restartButton.Visible = true;
                debugButton.Visible = true;
            }

            speedStep.Visible = true;
            restartButton.Visible = true;
            nextButton.Visible = true;
            playerStatusStrip.Visible = false;
        }
Ejemplo n.º 13
0
        public JournalForm(Character[] characters, Game game, Character fixedPerspective)
        {
            InitializeComponent();
            this.game = game;
            this.characters = characters;
            this.fixedPerspective = fixedPerspective;
            knownCharacters.Items.AddRange(characters);
            knownCharacters.SelectedIndex = 0;

            if(fixedPerspective != null)
            {
                debugPerspectiveBox.Visible = false;
            }
            else
            {
                debugPerspectiveBox.Items.AddRange(characters);
                debugPerspectiveBox.SelectedIndex = 0;
            }
        }
Ejemplo n.º 14
0
        public void AssignInitialTraits(Game game, Character character, int maxInitialTraits)
        {
            ISet<string> banned = new HashSet<string>();
            for (int i = 0; i < maxInitialTraits; ++i)
            {
                Trait nextTrait = traits.Values.ElementAt(game.GetRandom(traits.Values.Count));
                if (banned.Contains(nextTrait.Identifier))
                {
                    continue;
                }

                foreach (var opposite in nextTrait.Opposites)
                {
                    banned.Add(opposite);
                }

                banned.Add(nextTrait.Identifier);
                character.AddTrait(nextTrait);
            }
        }
Ejemplo n.º 15
0
        public Character(string name, int birthdate, Dynasty dynasty, int money, Game game, Gender gender)
        {
            Name = name;
            BirthDate = birthdate;
            Dynasty = dynasty;
            Money = money;
            WillPower = Game.MAX_WILLPOWER;
            Game = game;
            Gender = gender;
            KnownInformation = new List<InformationInstance>();
            traits = new Dictionary<string, Trait>();
            jobs = new Dictionary<string, Job>();
            prestigeModifiers = new HashSet<PrestigeModifier>();
            Children = new List<Character>();

            //TODO: have actual personality in the weights.
            //TODO: public and private weights should be different
            publicWeights = new Weights(this);
            privateWeights = new Weights(this);
        }
Ejemplo n.º 16
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;
        }
Ejemplo n.º 17
0
        public bool Evaluate(EventContext context, Game game)
        {
            Event e = game.GetEventById(eventId);
            if (e == null)
                return false;

            Dictionary<string, object> computedParameters = new Dictionary<string, object>();
            foreach (var pair in parameters)
            {
                computedParameters.Add(pair.Key, context.GetScopedObjectByName(pair.Value));
            }
            EventContext newContext = new EventContext(context.CurrentCharacter, computedParameters);
            return e.GetAvailableOptions(newContext, game).Length > 0;
        }
Ejemplo n.º 18
0
 public bool Evaluate(EventContext context, Game game)
 {
     context.PushScope(context.GetScopedObjectByName(scopeName));
     bool result = logic.Evaluate(context, game);
     context.PopScope();
     return result;
 }
Ejemplo n.º 19
0
 public bool Evaluate(EventContext context, Game game)
 {
     return context.CurrentCharacter.PrestigeRank <= prestigeRank;
 }
Ejemplo n.º 20
0
 public bool Evaluate(EventContext context, Game game)
 {
     return !logic.Evaluate(context, game);
 }
Ejemplo n.º 21
0
 public bool Evaluate(EventContext context, Game game)
 {
     return game.GetJobById(jobId).CanPerformJob(context.CurrentCharacter, game);
 }
Ejemplo n.º 22
0
 public bool Evaluate(EventContext context, Game game)
 {
     return (context.GetScopedObjectByName(otherCharacter) as Character).Spouse == context.CurrentCharacter;
 }
Ejemplo n.º 23
0
 public bool Evaluate(EventContext context, Game game)
 {
     return context.CurrentCharacter.Gender == Gender.Male;
 }
Ejemplo n.º 24
0
 public bool Evaluate(EventContext context, Game game)
 {
     return game.CurrentTime == game.CurrentDay;
 }
Ejemplo n.º 25
0
 public bool Evaluate(EventContext context, Game game)
 {
     return (context.GetScopedObjectByName(otherCharacter) as Character).Children.Contains(context.CurrentCharacter);
 }
Ejemplo n.º 26
0
 public bool Evaluate(EventContext context, Game game)
 {
     return true;
 }
Ejemplo n.º 27
0
 public bool Evaluate(EventContext context, Game game)
 {
     double myValue = XmlHelper.GetTestValue(context, game, varName);
     return myValue < testValue.Calculate(context, game);
 }
Ejemplo n.º 28
0
 public bool Evaluate(EventContext context, Game game)
 {
     return context.CurrentCharacter.HasTrait(traitId);
 }
Ejemplo n.º 29
0
 public bool Evaluate(EventContext context, Game game)
 {
     double myValue = XmlHelper.GetTestValue(context, game, varName);
     return Math.Abs(myValue - testValue.Calculate(context, game)) >= Logic.EPSILON;
 }
Ejemplo n.º 30
0
 public bool Evaluate(EventContext context, Game game)
 {
     return context.CurrentCharacter.Age >= 21;
 }