Esempio n. 1
0
        public async Task <IActionResult> PutSettlementType(int id, SettlementType settlementType)
        {
            if (id != settlementType.Id)
            {
                return(BadRequest());
            }

            _context.Entry(settlementType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SettlementTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public IHttpActionResult DeleteSettlementType(int id, int UILoginUserID, string UILoginPassword, int SiteID)
        {
            if (!Global.CheckUserIDAndPasswordWithSiteID(db, UILoginUserID, UILoginPassword, SiteID, "DeleteSettlementType"))
            {
                return(BadRequest());
            }
            SettlementType settlementType = db.SettlementTypes.Find(id);

            if (settlementType == null)
            {
                return(NotFound());
            }

            if (SiteID != settlementType.SiteID)
            {
                return(BadRequest());
            }
            User user = db.Users.Find(UILoginUserID);

            if (user == null)
            {
                return(BadRequest());
            }
            if (!user.IsRootUser && !user.IsSiteAdmin && settlementType.EntryByUserID != user.ID)
            {
                return(BadRequest());
            }
            db.SettlementTypes.Remove(settlementType);
            db.SaveChanges();

            return(Ok(settlementType));
        }
Esempio n. 3
0
        public async Task <ActionResult <SettlementType> > PostSettlementType(SettlementType settlementType)
        {
            _context.SettlementTypes.Add(settlementType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSettlementType", new { id = settlementType.Id }, settlementType));
        }
Esempio n. 4
0
 /// <summary>
 /// Constructor for the index option security
 /// </summary>
 /// <param name="symbol">Symbol of the index option</param>
 /// <param name="exchangeHours">Exchange hours of the index option</param>
 /// <param name="quoteCurrency">Quoted currency of the index option</param>
 /// <param name="symbolProperties">Symbol properties of the index option</param>
 /// <param name="currencyConverter">Currency converter</param>
 /// <param name="registeredTypes">Provides all data types registered to the algorithm</param>
 /// <param name="securityCache">Cache of security objects</param>
 /// <param name="settlementType">Settlement type for the index option. Most index options are cash-settled.</param>
 public IndexOption(Symbol symbol,
                    SecurityExchangeHours exchangeHours,
                    Cash quoteCurrency,
                    IndexOptionSymbolProperties symbolProperties,
                    ICurrencyConverter currencyConverter,
                    IRegisteredSecurityDataTypesProvider registeredTypes,
                    SecurityCache securityCache,
                    SettlementType settlementType = SettlementType.Cash)
     : base(symbol,
            quoteCurrency,
            symbolProperties,
            new OptionExchange(exchangeHours),
            securityCache,
            new OptionPortfolioModel(),
            new ImmediateFillModel(),
            new InteractiveBrokersFeeModel(),
            new ConstantSlippageModel(0),
            new ImmediateSettlementModel(),
            Securities.VolatilityModel.Null,
            new OptionMarginModel(),
            new OptionDataFilter(),
            new SecurityPriceVariationModel(),
            currencyConverter,
            registeredTypes
            )
 {
     ExerciseSettlement = settlementType;
 }
 /// <summary>
 /// Costruttore dell'insedimento da utilizzare per la creazione degli imperi
 /// </summary>
 /// <param name="type"></param>
 /// <param name="money"></param>
 /// <param name="inhabitants"></param>
 /// <param name="defense"></param>
 /// <param name="offense"></param>
 /// <param name="religion"></param>
 public Settlement(SettlementType type, int money, int inhabitants, int defense, int offense, Religion.ReligionType religion)
 {
     products = new List<Product>();
     this.type = type;
     this.money = money;
     this.inhabitants = inhabitants;
     defensiveArmy = defense;
     offensiveArmy = offense;
     SetInitialRates(religion);
 }
Esempio n. 6
0
    public Vec2i RandomPathPoint()
    {
        bool isvalid = false;

        int   x   = GenerationRandom.RNG.RandomInt(1, SettlementType.GetSize() - 2);
        int   z   = GenerationRandom.RNG.RandomInt(1, SettlementType.GetSize() - 2);
        Vec2i pos = new Vec2i(x, z);

        return(BaseCoord + pos * World.ChunkSize);
    }
        public static string GetStringValue(this SettlementType settlementType)
        {
            switch (settlementType)
            {
            case SettlementType.Receivable: return("Należność");

            case SettlementType.Liability: return("Zobowiązanie");

            default: throw new ArgumentOutOfRangeException($"Brak wartości {nameof(settlementType)} dla typu wyliczeniowego {nameof(SettlementType)}.");
            }
        }
Esempio n. 8
0
 public M2Building(M2Building mbuilding)
 {
     settlementType   = mbuilding.settlementType;
     buildingName     = mbuilding.buildingName;
     factionsRequired = new List <string>(mbuilding.factionsRequired);
     capability       = mbuilding.capability;
     construction     = mbuilding.construction;
     Bconvert_to      = mbuilding.Bconvert_to;
     fcapability      = mbuilding.fcapability;
     material         = mbuilding.material;
 }
Esempio n. 9
0
 public async Task DoSettlement(SettlementType settlement, ReceiptCutModeType cutMode,
                                PadField padInfo, ReceiptPrintModeType printMode, bool resetTotals)
 {
     await SendRequest <EFTSettlementResponse>(new EFTSettlementRequest
     {
         SettlementType       = settlement,
         CutReceipt           = cutMode,
         PurchaseAnalysisData = padInfo,
         ReceiptAutoPrint     = printMode,
         ResetTotals          = resetTotals
     });
 }
Esempio n. 10
0
        public IHttpActionResult PutSettlementType(int id, SettlementType settlementType)
        {
            if (!Global.CheckUserIDAndPasswordWithSiteID(db, settlementType.UILoginUserID, settlementType.UILoginPassword, settlementType.SiteID, "PutSettlementType"))
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != settlementType.ID)
            {
                return(BadRequest());
            }

            SettlementType st = db.SettlementTypes.AsNoTracking().SingleOrDefault(p => p.ID == id);

            if (st == null)
            {
                return(NotFound());
            }
            if (st.SiteID != settlementType.SiteID)
            {
                return(BadRequest());
            }
            User user = db.Users.Find(settlementType.UILoginUserID);

            if (!user.IsRootUser && !user.IsSiteAdmin && st.EntryByUserID != user.ID)
            {
                return(BadRequest());
            }
            db.Entry(settlementType).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SettlementTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 11
0
 /// <summary>
 /// Costruttore dell'insediamento del giocatore
 /// </summary>
 /// <param name="type"></param>
 /// <param name="religion"></param>
 public Settlement(SettlementType type, Religion.ReligionType religion)
 {
     products = new List<Product>();
     this.type = type;
     money = 20000;
     inhabitants = 50000;
     //inhabitants = 100000000;//
     defensiveArmy = 3000;
     offensiveArmy = 20;
     SetInitialRates(religion);
     //scienceGrowthRate = 100f;//
     //commerceGrowthRate = 100f;//
     //tecnoGrowthRate = 100f;//
     //inhaGrowthRate = 1.5f;//
 }
Esempio n. 12
0
        private uint GetRandomPopulation(SettlementType higherValue)
        {
            Random r = new Random();
            double u = r.NextDouble();

            int lowerValue = Enum.GetValues(typeof(SettlementType)).Cast <int>().Where(st => st < (int)higherValue).LastOrDefault();

            if (!lowerValue.Equals(SettlementType.Metropolis))
            {
                return((uint)r.Next(lowerValue, (int)higherValue));
            }
            else
            {
                return((uint)r.NormalNext(100, lowerValue, (int)higherValue));
            }
        }
Esempio n. 13
0
        public IHttpActionResult PostSettlementType(SettlementType settlementType)
        {
            if (!Global.CheckUserIDAndPasswordWithSiteID(db, settlementType.UILoginUserID, settlementType.UILoginPassword, settlementType.SiteID, "PostSettlementType"))
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SettlementTypes.Add(settlementType);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = settlementType.ID }, settlementType));
        }
