Esempio n. 1
0
        public static bool MassHarvest(BaseObject[] plots)
        {
            Game.Requests.BatchRequest req = new Game.Requests.BatchRequest("laughy") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, Program.Instance.GameSession.ServerSession.Token, Program.Instance.GameSession.ServerSession.FlashRevision, Program.Instance.GameSession.ServerSession.FbId) };
            foreach ( PlotObject plot in plots )
                req.BatchedRequests.Add(new Game.Requests.HarvestPlotSubRequest(1, plot));
            Bot.Server.ServerSession.BlockingCallback result = Program.Instance.GameSession.ServerSession.MakeBlockingRequest(req);

            object[] dataArray;

            if (!Bot.Server.ServerSession.GetRequestData(result, out dataArray))
                return false;
            for (int x = 0; x < dataArray.Length; x++)
            {
                PlotObject curPlot = plots[x] as PlotObject;
                if (!curPlot.OnHarvestResult(req.BatchedRequests[x] as Game.Requests.HarvestPlotSubRequest, dataArray[x] as FluorineFx.ASObject))
                    return false;
            }

            return true;
        }
Esempio n. 2
0
        public static bool MassPlant(BaseObject[] plots, string seedName, bool usePicker = true)
        {
            Game.Requests.BatchRequest req = new Game.Requests.BatchRequest("laughy") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, Program.Instance.GameSession.ServerSession.Token, Program.Instance.GameSession.ServerSession.FlashRevision, Program.Instance.GameSession.ServerSession.FbId) };
            foreach (PlotObject plot in plots)
            {
                if (!usePicker)
                    req.BatchedRequests.Add(new Game.Requests.PlantPlotSubRequest(1, plot, seedName));
                else
                    req.BatchedRequests.Add(new Game.Requests.PlantPlotSubRequest(1, plot, Bot.Scripts.ScriptManager.Instance.Main.SeedPicker.PickSeed(plot)));
            }
            Bot.Server.ServerSession.BlockingCallback result = Program.Instance.GameSession.ServerSession.MakeBlockingRequest(req);
            object[] dataArray;
            if (!Bot.Server.ServerSession.GetRequestData(result, out dataArray))
                return false;

            for (int x = 0; x < dataArray.Length; x++)
            {
                PlotObject curPlot = plots[x] as PlotObject;
                FluorineFx.ASObject firstObject = dataArray[x] as FluorineFx.ASObject;
                if (!curPlot.OnPlantResult(req.BatchedRequests[x] as Game.Requests.PlantPlotSubRequest, firstObject))
                    return false;
            }
            return true;
        }
