Beispiel #1
0
        /// <summary>
        /// 获取当前正在骑乘的坐骑的进阶养成点
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static int GetCurrentHorseBlessPoint(GameClient client)
        {
            int horseDbID = client.ClientData.HorseDbID;

            if (horseDbID <= 0)
            {
                return(0);
            }

            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(0);
            }

            SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);

            if (null == horseUpXmlNode)
            {
                return(0);
            }

            int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint");

            return(horseBlessPoint);
        }
Beispiel #2
0
        private void OnDayStarted(object sender, EventArgs e)
        {
            if (!Context.IsWorldReady || !Game1.currentLocation.IsFarm ||
                !Context.IsMainPlayer)
            {
                return;
            }

            horseFed          = false;
            isHorseSpeedAdded = false;

            // Migration.
            HorseData horseData = LoadHorseDataForPlayer(Game1.player.name);

            if (horseData == null)
            {
                // Read Global for migration from 1.0.0
                horseData = Helper.Data.ReadGlobalData <HorseData>(
                    String.Format("{0}-horse-data", Game1.player.name) // Not sure if player name is unique.
                    );
                if (horseData == null)
                {
                    horseData = new HorseData(0, false);
                }
            }

            horseData.Full  = false;
            addedHorseSpeed = Math.Max(horseData.Friendship / 200, 3);

            SaveTempHorseDataForPlayer(Game1.player.name, horseData);
        }
        public static User GetUser(string name)
        {
            User user = null;

            using (var db = new HorseData())
            {
                user = db.Users.Where(u => u.NTAccount == name).FirstOrDefault();

                if (user == null)
                {
                    user              = new Horse.WebSite.Models.User();
                    user.NTAccount    = name;
                    user.CreateDt     = DateTime.Now;
                    user.LastUpdateDt = DateTime.Now;
                    setUserData(user);
                    db.Users.Add(user);
                }
                else if (user.LastUpdateDt.Value.AddDays(1).CompareTo(DateTime.Now) < 0)
                {
                    setUserData(user);
                    user.LastUpdateDt = DateTime.Now;
                }

                db.SaveChanges();
            }

            return(user);
        }
Beispiel #4
0
        public static int GetCurrentHorseBlessPoint(GameClient client)
        {
            int horseDbID = client.ClientData.HorseDbID;
            int result;

            if (horseDbID <= 0)
            {
                result = 0;
            }
            else
            {
                HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
                if (null == horseData)
                {
                    result = 0;
                }
                else
                {
                    SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);
                    if (null == horseUpXmlNode)
                    {
                        result = 0;
                    }
                    else
                    {
                        int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint", -1);
                        result = horseBlessPoint;
                    }
                }
            }
            return(result);
        }
        private RaceData CreateRaceData(Domain.Race race, IEnumerable <Domain.Bet> bets)
        {
            RaceData raceData = new RaceData
            {
                Id     = race.Id,
                Status = race.Status.GetDescription()
            };

            IEnumerable <Bet> betsOnRace = bets?.Where(b => b.Race?.Id == race.Id);

            raceData.TotalMoneyOnRace = betsOnRace.Sum(b => b.Stake);

            if (race.Horses != null)
            {
                IList <HorseData> horsesData = new List <HorseData>();

                foreach (Horse horse in race.Horses)
                {
                    HorseData horseData = new HorseData
                    {
                        Id           = horse.Id,
                        Name         = horse.Name,
                        NumberOfBets = bets?.Where(b => b.Horse?.Id == horse.Id).Count() ?? 0
                    };
                    horseData.PayoutIfWon = horseData.NumberOfBets * horse.Odds;

                    horsesData.Add(horseData);
                }

                raceData.Horses = horsesData;
            }

            return(raceData);
        }
Beispiel #6
0
        public static int ProcessAddHorseAwardLucky(GameClient client, int luckyValue, bool usedTimeLimited, string getType)
        {
            int result;

            if (0 == luckyValue)
            {
                result = 0;
            }
            else
            {
                int horseDbID = client.ClientData.HorseDbID;
                if (horseDbID <= 0)
                {
                    result = -300;
                }
                else
                {
                    HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
                    if (null == horseData)
                    {
                        result = -1;
                    }
                    else
                    {
                        SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);
                        if (null == horseUpXmlNode)
                        {
                            result = -35;
                        }
                        else
                        {
                            int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint", -1);
                            int jinJieFailedNum = Global.GetHorseFailedNum(horseData);
                            if (horseData.HorseID >= Global.MaxHorseID)
                            {
                                result = -10;
                            }
                            else
                            {
                                int addLuckValue = Global.GMin(luckyValue, horseBlessPoint - jinJieFailedNum);
                                addLuckValue = Global.GMax(0, addLuckValue);
                                if (!usedTimeLimited)
                                {
                                    Global.AddHorseFailedNum(horseData, addLuckValue);
                                }
                                else
                                {
                                    Global.AddHorseTempJiFen(horseData, addLuckValue);
                                }
                                Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);
                                Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, getType);
                                result = addLuckValue;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #7
0
        private void OpenHorseMenu(Nullable <int> x = null, Nullable <int> y = null)
        {
            if (x == null && y == null)
            {
                String horseName = Game1.player.horseName;

                if (horseName == null)
                {
                    return;
                }

                HorseData horseData = LoadTempHorseDataForPlayer(Game1.player.name);

                if (horseData == null)
                {
                    horseData = new HorseData(0, false);
                }

                UpgradedHorse horse = new UpgradedHorse(
                    horseName, horseData
                    );

                Game1.activeClickableMenu = (IClickableMenu) new HorseMenu(horse, this);
                return;
            }

            if (Game1.activeClickableMenu is GameMenu menu)
            {
                if (menu.currentTab == INVENTORY_TAB)
                {
                    Vector2 rectangle = new Vector2((float)((double)(openMenuX + Game1.tileSize * 5 + Game1.pixelZoom * 2) + (double)Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f) + (Game1.player.getPetDisplayName() != null ? (double)Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.getPetDisplayName()).X) : 0.0)), (float)(openMenuY + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize - Game1.pixelZoom));
                    if (Utility.distance((float)x, rectangle.X, (float)y, rectangle.Y) <= 100)
                    {
                        String horseName = Game1.player.horseName;

                        if (horseName == null)
                        {
                            return;
                        }

                        HorseData horseData = LoadTempHorseDataForPlayer(Game1.player.name);

                        if (horseData == null)
                        {
                            horseData = new HorseData(0, false);
                        }

                        UpgradedHorse horse = new UpgradedHorse(
                            horseName, horseData
                            );

                        Game1.activeClickableMenu = (IClickableMenu) new HorseMenu(horse, this);
                        return;
                    }
                }
            }
        }
Beispiel #8
0
        private void OnSaving(object sender, SavingEventArgs e)
        {
            if (!Context.IsMainPlayer)
            {
                return;
            }
            // Same Temp Horse Data to Global On Save
            HorseData horseData = LoadTempHorseDataForPlayer(Game1.player.name);

            if (horseData.Friendship > 800 && !horseData.Full)
            {
                horseData.Friendship -= 10;
            }
            SaveHorseDataForPlayer(Game1.player.name, horseData);
        }
