Ejemplo n.º 1
0
        public static Town CreateTown(TownType typeId)
        {
            var town = new Town
            {
                Type = typeId,
            };

            UpdateTownType(town, typeId);
            town.RicePrice = 1.0f;

            {
                // 都市施設
                var b = new TownBuilding[]
                {
                    TownBuilding.MilitaryStation,
                    TownBuilding.OpenWall,
                    // TownBuilding.RepairWall,
                    TownBuilding.TrainIntellect,
                    TownBuilding.TrainLeadership,
                    TownBuilding.TrainPopularity,
                    TownBuilding.TrainStrong,
                    TownBuilding.Houses,
                    TownBuilding.Casting,
                    TownBuilding.TrainingBuilding,
                    TownBuilding.Camp,
                    TownBuilding.Extension,
                    TownBuilding.Sukiya,
                    TownBuilding.School,
                };
                var r = RandomService.Next(0, b.Length);
                town.TownBuilding = b[r];
            }
            return(town);
        }
 public InitialTownData(int id, string townName, TownType townType, IRace race)
 {
     Id       = id;
     TownName = townName;
     TownType = townType;
     Race     = race;
 }
Ejemplo n.º 3
0
 public static TownEntity Create(int id, string townName, TownType townType, IRace race, bool isCapital = false)
 {
     return(townType switch
     {
         TownType.Port => new Port(id, townName, townType, race, isCapital),
         TownType.Inland => new Inland(id, townName, townType, race, isCapital),
         _ => throw new ArgumentException(townType.ToString())
     });
Ejemplo n.º 4
0
        protected TownEntity(int id, string townName, TownType townType, IRace race, IEnumerable <IDivision> divisions, int popNum = 5, bool isCapital = false)
        {
            Id        = id;
            TownName  = townName;
            TownType  = townType;
            IsCapital = isCapital;
            Divisions = new List <IDivision>(divisions);

            InitializePops(race, popNum);
        }
Ejemplo n.º 5
0
 public Agglomeration(string name, string type, string comment, int dimension,
                      TownType edgeWeightType, string displayDataType, List <Town> towns)
 {
     Name            = name;
     Type            = type;
     Comment         = comment;
     Dimension       = dimension;
     EdgeWeightType  = edgeWeightType;
     DisplayDataType = displayDataType;
     Towns           = new List <Town>(towns);
 }
Ejemplo n.º 6
0
        public static string GetTown(this TownType townType)
        {
            switch (townType)
            {
            case TownType.AB_DENDRIEL:
                return("Ab'Dendriel");

            case TownType.ANKRAHMUN:
                return("Ankrahmun");

            case TownType.CARLIN:
                return("Carlin");

            case TownType.DARASHIA:
                return("Darashia");

            case TownType.EDRON:
                return("Edron");

            case TownType.FARMINE:
                return("Farmine");

            case TownType.GRAY_BEACH:
                return("Gray Beach");

            case TownType.KAZORDOON:
                return("Kazordoon");

            case TownType.LIBERTY_BAY:
                return("Liberty Bay");

            case TownType.PORT_HOPE:
                return("Port Hope");

            case TownType.RATHLETON:
                return("Rathleton");

            case TownType.SVARGROND:
                return("Svargrond");

            case TownType.THAIS:
                return("Thais");

            case TownType.VENORE:
                return("Venore");

            case TownType.YALAHAR:
                return("Yalahar");

            default:
                throw new ArgumentOutOfRangeException(nameof(townType), townType, "Couldnt find the town string value");
            }
        }
Ejemplo n.º 7
0
 public Town(TownType townType)
 {
     if (townType == TownType.Rocksberg)
     {
         townName = "Роксберг";
     }
     if (townType == TownType.Denberg)
     {
         townName = "Денберг";
     }
     if (townType == TownType.Qorberg)
     {
         townName = "Корберг";
     }
 }
Ejemplo n.º 8
0
        public static void UpdateTownType(Town town, TownType typeId)
        {
            if (typeId == TownType.Any)
            {
                var r = RandomService.Next(0, 9);
                if (r <= 2)
                {
                    typeId = TownType.Agriculture;
                }
                else if (r <= 6)
                {
                    typeId = TownType.Commercial;
                }
                else if (r <= 8)
                {
                    typeId = TownType.Fortress;
                }
                else
                {
                    typeId = TownType.Agriculture;
                }
            }
            town.Type = typeId;

            var type = typeId == TownType.Agriculture ? TownTypeDefinition.AgricultureType :
                       typeId == TownType.Commercial ? TownTypeDefinition.CommercialType :
                       typeId == TownType.Fortress ? TownTypeDefinition.FortressType :
                       TownTypeDefinition.LargeType;

            town.Agriculture    = type.Agriculture;
            town.AgricultureMax = type.AgricultureMax;
            town.Commercial     = type.Commercial;
            town.CommercialMax  = type.CommercialMax;
            town.Technology     = type.Technology;
            town.TechnologyMax  = type.TechnologyMax;
            town.Wall           = type.Wall;
            town.WallMax        = type.WallMax;
            town.PeopleMax      = type.PeopleMax;
            town.People         = type.People;
            town.Security       = (short)type.Security;
            town.Agriculture    = Math.Min(town.Agriculture, town.AgricultureMax);
            town.Commercial     = Math.Min(town.Commercial, town.CommercialMax);
            town.Technology     = Math.Min(town.Technology, town.TechnologyMax);
            town.Wall           = Math.Min(town.Wall, town.WallMax);
            town.People         = Math.Min(town.People, town.PeopleMax);
        }
Ejemplo n.º 9
0
    public Town(TownType type)
    {
        Type = type;

        if (Type.MinLocations < Type.RequiredLocations.Count)
        {
            Type.MinLocations = Type.RequiredLocations.Count;
        }
        if (Type.MaxLocations < Type.RequiredLocations.Count)
        {
            Type.MaxLocations = Type.RequiredLocations.Count;
        }

        if (Locations.Count <= 0)
        {
            GenerateTown();
            GeneratePrices();
        }

        GameController.GameTime.NewDay += GeneratePrices;
    }
Ejemplo n.º 10
0
 public EvaluationFunction(TownType townType)
 {
     TownType = townType;
 }
Ejemplo n.º 11
0
 public Port(int id, string townName, TownType townType, IRace race, bool isCapital)
     : base(id, townName, townType, race, InitialDivisions(), isCapital: isCapital)
 {
 }
Ejemplo n.º 12
0
 public TownEntityTesting(int id, string townName, TownType townType, IRace race, IEnumerable <IDivision> divisions, int popNum = 5, bool isCapital = false) :
     base(id, townName, townType, race, divisions, popNum, isCapital)
 {
 }
Ejemplo n.º 13
0
        public async Task <IActionResult> GetAllHouses(string world, TownType townType, HouseType houseType, [FromQuery] int status = -1, [FromQuery] string orderBy = "", [FromQuery] int sortDirection = 0)
        {
            var response = new Response <AllHousesDTO>
            {
                Succeed = false
            };

            if (string.IsNullOrEmpty(world))
            {
                response.Message = "The world name must be provided";
                return(BadRequest(response));
            }

            try
            {
                var r = await _houseService.GetAllHouses(
                    world,
                    townType.GetTown(),
                    houseType.GetHouse());

                response.Result = _mapper.Map <AllHousesDTO>(r.Response);
                IEnumerable <SimpleHouseDTO> filteredHouses = response.Result.Houses;

                if (status == (int)HouseStatusType.AUCTIONED_BID)
                {
                    filteredHouses = filteredHouses
                                     .Where(h => h.Status == HouseStatusType.AUCTIONED_BID);
                }
                else if (status == (int)HouseStatusType.AUCTIONED_NO_BID)
                {
                    filteredHouses = filteredHouses
                                     .Where(h => h.Status == HouseStatusType.AUCTIONED_NO_BID);
                }
                else if (status == (int)HouseStatusType.RENTED)
                {
                    filteredHouses = filteredHouses
                                     .Where(h => h.Status == HouseStatusType.RENTED);
                }

                switch (orderBy.ToLower())
                {
                case "size":
                    if (sortDirection == 0)
                    {
                        filteredHouses = filteredHouses.OrderBy(h => h.Size);
                    }
                    else
                    {
                        filteredHouses = filteredHouses.OrderByDescending(h => h.Size);
                    }
                    break;

                case "rent":
                    if (sortDirection == 0)
                    {
                        filteredHouses = filteredHouses.OrderBy(h => h.Rent);
                    }
                    else
                    {
                        filteredHouses = filteredHouses.OrderByDescending(h => h.Rent);
                    }
                    break;

                case "bid":
                    if (sortDirection == 0)
                    {
                        filteredHouses = filteredHouses
                                         .OrderBy(h => h.Bid.HasValue)
                                         .ThenBy(h => h.Bid);
                    }
                    else
                    {
                        filteredHouses = filteredHouses
                                         .OrderByDescending(h => h.Bid.HasValue)
                                         .ThenBy(h => h.Bid);
                    }
                    break;

                case "auction_end":
                    if (sortDirection == 0)
                    {
                        filteredHouses = filteredHouses
                                         .OrderBy(h => h.MinutesUntilAuctionEnds.HasValue)
                                         .ThenBy(h => h.MinutesUntilAuctionEnds);
                    }
                    else
                    {
                        filteredHouses = filteredHouses
                                         .OrderByDescending(h => h.MinutesUntilAuctionEnds.HasValue)
                                         .ThenBy(h => h.MinutesUntilAuctionEnds);
                    }
                    break;

                default:
                    if (sortDirection == 0)
                    {
                        filteredHouses = filteredHouses.OrderBy(h => h.Name);
                    }
                    else
                    {
                        filteredHouses = filteredHouses.OrderByDescending(h => h.Name);
                    }
                    break;
                }
                response.Result.Houses = filteredHouses.ToList();
                response.Succeed       = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(StatusCode(StatusCodes.Status500InternalServerError, response));
            }
            return(Ok(response));
        }
Ejemplo n.º 14
0
 public async Task <IActionResult> GetAllHouses(string world, TownType townType, [FromQuery] int status = -1, [FromQuery] string orderBy = "", [FromQuery] int sortDirection = 0)
 {
     return(await GetAllHouses(world, townType, HouseType.HOUSE, status, orderBy, sortDirection));
 }