示例#1
0
        public static Person Random()
        {
            int      cashTotal = 0;
            Random   r         = Form1.r;
            Customer c         = new Customer();

            int    val = r.Next() % 3;
            Wealth w   = 0;

            switch (val)
            {
            case 0:
                w = Wealth.Lower;
                break;

            case 1:
                w = Wealth.Middle;
                break;

            case 2:
                w = Wealth.Upper;
                break;
            }

            cashTotal = RandomAmount(r, w);
            c.FillWallet(cashTotal);

            for (int i = 0; i <= val; ++i)
            {
                c.memShip.OpenAccount(RandomAmount(r, w));
                c.checks.Add(new Check((string)nameList[r.Next(nameList.Count)], c.Name, RandomAmount(r, w)));
            }

            return(c);
        }
示例#2
0
        public ActionResult Create([Bind(Include = "PersonID,FirstName,LastName,EmailAddress,GalRanchConsumed")] User user,
                                   List <int> PetIds)
        {
            if (ModelState.IsValid)
            {
                string creatore = System.Web.HttpContext.Current.User.Identity.GetUserName();
                Wealth MyMoney  = new Wealth();
                MyMoney.Cash = 300;

                // TODO: add UI hook to add pets either in create or seperate service
                if (PetIds != null)
                {
                    user.MyPets = new List <Pet>();
                    // Add all pets to user's collection of pets
                    foreach (var petNum in PetIds)
                    {
                        user.MyPets.Add(
                            new Pet {
                            PetID = petNum
                        }
                            );
                    }
                }
                user.creator  = creatore;
                user.MyWealth = MyMoney;
                _dataRepository.AddNewUser(user);

                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
 public Neighborhood(Wealth nWealth)
 {
     buildings = new List<Building>();
     Random r = new Random();
     var numberOfBuildings = r.Next(6, 15);
     for (int i = 0; i < numberOfBuildings; i++)
     {
         buildings.Add(new Building());
     }
 }
示例#4
0
 public Location(
     string name,
     Wealth wealth,
     ResourceRichness resourceRichness,
     CitySize citySize,
     TileManager.Biome.TypeEnum biomeType
     )
 {
     this.name             = name;
     this.wealth           = wealth;
     this.resourceRichness = resourceRichness;
     this.citySize         = citySize;
     this.biomeType        = biomeType;
 }
示例#5
0
 /// <summary>
 /// Serves as a hash function for a <see cref="Faction"/> object.
 /// </summary>
 /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
 /// hash table.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Id != null ? Id.GetHashCode() : 0) * 397) ^
                (Name != null ? Name.GetHashCode() : 0) ^
                (Description != null ? Description.GetHashCode() : 0) ^
                (FlagId != null ? FlagId.GetHashCode() : 0) ^
                (CultureId != null ? CultureId.GetHashCode() : 0) ^
                Colour.GetHashCode() ^
                Wealth.GetHashCode() ^
                Alive.GetHashCode());
     }
 }
示例#6
0
    /// <summary>
    /// This is a mock function.
    /// </summary>
    virtual public void MockInstantiate(UInt64 maxWealth)
    {
        /**** ORDER IS ESSENTIAL ****/
        Amiability = new Amiability.Amiability(Seed);        // Will have a bearing on TechLevel
        TechLevel  = Tech.TechLevel.WESTERN;                 // Need to determine how to set this
        Wealth     = new Wealth(Seed, TechLevel, maxWealth); // Dependent on TechLevel

        Population = new Population(this);                   // Dependent on Tech, Amiability, and Wealth

        RaceMakeup = new RaceMakeup(Seed);
        Weather    = new Weather.Weather();
        Flora      = new Flora(Weather);
        Fauna      = new Fauna(Weather);
    }
        public void GivenThereIsAGameOfPlayerA()
        {
            playerA = new Player(0, "PA", "Player A", 4);
            Player[] players = new Player[1];
            players[0] = playerA;
            List <Card> ls = new List <Card>();

            c = new Wealth(CardSuit.Heart, 3);
            ls.Add(c);
            ls.Add(c);
            ls.Add(c);
            ls.Add(c);
            game = new Game(players, new FakeCardSet(ls));
            game.start(0);
        }
        public IActionResult Create(WealthDto wealthDto)
        {
            var wealth = new Wealth
            {
                Name    = wealthDto.Name,
                OwnerId = User.FindFirst(x => x.Type == ClaimTypes.NameIdentifier)?.Value
            };

            dbContext.Wealths.Add(wealth);
            dbContext.SaveChanges();

            var location = this.Url.Action(nameof(this.GetWealth), new { id = wealth.Id });

            wealthDto.Id = wealth.Id;
            return(Created(location, wealthDto));
        }