Beispiel #9
0
        private void FeedHorse(GameLocation currentLocation, int x, int y)
        {
            if (Game1.player.CurrentItem == null)
            {
                return;
            }

            // Find if click was on Horse
            foreach (Horse horse in currentLocation.characters.OfType <Horse>())
            {
                // Can only feed your own horse
                if (horse.getOwner() != Game1.player)
                {
                    return;
                }

                if (Utility.withinRadiusOfPlayer((int)(horse.Position.X), (int)(horse.Position.Y), 1, Game1.player) &&
                    (Utility.distance((float)x, horse.Position.X, (float)y, horse.Position.Y) <= 110))
                {
                    // Holding food
                    Item currentItem = Game1.player.CurrentItem;
                    if (IsEdible(currentItem))
                    {
                        Item food = Game1.player.CurrentItem;
                        Game1.drawObjectDialogue(string.Format("{0} ate your {1}.", horse.name, food.Name));
                        Game1.player.reduceActiveItemByOne();

                        HorseData horseData = LoadTempHorseDataForPlayer(Game1.player.name);


                        if (horseData == null)
                        {
                            horseData = new HorseData(10, true);
                        }

                        horseData.Friendship += CalculateExpGain(currentItem, horseData.Friendship);
                        horseData.Full        = true;
                        horseFed              = true;

                        // Update addedHorseSpeed if Friendship increases enough
                        addedHorseSpeed = horseData.Friendship / 200;

                        SaveTempHorseDataForPlayer(Game1.player.name, horseData);
                    }
                }
            }
        }
Beispiel #10
0
        public HorseData LoadTempHorseDataForPlayer(string player)
        {
            HorseData saveData;

            try
            {
                saveData = this.Helper.Data.ReadSaveData <HorseData>(
                    String.Format("{0}-horse-data-temp", player)
                    );
            }
            catch (Exception)
            {
                saveData = new HorseData(0, false);
            }

            return(saveData);
        }
Beispiel #11
0
    public static List <HorseData> GetHourseData(string str)
    {
        List <HorseData> list = new List <HorseData>();

        if (str.Length == 0 || str == null)
        {
            return(null);
        }
        JsonData js = JsonMapper.ToObject(str);

        for (int i = 0; i < js.Count; i++)
        {
            string    json      = js[i].ToJson();
            HorseData horseData = JsonMapper.ToObject <HorseData>(json);
            list.Add(horseData);
        }
        return(list);
    }
Beispiel #12
0
        static void Main(string[] args)
        {
            var horseData = new HorseData();



            Console.WriteLine("");
            Console.WriteLine("All the horses enter in race");
            horseData.GetHorsesByName();

            Console.WriteLine("");
            Console.WriteLine("The percentage chance of all racing hors");
            horseData.BestChanceDisplay();


            Console.WriteLine("");
            Console.WriteLine("The winner of the game");
            horseData.ChanceToWin();

            Console.ReadLine();
        }
