void ReleaseDesignerOutlets()
        {
            if (LeagueName != null)
            {
                LeagueName.Dispose();
                LeagueName = null;
            }

            if (MatchContainer != null)
            {
                MatchContainer.Dispose();
                MatchContainer = null;
            }

            if (StatContainer != null)
            {
                StatContainer.Dispose();
                StatContainer = null;
            }

            if (TableContainer != null)
            {
                TableContainer.Dispose();
                TableContainer = null;
            }
        }
Exemplo n.º 2
0
 //Indexed Properties
 public float this[STAT name, StatContainer.Stat.statPart part]
 {
     get
     {
         return myStats[name, part];
     }
 }
Exemplo n.º 3
0
        public void SimpleAverageWinsOnTieTest()
        {
            DummyDealer     dealer = new();
            PlayerAlwaysHit player = new();
            StatContainer   stat   = StatCollector.RunBlackjackGame(dealer, player, "test", 1000, 2, 2);

            Assert.AreEqual(0, stat.AverageWins);
        }
Exemplo n.º 4
0
        public void SimpleAverageWinsTest()
        {
            DealerStackDoubler dealer = new();
            PlayerAlwaysHit    player = new();
            StatContainer      stat   = StatCollector.RunBlackjackGame(dealer, player, "test", 1000, 1, 2);

            Assert.AreEqual(1000, stat.AverageReturn);
        }
Exemplo n.º 5
0
 public WeaponStats()
 {
     attack     = new StatContainer(10);
     durability = new StatContainer(30);
     flame      = new StatContainer(5);
     chill      = new StatContainer(5);
     lightning  = new StatContainer(5);
     cyclone    = new StatContainer(5);
     exorcism   = new StatContainer(5);
     beast      = new StatContainer(5);
     scale      = new StatContainer(5);
 }
Exemplo n.º 6
0
        public void NoErrorPrintTest()
        {
            DummyDealer     dealer = new();
            PlayerAlwaysHit player = new();
            StatContainer   stat   = StatCollector.RunBlackjackGame(dealer, player, "test", 1000, 1, 1);

            byte[] data = new byte[1000];
            using (MemoryStream ms = new MemoryStream(data))
            {
                Assert.AreEqual(0, stat.PrintMainData(ms));
            }
        }
Exemplo n.º 7
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Space();

            _cs.Level = EditorGUILayout.IntField("Level", _cs.Level);

            StatContainer group = null;
            foreach (var stat in (Stats[])Enum.GetValues(typeof(Stats)))
            {

                StatContainer currentContainer;
                // смотрим текущую стату
                // если её еще нет в списке, то создать и добавить
                if (!_cs.StatsList.Exists(s => s.Name == stat))
                {
                    currentContainer = new StatContainer(stat, 1);
                    _cs.StatsList.Add(currentContainer);
                }
                // в противном случае, получаем на неё ссылку
                else
                    currentContainer = _cs.StatsList.FindLast(s => s.Name == stat);

                // если это стата-группа (например Constitution),
                // то сохраняем ссылку на неё в отдельной переменной group
                if (((int)stat & 0x0f) == 0x01)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(stat.ToString(), EditorStyles.boldLabel);
                    group = currentContainer;
                    group.Value = EditorGUILayout.IntField(stat.ToString(), group.Value);
                    continue;
                }

                // для зависимых статов (для Constitution это Health и т.д.)
                // устанавлваем соответствующую связь
                // все связи описаны в BaseStatsDependency
                //currentContainer.Value = EditorGUILayout.IntField(stat.ToString(), group.Value * 10);
                currentContainer.Value = EditorGUILayout.IntField(stat.ToString(),
                                        BaseStatsDependency.ParentToChildCalculation(group, stat));
            }

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed)
                EditorUtility.SetDirty(_cs);
        }
Exemplo n.º 8
0
 // i really wanted to have this be part of the initalization or constructor of the binded text boxes but i couldn't find a way to do it without running into errors
 private void InitalizeTabChildControls()
 {
     foreach (var tabPage in tabControl1.TabPages)
     {
         var tab = tabPage as TabPage;
         foreach (Control childControl in tab.Controls)
         {
             bool isBindedTextBox = childControl.GetType() == typeof(CustomControls.StatContainerBindedTextBox);
             if (isBindedTextBox)
             {
                 var           bindedTextBox = childControl as CustomControls.StatContainerBindedTextBox;
                 Stat          bindTarget    = bindedTextBox.bindTarget;
                 StatContainer foundStat     = RequestStat(bindTarget);
                 bindedTextBox.Bind(foundStat);
             }
         }
     }
 }