Esempio n. 3
0
        public override bool OnFarmWork(GameSession session)
        {
            if (!Program.Instance.Config.ReadCustomBool("neighborlynx", "active", false))
                return true;

            string[] rewardGiftTypes = new string[] {
                "CollectionsFriendReward",
                "DairyFarmFertilizerFriendReward",
                "EggFriendReward",
                "FlowerFriendReward",
                "HolidayTreeFriendReward",
                "HorseStableFriendReward",
                "lonelyAnimals",
                "StorageExpansionFriendReward",
                "ValentineFriendReward",
                "ValentineRedeemFriendReward"
               };
            string[] rewardCoinTypes = new string[] {
                "AchievementFriendReward",
                "CoinFriendReward",
                "FertilizeThankFriendReward",
                "MasteryFriendReward"
            };

            Dictionary<string, List<string>> links = new Dictionary<string, List<string>>();

            // if (!Program.Instance.Config.ReadCustomBool("neighborlinks", "active", false))
            //    return true;

            int x = 0;
            int y = 0;
            foreach (string info in Program.Instance.GameSession.Player.Neighbors)
            {
                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "NeighborLynx", "Visiting {0} of {1}", ++x, Program.Instance.GameSession.Player.Neighbors.Count);
                Game.Requests.BatchRequest req = new Game.Requests.BatchRequest("test") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, Program.Instance.GameSession.ServerSession.Token, Program.Instance.GameSession.ServerSession.FlashRevision, Program.Instance.GameSession.ServerSession.FbId) };
                Game.Requests.LoadWorldRequest loadWorld = new Game.Requests.LoadWorldRequest(1, info);
                req.BatchedRequests.Add(loadWorld);
                Server.ServerSession.BlockingCallback callback = Program.Instance.GameSession.ServerSession.MakeBlockingRequest(req);
                object[] data;
                if (callback.Success == false || !Server.ServerSession.GetRequestData(callback, out data))
                    return false;

                FluorineFx.ASObject dataObj = data[0] as FluorineFx.ASObject;
                dataObj = dataObj["data"] as FluorineFx.ASObject;
                FluorineFx.ASObject playerObj = dataObj["player"] as FluorineFx.ASObject;
                FluorineFx.ASObject friendRewards = playerObj["friendRewards"] as FluorineFx.ASObject;
                if (friendRewards != null)
                {
                    foreach (string key in friendRewards.Keys)
                    {
                        if (!rewardGiftTypes.Contains(key))
                            Console.WriteLine("found unknown: " + key);
                    }
                    foreach (string reward in rewardGiftTypes)
                    {
                        if (friendRewards.ContainsKey(reward))
                        {
                            FluorineFx.ASObject theobj = friendRewards[reward] as FluorineFx.ASObject;
                            foreach (string key in theobj.Keys)
                            {
                                FluorineFx.ASObject rewardData = theobj[key] as FluorineFx.ASObject;
                                FluorineFx.ASObject helpers = rewardData["helpers"] as FluorineFx.ASObject;

                                if (reward == "FlowerFriendReward" && helpers != null && helpers.Count >= ((int)rewardData["m_numItems"]))
                                    continue;
                                else if (rewardData.ContainsKey("helpers") && helpers != null && helpers.Count >= 10)
                                    continue;
                                if (reward == "EggFriendReward" && helpers != null && helpers.Count >= 3)
                                    continue;
                                if (reward == "ValentineRedeemFriendReward" && helpers != null && helpers.Count >= 1)
                                    continue;
                                if (helpers == null || !helpers.ContainsKey(Program.Instance.GameSession.ServerSession.FbId))
                                {
                                    if (_visitedLinks.ContainsKey(key))
                                        continue;
                                    _visitedLinks.Add(key, key);
                                    // we haven't helped.

                                    string like = string.Format("http://apps.facebook.com/onthefarm/reward.php?frHost={0}&frId={1}&frType={2}", info, key, reward);
                                    if (!links.ContainsKey(reward))
                                        links.Add(reward, new List<string>());
                                    links[reward].Add(like);
                                }
                                y++;

                            }
                        }
                    }
                }

            }
            Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "NeighborLynx", "{0} links generated.", y);
            y = 0;
            using (System.IO.TextWriter tw = new System.IO.StreamWriter(string.Format("{0}.links.html", Everworld.Utility.Time.UnixTime())))
            {
                foreach (string key in links.Keys)
                {
                    List<string> linkslist = links[key];
                    linkslist.Sort();
                    tw.WriteLine(key+"<br />");
                    foreach (string str in linkslist)
                        tw.WriteLine("<a href=\"" + str + "\">" + (y++) + "</a><br />");
                }
                tw.Flush();
                tw.Close();
            }

            return false;
        }