Beispiel #13
0
        private static int ProcessHorseUpgradeNow(GameClient client, int horseDbID, HorseData horseData)
        {
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                Global.UpdateHorseDataProps(client, false);
            }
            int oldHorseID = horseData.HorseID;
            int newHorseID = horseData.HorseID + 1;

            Global.AddHorseTempJiFen(horseData, 0);
            horseData.JinJieFailedDayID = TimeUtil.NowDateTime().DayOfYear;
            horseData.JinJieFailedNum   = 0;
            int ret = 0;

            if (Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, newHorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID) < 0)
            {
                ret = -2000;
            }
            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "成功");
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                Global.UpdateHorseDataProps(client, true);
                if (0 == ret)
                {
                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                }
                if (0 == ret)
                {
                    client.ClientData.RoleHorseJiFen = Global.CalcHorsePropsJiFen(horseData);
                    List <object> objsList = Global.GetAll9Clients(client);
                    GameManager.ClientMgr.NotifyHorseCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, 0, 1, horseDbID, horseData.HorseID, horseData.BodyID, objsList);
                    Global.BroadcastHorseUpgradeOk(client, oldHorseID, newHorseID);
                }
            }
            return(0);
        }
        /// <summary>A method called via Harmony before <see cref="Horse.checkAction" />.</summary>
        /// <returns>
        ///     Returns <see langword="false"/>, terminating prefixes and skipping the execution of the original method,
        ///     effectively replacing the original method.
        /// </returns>
        private static bool BeforeHorseCheckAction(
            Horse __instance,
            Farmer who,
            GameLocation l,
            ref bool ___roomForHorseAtDismountTile,
            ref Vector2 ___dismountTile,
            ref bool __result)
        {
            HorseData horseData = CharactersPatcher.HorsesData.GetOrCreateValue(__instance);

            if (!horseData.CheckActionEnabled)
            {
                horseData.CheckActionEnabled = true;

                __result = false;
                return(false);
            }

            if (who is not null && !who.canMove)
            {
                __result = false;
                return(false);
            }

            if (__instance.rider is null)
            {
                __instance.mutex.RequestLock(
                    delegate
                {
                    if (who.mount is not null || __instance.rider is not null ||
                        who.FarmerSprite.PauseForSingleAnimation)
                    {
                        __instance.mutex.ReleaseLock();
                    }
                    else if ((__instance.getOwner() == Game1.player ||
                              (__instance.getOwner() is null &&
                               (string.IsNullOrEmpty(Game1.player.horseName.Value) ||
                                Utility.findHorseForPlayer(Game1.player.UniqueMultiplayerID) is null))) &&
                             __instance.Name.Length <= 0)
                    {
                        foreach (Building building in (Game1.getLocationFromName("Farm") as Farm).buildings)
                        {
                            if (building.daysOfConstructionLeft.Value <= 0 && building is Stable stable)
                            {
                                if (stable.getStableHorse() == __instance)
                                {
                                    stable.owner.Value = who.UniqueMultiplayerID;
                                    stable.updateHorseOwnership();
                                }
                                else if (stable.owner.Value == who.UniqueMultiplayerID)
                                {
                                    stable.owner.Value = 0;
                                    stable.updateHorseOwnership();
                                }
                            }
                        }

                        if (string.IsNullOrEmpty(Game1.player.horseName.Value))
                        {
                            Game1.activeClickableMenu = new NamingMenu(
                                __instance.nameHorse,
                                Game1.content.LoadString("Strings\\Characters:NameYourHorse"),
                                Game1.content.LoadString("Strings\\Characters:DefaultHorseName"));
                        }
                    }
Beispiel #15
0
        public static int ProcessHorseEnchance(GameClient client, int horseDbID, int extPropIndex, bool allowAutoBuy)
        {
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
            int       result;

            if (null == horseData)
            {
                result = -1;
            }
            else if (extPropIndex < 0 || extPropIndex >= 10)
            {
                result = -10;
            }
            else
            {
                int EnchanceNeedGoodsID = (int)GameManager.systemParamsList.GetParamValueIntByName("HorseEnchancseGoodsID", -1);
                if (EnchanceNeedGoodsID <= 0)
                {
                    result = -20;
                }
                else
                {
                    int[]         horseExtNumIntArray  = Global.HorseExtStr2IntArray(horseData.PropsNum);
                    int[]         horseExtPropIntArray = Global.HorseExtStr2IntArray(horseData.PropsVal);
                    int           horseExtNum          = Global.GetHorseExtFieldIntVal(horseExtNumIntArray, (HorseExtIndexes)extPropIndex);
                    int           horseExtVal          = Global.GetHorseExtFieldIntVal(horseExtPropIntArray, (HorseExtIndexes)extPropIndex);
                    SystemXmlItem systemHorseEnchance  = Global.GetHorseEnchanceXmlNode(horseExtNum + 1, (HorseExtIndexes)extPropIndex);
                    if (null == systemHorseEnchance)
                    {
                        result = -35;
                    }
                    else
                    {
                        int baseVal   = Global.GetHorseBasePropVal(horseData.HorseID, (HorseExtIndexes)extPropIndex, null);
                        int propLimit = Global.GetHorsePropLimitVal(horseData.HorseID, (HorseExtIndexes)extPropIndex);
                        if (baseVal + horseExtVal >= propLimit)
                        {
                            result = -40;
                        }
                        else
                        {
                            int needYinLiang = Global.GMax(systemHorseEnchance.GetIntValue("UseMoney", -1), 0);
                            if (client.ClientData.YinLiang < needYinLiang)
                            {
                                result = -60;
                            }
                            else
                            {
                                int needBuyGoodsNum = 0;
                                int needGoodsNum    = Global.GMax(systemHorseEnchance.GetIntValue("HanTie", -1), 0);
                                int needSubGoodsNum = needGoodsNum;
                                if (Global.GetTotalGoodsCountByID(client, EnchanceNeedGoodsID) < needGoodsNum)
                                {
                                    if (!allowAutoBuy)
                                    {
                                        return(-70);
                                    }
                                    needSubGoodsNum = Global.GetTotalGoodsCountByID(client, EnchanceNeedGoodsID);
                                    needBuyGoodsNum = needGoodsNum - needSubGoodsNum;
                                }
                                bool usedBinding     = false;
                                bool usedTimeLimited = false;
                                if (needSubGoodsNum > 0)
                                {
                                    if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, EnchanceNeedGoodsID, needSubGoodsNum, false, out usedBinding, out usedTimeLimited, false))
                                    {
                                        return(-70);
                                    }
                                }
                                if (needBuyGoodsNum > 0)
                                {
                                    int retAuto = Global.SubUserMoneyForGoods(client, EnchanceNeedGoodsID, needBuyGoodsNum, "坐骑强化");
                                    if (retAuto <= 0)
                                    {
                                        return(retAuto);
                                    }
                                }
                                if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYinLiang, "坐骑强化", false))
                                {
                                    result = -60;
                                }
                                else
                                {
                                    int successRate = Global.GMax(systemHorseEnchance.GetIntValue("SucceedRate", -1), 0);
                                    int randNum     = Global.GetRandomNumber(0, 101);
                                    if (client.ClientData.TempHorseEnchanceRate != 1)
                                    {
                                        successRate *= client.ClientData.TempHorseEnchanceRate;
                                        successRate  = Global.GMin(100, successRate);
                                    }
                                    if (randNum > successRate)
                                    {
                                        result = -1000;
                                    }
                                    else
                                    {
                                        int addPropValue = Global.GMax(systemHorseEnchance.GetIntValue("PropVal", -1), 0);
                                        if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
                                        {
                                            Global.UpdateHorseDataProps(client, false);
                                        }
                                        int ret = 0;
                                        if (Global.UpdateHorsePropsDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, (HorseExtIndexes)extPropIndex, addPropValue, 1) < 0)
                                        {
                                            ret = -2000;
                                        }
                                        if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
                                        {
                                            Global.UpdateHorseDataProps(client, true);
                                            if (0 == ret)
                                            {
                                                client.ClientData.RoleHorseJiFen = Global.CalcHorsePropsJiFen(horseData);
                                                GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                                GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                                            }
                                        }
                                        if (0 == ret)
                                        {
                                            if (Global.IsHorsePropsFull(horseData))
                                            {
                                                Global.BroadcastHorseEnchanceOk(client, horseData.HorseID);
                                            }
                                        }
                                        result = ret;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #16
0
	public void unpackHorses(SFSArray aArray) {
		for(int i = 0;i<aArray.Size();i++) {
			HorseData h = new HorseData((SFSObject) aArray.GetSFSObject(i));
			horses.Add(h);  
		}
	}
Beispiel #17
0
 public void UpdateCurHorseData(HorseData data)
 {
     horseDataList.Add(data);
     mCurHorseDataIdx = horseDataList.Count - 1;
 }
Beispiel #18
0
	public void combineHorses(HorseData aHorseA,HorseData aHorseB)
	{
		
		Debug.LogError("Form Breding Adder not working and Top Breeder Talent not working");
		/*
		int l_assignedTalents = 0;
		HorseTalents horseATalents = aHorseA.horseTalents;
		HorseTalents horseBTalents = aHorseB.horseTalents;
		
		List<TalentListItem> talentList = new List<TalentListItem>();
		horseATalents.addTalentsToList(talentList);
		horseBTalents.addTalentsToList(talentList);
		
		for(int i = 0;i<formValue+1;i++) {
			talentList.push(new TalentListItem("None"));
		}
		/*
		
		while(l_assignedTalents<18+aHorseA.horseTalents.topBreeder+aHorseB.horseTalents.topBreeder)
		{
			int random = Random.Range(0f,1f)*talentList.length;
			l_assignedTalents++;
			if(count>=12) {
				break;
			} else
				switch(talentList[random].talentName)
			{
				case("None"):default:break;
				case("Super Speed"):
				if(superSpeed<2)
				{
					int parentsTalents = horseATalents.superSpeed+horseBTalents.superSpeed;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.superSpeed++;
						this.count++;
					}
				}
				break;
				case("Acceleration"):
				if(acceleration<2)
				{
					parentsTalents = horseATalents.acceleration+horseBTalents.acceleration;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.acceleration++;
						this.count++;
					}
				}
				break;
				case("Distance Runner"):
				if(distanceRunner<2)
				{
					parentsTalents = horseATalents.distanceRunner+horseBTalents.distanceRunner;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.distanceRunner++;
						this.count++;
					}
				}
				break;
				case("Fast Finisher"):
				if(this.fastFinisher<2)
				{
					parentsTalents = horseATalents.fastFinisher+horseBTalents.fastFinisher;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.fastFinisher++;
						this.count++;
					}
				}
				break;
				case("All Terrain"):
				if(this.allTerrain<2)
				{
					parentsTalents = horseATalents.allTerrain+horseBTalents.allTerrain;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.allTerrain++;
						this.count++;
					}
				}
				break;
				case("Jumper"):
				if(this.jumper<2)
				{
					parentsTalents = horseATalents.jumper+horseBTalents.jumper;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.jumper++;
						this.count++;
					}
				}
				break;
				case("Controllability"):
				if(this.controllability<2)
				{
					parentsTalents = horseATalents.controllability+horseBTalents.controllability;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.controllability++;
						this.count++;
					}
				}
				break;
				case("Show Jump Ability"):
				if(this.showjumpAbility<2)
				{
					parentsTalents = horseATalents.showjumpAbility+horseBTalents.showjumpAbility;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.showjumpAbility++;
						this.count++;
					}
				}
				break;
				
				case("Big Racer"):
				if(this.bigRacer<2)
				{
					parentsTalents = horseATalents.bigRacer+horseBTalents.bigRacer;
					if(shouldCombineTalent(parentsTalents,formValue))
					{
						this.bigRacer++;
						this.count++;
					}
				}
				break;
				
			}
			bornWith = this.count;
		}*/
	}
 public FractionalConvertionTest()
 {
     fractionalConvertion = new FractionalConvertion();
     horseData            = new HorseData();
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="line"></param>
        /// <param name="entireDbSetting">false to try selected herds, true to try entire DB</param>
        /// <returns></returns>
        private HorseData GetHorseDataFromAnyLogEvent(string line, bool entireDbSetting)
        {
            HorseEntity[] horses = _context.Horses.ToArray();
            if (!entireDbSetting)
            {
                var selectedHerds = _context.Herds.AsEnumerable().Where(x => x.Selected).Select(x => x.HerdID).ToArray();
                horses = horses.Where(x => selectedHerds.Contains(x.Herd)).ToArray();
            }

            horses = horses.Where(x => line.Contains(x.Name, StringComparison.OrdinalIgnoreCase)).ToArray();

            var result = new HorseData();
            foreach (HorseEntity horseEntity in horses)
            {
                // it is possible we have found event lines that simply contain horse name
                // in a totally unrelated context
                // attempting to get horse age should fail for those and loop continues
                result.SecondaryInfo = null;
                Match match = Regex.Match(line, @"(\w+) (\w+) " + horseEntity.Name, RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    result.Age = HorseAge.CreateAgeFromRawHorseName(match.Groups[1].Value);
                    if (result.Age.EnumVal != HorseAge.Age.Unknown)
                    {
                        result.SecondaryInfo = match.Groups[2].Value;
                    }
                    else
                    {
                        match = Regex.Match(line, @"(\w+) " + horseEntity.Name, RegexOptions.IgnoreCase);
                        if (match.Success)
                        {
                            result.Age = HorseAge.CreateAgeFromRawHorseName(match.Groups[1].Value);
                            if (result.Age.EnumVal != HorseAge.Age.Unknown)
                            {
                                result.SecondaryInfo = String.Empty;
                            }
                        }
                    }
                    if (result.Age.EnumVal != HorseAge.Age.Unknown)
                    {
                        // we have found the correct horse data
                        result.Horse = horseEntity;
                        // possibly existing horse is a foal
                        var prevAge = result.Horse.Age.EnumVal;
                        var newAge = result.Age.EnumVal;
                        // since adding horse for first time gets correct age
                        // we can asume here that horse can't be younger than it is
                        // and go for foal status where applicable
                        if (prevAge == HorseAge.Age.YoungFoal)
                        {
                            if (newAge == HorseAge.Age.Young) 
                                result.Age = new HorseAge(HorseAge.Age.YoungFoal);
                            if (newAge == HorseAge.Age.Adolescent)
                                result.Age = new HorseAge(HorseAge.Age.AdolescentFoal);
                        }
                        if (prevAge == HorseAge.Age.AdolescentFoal)
                        {
                            // here we allow updating to regular Young
                            if (newAge == HorseAge.Age.Adolescent) 
                                result.Age = new HorseAge(HorseAge.Age.AdolescentFoal);
                        }

                        break;
                    }
                }
            }

            if (result.Horse == null)
            {
                return null;
            }
            var existingHorsesInQuery = horses.Where(x => x.Name == result.Horse.Name).ToArray();
            if (existingHorsesInQuery.Length == 1)
            {
                return result;
            }
            else if (existingHorsesInQuery.Length > 1)
            {
                result.TooManyHorsesFound = true;
                return result;
            }
            return null;
        }
Beispiel #21
0
        /// <summary>
        /// 坐骑进阶
        /// </summary>
        /// <param name="client"></param>
        /// <param name="horseDbID"></param>
        public static int ProcessHorseUpgrade(GameClient client, int horseDbID, bool allowAutoBuy)
        {
            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(-1);
            }

            SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);

            if (null == horseUpXmlNode)
            {
                return(-35);
            }

            //int needRoleLevel = horseUpXmlNode.GetIntValue("LevelLimit");
            //if (client.ClientData.Level < needRoleLevel)
            //{
            //    return -38;
            //}

            //获取强化需要的道具的物品ID
            int horseUpgradeGoodsID  = 0;
            int horseUpgradeGoodsNum = 0;

            //解析进阶需要的物品ID和数量
            Global.ParseHorseJinJieFu(horseData.HorseID, out horseUpgradeGoodsID, out horseUpgradeGoodsNum, horseUpXmlNode);
            if (horseUpgradeGoodsID <= 0)
            {
                return(-20);
            }

            if (horseData.HorseID >= Global.MaxHorseID)
            {
                return(-30);
            }

            //本次强化需要的银两
            int needYinLiang = Global.GMax(horseUpXmlNode.GetIntValue("UseYinLiang"), 0);

            needYinLiang = Global.RecalcNeedYinLiang(needYinLiang); //判断银两是否折半
            if (client.ClientData.YinLiang < needYinLiang)
            {
                return(-60);
            }

            int needBuyGoodsNum = 0; //需要购买的
            int needSubGoodsNum = 0; //需要扣除的

            //本次强化需要的辅助物品的个数
            int needGoodsNum = Global.GMax(horseUpgradeGoodsNum, 0);

            needSubGoodsNum = needGoodsNum;

            if (Global.GetTotalGoodsCountByID(client, horseUpgradeGoodsID) < needGoodsNum)
            {
                if (allowAutoBuy)
                {
                    needSubGoodsNum = Global.GetTotalGoodsCountByID(client, horseUpgradeGoodsID);
                    needBuyGoodsNum = needGoodsNum - needSubGoodsNum;
                }
                else
                {
                    return(-70);
                }
            }

            bool usedBinding     = false;
            bool usedTimeLimited = false;

            //自动扣除物品
            if (needSubGoodsNum > 0)
            {
                //扣除物品
                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                          Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, horseUpgradeGoodsID, needSubGoodsNum, false, out usedBinding, out usedTimeLimited))
                {
                    return(-70);
                }
            }

            //自动扣除money
            if (needBuyGoodsNum > 0)
            {
                //自动扣除元宝购买
                int ret = Global.SubUserMoneyForGoods(client, horseUpgradeGoodsID, needBuyGoodsNum, "坐骑进阶");

                if (ret <= 0)
                {
                    return(ret);
                }
            }

            //扣除银两
            if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener,
                                                       Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYinLiang, "坐骑进阶"))
            {
                return(-60);
            }

            int    horseOne   = 110000 - horseUpXmlNode.GetIntValue("HorseOne");
            int    horseTwo   = 110000 - horseUpXmlNode.GetIntValue("HorseTwo");
            double horseThree = horseUpXmlNode.GetDoubleValue("HorseThree");
            //int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint");

            //获取坐骑的失败积分
            int jinJieFailedNum = Global.GetHorseFailedNum(horseData);

            //判断如果还没到真概率,则直接返回失败
            if (jinJieFailedNum < horseTwo)
            {
                //if (!usedTimeLimited) //不是限时的道具
                {
                    //记录失败次数
                    //horseData.JinJieFailedNum += 1;
                    Global.AddHorseFailedNum(horseData, 1);
                }
                //else
                //{
                //    Global.AddHorseTempJiFen(horseData, 1);
                //}

                //记录失败次数
                Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);

                //写入角色进阶坐骑的行为日志
                Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "失败");

                //改变坐骑的临时ID
                //Global.ChangeTempHorseID(client, horseData.HorseID + 1);

                return(-1000);
            }

            //判断如果还没到必定成功的幸运值,则判断随机数
            if (jinJieFailedNum < (horseOne - 1))
            {
                int successRate = (int)(horseThree * 10000);
                int randNum     = Global.GetRandomNumber(1, 10001);

                if (client.ClientData.TempHorseUpLevelRate != 1) //临时测试加成功率
                {
                    successRate *= client.ClientData.TempHorseUpLevelRate;
                    successRate  = Global.GMin(10000, successRate);
                }

                if (randNum > successRate)
                {
                    //if (!usedTimeLimited) //不是限时的道具
                    {
                        //记录失败次数
                        //horseData.JinJieFailedNum += 1;
                        Global.AddHorseFailedNum(horseData, 1);
                    }
                    //else
                    //{
                    //    Global.AddHorseTempJiFen(horseData, 1);
                    //}

                    //记录失败次数
                    Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);

                    //写入角色进阶坐骑的行为日志
                    Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "失败");

                    //改变坐骑的临时ID
                    //Global.ChangeTempHorseID(client, horseData.HorseID + 1);

                    return(-1000);
                }
            }

            //处理坐骑进阶
            return(ProcessHorseUpgradeNow(client, horseDbID, horseData));
        }