Exemplo n.º 9
0
        void LoadContainer()
        {
            if (!File.Exists(ContainerPath))
            {
                _container = new StatContainer();
                _logger.LogDebug($"Not found stat file at '{ContainerPath}', initialize as empty.");
                return;
            }
            var serializer = CreateSerializer();

            using (var stream = new FileStream(ContainerPath, FileMode.OpenOrCreate)) {
                try {
                    _container = serializer.Deserialize(stream) as StatContainer;
                } catch (Exception e) {
                    _logger.LogError($"Can't load stat file from '{ContainerPath}': \"{e}\"");
                    _container = new StatContainer();
                }
            }
        }
Exemplo n.º 10
0
    //Initializer
    public void InIt()
    {
        myStats = new StatContainer(3, 9);
        myStats.addStat(STAT.HEALTH);
        myStats.addStat(STAT.ARMOR);
        myStats.addStat(STAT.STAMINA);

        myStats.addAttribute(ATTRIBUTE.STRENGTH);
        myStats.addAttribute(ATTRIBUTE.INTELLIGENCE);
        myStats.addAttribute(ATTRIBUTE.AGILITY);
        myStats.addAttribute(ATTRIBUTE.ENDURANCE);
        myStats.addAttribute(ATTRIBUTE.REFLEXES);
        myStats.addAttribute(ATTRIBUTE.CURRENCY);
        myStats.addAttribute(ATTRIBUTE.DAMAGEREDUCTION);
        myStats.addAttribute(ATTRIBUTE.EXPERIENCE);
        myStats.addAttribute(ATTRIBUTE.DAMAGE);

        if (IsAI)
            this.playerType = PlayerType.Enemy;

        LoadAll();
        GetComponentInChildren<Attack>().Init();
    }
Exemplo n.º 11
0
        private void InitializeHistory()
        {
            var hasDamage      = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallDamage") > 0;
            var hasHealing     = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallHealing") > 0;
            var hasDamageTaken = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallDamageTaken") > 0;

            if (hasDamage || hasHealing || hasDamageTaken)
            {
                StatContainer  currentOverallStats = this.ParseControl.Timeline.Overall.Stats;
                var            historyItem         = new ParseHistoryItem();
                HistoryControl historyController   = historyItem.HistoryControl = new HistoryControl();
                foreach (Stat <double> stat in currentOverallStats)
                {
                    historyController.Timeline.Overall.Stats.EnsureStatValue(stat.Name, stat.Value);
                }

                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDPS", currentOverallStats.GetStatValue("DPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDOTPS", currentOverallStats.GetStatValue("DOTPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHPS", currentOverallStats.GetStatValue("HPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHOHPS", currentOverallStats.GetStatValue("HOHPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHOTPS", currentOverallStats.GetStatValue("HOTPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHMPS", currentOverallStats.GetStatValue("HMPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDTPS", currentOverallStats.GetStatValue("DTPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDTOTPS", currentOverallStats.GetStatValue("DTOTPS"));
                StatGroup[] playerList = this.ParseControl.Timeline.Party.ToArray();
                foreach (StatGroup player in playerList)
                {
                    HistoryGroup playerInstance = historyController.Timeline.GetSetPlayer(player.Name);
                    playerInstance.Last20DamageActions      = ((Player)player).Last20DamageActions.ToList();
                    playerInstance.Last20DamageTakenActions = ((Player)player).Last20DamageTakenActions.ToList();
                    playerInstance.Last20HealingActions     = ((Player)player).Last20HealingActions.ToList();
                    playerInstance.Last20Items = ((Player)player).Last20Items.ToList();
                    foreach (Stat <double> stat in player.Stats)
                    {
                        playerInstance.Stats.EnsureStatValue(stat.Name, stat.Value);
                    }

                    this.RabbitHoleCopy(ref playerInstance, player);
                }

                StatGroup[] monsterList = this.ParseControl.Timeline.Monster.ToArray();
                foreach (StatGroup monster in monsterList)
                {
                    HistoryGroup monsterInstance = historyController.Timeline.GetSetMonster(monster.Name);
                    monsterInstance.Last20DamageActions      = ((Monster)monster).Last20DamageActions.ToList();
                    monsterInstance.Last20DamageTakenActions = ((Monster)monster).Last20DamageTakenActions.ToList();
                    monsterInstance.Last20HealingActions     = ((Monster)monster).Last20HealingActions.ToList();
                    monsterInstance.Last20Items = ((Monster)monster).Last20Items.ToList();
                    foreach (Stat <double> stat in monster.Stats)
                    {
                        monsterInstance.Stats.EnsureStatValue(stat.Name, stat.Value);
                    }

                    this.RabbitHoleCopy(ref monsterInstance, monster);
                }

                historyItem.Start       = this.ParseControl.StartTime;
                historyItem.End         = DateTime.Now;
                historyItem.ParseLength = historyItem.End - historyItem.Start;
                var parseTimeDetails = $"{historyItem.Start} -> {historyItem.End} [{historyItem.ParseLength}]";
                var zone             = "UNKNOWN";
                if (XIVInfoViewModel.Instance.CurrentUser != null)
                {
                    var     mapIndex = XIVInfoViewModel.Instance.CurrentUser.MapIndex;
                    MapItem mapItem  = ZoneLookup.GetZoneInfo(mapIndex);
                    switch (Constants.GameLanguage)
                    {
                    case "French":
                        zone = mapItem.Name.French;
                        break;

                    case "Japanese":
                        zone = mapItem.Name.Japanese;
                        break;

                    case "German":
                        zone = mapItem.Name.German;
                        break;

                    case "Chinese":
                        zone = mapItem.Name.Chinese;
                        break;

                    case "Korean":
                        zone = mapItem.Name.Korean;
                        break;

                    default:
                        zone = mapItem.Name.English;
                        break;
                    }
                }

                var monsterName = "NULL";
                try {
                    StatGroup biggestMonster = null;
                    foreach (StatGroup monster in this.ParseControl.Timeline.Monster)
                    {
                        if (biggestMonster == null)
                        {
                            biggestMonster = monster;
                        }
                        else
                        {
                            if (monster.Stats.GetStatValue("TotalOverallDamage") > biggestMonster.Stats.GetStatValue("TotalOverallDamage"))
                            {
                                biggestMonster = monster;
                            }
                        }
                    }

                    if (biggestMonster != null)
                    {
                        monsterName = biggestMonster.Name;
                    }
                }
                catch (Exception ex) {
                    Logging.Log(Logger, new LogItem(ex, true));
                }

                foreach (Stat <double> oStat in currentOverallStats)
                {
                    historyController.Timeline.Overall.Stats.EnsureStatValue(oStat.Name, oStat.Value);
                }

                historyItem.Name = $"{zone} [{monsterName}] {parseTimeDetails}";
                DispatcherHelper.Invoke(() => MainViewModel.Instance.ParseHistory.Insert(1, historyItem));
            }
        }