示例#9
0
        public bool AddWealth(IEntity entity, string currency, int amount)
        {
            var wealth = GetWealthByCurrency(entity, currency);

            if (wealth == null)
            {
                wealth = new Wealth {
                    Currency = currency, Amount = 0
                };
                entityEngine.AddComponent(entity, wealth);
            }

            wealth.Amount += amount;

            return(true);
        }
        public async Task createWealth(Transaction transaction)
        {
            int    symbolId = transaction.Trade.SymbolId;
            string userId   = transaction.UserId;
            string action   = transaction.Trade.Action.ToString();

            _logger.LogWarning(action);
            var wealth = await isWealthOwner(symbolId, userId);

            _logger.LogWarning("Wealth is null??????????????" + wealth);
            if (wealth != null)
            {
                _logger.LogWarning("Inside createWealth  if block: " + transaction.TransactionType.ToString().ToUpper());
                if (transaction.Trade.Action.ToString().ToUpper() == "BUY")
                {
                    wealth.Quantity    = wealth.Quantity + transaction.Trade.Quantity;
                    wealth.UpdatedDate = DateTime.Now;
                    await _dbContext.SaveChangesAsync();
                }
                else if (transaction.Trade.Action.ToString().ToUpper() == "SELL")
                {
                    _logger.LogWarning("Inside createWealth SELL if block qty: " + wealth.Quantity + " tras: " + transaction.Trade.Quantity);
                    if (transaction.Trade.Quantity <= wealth.Quantity)
                    {
                        wealth.Quantity    = wealth.Quantity - transaction.Trade.Quantity;
                        wealth.UpdatedDate = DateTime.Now;
                        await _dbContext.SaveChangesAsync();
                    }
                    else
                    {
                        //we had to check it before.
                        // Not happens
                        // ajax and jQuery already implemented. It will not happen if user doesn't have share enough.
                    }
                }
            }
            else
            {
                Wealth tempWealth = new Wealth();
                tempWealth.CreationDate = DateTime.Now;
                tempWealth.UpdatedDate  = DateTime.Now;
                tempWealth.Quantity     = transaction.Trade.Quantity;
                tempWealth.SymbolId     = transaction.Trade.SymbolId;
                tempWealth.UserId       = transaction.UserId;
                await CreateWealth(tempWealth);
            }
        }
示例#11
0
    private int[] GetCoinDropWeight(Wealth wealth)
    {
        switch (wealth)
        {
        case Wealth.Bankrupt:
            return(_COIN_DROP_WEIGHT_BANKRUPT);

        case Wealth.Poor:
            return(_COIN_DROP_WEIGHT_POOR);

        case Wealth.Rich:
            return(_COIN_DROP_WEIGHT_RICH);

        case Wealth.Extravagant:
            return(_COIN_DROP_WEIGHT_EXTRAVAGANT);

        default:
            return(_COIN_DROP_WEIGHT_DEFUALT);
        }
    }