Beispiel #22
0
        /// <summary>
        /// 为指定的坐骑增加养成点(临时)
        /// </summary>
        /// <param name="client"></param>
        /// <param name="horseDbID"></param>
        /// <param name="luckyGoodsID"></param>
        /// <returns></returns>
        public static int ProcessAddHorseLucky(GameClient client, int horseDbID, int luckyGoodsID)
        {
            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(-1);
            }

            SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);

            if (null == horseUpXmlNode)
            {
                return(-35);
            }

            int horseOne = 110000 - horseUpXmlNode.GetIntValue("HorseOne");
            int horseTwo = 110000 - horseUpXmlNode.GetIntValue("HorseTwo");
            //int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint");

            //获取坐骑的失败积分
            int jinJieFailedNum = Global.GetHorseFailedNum(horseData);

            //判断如果已经到了幸运点 - 1,则提示用户不需要使用祝福丹
            if (jinJieFailedNum >= (horseOne - 1))
            {
                return(-100);
            }

            //获取增加幸运点需要的物品ID
            int[] allHorseLuckyGoodsIDs        = GameManager.systemParamsList.GetParamValueIntArrayByName("AllHorseLuckyGoodsIDs");
            int[] allHorseLuckyGoodsIDsToLucky = GameManager.systemParamsList.GetParamValueIntArrayByName("AllHorseLuckyGoodsIDsToLucky");
            if (null == allHorseLuckyGoodsIDs || null == allHorseLuckyGoodsIDsToLucky || allHorseLuckyGoodsIDs.Length != allHorseLuckyGoodsIDsToLucky.Length)
            {
                return(-2);
            }

            //如果已经是最高阶,则不需要再增加幸运点
            if (horseData.HorseID >= Global.MaxHorseID)
            {
                return(-10);
            }

            //判断物品数量
            if (Global.GetTotalGoodsCountByID(client, luckyGoodsID) <= 0)
            {
                return(-20);
            }

            bool usedBinding     = false;
            bool usedTimeLimited = false;

            //扣除物品
            if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                      Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, luckyGoodsID, 1, false, out usedBinding, out usedTimeLimited))
            {
                return(-30);
            }

            int addLuckValue = 0;

            for (int i = 0; i < allHorseLuckyGoodsIDs.Length; i++)
            {
                if (allHorseLuckyGoodsIDs[i] == luckyGoodsID)
                {
                    addLuckValue = allHorseLuckyGoodsIDsToLucky[i];
                    break;
                }
            }

            //addLuckValue = Global.GMin(addLuckValue, horseBlessPoint - jinJieFailedNum);
            addLuckValue = Global.GMax(0, addLuckValue);

            //if (!usedTimeLimited) //不是限时的道具
            {
                //记录失败次数
                //horseData.JinJieFailedNum += addLuckValue;
                Global.AddHorseFailedNum(horseData, addLuckValue);
            }
            //else
            //{
            //    Global.AddHorseTempJiFen(horseData, addLuckValue);
            //}

            //记录失败次数
            Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);

            //写入角色进阶坐骑的行为日志
            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "祝福丹");

            return(addLuckValue);
        }