Exemplo n.º 12
0
            public static JsonParse ConvertParse()
            {
                var hasDamage      = ParseControl.Instance.Timeline.Overall.Stats.GetStatValue("TotalOverallDamage") > 0;
                var hasHealing     = ParseControl.Instance.Timeline.Overall.Stats.GetStatValue("TotalOverallHealing") > 0;
                var hasDamageTaken = ParseControl.Instance.Timeline.Overall.Stats.GetStatValue("TotalOverallDamageTaken") > 0;

                if (!hasDamage && !hasHealing && !hasDamageTaken)
                {
                    return(new JsonParse());
                }

                StatContainer currentOverallStats       = ParseControl.Instance.Timeline.Overall.Stats;
                Dictionary <string, object> historyItem = new Dictionary <string, object>();
                Dictionary <string, object> timeline    = new Dictionary <string, object>();
                Dictionary <string, object> overall     = new Dictionary <string, object> {
                    {
                        "Stats", new Dictionary <string, object>()
                    }
                };

                foreach (Stat <double> stat in currentOverallStats)
                {
                    ((Dictionary <string, object>)overall["Stats"]).Add(stat.Name, stat.Value);
                }

                timeline.Add("Overall", overall);
                StatGroup[] playerList = ParseControl.Instance.Timeline.Party.ToArray();
                Dictionary <string, object> players = new Dictionary <string, object>();

                foreach (StatGroup player in playerList)
                {
                    Dictionary <string, object> playerItem = new Dictionary <string, object> {
                        {
                            "Stats", new Dictionary <string, object>()
                        }, {
                            "Last20DamageActions", ((Player)player).Last20DamageActions.ToList()
                        }, {
                            "Last20DamageTakenActions", ((Player)player).Last20DamageTakenActions.ToList()
                        }, {
                            "Last20HealingActions", ((Player)player).Last20HealingActions.ToList()
                        }, {
                            "Last20Items", ((Player)player).Last20Items.ToList()
                        }
                    };
                    foreach (Stat <double> stat in player.Stats)
                    {
                        ((Dictionary <string, object>)playerItem["Stats"]).Add(stat.Name, stat.Value);
                    }

                    players.Add(player.Name, playerItem);
                    RabbitHoleCopy(ref playerItem, player);
                }

                timeline.Add("Party", players);
                StatGroup[] monsterList = ParseControl.Instance.Timeline.Monster.ToArray();
                Dictionary <string, object> monsters = new Dictionary <string, object>();

                foreach (StatGroup monster in monsterList)
                {
                    Dictionary <string, object> monsterItem = new Dictionary <string, object> {
                        {
                            "Stats", new Dictionary <string, object>()
                        }, {
                            "Last20DamageActions", ((Monster)monster).Last20DamageActions.ToList()
                        }, {
                            "Last20DamageTakenActions", ((Monster)monster).Last20DamageTakenActions.ToList()
                        }, {
                            "Last20HealingActions", ((Monster)monster).Last20HealingActions.ToList()
                        }, {
                            "Last20Items", ((Monster)monster).Last20Items.ToList()
                        }
                    };
                    foreach (Stat <double> stat in monster.Stats)
                    {
                        ((Dictionary <string, object>)monsterItem["Stats"]).Add(stat.Name, stat.Value);
                    }

                    monsters.Add(monster.Name, monsterItem);
                    RabbitHoleCopy(ref monsterItem, monster);
                }

                timeline.Add("Monster", monsters);
                historyItem.Add("Timeline", timeline);



                DateTime start            = ParseControl.Instance.StartTime;
                DateTime end              = DateTime.Now;
                TimeSpan parseLength      = end - start;
                var      parseTimeDetails = $"{start} -> {end} [{parseLength}]";
                var      zone             = "UNKNOWN";

                if (XIVInfoViewModel.Instance.CurrentUser != null)
                {
                    var     mapIndex = XIVInfoViewModel.Instance.CurrentUser.MapIndex;
                    MapItem mapItem  = ZoneLookup.GetZoneInfo(mapIndex);
                    switch (Constants.GameLanguage)
                    {
                    case "French":
                        zone = mapItem.Name.French;
                        break;

                    case "Japanese":
                        zone = mapItem.Name.Japanese;
                        break;

                    case "German":
                        zone = mapItem.Name.German;
                        break;

                    case "Chinese":
                        zone = mapItem.Name.Chinese;
                        break;

                    case "Korean":
                        zone = mapItem.Name.Korean;
                        break;

                    default:
                        zone = mapItem.Name.English;
                        break;
                    }
                }

                var monsterName = "NULL";

                try {
                    StatGroup biggestMonster = null;
                    foreach (StatGroup monster in ParseControl.Instance.Timeline.Monster)
                    {
                        if (biggestMonster == null)
                        {
                            biggestMonster = monster;
                        }
                        else
                        {
                            if (monster.Stats.GetStatValue("TotalOverallDamage") > biggestMonster.Stats.GetStatValue("TotalOverallDamage"))
                            {
                                biggestMonster = monster;
                            }
                        }
                    }

                    if (biggestMonster != null)
                    {
                        monsterName = biggestMonster.Name;
                    }
                }
                catch (Exception ex) {
                    Logging.Log(Logger, new LogItem(ex, true));
                }



                return(new JsonParse {
                    Name = $"{zone} [{monsterName}] {parseTimeDetails}",
                    Parse = JsonConvert.SerializeObject(
                        historyItem,
                        new JsonSerializerSettings {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    })
                });
            }
