protected override void Eval(NodeChain nodeChain)
        {
            var value = (bool)ValueOf("Value");

            ApplyFunctionTo("Boolean", o =>
            {
                o = value;
                return(o);
            });
        }
        protected override void Eval(NodeChain nodeChain)
        {
            var value = (string)ValueOf("Value");

            ApplyFunctionTo("String", o =>
            {
                o = value;
                return(o);
            });
        }
Beispiel #3
0
        protected override void Eval(NodeChain nodeChain)
        {
            var value = (RPGVector3)ValueOf("Value");

            ApplyFunctionTo("Vector3", o =>
            {
                o = value;
                return(o);
            });
        }
Beispiel #4
0
            public bool Append(NodeChain chain)
            {
                if (chain.Left != Right)
                {
                    return(false);
                }

                Right = chain.Right;
                _nodes.AddRange(chain.Nodes.Skip(1));

                return(true);
            }
Beispiel #5
0
        public void FundMainChainNode()
        {
            this.StartNodes(Chain.Main);
            this.ConnectMainChainNodes();

            NodeChain mainUser = this.MainAndSideChainNodeMap["mainUser"];
            NodeChain fedMain1 = this.MainAndSideChainNodeMap["fedMain1"];
            NodeChain fedMain2 = this.MainAndSideChainNodeMap["fedMain2"];
            NodeChain fedMain3 = this.MainAndSideChainNodeMap["fedMain3"];

            TestHelper.MineBlocks(mainUser.Node, (int)this.mainchainNetwork.Consensus.CoinbaseMaturity + 1);
            TestHelper.WaitForNodeToSync(mainUser.Node, fedMain1.Node, fedMain2.Node, fedMain3.Node);

            Assert.Equal(this.mainchainNetwork.Consensus.ProofOfWorkReward, GetBalance(mainUser.Node));
        }
Beispiel #6
0
        public void AddConnection(Connection connection)
        {
            NodeChain left  = null;
            NodeChain right = null;

            foreach (var chain in _chains)
            {
                if (chain.Append(connection))
                {
                    if (left == null)
                    {
                        left = chain;
                    }
                    else
                    {
                        Debug.Assert(right == null);
                        right = chain;
                    }
                }
            }

            if (left != null && right != null)
            {
                if (left.Append(right))
                {
                    _chains.Remove(right);
                }
                else if (right.Append(left))
                {
                    _chains.Remove(left);
                }
                else
                {
                    Debug.Assert(false);
                }
            }
            else if (left == null && right == null)
            {
                _chains.Add(new NodeChain(connection, this));
            }
        }
Beispiel #7
0
        /// <summary>
        /// "-nopreload" - prevents loading shedules on start
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            using (StreamReader file = File.OpenText("markov.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                Markov = (NodeChain)serializer.Deserialize(file, typeof(NodeChain));
            }
            //Markov = System.Text.Json.JsonSerializer.Deserialize<NodeChain>(File.ReadAllText("markov.json"));

            Json_Data.ReadData();
            KeyboardInit();


            BOT = new Telegram.Bot.TelegramBotClient(ReadToken());
            logger.Info("Bot connected.");
            BOT.OnMessage += BotOnMessageReceived;

            BOT.StartReceiving(new UpdateType[] { UpdateType.Message });
            //Scheduler.RunNotifier().GetAwaiter().GetResult();
            logger.Info("Waiting for messages...");

            Console.CancelKeyPress += OnExit;
            _closing.WaitOne();
        }
Beispiel #8
0
 protected override void Eval(NodeChain nodeChain)
 {
     DialogHandler.Instance.EndDialog();
 }
        static void Main(string[] args)
        {
            double ID;
            string response;


            Console.WriteLine("Hit enter to begin");
            response = Console.ReadLine();
            try
            {
                Task <List <Jedi> > jediListReturn = JediAPI.GetAllJedis();

                jediListReturn.Wait();

                List <Jedi> jediListComplete = jediListReturn.Result;

                jediListComplete.ForEach(item => Console.Write(JsonConvert.SerializeObject(item) + Environment.NewLine));

                Console.WriteLine("Here are your star wars characters, please press enter");

                Console.ReadLine();

                Console.WriteLine("Please select which module you would like displayed with these characters:");
                Console.WriteLine("Type one of the following: nodes, linked list, stack, queue, binary tree, hash table");

                switch (Console.ReadLine())
                {
                case "linked list":
                    Instruction.SetLinkedList(jediListComplete);
                    break;

                case "stack":
                    Instruction.SetStackArray(jediListComplete);
                    break;

                case "nodes":
                    NodeChain.Noderize(jediListComplete);
                    break;

                case "queue":
                    Instruction.SetQueue(jediListComplete);
                    break;

                case "binary tree":
                    Instruction.SetBinaryTree(jediListComplete);
                    break;

                case "hash table":
                    Instruction.SetHashTable(jediListComplete);
                    break;

                default:
                    Console.WriteLine("Please select from the list above");
                    break;
                }
            }

            catch (Exception ex) //Exceptions here or in the function will be caught here
            {
                Console.WriteLine("Exception: " + ex.Message);
            }
        }
Beispiel #10
0
 protected override void Eval(NodeChain nodeChain)
 {
     GameMaster.ShowUI = true;
 }
