Ejemplo n.º 1
0
        /// <summary>
        /// Validation logic for adding or updating an inmate.
        /// </summary>
        /// <param name="inmate"></param>
        private static InmateValidationStatus InmateValidation(IInmate inmate)
        {
            if (string.IsNullOrEmpty(inmate.FirstName) || inmate.FirstName.Any(ch => !char.IsLetter(ch)))
            {
                return(InmateValidationStatus.InvalidFirstName);
            }

            if (string.IsNullOrEmpty(inmate.LastName) || inmate.LastName.Any(ch => !char.IsLetter(ch)))
            {
                return(InmateValidationStatus.InvalidLastName);
            }

            if (string.IsNullOrEmpty(inmate.GDCNumber) || inmate.GDCNumber.Any(digit => !char.IsDigit(digit)))
            {
                return(InmateValidationStatus.InvalidGDC);
            }

            // Compares the shop objects with an equality comparer
            if (inmate.AssignedShop == null || !Shops.Contains(inmate.AssignedShop, new ShopEqualityComparer()))
            {
                return(InmateValidationStatus.NoShopAssigned);
            }

            return(InmateValidationStatus.IsValidated);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// データファイルを読み込む。
        ///
        /// </summary>
        /// <param name="dir">フォルダ</param>
        private void ReadDataFiles(string dir)
        {
            string itemsPath = System.IO.Path.Combine(dir, "Items.json");

            if (System.IO.File.Exists(itemsPath))
            {
                items = DataItemListParser.Read(itemsPath);
            }

            string weaponsPath = System.IO.Path.Combine(dir, "Weapons.json");

            if (System.IO.File.Exists(weaponsPath))
            {
                weapons = DataWeaponListParser.Read(weaponsPath);
            }

            string armorsPath = System.IO.Path.Combine(dir, "Armors.json");

            if (System.IO.File.Exists(armorsPath))
            {
                armors = DataArmorListParser.Read(armorsPath);
            }

            Shops.Clear();

            string shopPath = System.IO.Path.Combine(dir, "Shops.json");

            if (System.IO.File.Exists(shopPath))
            {
                Shops = DataShopListReader.Read(shopPath);
                if (!Shops.Contains(null))
                {
                    Shops.Add(null);
                }
                Shops.Sort((a, b) => {
                    if (a == null)
                    {
                        return(-1);
                    }
                    else if (b == null)
                    {
                        return(1);
                    }
                    else
                    {
                        return(a.Id - b.Id);
                    }
                });
            }
            else
            {
                Shops.Add(null);
                Shops.Add(new DataShop()
                {
                    Id = 1
                });
            }
        }
Ejemplo n.º 3
0
        private void OnMenuChanged(object sender, EventArgsClickableMenuChanged args)
        {
            var locationName = Game1.currentLocation?.Name;

            if (!Shops.Contains(locationName) || !(args.NewMenu is ShopMenu shopMenu))
            {
                return;
            }

            var menuProxy = new ShopMenuProxy(shopMenu);

            AddItems(locationName, menuProxy, ShopFurniture, si => new Furniture(si.ID, Vector2.Zero));
            // TODO: Other items.

            MenuItemsAdded?.Invoke(this, args);
        }