コード例 #1
0
ファイル: MercService.cs プロジェクト: yangbingqi155/tnet
        public static Merc Add(Merc merc)
        {
            TN db = new TN();

            db.Mercs.Add(merc);
            db.SaveChanges();
            return(merc);
        }
コード例 #2
0
        public static SpecViewModel GetSpec(string idspec)
        {
            SpecViewModel viewModel = null;
            Spec          spec      = GetALL().Where(en => en.idspec == idspec).FirstOrDefault();

            if (spec != null)
            {
                viewModel = new SpecViewModel();
                viewModel.CopyFromBase(spec);
                Merc merc = MercService.GetMerc(viewModel.idmerc);
                viewModel.merc = merc != null ? merc.merc1 : "";
            }
            return(viewModel);
        }
コード例 #3
0
ファイル: MercService.cs プロジェクト: yangbingqi155/tnet
        public static bool SetDefaultMercImage(int idmerc)
        {
            bool result = false;

            try
            {
                TN        db         = new TN();
                MercImage firstImage = db.MercImages.Where(en => en.idmerc == idmerc).OrderBy(en => en.SortID).First();
                string    imagPath   = firstImage == null ? "" : firstImage.Path;
                Merc      merc       = db.Mercs.Find(idmerc);
                merc.imgs = imagPath;
                db.SaveChanges();
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
コード例 #4
0
ファイル: MercService.cs プロジェクト: yangbingqi155/tnet
        public static Merc Edit(Merc merc)
        {
            TN   db      = new TN();
            Merc oldMerc = db.Mercs.Where(en => en.idmerc == merc.idmerc).FirstOrDefault();

            oldMerc.idtype    = merc.idtype;
            oldMerc.merc1     = merc.merc1;
            oldMerc.sellpt    = merc.sellpt;
            oldMerc.baseprice = merc.baseprice;
            oldMerc.stime     = merc.stime;
            oldMerc.entime    = merc.entime;
            oldMerc.netype    = merc.netype;
            //oldMerc.imgs = merc.imgs;
            oldMerc.descs  = merc.descs;
            oldMerc.notes  = merc.notes;
            oldMerc.sortno = merc.sortno;
            oldMerc.isetup = merc.isetup;
            oldMerc.inuse  = merc.inuse;

            db.SaveChanges();
            return(oldMerc);
        }
コード例 #5
0
        public static List <SpecViewModel> GetSpecsByIdMerc(int idmerc)
        {
            List <SpecViewModel> specs = new List <SpecViewModel>();
            TN          tn             = new TN();
            List <Spec> entities       = GetALL().Where(en => en.idmerc == idmerc).ToList();

            if (entities != null && entities.Count > 0)
            {
                specs = entities.Select(model => {
                    SpecViewModel viewModel = new SpecViewModel();
                    viewModel.CopyFromBase(model);
                    return(viewModel);
                }).ToList();
                List <Merc> mercs = tn.Mercs.ToList();
                specs = specs.Select(en => {
                    Merc merc = mercs.Find(model => model.idmerc == en.idmerc);
                    en.merc   = merc != null ? merc.merc1 : "";
                    return(en);
                }).ToList();
            }

            return(specs);
        }
コード例 #6
0
    private Merc readMerc(string dataType, string dataText, string fileName, StreamReader reader)
    {
        if (dataText == "<{>") {
            Merc merc = new Merc();
            string line = reader.ReadLine().Trim ();

            bool sustain = false;
            bool evasion = false;
            bool capacity = false;
            bool groundShots = false;
            bool spaceShots = false;

            do {
                string[] lineParts;
                //Split category name from data
                lineParts = line.Split(":".ToCharArray(), 2);

                //Remove any extra whitespace from parts & set descriptive variables
                string newDataType = gameManager.LanguageMgr.StringToDataType(lineParts[0].Trim ());
                string newDataText = lineParts[1].Trim ();

                if (newDataType == "Name") {
                    merc.Name = readTextLine(newDataType, newDataText, fileName);
                } else if (newDataType == "Sustain Damage") {
                    sustain = merc.SustainDamage = true;
                } else if (newDataType == "Evasion") {
                    merc.Evasion = readIntLine(newDataType, newDataText, fileName);
                    evasion = true;
                } else if (newDataType == "Capacity") {
                    merc.Capacity = readIntLine(newDataType, newDataText, fileName);
                    capacity = true;
                } else if (newDataType == "Text") {
                    merc.Text = readTextLine(newDataType, newDataText, fileName);
                } else if (newDataType == "Space Battle") {
                    merc.SpaceBattle = readIntLine(newDataType, newDataText, fileName);
                } else if (newDataType == "Space Shots") {
                    merc.SpaceShots = readIntLine(newDataType, newDataText, fileName);
                    spaceShots = true;
                } else if (newDataType == "Ground Battle") {
                    merc.GroundBattle = readIntLine(newDataType, newDataText, fileName);
                } else if (newDataType == "Ground Shots") {
                    merc.GroundShots = readIntLine(newDataType, newDataText, fileName);
                    groundShots = true;
                } else if (newDataType == "Movement") {
                    merc.Movement = readIntLine(newDataType, newDataText, fileName);
                } else if (newDataType == "ID") {
                    merc.Id = readTextLine (newDataType, newDataText, fileName);
                }

                line = reader.ReadLine().Trim ();
            } while (line != "<}>");
            // End of outermost block

            if (!sustain) {
                merc.SustainDamage = false;
            }
            if (!evasion) {
                merc.Evasion = 0;
            }
            if (!capacity) {
                merc.Capacity = 0;
            }
            if (!groundShots) {
                merc.GroundShots = 1;
            }
            if (!spaceShots) {
                merc.SpaceShots = 1;
            }

            if (merc.Id == default(string)) {
                merc.Id = merc.Name;
            }

            return merc;
        } else {
            throw new System.Exception(string.Format("Error reading file {0}:: got \"{1}\" should be <{>", fileName, dataText));
        }
    }