Beispiel #11
0
        public static Damage EvaluateSkillDamage(string damageScalingTreeID, Damage damage, BaseCharacter character)
        {
            var dmgHasVariance = Rm_RPGHandler.Instance.Items.DamageHasVariance;
            var combatant      = character;
            var combatCalcTree = Rm_RPGHandler.Instance.Nodes.CombatNodeBank.NodeTrees.First(n => n.ID == damageScalingTreeID);

            NodeChain nodeChain = null;

            if (dmgHasVariance)
            {
                nodeChain = new NodeChain(combatCalcTree, typeof(CombatStartNode), "MIN_Physical")
                {
                    CombatantA = combatant,
                    IntValue   = damage.MinDamage
                };
                while (!nodeChain.Done)
                {
                    nodeChain.Evaluate();
                }
            }


            var nodeChainMax = new NodeChain(combatCalcTree, typeof(CombatStartNode), "MAX_Physical")
            {
                Combatant = combatant, IntValue = damage.MaxDamage
            };

            while (!nodeChainMax.Done)
            {
                nodeChainMax.Evaluate();
            }

            damage.MinDamage = dmgHasVariance ? nodeChain.IntValue : nodeChainMax.IntValue;
            damage.MaxDamage = nodeChainMax.IntValue;

            foreach (var element in Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions)
            {
                var       eleDamage = damage.ElementalDamages.FirstOrDefault(e => e.ElementID == element.ID);
                NodeChain chain     = null;
                if (dmgHasVariance)
                {
                    chain = new NodeChain(combatCalcTree, typeof(CombatStartNode), "MIN_" + element.ID)
                    {
                        Combatant = combatant, IntValue = eleDamage.MinDamage
                    };
                    while (!chain.Done)
                    {
                        chain.Evaluate();
                    }
                }


                var chainMax = new NodeChain(combatCalcTree, typeof(CombatStartNode), "MAX_" + element.ID)
                {
                    Combatant = combatant, IntValue = eleDamage.MaxDamage
                };
                while (!chainMax.Done)
                {
                    chainMax.Evaluate();
                }

                eleDamage.MinDamage = dmgHasVariance ? chain.IntValue : chainMax.IntValue;
                eleDamage.MaxDamage = chainMax.IntValue;
            }

            return(damage);
        }
Beispiel #12
0
        public DamageOutcome Evaluate(BaseCharacter attacker, BaseCharacter defender, Damage attackerDamage)
        {
            var damageDealt   = attackerDamage.DamageDealt;
            var doNotEval     = false;
            var evalWithDummy = false;

            if (attacker == null)
            {
                if (Rm_RPGHandler.Instance.Combat.SkipEvaluatingDmgWithNullAttack)
                {
                    doNotEval = true;
                }
                else
                {
                    attacker = new BaseCharacter();
                    attacker.Init();
                    evalWithDummy = true;
                }
            }

            if (!doNotEval && !evalWithDummy && (attacker.CharacterType == CharacterType.Player || defender.CharacterType == CharacterType.Player))
            {
                var participants = new[] { attacker, defender };
                if (participants.All(p => p != null) && participants.Any(p => p.CharacterType != CharacterType.Player))
                {
                    var player = participants.First(p => p.CharacterType == CharacterType.Player);
                    var other  = participants.First(p => p.CharacterType != CharacterType.Player);

                    var cc = other as CombatCharacter;
                    if (!cc.AttackedOnceByPlayer)
                    {
                        var repDef = Rm_RPGHandler.Instance.Repositories.Quests.AllReputations.FirstOrDefault(r => r.ID == cc.ReputationId);
                        if (repDef != null)
                        {
                            if (repDef.ValueLossForNPCAttack > 0)
                            {
                                var playerRep = GetObject.PlayerSave.QuestLog.AllReputations.FirstOrDefault(r => r.ReputationID == cc.ReputationId);
                                if (playerRep != null)
                                {
                                    playerRep.Value -= repDef.ValueLossForNPCAttack;
                                }
                            }
                        }
                        cc.AttackedOnceByPlayer = true;
                    }
                }
            }

            var combatCalcTree = Rm_RPGHandler.Instance.Nodes.DamageTakenTree;

            if (defender.CharacterType == CharacterType.Player)
            {
                var playerDifficulty = GetObject.PlayerSave.Difficulty;
                var difficultyDef    = Rm_RPGHandler.Instance.Player.Difficulties.FirstOrDefault(d => d.ID == playerDifficulty);
                if (difficultyDef != null)
                {
                    attackerDamage.ApplyMultiplier(difficultyDef.DamageMultiplier);
                }
            }

            if (!doNotEval)
            {
                var nodeChain = new NodeChain(combatCalcTree, typeof(CombatStartNode), "DamageTaken")
                {
                    Attacker    = attacker,
                    Defender    = defender,
                    Damage      = attackerDamage,
                    DamageDealt = damageDealt
                };

                AttackOutcome?outcome = null;
                while (!nodeChain.Done)
                {
                    nodeChain.Evaluate();

                    if (nodeChain.CurrentNode is MissedHitNode)
                    {
                        outcome = AttackOutcome.Missed;
                    }
                    else if (nodeChain.CurrentNode is EvadedHitNode)
                    {
                        outcome = AttackOutcome.Evaded;
                    }
                }

                if (outcome != null && (outcome != AttackOutcome.Success || outcome != AttackOutcome.Critical))
                {
                    return(new DamageOutcome(null, outcome.Value));
                }
                else
                {
                    return(new DamageOutcome(attackerDamage, damageDealt, nodeChain.Damage.IsCritical ? AttackOutcome.Critical : AttackOutcome.Success));
                }
            }
            else
            {
                return(new DamageOutcome(attackerDamage, attackerDamage.DamageDealt, AttackOutcome.Success));
            }
        }