Beispiel #23
0
	public void debugInit(HorseData aHorse) {
		this.dataFromServer(Convert.ToInt32(aHorse.ownerID),aHorse.compressedString(1));
	} 
Beispiel #24
0
        /// <summary>
        /// 坐骑快速全部属性强化
        /// </summary>
        /// <param name="client"></param>
        /// <param name="horseDbID"></param>
        /// <param name="extPropIndex"></param>
        public static int ProcessHorseQuickAllEnchance(GameClient client, int horseDbID)
        {
            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(-1);
            }

            //判断坐骑的属性是否已经满了?
            if (Global.IsHorsePropsFull(horseData))
            {
                return(-10);
            }

            //获取强化需要的道具的物品ID
            int chaoJiLianGuGoodsID = (int)GameManager.systemParamsList.GetParamValueIntByName("ChaoJiLianGuGoodsID");

            if (chaoJiLianGuGoodsID <= 0)
            {
                return(-20);
            }

            //本次强化需要的银两
            int needYinLiang = Global.QuickHorseExtPropNeedYinLiang;

            if (client.ClientData.YinLiang < needYinLiang)
            {
                return(-30);
            }

            //本次强化需要的辅助物品的个数
            if (Global.GetTotalGoodsCountByID(client, chaoJiLianGuGoodsID) < 1)
            {
                return(-40);
            }

            bool usedBinding     = false;
            bool usedTimeLimited = false;

            //扣除物品
            if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                      Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, chaoJiLianGuGoodsID, 1, false, out usedBinding, out usedTimeLimited))
            {
                return(-60);
            }

            //扣除银两
            if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener,
                                                       Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYinLiang, "坐骑快速全部属性强化"))
            {
                return(-70);
            }

            //处理先前的坐骑
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                //减去buffer属性值
                //加载骑乘的属性
                /// 将坐骑的扩展属性加入Buffer中
                Global.UpdateHorseDataProps(client, false);
            }

            for (int i = (int)HorseExtIndexes.Attack; i < (int)HorseExtIndexes.MaxVal; i++)
            {
                int[] horseExtNumIntArray  = Global.HorseExtStr2IntArray(horseData.PropsNum);
                int[] horseExtPropIntArray = Global.HorseExtStr2IntArray(horseData.PropsVal);
                int   horseExtNum          = Global.GetHorseExtFieldIntVal(horseExtNumIntArray, (HorseExtIndexes)i);
                int   horseExtVal          = Global.GetHorseExtFieldIntVal(horseExtPropIntArray, (HorseExtIndexes)i);


                //获取坐骑基础属性值
                int baseVal = Global.GetHorseBasePropVal(horseData.HorseID, (HorseExtIndexes)i, null);

                //获取坐骑属性的上限值
                int propLimit = Global.GetHorsePropLimitVal(horseData.HorseID, (HorseExtIndexes)i);
                //propLimit += baseVal;

                if ((baseVal + horseExtVal) >= propLimit)
                {
                    continue;
                }

                //坐骑的最大强化次数
                int maxEnchanceLevel = Global.GetHorseEnchanceNum(horseData.HorseID);

                int addNum       = maxEnchanceLevel - horseExtNum;
                int addPropValue = propLimit - baseVal - horseExtVal;

                //进行坐骑属性的强化,并存入数据库中
                Global.UpdateHorsePropsDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, (HorseExtIndexes)i, addPropValue, addNum);
            }

            //如果成功,并且坐骑处于骑乘状态
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                //减去buffer属性值
                //加载骑乘的属性
                /// 将坐骑的扩展属性加入Buffer中
                Global.UpdateHorseDataProps(client, true);

                {
                    //计算坐骑的积分值
                    client.ClientData.RoleHorseJiFen = Global.CalcHorsePropsJiFen(horseData);

                    //通知客户端属性变化
                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);

                    // 总生命值和魔法值变化通知(同一个地图才需要通知)
                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                }
            }

            {
                //判断坐骑的属性是否已经满了?
                if (Global.IsHorsePropsFull(horseData))
                {
                    //坐骑强化完毕
                    Global.BroadcastHorseEnchanceOk(client, horseData.HorseID);
                }
            }

            return(0);
        }