Esempio n. 4
0
        public virtual bool LoadWorld()
        {
            Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "GameSession", "Requesting world info.");
            Game.Requests.BatchRequest req = new Game.Requests.BatchRequest("laughy") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, _serverSession.Token, _serverSession.FlashRevision, _serverSession.FbId) };
            req.BatchedRequests.Add(new Game.Requests.InitUserSubRequest(1));
            Server.ServerSession.BlockingCallback result =_serverSession.MakeBlockingRequest(req);
            if (result.Success == false)
                return false;

            FluorineFx.ASObject res = result.Result.Result as FluorineFx.ASObject;
            if (res != null)
            {
                object[] dataArray = res["data"] as object[];

                FluorineFx.ASObject firstObject = dataArray[0] as FluorineFx.ASObject;
                double? serverTime = firstObject["serverTime"] as double?;

                FluorineFx.ASObject gameDataObject = firstObject["data"] as FluorineFx.ASObject;
                Game.Classes.InitUserResponseData initUserResponse = new Game.Classes.InitUserResponseData();
                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "GameSession", "Processing world info.");
                initUserResponse.FromAMF(gameDataObject);
                _world = initUserResponse.UserInfo.World;
                _player = initUserResponse.UserInfo.Player;
            }

            Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "GameSession", "World loaded.");
            return true;
        }
