示例#1
0
        private void writeButton_Click(object sender, EventArgs e)
        {
            int id = Province.ProvincesUnordered.Count;

            int[] colour = { (int)redInput.Value, (int)greenInput.Value, (int)blueInput.Value };
            if (!Province.Create(id, colour))
            {
                return;
            }
            Province p = Province.Get(id);

            p.Type      = (ProvinceType)provTypeInput.SelectedItem;
            p.Terrain   = (Terrain)terrainInput.SelectedItem;
            p.Continent = (Continent)continentInput.SelectedItem;
            p.Coastal   = (bool)coastalInput.SelectedItem;
            State s = (State)stateInput.SelectedItem;

            s.Provinces.Add(p);
            Province.Save();

            string regionFile = regionFiles.Find(x => x.Split(@"\").Last().StartsWith($"{regionInput.SelectedItem}-"));

            string[] regionFileContents = File.ReadAllLines(regionFile);
            regionFileContents[4] += $" {id}";
            File.WriteAllLines(regionFile, regionFileContents);

            statusLabel.Text = $"Province {id} successfully written";

            Reset();
        }
示例#2
0
        public HttpResponseMessage Get(
            string country  = "",
            string province = ""
            )
        {
            DataTable     dt   = Province.Get(country, province);
            List <object> list = Province.GetDataSource(dt);

            return(Request.CreateResponse(HttpStatusCode.OK, Util.APIResponse.GetData(list)));
        }
        public CascadingDropDownNameValue[] GetProvinces(
            string knownCategoryValues,
            string category)
        {
            StringDictionary values    = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            Int32            CountryId = Convert.ToInt32(values["Country"]);

            return(Province.Get(CountryId).Select(p =>
                                                  new CascadingDropDownNameValue(p.Title, p.ProvinceId.ToString())
                                                  ).ToArray());
        }
示例#4
0
 public static List <Card> VictoryAndTreasures()
 {
     return(new List <Card>
     {
         Copper.Get(),
         Silver.Get(),
         Gold.Get(),
         Estate.Get(),
         Duchy.Get(),
         Province.Get()
     });
 }
示例#5
0
 private static List <Pile> VictoryAndTreasures(bool two)
 {
     return(new List <Pile>
     {
         new Pile(Copper.Get(), 60),
         new Pile(Silver.Get(), 40),
         new Pile(Gold.Get(), 30),
         new Pile(Estate.Get(), two ? 8 : 12),
         new Pile(Duchy.Get(), two ? 8 : 12),
         new Pile(Province.Get(), two ? 8 : 12)
     });
 }
示例#6
0
文件: Parser.cs 项目: TFPAcer/HOI4MI
        public static bool ParseState(string path)
        {
            string f = File.ReadAllText(path);

            currentFile = RemoveWhiteSpace(f);

            //check the provinces list is a list of numbers
            string provinceString = FindKey("provinces");

            if (!Regex.IsMatch(provinceString, @"{((\s+)(\d+))+\s*}"))
            {
                Status = $"Malformed provinces in {path}.";
                return(false);
            }

            //get all the numbers in string form
            var provStrings          = Regex.Matches(provinceString, @"\d+");
            HashSet <Province> provs = new HashSet <Province>();

            foreach (Match m in provStrings)
            {
                string s = m.Value;
                //one of the provinces wasn't a number
                if (!int.TryParse(s, out int provId))
                {
                    Status = $"Province {s} isn't an int in {path}.";
                    return(false);
                }

                Province p = Province.Get(provId);
                if (p == null)
                {
                    Status = $"Province {provId} doesn't exist";
                    return(false);
                }
                //check if there are any province-level buildings
                string temp = FindKey(s);
                if (!string.IsNullOrEmpty(temp))
                {
                    p.LandForts    = FindKeyInt("[^_]bunker", temp);
                    p.CoastalForts = FindKeyInt("coastal_bunker", temp);
                    p.NavalBase    = FindKeyInt("naval_base", temp);
                }
                provs.Add(p);
                p.SetUnmodified();
            }

            //check if there's any vps specified in the file
            //doesnt have to be for provinces from this state
            List <string> vpLists = FindMultipleKey("victory_points");

            foreach (string s in vpLists)
            {
                Match m = Regex.Match(s, $@"(\d+)\s+(\d+)");
                if (m.Success)
                {
                    int      pid = int.Parse(m.Groups[1].Value);
                    Province p   = Province.Get(pid);
                    if (p == null)
                    {
                        Status = $"Victory points specified for invalid province {pid}";
                        return(false);
                    }
                    p.VictoryPoints = int.Parse(m.Groups[2].Value);
                    p.SetUnmodified();
                }
            }

            ResourceSet res = new ResourceSet {
                Aluminium = FindKeyDouble("aluminium"),
                Steel     = FindKeyDouble("steel"),
                Tungsten  = FindKeyDouble("tungsten"),
                Chromium  = FindKeyDouble("chromium"),
                Oil       = FindKeyDouble("oil"),
                Rubber    = FindKeyDouble("rubber")
            };

            StateCategory?c = FindKey("category").ConvertStateCategory();

            if (c == null)
            {
                //state didn't have a valid category listed
                Status = $"Error parsing state category in {path}.";
                return(false);
            }

            int    stateId        = FindKeyInt("id");
            string stateName      = FindKey("name");
            int    buildingFactor = FindKeyInt("buildings_max_level_factor");

            if (State.Create(stateId))
            {
                State s = State.Get(stateId);
                s.Name        = stateName;
                s.FileName    = path.Split('\\').Last();
                s.Manpower    = FindKeyInt("manpower");
                s.BuildFactor = buildingFactor == 0 ? 1 : buildingFactor;
                s.Category    = (StateCategory)c;
                s.Resources   = res;

                s.Owner              = FindKey("owner");
                s.Cores              = FindMultipleKey("add_core_of").ToHashSet();
                s.Infrastructure     = FindKeyInt("infrastructure");
                s.CivillianFactories = FindKeyInt("industrial_complex");
                s.MilitaryFactories  = FindKeyInt("arms_factory");
                s.Dockyards          = FindKeyInt("dockyard");
                s.Refineries         = FindKeyInt("synthetic_refinery");
                s.Antiair            = FindKeyInt("antiair");
                s.Silos              = FindKeyInt("fuel_silo");
                s.Radar              = FindKeyInt("radar_station");
                s.Rockets            = FindKeyInt("rocket_site");
                s.Reactors           = FindKeyInt("nuclear_reactor");
                s.Airbases           = FindKeyInt("air_base");
                s.Impassable         = FindKey("impassable") == "yes";
                s.Provinces          = provs;
                s.SetUnmodified();
            }
            //something went wrong when creating the state
            else
            {
                Status = $"Error creating state {stateId} for {path}.";
                return(false);
            }

            return(true);
        }
示例#7
0
文件: Parser.cs 项目: TFPAcer/HOI4MI
        public static bool ParseProvinceDef(string path)
        {
            string[] lines = File.ReadAllLines(path);
            string[] data;
            foreach (string l in lines)
            {
                data = l.Split(';');
                int   id  = -1;
                int[] rgb = new int[3];
                if (!int.TryParse(data[0], out id))
                {
                    Status = $"malformed province ID in line {l}";
                    return(false);
                }
                if (!int.TryParse(data[1], out rgb[0]))
                {
                    Status = $"malformed R for province {id}";
                    return(false);
                }
                if (!int.TryParse(data[2], out rgb[1]))
                {
                    Status = $"malformed G for province {id}";
                    return(false);
                }
                if (!int.TryParse(data[3], out rgb[2]))
                {
                    Status = $"malformed B for province {id}";
                    return(false);
                }

                if (Province.Create(id, rgb))
                {
                    Province p = Province.Get(id);
                    p.Type = data[4] switch {
                        "sea" => ProvinceType.Sea,
                        "lake" => ProvinceType.Lake,
                        _ => ProvinceType.Land,
                    };
                    p.Coastal = data[5] == "true";
                    p.Terrain = data[6] switch {
                        "ocean" => Terrain.Ocean,
                        "lake" => Terrain.Lake,
                        "forest" => Terrain.Forest,
                        "hills" => Terrain.Hills,
                        "mountain" => Terrain.Mountain,
                        "plains" => Terrain.Plains,
                        "urban" => Terrain.Urban,
                        "jungle" => Terrain.Jungle,
                        "marsh" => Terrain.Marsh,
                        "desert" => Terrain.Desert,
                        "water_fjords" => Terrain.Water_Fjords,
                        "water_shallow_sea" => Terrain.Water_Shallow_Sea,
                        "water_deep_ocean" => Terrain.Water_Deep_Ocean,
                        _ => Terrain.Unknown,
                    };
                    if (!int.TryParse(data[7], out int continent))
                    {
                        Status = $"malformed continent for province {id}";
                        return(false);
                    }
                    p.Continent = (Continent)continent;
                    p.SetUnmodified();
                }

                else
                {
                    Status = $"Error creating province {id}.\n{Province.Status}";
                    return(false);
                }
            }
            return(true);
        }
示例#8
0
        public override Card SelectCardToGain(KingdomWrapper wrapper, PlayerState ps, Kingdom k, Phase phase)
        {
            var provinces = k.GetPile(CardType.Province);

            if (buyAgenda.Provinces > provinces.Count && wrapper.GetCard(CardType.Province) != null)
            {
                return(Province.Get());
            }

            var duchies = k.GetPile(CardType.Duchy);

            if (buyAgenda.Duchies > provinces.Count && wrapper.GetCard(CardType.Duchy) != null)
            {
                return(Duchy.Get());
            }

            var estates = k.GetPile(CardType.Estate);

            if (buyAgenda.Estates > provinces.Count && wrapper.GetCard(CardType.Estate) != null)
            {
                return(Estate.Get());
            }

            for (int i = 0; i < buyAgenda.BuyMenu.Count; i++)
            {
                var tuple = buyAgenda.BuyMenu[i];
                if (tuple.Number <= 0)
                {
                    continue;
                }

                var card = wrapper.GetCard(tuple.Card);
                if (card == null)
                {
                    continue;
                }

                tuple.Number--;
                if (tuple.Number == 0)
                {
                    buyAgenda.BuyMenu.RemoveAt(i);
                }
                else
                {
                    buyAgenda.BuyMenu[i] = tuple; // this is a value type, i have to return the value back
                }
                if (card.IsTreasure)
                {
                    playerInfo.TreasureTotal += card.Coins;
                }
                if (card.Type == CardType.Moneylender)
                {
                    playerInfo.TreasureTotal -= 1;
                }
                else if (card.Type == CardType.Bureaucrat)
                {
                    playerInfo.TreasureTotal += 2;
                }
                else if (card.Type == CardType.Mine)
                {
                    playerInfo.TreasureTotal += 1;
                }

                return(card);
            }
            return(null);
        }
 protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
 {
     ddlCountry.Cascade(ddlProvince, (CountryId) => Province.Get(CountryId));
     ddlProvince.Cascade(ddlCity, (ProvinceId) => City.Get(ProvinceId));
 }
示例#10
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            //Create the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            //Create the context
            IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            tracingService.Trace("Loaded UpsertSupplierWorkflow");
            tracingService.Trace("CREATING Contact object with the input values");
            tracingService.Trace("Checkpoint 1");

            Contact contact = new Contact();

            int partyid = PartyID.Get <int>(executionContext);


            tracingService.Trace("Starting assigning attribute variables.");

            contact.First_Name = FirstName.Get <string>(executionContext).ToString();
            tracingService.Trace("First Name Populated");

            tracingService.Trace(string.Format("Setting party id = {0}", partyid));
            contact.Party_Id = partyid;
            tracingService.Trace("Party ID populated");

            contact.Last_Name = LastName.Get <string>(executionContext).ToString();
            tracingService.Trace("Last Name Populated");

            contact.Payment_Method = PaymentMethod.Get <string>(executionContext).ToString();
            tracingService.Trace("Payment Method Populated");

            contact.SIN = SIN.Get <string>(executionContext).ToString();
            tracingService.Trace("SIN Populated");

            contact.Address1 = Address1.Get <string>(executionContext).ToString();
            tracingService.Trace("Address1 Populated");

            contact.Country_Code = Country.Get <string>(executionContext).ToString();
            tracingService.Trace("Country Populated");

            contact.City = City.Get <string>(executionContext).ToString();
            tracingService.Trace("City Populated");

            contact.Province_Code = Province.Get <string>(executionContext).ToString();
            tracingService.Trace("Province Populated");

            contact.Postal_Code = PostalCode.Get <string>(executionContext).ToString();
            tracingService.Trace("Postal Code Populated");
            tracingService.Trace("Checkpoint 2");


            EntityReference contactRef = ContactReference.Get <EntityReference>(executionContext);

            contact.ID = contactRef.Id;

            tracingService.Trace("Fetching the Configs");
            ////Get the configuration record for Oracle_T4A group from the configs entity and get the connection value from the record.
            var configs = Helper.GetSystemConfigurations(service, ConfigEntity.Group.ORACLE_T4A, string.Empty);

            tracingService.Trace("Fetching Connection");
            string connection = Helper.GetConfigKeyValue(configs, ConfigEntity.Key.CONNECTION, ConfigEntity.Group.ORACLE_T4A);

            try
            {
                tracingService.Trace("Fetching Oracle Response by making call to Helper.UpsertSupplierInOracle()");
                OracleResponse response = Helper.UpsertSupplierInOracle(contact, connection, tracingService);

                if (response.TransactionCode == OracleResponse.T4A_STATUS.OK)
                {
                    tracingService.Trace("Inside OracleResponse.T4A_STATUS.OK \nRetriving and setting response values to output");
                    PartyID.Set(executionContext, response.PartyId);
                    tracingService.Trace("Party ID Output Param is set");
                }

                tracingService.Trace("Setting up transaction code and transaction message");
                TransactionCode.Set(executionContext, response.TransactionCode.Trim());
                TransactionMessage.Set(executionContext, response.TransactionMessage);
            }
            catch (InvalidWorkflowException ex)
            {
                Helper.LogIntegrationError(service, ErrorType.CONTACT_ERROR, IntegrationErrorCodes.UPSERT_SUPPLIER.GetIntValue(), Strings.T4A_FER_ERROR,
                                           string.Format("Error Description: {0} ", ex.Message), contactRef);
            }
            catch (Exception ex)
            {
                Helper.LogIntegrationError(service, ErrorType.CONTACT_ERROR, IntegrationErrorCodes.UPSERT_SUPPLIER.GetIntValue(), Strings.T4A_FER_ERROR,
                                           string.Format("Error Description: {0} ", ex.Message), contactRef);
            }
        }