Beispiel #25
0
 public void SaveTempHorseDataForPlayer(string player, HorseData horseData)
 {
     this.Helper.Data.WriteSaveData <HorseData>(
         String.Format("{0}-horse-data-temp", player), horseData
         );
 }
Beispiel #26
0
        /// <summary>
        /// 处理坐骑进阶
        /// </summary>
        private static int ProcessHorseUpgradeNow(GameClient client, int horseDbID, HorseData horseData)
        {
            //处理先前的坐骑
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                //减去buffer属性值
                //加载骑乘的属性
                /// 将坐骑的扩展属性加入Buffer中
                Global.UpdateHorseDataProps(client, false);
            }

            int oldHorseID = horseData.HorseID;
            int newHorseID = horseData.HorseID + 1;

            //强制清空临时的积分
            Global.AddHorseTempJiFen(horseData, 0);

            horseData.JinJieFailedDayID = TimeUtil.NowDateTime().DayOfYear;
            horseData.JinJieFailedNum   = 0; //清空失败的积分

            //进行坐骑属性的强化,并存入数据库中
            int ret = 0;

            if (Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, newHorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID) < 0)
            {
                ret = -2000;
            }

            //写入角色进阶坐骑的行为日志
            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "成功");

            //如果成功,并且坐骑处于骑乘状态
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                //减去buffer属性值
                //加载骑乘的属性
                /// 将坐骑的扩展属性加入Buffer中
                Global.UpdateHorseDataProps(client, true);

                if (0 == ret) //如果成功了, 否则没变化,不通知
                {
                    //通知客户端属性变化
                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);

                    // 总生命值和魔法值变化通知(同一个地图才需要通知)
                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                }

                //通知用户更新坐骑的形象
                if (0 == ret) //如果成功了, 否则没变化,不通知
                {
                    //计算坐骑的积分值
                    client.ClientData.RoleHorseJiFen = Global.CalcHorsePropsJiFen(horseData);

                    List <Object> objsList = Global.GetAll9Clients(client);

                    //通知骑乘的的指令信息
                    GameManager.ClientMgr.NotifyHorseCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                         0, (int)HorseCmds.On, horseDbID, horseData.HorseID, horseData.BodyID, objsList);

                    //坐骑进阶成功
                    Global.BroadcastHorseUpgradeOk(client, oldHorseID, newHorseID);
                }
            }

            return(0);
        }
Beispiel #27
0
        public static int ProcessAddHorseLucky(GameClient client, int horseDbID, int luckyGoodsID)
        {
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
            int       result;

            if (null == horseData)
            {
                result = -1;
            }
            else
            {
                SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);
                if (null == horseUpXmlNode)
                {
                    result = -35;
                }
                else
                {
                    int horseOne        = 110000 - horseUpXmlNode.GetIntValue("HorseOne", -1);
                    int horseTwo        = 110000 - horseUpXmlNode.GetIntValue("HorseTwo", -1);
                    int jinJieFailedNum = Global.GetHorseFailedNum(horseData);
                    if (jinJieFailedNum >= horseOne - 1)
                    {
                        result = -100;
                    }
                    else
                    {
                        int[] allHorseLuckyGoodsIDs        = GameManager.systemParamsList.GetParamValueIntArrayByName("AllHorseLuckyGoodsIDs", ',');
                        int[] allHorseLuckyGoodsIDsToLucky = GameManager.systemParamsList.GetParamValueIntArrayByName("AllHorseLuckyGoodsIDsToLucky", ',');
                        if (allHorseLuckyGoodsIDs == null || allHorseLuckyGoodsIDsToLucky == null || allHorseLuckyGoodsIDs.Length != allHorseLuckyGoodsIDsToLucky.Length)
                        {
                            result = -2;
                        }
                        else if (horseData.HorseID >= Global.MaxHorseID)
                        {
                            result = -10;
                        }
                        else if (Global.GetTotalGoodsCountByID(client, luckyGoodsID) <= 0)
                        {
                            result = -20;
                        }
                        else
                        {
                            bool usedBinding     = false;
                            bool usedTimeLimited = false;
                            if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, luckyGoodsID, 1, false, out usedBinding, out usedTimeLimited, false))
                            {
                                result = -30;
                            }
                            else
                            {
                                int addLuckValue = 0;
                                for (int i = 0; i < allHorseLuckyGoodsIDs.Length; i++)
                                {
                                    if (allHorseLuckyGoodsIDs[i] == luckyGoodsID)
                                    {
                                        addLuckValue = allHorseLuckyGoodsIDsToLucky[i];
                                        break;
                                    }
                                }
                                addLuckValue = Global.GMax(0, addLuckValue);
                                Global.AddHorseFailedNum(horseData, addLuckValue);
                                Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);
                                Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "祝福丹");
                                result = addLuckValue;
                            }
                        }
                    }
                }
            }
            return(result);
        }
 public UpgradedHorse(String displayName, HorseData horseData)
 {
     this.displayName = displayName;
     this.horseData   = horseData;
 }