Esempio n. 14
0
 /// <summary>
 /// Costruttore dell'insediamento da salvataggio file
 /// </summary>
 /// <param name="type"></param>
 /// <param name="money"></param>
 /// <param name="inhabitants"></param>
 /// <param name="defense"></param>
 /// <param name="offense"></param>
 /// <param name="inhaRate"></param>
 /// <param name="science"></param>
 /// <param name="scienceRate"></param>
 /// <param name="commerce"></param>
 /// <param name="commerceRate"></param>
 /// <param name="tecno"></param>
 /// <param name="tecnoRate"></param>
 public Settlement(SettlementType type, int money, int inhabitants, int defense, int offense, float inhaRate,
     float science, float scienceRate, float commerce, float commerceRate, float tecno, float tecnoRate)
 {
     this.type = type;
     this.money = money;
     this.inhabitants = inhabitants;
     defensiveArmy = defense;
     offensiveArmy = offense;
     inhaGrowthRate = inhaRate;
     scienceLevel = science;
     scienceGrowthRate = scienceRate;
     commerceLevel = commerce;
     commerceGrowthRate = commerceRate;
     tecnoLevel = tecno;
     tecnoGrowthRate = tecnoRate;
     products = new List<Product>();
 }
Esempio n. 15
0
    public static int GetSize(this SettlementType t)
    {
        switch (t)
        {
        case SettlementType.CAPITAL:
            return(18);

        case SettlementType.CITY:
            return(18);

        case SettlementType.TOWN:
            return(16);

        case SettlementType.VILLAGE:
            return(14);
        }
        return(10);
    }