示例#12
0
        protected override void SetChildrenProperties()
        {
            base.SetChildrenProperties();

            background.Location   = Location;
            background.Size       = Size;
            background.TintColour = BackgroundColour;

            provincesItem.ForegroundColour = ForegroundColour;
            provincesItem.Location         = new Point2D(Location.X + Spacing, Location.Y + (Size.Height - provincesItem.ClientRectangle.Height) / 2);
            provincesItem.Size             = new Size2D((Size.Width - Spacing * 3) / 4, 16);
            provincesItem.Text             = Provinces.ToString();

            holdingsItem.ForegroundColour = ForegroundColour;
            holdingsItem.Location         = new Point2D(provincesItem.ClientRectangle.Right + Spacing, provincesItem.Location.Y);
            holdingsItem.Size             = new Size2D((Size.Width - Spacing * 3) / 4, 16);
            holdingsItem.Text             = Holdings.ToString();

            wealthItem.ForegroundColour = ForegroundColour;
            wealthItem.Location         = new Point2D(holdingsItem.ClientRectangle.Right + Spacing, holdingsItem.Location.Y);
            wealthItem.Size             = new Size2D((Size.Width - Spacing * 3) / 4, 16);
            wealthItem.Text             = Wealth.ToString();

            troopsItem.ForegroundColour = ForegroundColour;
            troopsItem.Location         = new Point2D(wealthItem.ClientRectangle.Right + Spacing, wealthItem.Location.Y);
            troopsItem.Size             = new Size2D((Size.Width - Spacing * 3) / 4, 16);
            troopsItem.Text             = "0";

            provincesTooltip.Location = new Point2D(provincesItem.Location.X, ClientRectangle.Bottom);
            holdingsTooltip.Location  = new Point2D(holdingsItem.Location.X, ClientRectangle.Bottom);
            wealthTooltip.Location    = new Point2D(wealthItem.Location.X, ClientRectangle.Bottom);
            troopsTooltip.Location    = new Point2D(troopsItem.Location.X, ClientRectangle.Bottom);

            troopsTooltip.Text = string.Empty;

            if (Troops != null && Troops.Count > 0)
            {
                troopsItem.Text = Troops.Values.Sum().ToString();
                Troops.ToList().ForEach(t => troopsTooltip.Text += $"{t.Key}: {t.Value}\n");
            }
        }