Beispiel #29
0
        public static int ProcessHorseUpgrade(GameClient client, int horseDbID, bool allowAutoBuy)
        {
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
            int       result;

            if (null == horseData)
            {
                result = -1;
            }
            else
            {
                SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);
                if (null == horseUpXmlNode)
                {
                    result = -35;
                }
                else
                {
                    int horseUpgradeGoodsID  = 0;
                    int horseUpgradeGoodsNum = 0;
                    Global.ParseHorseJinJieFu(horseData.HorseID, out horseUpgradeGoodsID, out horseUpgradeGoodsNum, horseUpXmlNode);
                    if (horseUpgradeGoodsID <= 0)
                    {
                        result = -20;
                    }
                    else if (horseData.HorseID >= Global.MaxHorseID)
                    {
                        result = -30;
                    }
                    else
                    {
                        int needYinLiang = Global.GMax(horseUpXmlNode.GetIntValue("UseYinLiang", -1), 0);
                        needYinLiang = Global.RecalcNeedYinLiang(needYinLiang);
                        if (client.ClientData.YinLiang < needYinLiang)
                        {
                            result = -60;
                        }
                        else
                        {
                            int needBuyGoodsNum = 0;
                            int needGoodsNum    = Global.GMax(horseUpgradeGoodsNum, 0);
                            int needSubGoodsNum = needGoodsNum;
                            if (Global.GetTotalGoodsCountByID(client, horseUpgradeGoodsID) < needGoodsNum)
                            {
                                if (!allowAutoBuy)
                                {
                                    return(-70);
                                }
                                needSubGoodsNum = Global.GetTotalGoodsCountByID(client, horseUpgradeGoodsID);
                                needBuyGoodsNum = needGoodsNum - needSubGoodsNum;
                            }
                            bool usedBinding     = false;
                            bool usedTimeLimited = false;
                            if (needSubGoodsNum > 0)
                            {
                                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, horseUpgradeGoodsID, needSubGoodsNum, false, out usedBinding, out usedTimeLimited, false))
                                {
                                    return(-70);
                                }
                            }
                            if (needBuyGoodsNum > 0)
                            {
                                int ret = Global.SubUserMoneyForGoods(client, horseUpgradeGoodsID, needBuyGoodsNum, "坐骑进阶");
                                if (ret <= 0)
                                {
                                    return(ret);
                                }
                            }
                            if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYinLiang, "坐骑进阶", false))
                            {
                                result = -60;
                            }
                            else
                            {
                                int    horseOne        = 110000 - horseUpXmlNode.GetIntValue("HorseOne", -1);
                                int    horseTwo        = 110000 - horseUpXmlNode.GetIntValue("HorseTwo", -1);
                                double horseThree      = horseUpXmlNode.GetDoubleValue("HorseThree");
                                int    jinJieFailedNum = Global.GetHorseFailedNum(horseData);
                                if (jinJieFailedNum < horseTwo)
                                {
                                    Global.AddHorseFailedNum(horseData, 1);
                                    Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);
                                    Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "失败");
                                    result = -1000;
                                }
                                else
                                {
                                    if (jinJieFailedNum < horseOne - 1)
                                    {
                                        int successRate = (int)(horseThree * 10000.0);
                                        int randNum     = Global.GetRandomNumber(1, 10001);
                                        if (client.ClientData.TempHorseUpLevelRate != 1)
                                        {
                                            successRate *= client.ClientData.TempHorseUpLevelRate;
                                            successRate  = Global.GMin(10000, successRate);
                                        }
                                        if (randNum > successRate)
                                        {
                                            Global.AddHorseFailedNum(horseData, 1);
                                            Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);
                                            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "失败");
                                            return(-1000);
                                        }
                                    }
                                    result = ProcessHorse.ProcessHorseUpgradeNow(client, horseDbID, horseData);
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #30
0
        /// <summary>
        /// 坐骑强化
        /// </summary>
        /// <param name="client"></param>
        /// <param name="horseDbID"></param>
        /// <param name="extPropIndex"></param>
        public static int ProcessHorseEnchance(GameClient client, int horseDbID, int extPropIndex, bool allowAutoBuy)
        {
            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(-1);
            }

            //判断要强化的属性是否超出了索引
            if (extPropIndex < 0 || extPropIndex >= (int)HorseExtIndexes.MaxVal)
            {
                return(-10);
            }

            //获取强化需要的道具的物品ID
            int EnchanceNeedGoodsID = (int)GameManager.systemParamsList.GetParamValueIntByName("HorseEnchancseGoodsID");

            if (EnchanceNeedGoodsID <= 0)
            {
                return(-20);
            }

            int[] horseExtNumIntArray  = Global.HorseExtStr2IntArray(horseData.PropsNum);
            int[] horseExtPropIntArray = Global.HorseExtStr2IntArray(horseData.PropsVal);
            int   horseExtNum          = Global.GetHorseExtFieldIntVal(horseExtNumIntArray, (HorseExtIndexes)extPropIndex);
            int   horseExtVal          = Global.GetHorseExtFieldIntVal(horseExtPropIntArray, (HorseExtIndexes)extPropIndex);
            //if (horseExtNum >= Global.MaxEnchanceLevel)
            //{
            //    return -30;
            //}

            //获取坐骑强到指定级别时,指定属性的配置xml节点
            SystemXmlItem systemHorseEnchance = Global.GetHorseEnchanceXmlNode(horseExtNum + 1, (HorseExtIndexes)extPropIndex);

            if (null == systemHorseEnchance)
            {
                return(-35);
            }

            //获取坐骑基础属性值
            int baseVal = Global.GetHorseBasePropVal(horseData.HorseID, (HorseExtIndexes)extPropIndex, null);

            //获取坐骑属性的上限值
            int propLimit = Global.GetHorsePropLimitVal(horseData.HorseID, (HorseExtIndexes)extPropIndex);

            //propLimit += baseVal;

            if ((baseVal + horseExtVal) >= propLimit)
            {
                return(-40);
            }

            //本次强化需要的银两
            int needYinLiang = Global.GMax(systemHorseEnchance.GetIntValue("UseMoney"), 0);

            if (client.ClientData.YinLiang < needYinLiang)
            {
                return(-60);
            }

            int needBuyGoodsNum = 0; //需要购买的
            int needSubGoodsNum = 0; //需要扣除的

            //本次强化需要的辅助物品的个数
            int needGoodsNum = Global.GMax(systemHorseEnchance.GetIntValue("HanTie"), 0);

            needSubGoodsNum = needGoodsNum;

            if (Global.GetTotalGoodsCountByID(client, EnchanceNeedGoodsID) < needGoodsNum)
            {
                if (allowAutoBuy)
                {
                    needSubGoodsNum = Global.GetTotalGoodsCountByID(client, EnchanceNeedGoodsID);
                    needBuyGoodsNum = needGoodsNum - needSubGoodsNum;
                }
                else
                {
                    return(-70);
                }
            }

            bool usedBinding     = false;
            bool usedTimeLimited = false;

            //自动扣除物品
            if (needSubGoodsNum > 0)
            {
                //扣除物品
                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                          Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, EnchanceNeedGoodsID, needSubGoodsNum, false, out usedBinding, out usedTimeLimited))
                {
                    return(-70);
                }
            }

            //自动扣除money
            if (needBuyGoodsNum > 0)
            {
                //自动扣除元宝购买
                int retAuto = Global.SubUserMoneyForGoods(client, EnchanceNeedGoodsID, needBuyGoodsNum, "坐骑强化");

                if (retAuto <= 0)
                {
                    return(retAuto);
                }
            }

            //扣除银两
            if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener,
                                                       Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYinLiang, "坐骑强化"))
            {
                return(-60);
            }

            int successRate = Global.GMax(systemHorseEnchance.GetIntValue("SucceedRate"), 0);
            int randNum     = Global.GetRandomNumber(0, 101);

            if (client.ClientData.TempHorseEnchanceRate != 1) //临时测试加成功率
            {
                successRate *= client.ClientData.TempHorseEnchanceRate;
                successRate  = Global.GMin(100, successRate);
            }

            if (randNum > successRate)
            {
                return(-1000);
            }

            int addPropValue = Global.GMax(systemHorseEnchance.GetIntValue("PropVal"), 0);

            //处理先前的坐骑
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                //减去buffer属性值
                //加载骑乘的属性
                /// 将坐骑的扩展属性加入Buffer中
                Global.UpdateHorseDataProps(client, false);
            }

            //进行坐骑属性的强化,并存入数据库中
            int ret = 0;

            if (Global.UpdateHorsePropsDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, (HorseExtIndexes)extPropIndex, addPropValue, 1) < 0)
            {
                ret = -2000;
            }

            //如果成功,并且坐骑处于骑乘状态
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                //减去buffer属性值
                //加载骑乘的属性
                /// 将坐骑的扩展属性加入Buffer中
                Global.UpdateHorseDataProps(client, true);

                if (0 == ret) //如果成功了, 否则没变化,不通知
                {
                    //计算坐骑的积分值
                    client.ClientData.RoleHorseJiFen = Global.CalcHorsePropsJiFen(horseData);

                    //通知客户端属性变化
                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);

                    // 总生命值和魔法值变化通知(同一个地图才需要通知)
                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                }
            }

            if (0 == ret) //如果成功了, 否则没变化,不通知
            {
                //判断坐骑的属性是否已经满了?
                if (Global.IsHorsePropsFull(horseData))
                {
                    //坐骑强化完毕
                    Global.BroadcastHorseEnchanceOk(client, horseData.HorseID);
                }
            }

            return(ret);
        }