Exemplo n.º 13
0
 public void addDelegate(ATTRIBUTE n, StatContainer.varChange d)
 {
     myStats[n, false] = d;
 }
Exemplo n.º 14
0
 public void addDelegate(STAT n, StatContainer.Stat.statPart p, StatContainer.varChange d)
 {
     myStats[n, p, false] = d;
 }
Exemplo n.º 15
0
 public void Bind(StatContainer stat)
 {
     _boundStat   = stat;
     Text         = stat.GetContents();
     TextChanged += TextUpdated; // adding the handler here avoids having the initial setting of the text trigger a change
 }
Exemplo n.º 16
0
    // Use this for initialization
    void Awake()
    {
        MyCharacters  = new CharacterContainer();
        MyPaths       = new PathsContainer();
        MyDisciplines = new DisciplineContainer();
        MyConcepts    = new ConceptContainer();
        MyClans       = new ClanContainer();
        MyBackgrounds = new BackgroundContainer();
        MyArchetypes  = new ArchetypesContainer();
        MyMeritFlaws  = new MeritFlawContainer();
        MyStats       = new StatContainer();

        CharacterXMLPath  = Application.dataPath + "/XML/Characters2.xml";
        AchetypeXMLPath   = Application.dataPath + "/XML/Archetypes.xml";
        BackgroundXMLPath = Application.dataPath + "/XML/Backgrounds.xml";
        ClanXMLPath       = Application.dataPath + "/XML/Clans.xml";
        ConceptXMLPath    = Application.dataPath + "/XML/Concepts.xml";
        DisciplineXMLPath = Application.dataPath + "/XML/Disciplines.xml";
        PathXMLPath       = Application.dataPath + "/XML/Paths.xml";
        MeritFlawXMLPath  = Application.dataPath + "/XML/MeritsFlaws.xml";
        StatsPath         = Application.dataPath + "/XML/Stats.xml";


        DirectoryInfo dirInf = new DirectoryInfo(Application.dataPath + "/XML");

        if (!dirInf.Exists)  //Check if directory exists
        {
            dirInf.Create();
        }
        if (!File.Exists(CharacterXMLPath))
        {
            //Debug.Log("No Character XML Data. Creating....");
            File.WriteAllText(CharacterXMLPath, CharacterXML.ToString());
            MyCharacters = CharacterContainer.Load(CharacterXMLPath);
        }
        else
        {
            //Debug.Log("Loading Character Data");
            MyCharacters = CharacterContainer.Load(CharacterXMLPath);
        }

        if (!File.Exists(AchetypeXMLPath))
        {
            //Debug.Log("No Archetype XML Data. Creating....");
            File.WriteAllText(AchetypeXMLPath, AchetypeXML.ToString());
            MyArchetypes = ArchetypesContainer.Load(AchetypeXMLPath);
        }
        else
        {
            //Debug.Log("Loading Archetype Data");
            MyArchetypes = ArchetypesContainer.Load(AchetypeXMLPath);
        }

        if (!File.Exists(BackgroundXMLPath))
        {
            //Debug.Log("No Backgrounds XML Data. Creating....");
            File.WriteAllText(BackgroundXMLPath, BackgroundXML.ToString());
            MyBackgrounds = BackgroundContainer.Load(BackgroundXMLPath);
        }
        else
        {
            //Debug.Log("Loading Background Data");
            MyBackgrounds = BackgroundContainer.Load(BackgroundXMLPath);
        }

        if (!File.Exists(ClanXMLPath))
        {
            //Debug.Log("No Clan XML Data. Creating....");
            File.WriteAllText(ClanXMLPath, ClanXML.ToString());
            MyClans = ClanContainer.Load(ClanXMLPath);
        }
        else
        {
            //Debug.Log("Loading Clan Data");
            MyClans = ClanContainer.Load(ClanXMLPath);
        }

        if (!File.Exists(DisciplineXMLPath))
        {
            //Debug.Log("No Discipline XML Data. Creating....");
            File.WriteAllText(DisciplineXMLPath, DisciplineXML.ToString());
            MyDisciplines = DisciplineContainer.Load(DisciplineXMLPath);
        }
        else
        {
            //Debug.Log("Loading Discipline Data");
            MyDisciplines = DisciplineContainer.Load(DisciplineXMLPath);
        }

        if (!File.Exists(PathXMLPath))
        {
            //Debug.Log("No Paths XML Data. Creating....");
            File.WriteAllText(PathXMLPath, PathXML.ToString());
            MyPaths = PathsContainer.Load(PathXMLPath);
        }
        else
        {
            //Debug.Log("Loading Paths Data");
            MyPaths = PathsContainer.Load(PathXMLPath);
        }

        if (!File.Exists(ConceptXMLPath))
        {
            //Debug.Log("No Concept XML Data. Creating....");
            File.WriteAllText(ConceptXMLPath, ConceptXML.ToString());
            MyConcepts = ConceptContainer.Load(ConceptXMLPath);
        }
        else
        {
            //Debug.Log("Loading Concept Data");
            MyConcepts = ConceptContainer.Load(ConceptXMLPath);
        }

        if (!File.Exists(MeritFlawXMLPath))
        {
            //Debug.Log("No MeritFlaw XML Data. Creating....");
            File.WriteAllText(MeritFlawXMLPath, MeritFlawXML.ToString());
            MyMeritFlaws = MeritFlawContainer.Load(MeritFlawXMLPath);
        }
        else
        {
            //Debug.Log("Loading MeritFlaw Data");
            MyMeritFlaws = MeritFlawContainer.Load(MeritFlawXMLPath);
        }
        if (!File.Exists(StatsPath))
        {
            //Debug.Log("No Stats XML Data. Creating....");
            File.WriteAllText(StatsPath, StatsXML.ToString());
            MyStats = StatContainer.Load(StatsPath);
        }
        else
        {
            //Debug.Log("Loading Stats XML Data");
            MyStats = StatContainer.Load(StatsPath);
        }
        Loaded = true;
    }