Esempio n. 5
0
        public override bool OnFarmWork(GameSession session)
        {
            try
            {
                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "Wither Hack", "Before active check");
                if (!Program.Instance.Config.ReadCustomBool("witherhack", "active", false))
                    return true;

                int posx = Program.Instance.Config.ReadCustomInt("witherhack", "witherx", 0);
                int posy = Program.Instance.Config.ReadCustomInt("witherhack", "withery", 0);

                List<Game.Classes.BaseObject> objlist = Program.Instance.GameSession.World.ObjectsArray.FindAll(
                    x => x is Game.Objects.PlotObject &&
                        (x.Position.X >= (posx * 4)) &&
                        (x.Position.X <= ((posx + 5) * 4)) &&
                        (x.Position.Y >= (posy * 4)) &&
                        (x.Position.Y <= ((posy + 5) * 4)));

                if (objlist.Count > 0)
                    Game.Objects.PlotObject.MassRemove(objlist.ToArray());
                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "Wither Hack", "After active check");

                // Run script constantly.
                ScriptManager.Instance.SetNextUpdate(DateTime.Now.AddSeconds(-5));

                Game.Requests.BatchRequest req = new Game.Requests.BatchRequest("test") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, Program.Instance.GameSession.ServerSession.Token, Program.Instance.GameSession.ServerSession.FlashRevision, Program.Instance.GameSession.ServerSession.FbId) };

                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "Wither Hack", "Cycle starting.");

                string seed = Scripts.ScriptManager.Instance.Main.SeedPicker.PickSeed(new Game.Objects.PlotObject()
                {
                    ClassName = "Plot",
                    Giftable = false,
                    GiftSenderId = null,
                    HasGiftRemaining = false,
                    Id = -1,
                    IsBigPlot = false,
                    IsJumbo = false,
                    IsProduceItem = false,
                    ItemName = "",
                    PlantTime = 0,

                    Position = new Game.Classes.ObjectPosition()
                    {
                        X = Program.Instance.Config.ReadCustomInt("witherhack", "witherx", 0) * 4,
                        Y = Program.Instance.Config.ReadCustomInt("witherhack", "withery", 0) * 4,
                        Z = 0
                    },
                    State = "plowed",
                    UsesAltGraphic = false

                }
                );

                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "Wither Hack", "Withering {0}.", seed);

                for (int x = 0; x < 5; x++)
                {
                    for (int y = 0; y < 4; y++)
                    {
                        req.BatchedRequests.Add(
                            new Game.Requests.WitherHackDecorationRequest(1,
                                                                    session.GetNextTempId(),
                                                                    (x + Program.Instance.Config.ReadCustomInt("witherhack", "witherx", 0)) * 4,
                                                                    (y + Program.Instance.Config.ReadCustomInt("witherhack", "withery", 0)) * 4,
                                                                    seed));
                    }
                }
                Bot.Server.ServerSession.BlockingCallback result = session.ServerSession.MakeBlockingRequest(req);
                if (result.Success == false)
                    return false;

                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "Wither Hack", "Withered crops placed.");

                FluorineFx.ASObject resultObj = result.Result.Result as FluorineFx.ASObject;
                object[] resultData = resultObj["data"] as object[];
                Dictionary<string, object> dataDictionary = null;
                req = new Game.Requests.BatchRequest("test") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, Program.Instance.GameSession.ServerSession.Token, Program.Instance.GameSession.ServerSession.FlashRevision, Program.Instance.GameSession.ServerSession.FbId) };
                for (int x = 0, startIndex = 0; x < 5; x++)
                {
                    for (int y = 0; y < 4; y++)
                    {
                        dataDictionary = ((resultData[startIndex++] as FluorineFx.ASObject)["data"] as Dictionary<string, object>);
                        try
                        {
                            req.BatchedRequests.Add(new Game.Requests.WitherHackHarvestRequest(1,
                                (int)dataDictionary["id"],
                                (x + Program.Instance.Config.ReadCustomInt("witherhack", "witherx", 0)) * 4,
                                (y + Program.Instance.Config.ReadCustomInt("witherhack", "withery", 0)) * 4,
                                seed));
                        }
                        catch (Exception ex)
                        {
                            ex = ex;
                        }
                    }
                }
                if (session.ServerSession.MakeBlockingRequest(req).Success == false)
                    return false;

                string seedName = (req.BatchedRequests[0] as Game.Requests.WitherHackHarvestRequest).PlantRequest;
                if (Game.Settings.SeedSetting.SeedSettings[seedName].Mastery == true)
                {
                    if (!Program.Instance.GameSession.Player.MasteryCounters.ContainsKey(seedName))
                        Program.Instance.GameSession.Player.MasteryCounters.Add(seedName, 0);

                    Program.Instance.GameSession.Player.MasteryCounters[seedName] = Program.Instance.GameSession.Player.MasteryCounters[seedName] + req.BatchedRequests.Count; // one more mastery point
                }

                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "Wither Hack", "Withered crops harvested.");
                req = new Game.Requests.BatchRequest("test") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, Program.Instance.GameSession.ServerSession.Token, Program.Instance.GameSession.ServerSession.FlashRevision, Program.Instance.GameSession.ServerSession.FbId) };
                for (int x = 0, startIndex = 0; x < 5; x++)
                {
                    for (int y = 0; y < 4; y++)
                    {
                        dataDictionary = ((resultData[startIndex++] as FluorineFx.ASObject)["data"] as Dictionary<string, object>);
                        req.BatchedRequests.Add(new Game.Requests.WitherHackClearRequest(1,
                            (int)dataDictionary["id"],
                             (x + Program.Instance.Config.ReadCustomInt("witherhack", "witherx", 0)) * 4,
                             (y + Program.Instance.Config.ReadCustomInt("witherhack", "withery", 0)) * 4,
                           seed));
                    }
                }
                if (session.ServerSession.MakeBlockingRequest(req).Success == false)
                    return false;
                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "Wither Hack", "Withered plots removed.");
                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "Wither Hack", "Cycle complete.");
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace + "\n\nError in witherhack " + ex.Message);
                return false;
            }
        }
Esempio n. 6
0
        public virtual bool Plow()
        {
            Game.Requests.BatchRequest req = new Game.Requests.BatchRequest("laughy") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, Program.Instance.GameSession.ServerSession.Token, Program.Instance.GameSession.ServerSession.FlashRevision, Program.Instance.GameSession.ServerSession.FbId) };
            req.BatchedRequests.Add(new Game.Requests.PlowPlotSubRequest(1, this));
            Bot.Server.ServerSession.BlockingCallback result = Program.Instance.GameSession.ServerSession.MakeBlockingRequest(req);
            object[] dataArray;

            if (!Bot.Server.ServerSession.GetRequestData(result, out dataArray))
                return false;

            if (!OnPlowResult(req.BatchedRequests[0] as Game.Requests.PlowPlotSubRequest, dataArray[0] as FluorineFx.ASObject))
                return false;
            return true;
        }