Esempio n. 16
0
        internal void UpdateResourceCount(ResourceType resourceType, SettlementType settlementType, bool hasBaron)
        {
            if (settlementType == SettlementType.None)
            {
                throw new InvalidDataException("the settlement type shouldn't be None!");
            }

            ResourceCount resCount = null;

            if (_dictResourceCount.TryGetValue(resourceType, out resCount) == false)
            {
                resCount = new ResourceCount();
                _dictResourceCount[resourceType] = resCount;
            }

            int value = 0;

            if (settlementType == SettlementType.Settlement)
            {
                value = 1;
            }
            else if (settlementType == SettlementType.City)
            {
                value = 2;
            }

            if (hasBaron)
            {
                resCount.Lost     += value;
                MissedOpportunity += value;
            }
            else
            {
                resCount.Acquired += value;
                ResourceCount     += value;
            }

            string s = hasBaron ? "Lost" : "Gained";

            this.TraceMessage($"{this.PlayerName} {s} {value} of {resourceType} ");
        }
Esempio n. 17
0
        public static string GetName(this SettlementType s)
        {
            switch (s)
            {
            case SettlementType.Thorpe: return("Thorpe");

            case SettlementType.Hamlet: return("Hamlet");

            case SettlementType.Village: return("Village");

            case SettlementType.SmallTown: return("Small Town");

            case SettlementType.LargeTown: return("Large Town");

            case SettlementType.SmallCity: return("Small City");

            case SettlementType.LargeCity: return("Large City");

            case SettlementType.Metropolis: return("Metropolis");

            default: return("Undefined");
            }
        }
Esempio n. 18
0
    public SettlementBase(Vec2i centreChunk, int size, SettlementType type)
    {
        Centre         = centreChunk;
        BaseCoord      = (Centre - new Vec2i(size, size)) * World.ChunkSize; //The coordinate of the minimum (minX,minZ) point of the settlement
        SettlementType = type;
        BaseChunk      = new Vec2i(Centre.x - size, Centre.z - size);

        List <Vec2i> settlementChunks = new List <Vec2i>();

        //Itterate all chunks within bounds, add them to the list
        for (int x = -size; x <= size; x++)
        {
            for (int z = -size; z <= size; z++)
            {
                settlementChunks.Add(new Vec2i(Centre.x + x, Centre.z + z));
            }
        }
        SettlementChunks = settlementChunks.ToArray(); //Store the list to a local array


        TileSize  = (size * 2 + 1) * World.ChunkSize;
        ChunkSize = TileSize / World.ChunkSize;
    }
Esempio n. 19
0
 public VillageScript(SettlementType type)
 {
     this.type = type;
 }
Esempio n. 20
0
 public SettlementData(string name, string type)
 {
     this.name = name;
     this.type = Types.settlements[type];
 }
Esempio n. 21
0
 public Settlement(string name, string type, Region region)
 {
     this.name   = name;
     this.type   = Types.settlements[type];
     this.region = region;
 }
Esempio n. 22
0
 public SettlementShell(GridPoint gp, int kingdomID, SettlementType type) : base(gp, kingdomID)
 {
     Type = type;
 }