示例#13
0
        public void UsageTest()
        {
            Card x;

            x = new Attack(CardSuit.Club, 0);
            Assert.AreEqual(1, x.numOfTargets());
            x = new Miss(CardSuit.Club, 0);
            Assert.AreEqual(-1, x.numOfTargets()); // this means not usable
            x = new Wine(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new Peach(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new Negate(CardSuit.Club, 0);
            Assert.AreEqual(-1, x.numOfTargets());
            x = new Barbarians(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new HailofArrow(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new PeachGarden(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new Wealth(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new Steal(CardSuit.Club, 0);
            Assert.AreEqual(1, x.numOfTargets());
            x = new Break(CardSuit.Club, 0);
            Assert.AreEqual(1, x.numOfTargets());
            x = new Capture(CardSuit.Club, 0);
            Assert.AreEqual(1, x.numOfTargets());
            x = new Starvation(CardSuit.Club, 0);
            Assert.AreEqual(1, x.numOfTargets());
            x = new Crossbow(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new IceSword(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new Scimitar(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new BlackShield(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
            x = new EightTrigrams(CardSuit.Club, 0);
            Assert.AreEqual(0, x.numOfTargets());
        }
示例#14
0
    public RootPerson()
    {
        gender    = Generators.RootGender();
        ageGroup  = Generators.RootAgeGroup();
        age       = Generators.Age(ageGroup);
        sexuality = Generators.RootSexuality(gender);
        wealth    = Generators.RootWealth(ageGroup);

        if (sexuality == Sexuality.aroAce)
        {
            relationship = Relationship.single;
        }
        else
        {
            relationship = Generators.RootRelationship(wealth, ageGroup);
        }

        skinColor = Generators.RootSkinColor();
        hairColor = Generators.RootHairColor(skinColor);
        eyeColor  = Generators.RootEyeColor(skinColor);
    }
示例#15
0
        private static int RandomAmount(Random r, Wealth w)
        {
            int cashTotal = 0;

            switch (w)
            {
            case Wealth.Lower:
                cashTotal = r.Next((int)Wealth.Lower);
                break;

            case Wealth.Middle:
                cashTotal = r.Next((int)Wealth.Lower, (int)Wealth.Middle);
                break;

            case Wealth.Upper:
                cashTotal = r.Next((int)Wealth.Middle, (int)Wealth.Upper);
                break;
            }

            return(cashTotal);
        }
示例#16
0
    // Start is called before the first frame update
    void Start()
    {
        Strength  myStrength = new Strength();
        Dexterity myDext     = new Dexterity();
        Wealth    myWealth   = new Wealth();

        StrengthButton.onClick.AddListener(() =>
        {
            int tmp = myStrength.GiveStrength();
            Debug.Log($"Strengh is {tmp}");
        });
        DextButton.onClick.AddListener(() =>
        {
            int tmp = myDext.GiveDext();
            Debug.Log($"Dexterity is {tmp}");
        });
        WealthButton.onClick.AddListener(() =>
        {
            int tmp = myWealth.GiveWealth();
            Debug.Log($"Wealth is {tmp}");
        });
    }
示例#17
0
    public override string ToString()
    {
        return("Wealth=" + Wealth.ToString() + "\n" +
               "Wealth=" + Police.ToString() + "\n" +
               "Wealth=" + Heterogenity.ToString() + "\n" +
               "Wealth=" + Pollution.ToString() + "\n" +
               "Wealth=" + Corruption.ToString() + "\n\n" +

               "Wealth=" + Infrastructure.ToString() + "\n" +
               "Wealth=" + HealthServices.ToString() + "\n" +
               "Wealth=" + Crime.ToString() + "\n" +
               "Wealth=" + Religion.ToString() + "\n" +
               "Wealth=" + Food.ToString() + "\n" +
               "Wealth=" + Cleanness.ToString() + "\n" +
               "Wealth=" + Employment.ToString() + "\n" +
               "Wealth=" + Information.ToString() + "\n\n" +

               "Wealth=" + Nourishment.ToString() + "\n" +
               "Wealth=" + Health.ToString() + "\n" +
               "Wealth=" + Shelter.ToString() + "\n" +
               "Wealth=" + Trust.ToString() + "\n" +
               "Wealth=" + Safety.ToString());
    }
        public void WealthTest()
        {
            Wealth c = new Wealth(CardSuit.Club, (byte)1);

            Assert.AreEqual("Wealth Description", c.getDescription());
        }
        public void WealthTest2()
        {
            Wealth c = new Wealth(CardSuit.Club, (byte)1);

            Assert.AreEqual("Wealth", c.ToString());
        }
 public async Task CreateWealth([Bind("Id,UserId,SymbolId,Quantity,CreattionDate,UpdatedDate")] Wealth wealth)
 {
     _dbContext.Add(wealth);
     await _dbContext.SaveChangesAsync();
 }
        public void Banaccount_Wealth_get_correct_Wealth(decimal balance, Wealth expectedResult)
        {
            var ba = new Bankaccount(balance);

            Assert.AreEqual(expectedResult, ba.Wealth);
        }
示例#22
0
        public override string ToString()
        {
            string json = string.Concat(
                __jsonIgnore.ContainsKey("Id") ? string.Empty : string.Format(", Id : {0}", Id == null ? "null" : Id.ToString()),
                __jsonIgnore.ContainsKey("Order_id") ? string.Empty : string.Format(", Order_id : {0}", Order_id == null ? "null" : Order_id.ToString()),
                __jsonIgnore.ContainsKey("Productitem_id") ? string.Empty : string.Format(", Productitem_id : {0}", Productitem_id == null ? "null" : Productitem_id.ToString()),
                __jsonIgnore.ContainsKey("Create_time") ? string.Empty : string.Format(", Create_time : {0}", Create_time == null ? "null" : Create_time.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()),
                __jsonIgnore.ContainsKey("Descript") ? string.Empty : string.Format(", Descript : {0}", Descript == null ? "null" : string.Format("'{0}'", Descript.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Email") ? string.Empty : string.Format(", Email : {0}", Email == null ? "null" : string.Format("'{0}'", Email.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Img_url") ? string.Empty : string.Format(", Img_url : {0}", Img_url == null ? "null" : string.Format("'{0}'", Img_url.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("State") ? string.Empty : string.Format(", State : {0}", State == null ? "null" : string.Format("'{0}'", State.ToDescriptionOrString().Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Tel") ? string.Empty : string.Format(", Tel : {0}", Tel == null ? "null" : string.Format("'{0}'", Tel.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Telphone") ? string.Empty : string.Format(", Telphone : {0}", Telphone == null ? "null" : string.Format("'{0}'", Telphone.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Wealth") ? string.Empty : string.Format(", Wealth : {0}", Wealth == null ? "null" : Wealth.ToString()), " }");

            return(string.Concat("{", json.Substring(1)));
        }
示例#23
0
    // Determins the value of the coin
    private void DetermineValue(Wealth wealth = Wealth.Default)
    {
        int valueIndex = Helpers.RandomResultWeighted(GetCoinDropWeight(wealth));

        _value = _COIN_DROP_VALUE[valueIndex];
    }
示例#24
0
 public override string ToString()
 {
     return("Wealth: " + Wealth.ToString() + ", Alignment: " + Alignment.ToString()
            + ", Occupation: " + Occupation.ToString() + ", Region: " + Region.ToString() + ", Subject: " + Subject.ToString()
            + ", Faction: " + Faction.ToString());
 }
示例#25
0
    public IEnumerator Collect(Wealth wealth)
    {
        if (u.collectNum >= u.MaxCollectNum)
        {
            Debug.Log("采集次数达到上限");
            yield break;
        }
        if (wealth.isCollected == true)
        {
            Debug.Log("不能同时采集");
            yield break;
        }
        wealth.isCollected = true;
        Color       color     = wealth.GetComponentInChildren <SpriteRenderer>().color;
        GameObject  newSlider = GameObject.Instantiate(SliderPrefab, Canvas.transform);
        AudioSource collectVoice;

        if (wealth.name.Equals("Wood"))
        {
            collectVoice = voice[3];
        }
        else if (wealth.name.Equals("Stone") || wealth.name.Equals("Iron"))
        {
            collectVoice = voice[4];
        }
        else if (wealth.name.Equals("Berry"))
        {
            collectVoice = voice[5];
        }
        else
        {
            collectVoice = null;
        }
        if (collectVoice != null)
        {
            collectVoice.Play();
        }
        newSlider.transform.position = Camera.main.WorldToScreenPoint(wealth.transform.position + new Vector3(0, 1.5f, 0));
        notInCollect = false;
        float timeCount = 0;

        while (true)
        {
            timeCount += Time.deltaTime;
            if (wealth.count == 1)
            {
                color.a = 1 - timeCount / CollectTime;
                wealth.GetComponentInChildren <SpriteRenderer>().color = color;
            }
            newSlider.GetComponent <Slider>().value = timeCount / CollectTime;
            if (newSlider.GetComponent <Slider>().value >= 1)
            {
                break;
            }
            yield return(null);
        }
        u.collectNum++;
        if (wealth.name.Equals("Berry"))
        {
            u.Energy += 25;
            u.ControlMaxEnergy();
            u.collectNum--;
            wealth.count--;
        }
        else
        {
            package[u.collectNum - 1] = wealth.name;
            wealth.count--;
        }
        if (wealth.count == 0)
        {
            GameObject.Destroy(wealth.gameObject);
        }
        wealth.isCollected = false;
        if (u.collectNum > 0)
        {
            bagImage.gameObject.SetActive(true);
        }
        GameObject.Destroy(newSlider);
        notInCollect = true;
        if (collectVoice != null)
        {
            collectVoice.Stop();
        }
    }
示例#26
0
    public static Relationship RootRelationship(Wealth wealth, AgeGroup group)
    {
        float det = Random.Range(0.0f, 1.0f);

        switch (group)
        {
        case AgeGroup.youngAdult:
            switch (wealth)
            {
            case Wealth.poor:
                if (det <= 0.7f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.95f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }

            case Wealth.middleClass:
                if (det <= 0.6f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.9f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }

            case Wealth.wealthy:
                if (det <= 0.2f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.8f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }
            }
            break;

        case AgeGroup.adult:
            switch (wealth)
            {
            case Wealth.poor:
                if (det <= 0.55f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.75f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }

            case Wealth.middleClass:
                if (det <= 0.3f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.6f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }

            case Wealth.wealthy:
                if (det <= 0.1f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.5f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }
            }
            break;

        case AgeGroup.middleAged:
            switch (wealth)
            {
            case Wealth.poor:
                if (det <= 0.3f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.5f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }

            case Wealth.middleClass:
                if (det <= 0.2f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.35f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }

            case Wealth.wealthy:
                if (det <= 0.1f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.4f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }
            }
            break;

        case AgeGroup.senior:
            switch (wealth)
            {
            case Wealth.poor:
                if (det <= 0.25f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.3f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }

            case Wealth.middleClass:
                if (det <= 0.15f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.25f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }

            case Wealth.wealthy:
                if (det <= 0.1f)
                {
                    return(Relationship.single);
                }
                else if (det <= 0.3f)
                {
                    return(Relationship.dating);
                }
                else
                {
                    return(Relationship.married);
                }
            }
            break;
        }

        return(Relationship.single);
    }
示例#27
0
 public Coin(Wealth wealth)
 {
     DetermineValue(wealth);
 }