Beispiel #31
0
        public static int ProcessHorseQuickAllEnchance(GameClient client, int horseDbID)
        {
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
            int       result;

            if (null == horseData)
            {
                result = -1;
            }
            else if (Global.IsHorsePropsFull(horseData))
            {
                result = -10;
            }
            else
            {
                int chaoJiLianGuGoodsID = (int)GameManager.systemParamsList.GetParamValueIntByName("ChaoJiLianGuGoodsID", -1);
                if (chaoJiLianGuGoodsID <= 0)
                {
                    result = -20;
                }
                else
                {
                    int needYinLiang = Global.QuickHorseExtPropNeedYinLiang;
                    if (client.ClientData.YinLiang < needYinLiang)
                    {
                        result = -30;
                    }
                    else if (Global.GetTotalGoodsCountByID(client, chaoJiLianGuGoodsID) < 1)
                    {
                        result = -40;
                    }
                    else
                    {
                        bool usedBinding     = false;
                        bool usedTimeLimited = false;
                        if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, chaoJiLianGuGoodsID, 1, false, out usedBinding, out usedTimeLimited, false))
                        {
                            result = -60;
                        }
                        else if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYinLiang, "坐骑快速全部属性强化", false))
                        {
                            result = -70;
                        }
                        else
                        {
                            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
                            {
                                Global.UpdateHorseDataProps(client, false);
                            }
                            for (int i = 0; i < 10; i++)
                            {
                                int[] horseExtNumIntArray  = Global.HorseExtStr2IntArray(horseData.PropsNum);
                                int[] horseExtPropIntArray = Global.HorseExtStr2IntArray(horseData.PropsVal);
                                int   horseExtNum          = Global.GetHorseExtFieldIntVal(horseExtNumIntArray, (HorseExtIndexes)i);
                                int   horseExtVal          = Global.GetHorseExtFieldIntVal(horseExtPropIntArray, (HorseExtIndexes)i);
                                int   baseVal   = Global.GetHorseBasePropVal(horseData.HorseID, (HorseExtIndexes)i, null);
                                int   propLimit = Global.GetHorsePropLimitVal(horseData.HorseID, (HorseExtIndexes)i);
                                if (baseVal + horseExtVal < propLimit)
                                {
                                    int maxEnchanceLevel = Global.GetHorseEnchanceNum(horseData.HorseID);
                                    int addNum           = maxEnchanceLevel - horseExtNum;
                                    int addPropValue     = propLimit - baseVal - horseExtVal;
                                    Global.UpdateHorsePropsDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, (HorseExtIndexes)i, addPropValue, addNum);
                                }
                            }
                            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
                            {
                                Global.UpdateHorseDataProps(client, true);
                                client.ClientData.RoleHorseJiFen = Global.CalcHorsePropsJiFen(horseData);
                                GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                            }
                            if (Global.IsHorsePropsFull(horseData))
                            {
                                Global.BroadcastHorseEnchanceOk(client, horseData.HorseID);
                            }
                            result = 0;
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #32
0
        /// <summary>
        /// 为指定的坐骑增加养成点(临时或者永久)
        /// </summary>
        /// <param name="client"></param>
        /// <param name="horseDbID"></param>
        /// <param name="luckyGoodsID"></param>
        /// <returns></returns>
        public static int ProcessAddHorseAwardLucky(GameClient client, int luckyValue, bool usedTimeLimited, string getType)
        {
            if (0 == luckyValue)
            {
                return(0);
            }

            int horseDbID = client.ClientData.HorseDbID;

            if (horseDbID <= 0)
            {
                return(-300);
            }

            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(-1);
            }

            SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);

            if (null == horseUpXmlNode)
            {
                return(-35);
            }

            int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint");

            //获取坐骑的失败积分
            int jinJieFailedNum = Global.GetHorseFailedNum(horseData);

            //如果已经是最高阶,则不需要再增加幸运点
            if (horseData.HorseID >= Global.MaxHorseID)
            {
                return(-10);
            }

            int addLuckValue = luckyValue;

            addLuckValue = Global.GMin(addLuckValue, horseBlessPoint - jinJieFailedNum);
            addLuckValue = Global.GMax(0, addLuckValue);

            if (!usedTimeLimited)
            {
                //记录失败次数
                Global.AddHorseFailedNum(horseData, addLuckValue);
            }
            else
            {
                Global.AddHorseTempJiFen(horseData, addLuckValue);
            }

            //记录失败次数
            Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);

            //写入角色进阶坐骑的行为日志
            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, getType);

            return(addLuckValue);
        }