Esempio n. 1
0
        public override bool Equals(object obj)
        {
            SoldierClassStat other = obj as SoldierClassStat;

            if (other == null)
            {
                return(false);
            }

            if (stat != other.stat)
            {
                return(false);
            }

            if (value != other.value)
            {
                return(false);
            }

            if (rank != other.rank)
            {
                return(false);
            }

            return(true);
        }
        public bool updateStatsElement(string internalName, List <SoldierClassStat> soldierStats)
        {
            foreach (SoldierClassStat soldierStat in soldierStats)
            {
                if (!soldierStat.allowUpdate().valid)
                {
                    return(false);
                }
            }

            XElement        documentStatsElement = getClassElement(internalName, Constants.XML_STATS);
            List <XElement> documentStatElements = documentStatsElement.Elements(Constants.XML_STAT).ToList();

            foreach (XElement documentStatElement in documentStatElements)
            {
                int?documentRank = Utils.parseStringToInt(documentStatElement.Element(Constants.XML_STAT_RANK).Value);
                int?documentType = Utils.parseStringToInt(documentStatElement.Element(Constants.XML_STAT_TYPE).Value);

                SoldierClassStat soldierStat = soldierStats.Where(x => (int)x.rank == documentRank && (int)x.stat == documentType).SingleOrDefault();

                if (soldierStat == null)
                {
                    documentStatElement.Element(Constants.XML_STAT_VALUE).Value = "";
                }
                else
                {
                    XElement statElement = soldierStat.getXmlElement();
                    documentStatElement.Element(Constants.XML_STAT_VALUE).Value = statElement.Element(Constants.XML_STAT_VALUE).Value;
                }
            }

            document.Save(fullPath);

            return(true);
        }
Esempio n. 3
0
        private SoldierClassStat buildSoldierStatFromControl(TextBox control, SoldierRank rank, Stat stat)
        {
            SoldierClassStat soldierStat = new SoldierClassStat();

            soldierStat.rank  = rank;
            soldierStat.stat  = stat;
            soldierStat.value = Utils.parseStringToInt(control.Text);

            return(soldierStat);
        }
Esempio n. 4
0
        public SoldierClassStat readStat(XElement statElement)
        {
            SoldierClassStat soldierClassStat = new SoldierClassStat();

            soldierClassStat.stat  = (Stat)Utils.parseStringToInt(statElement.Element("type").Value);
            soldierClassStat.rank  = (SoldierRank)Utils.parseStringToInt(statElement.Element("rank").Value);
            soldierClassStat.value = Utils.parseStringToInt(statElement.Element("value").Value);

            return(soldierClassStat);
        }
Esempio n. 5
0
        public int?getStatValue(SoldierRank rank, Stat stat)
        {
            SoldierClassStat classStat = stats.Where(x => x.rank == rank && x.stat == stat).SingleOrDefault();

            if (classStat == null)
            {
                return(null);
            }

            return(classStat.value);
        }
Esempio n. 6
0
        public List <SoldierClassStat> readStats(XElement statsElement)
        {
            List <SoldierClassStat> stats = new List <SoldierClassStat>();

            List <XElement> statElements = statsElement.Elements("stat").ToList();

            foreach (XElement statElement in statElements)
            {
                SoldierClassStat soldierStat = readStat(statElement);

                if (soldierStat != null)
                {
                    stats.Add(soldierStat);
                }
            }

            return(stats);
        }
Esempio n. 7
0
 public SoldierClassStat(SoldierClassStat other) : base()
 {
     stat  = other.stat;
     value = other.value;
     rank  = other.rank;
 }