Esempio n. 23
0
 public static SettlementType GetSettlementTypeFromString(string settlementType)
 {
     Settlement.SettlementType type = Settlement.SettlementType.MILITARY;
     switch (settlementType)
     {
         case "Community":
             type = Settlement.SettlementType.COMMUNITY;
             break;
         case "Inhabited":
             type = Settlement.SettlementType.INHABITED;
             break;
         case "Military":
             type = Settlement.SettlementType.MILITARY;
             break;
         case "Capital":
         default:
             type = Settlement.SettlementType.CAPITAL;
             break;
     }
     return type;
 }
Esempio n. 24
0
 public Settlement(Player player1, SettlementType settlementType)
 {
     // TODO: Complete member initialization
     player = player1;
     type = settlementType;
 }
Esempio n. 25
0
    /// <summary>
    /// Decides the placement for all non capital settlements.
    ///
    /// <list type="bullet">
    ///     <item>
    ///         We choose a valid grid point by accessing <see cref="DesireWeightedGridpoints"/>,
    ///         and taking a weight random element from it.
    ///         </item>
    ///          <item>We then check which kingdom owns the territory of the point.</item>
    ///     <item>We check the number of capitals, towns, and villages allowed by the kingdom, based on <paramref name="kts"/></item>
    ///     <item>If they have not reached their maximum number of a settlement type, we place one here</item>
    ///     <item>We continuously do this until all settlements for all kingdoms are found,</item>
    /// </list>
    /// </summary>
    /// <param name="kts"></param>
    private Dictionary <int, Dictionary <SettlementType, List <SettlementShell> > > DecideSettlementPlacements(Dictionary <int, KingdomTotalSettlements> kts)
    {
        //Key = kingdom ID
        //Value[0] = Dictionary ordered by settlement type, containing values representing the desired settlement placement
        Dictionary <int, Dictionary <SettlementType, List <SettlementShell> > > setPlace = new Dictionary <int, Dictionary <SettlementType, List <SettlementShell> > >();

        //We create a data structure to hold each settlement
        foreach (Kingdom k in GameGen.KingdomGen.Kingdoms)
        {
            setPlace.Add(k.KingdomID, new Dictionary <SettlementType, List <SettlementShell> >());
            setPlace[k.KingdomID].Add(SettlementType.CITY, new List <SettlementShell>());
            setPlace[k.KingdomID].Add(SettlementType.TOWN, new List <SettlementShell>());
            setPlace[k.KingdomID].Add(SettlementType.VILLAGE, new List <SettlementShell>());
        }
        bool shouldContinue = true;

        while (shouldContinue)
        {
            //if no points remain, we break
            if (DesireWeightedGridpoints.Count == 0)
            {
                shouldContinue = false;
                break;
            }
            //We a random point
            GridPoint gp = DesireWeightedGridpoints.GetRandom(true);

            ChunkBase2 cb        = GameGen.TerGen.ChunkBases[gp.ChunkPos.x, gp.ChunkPos.z];
            int        kingdomID = cb.KingdomID;
            if (kingdomID == -1)
            {
                continue;
            }

            //We have now got to a valid settlement point so we check what type of settlement we need;

            SettlementType setType = SettlementType.CITY;
            if (setPlace[kingdomID][SettlementType.CITY].Count < kts[kingdomID].CityCount)
            {
                setType = SettlementType.CITY;
            }
            else if (setPlace[kingdomID][SettlementType.TOWN].Count < kts[kingdomID].TownCount)
            {
                setType = SettlementType.TOWN;
            }
            else if (setPlace[kingdomID][SettlementType.VILLAGE].Count < kts[kingdomID].VillageCount)
            {
                setType = SettlementType.VILLAGE;
            }
            else
            {
                Debug.Log("Already completed set placement for " + kingdomID);
                continue;
            }

            //Find the shorest distance
            int distSqr = FindShortestSquareDistance(setPlace[kingdomID], gp);
            //the maximum distance
            int minDistSqr = GridPlacement.GridPointSize * GridPlacement.GridPointSize * 5;
            if (distSqr >= minDistSqr || distSqr < 0)
            {
                gp.HasSet = true;
                gp.SETYPE = setType;
                SettlementShell sp = new SettlementShell(gp, kingdomID, setType);
                gp.Shell = sp;
                setPlace[kingdomID][setType].Add(sp);
            }
        }
        return(setPlace);
    }