public QuestPlugin(HzAccount account) : base(account) { //ActiveWorkerTimer = new Timer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, ActiveWorkerTimer_TickAsync, Application.Current.Dispatcher); //Quest Commands StartBestQuest = new AsyncRelayCommand( async() => await this.StartQuestAsync(Account.Data.BestQuest), () => Account.ActiveWorker == null && Account.IsLogined); StartQuest = new AsyncRelayCommand <Quest>( async quest => await this.StartQuestAsync(quest), quest => Account.ActiveWorker == null && Account.IsLogined && quest?.energy_cost <= Account.Character?.quest_energy); ClaimWorkerReward = new AsyncRelayCommand( async() => await this.ClaimWorkerRewardAsync(Account.ActiveWorker.WorkerType), () => Account.ActiveWorker?.status == WorkStatus.Finished); //Buy Quest Energy Commands ShowBuyQuestEnergyWindow = new RelayCommand( () => new ChooseCurrencyWindow(Account).ShowDialog(), () => Account.Character?.quest_energy < 50 && Account.Character?.quest_energy_refill_amount_today < 200 && Account.Character.game_currency >= Account.Character?.CurrentGameCurrencyCostEnergyRefill); BuyEnergyFromGold = new AsyncRelayCommand( async() => await this.BuyQuestEnergyAsync(false), CanBuyEnergyForGold); BuyEnergyFromPremium = new AsyncRelayCommand( async() => await this.BuyQuestEnergyAsync(true), () => Account.Character?.quest_energy < 50 && Account.ActiveWorker == null && Account.User?.premium_currency >= 2); }
public static bool HaveEnoughRessources(this IHideOutCost roomLevel, HzAccount account) { //var level = roomLevel.Levels.FirstOrDefault(); return(roomLevel != null && roomLevel.price_glue <= account.Data.hideout.current_resource_glue && roomLevel.price_stone <= account.Data.hideout.current_resource_stone && roomLevel.GetReducedGameCurrencyValue() <= account.Character.game_currency); }
public HzBot(HzAccount account) { //Initialize ActiveWorkerTimer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, ActiveWorkerTimer_TickAsync, Application.Current.Dispatcher); Account = account; Account.OnDataChanged += OnDataChanged; }
/// <summary>Removes the account.</summary> /// <param name="account">The account.</param> public static void RemoveAccount(HzAccount account) { if (account != null && RemoveAccountCommand.CanExecute(account)) { account.IsLogined = false; SynContext.Send((o) => Accounts.Remove(account), null); } }
public HideOutPlugin(HzAccount account) : base(account) { BuildRoomCommand = new RelayCommand(() => System.Console.WriteLine("")); UnlockSlotCommand = new AsyncRelayCommand <HideOutRoomSlot>( slot => this.UnlockHideoutRoomSlotAsync(slot), slot => slot.State == HideOutRoomSlotState.CanUnlock && Account.Data.hideout.ActiveActivity == null && slot.SlotUnlockCost.HaveEnoughRessources(Account)); }
public CharacterStatPlugin(HzAccount account) : base(account) { ImproveCharacterStatCommand = new AsyncRelayCommand <HzCharacterStat>( async stat => await this.ImproveCharacterStatAsync(stat.StatType), stat => Account.Character?.HzStats.CanImproveCharacterStat(stat) ?? false); TrainCharacterStatCommand = new AsyncRelayCommand <HzCharacterStat>( async(stat) => await this.StartTrainingAsync(stat.StatType), (stat) => Account.ActiveWorker == null && (Account.Character?.HzStats.CanTrain(stat) ?? false)); }
public AccountPlugin(HzAccount account) : base(account) { //Command for Login into Account LoginCommand = new AsyncRelayCommand( async() => Account.IsLogined = string.IsNullOrWhiteSpace(await this.LoginRequestAsync()), () => !Account.IsLogined); UpdateSessionCommand = new AsyncRelayCommand(async() => await this.updateGameSessionAsync(), () => Account.IsLogined); }
public DuelPlugin(HzAccount account) : base(account) { StartBestDuel = new AsyncRelayCommand( async() => await this.StartDuellAsync(GegnerID), () => Account.IsLogined); CheckForDuelComplete = new AsyncRelayCommand( async() => await this.CheckForDuelCompleteAsync()); claimDuelReward = new AsyncRelayCommand( async() => await this.ClaimDuelRewardsAsync()); }
public HzPlugins(HzAccount account) { hzAccount = account; DefaultContext = SynchronizationContext.Current; Log = RegisterPlugin(new LogPlugin(hzAccount)); Account = RegisterPlugin(new AccountPlugin(hzAccount)); Worldboss = RegisterPlugin(new WorldbossPlugin(hzAccount)); CharacterStat = RegisterPlugin(new CharacterStatPlugin(hzAccount)); Quest = RegisterPlugin(new QuestPlugin(hzAccount)); Duel = RegisterPlugin(new DuelPlugin(hzAccount)); HideOut = RegisterPlugin(new HideOutPlugin(hzAccount)); Item = RegisterPlugin(new ItemPlugin(hzAccount)); PrimaryWorker = RegisterPlugin(new PrimaryWorkerPlugin(hzAccount)); Booster = RegisterPlugin(new BoosterPlugin(hzAccount)); Goal = RegisterPlugin(new GoalPlugin(hzAccount)); voucher = RegisterPlugin(new VoucherPlugin(hzAccount)); }
/// <summary>Gets the default HttpRequest content.</summary> /// <param name="action">The action.</param> /// <param name="account">The account.</param> /// <returns></returns> public static PostContent DefaultRequestContent(this HzAccount account, string action) { var UserId = account.User?.id ?? 0; var UserSessionId = account.User?.session_id ?? "0"; var content = new PostContent(); content.Account = account; content.Content = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("device_type", "web"), new KeyValuePair <string, string>("client_version", $"flash_{account.Config.FlashVersion}"), new KeyValuePair <string, string>("user_id", UserId.ToString()), new KeyValuePair <string, string>("user_session_id", UserSessionId), new KeyValuePair <string, string>("auth", HzConstants.MD5Hash(action, UserId.ToString())), new KeyValuePair <string, string>("action", action) }; return(content); }
public ItemPlugin(HzAccount account) : base(account) { EquipItemCommand = new AsyncRelayCommand <Item>(async item => await EquipItemAsync(item)); UnEquipItemCommand = new AsyncRelayCommand <Item>(async item => await UnEquipItemAsync(item), item => Account.Data.HzInventory.FreeBagSpace > 0); SellItemCommand = new AsyncRelayCommand <Item>(async item => await this.SellInventoryItemAsync(item.id)); }
public LogPlugin(HzAccount account) : base(account) { Context = System.Threading.SynchronizationContext.Current; }
public PrimaryWorkerTimer(HzAccount account) : base(account) { workerTimer = new Timer(onTimerTick, null, Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan); Account.OnDataChanged += Account_OnDataChanged; UIContext = System.Threading.SynchronizationContext.Current; }
private protected HzPluginBase(HzAccount account) : base(account) { }
public static IEnumerable <CHideOutRoom> HaveEnoughRessources(this IEnumerable <CHideOutRoom> rooms, HzAccount account) { foreach (var room in rooms) { if (room.Levels.FirstOrDefault().HaveEnoughRessources(account)) { yield return(room); } } }
public PrimaryWorkerPlugin(HzAccount account) : base(account) { Task.Run(Timer); //timer = new Timer(Timer, null, TimeSpan.FromSeconds(1), Timeout.InfiniteTimeSpan); }
/// <summary>Merges the new data into the Accout</summary> /// <param name="jobj">The new JObject to merge.</param> /// <param name="account">The account.</param> public static void MergeNewData(this HzAccount account, JObject jobj) { account.ServerTimeOffset = jobj["data"]["server_time"].Value <long>() - DateTimeOffset.Now.ToUnixTimeSeconds(); var updateQuest = jobj.SelectToken("data.quest"); if (updateQuest != null) { var questToUpdate = account.JsonData["data"]?["quests"]?.OfType <JContainer>().FirstOrDefault(quest => quest["id"]?.Value <int>() == updateQuest["id"]?.Value <int>()); if (questToUpdate != null) { questToUpdate.Merge(updateQuest); } } if (jobj.SelectToken("data.quests")?.HasValues ?? false) { var quests = account.JsonData.Descendants().OfType <JProperty>().FirstOrDefault(prop => prop.Name == "quests"); if (quests != null) { quests.Remove(); } } if (jobj.SelectToken("data.opponents")?.HasValues ?? false) { var opponents = account.JsonData.Descendants().OfType <JProperty>().FirstOrDefault(prop => prop.Name == "opponents"); if (opponents != null) { opponents.Remove(); } } var updateRoom = jobj.SelectToken("data.hideout_room"); if (updateRoom != null) { var roomToUpdate = account.JsonData["data"]?["hideout_rooms"]?.OfType <JContainer>().FirstOrDefault(room => room["id"]?.Value <int>() == updateRoom["id"]?.Value <int>()); if (roomToUpdate != null) { roomToUpdate.Merge(updateRoom); } else { var data = account.JsonData["data"]; if (data != null) { var rooms = data["hideout_rooms"] as JContainer; if (rooms == null) { (data as JObject).Add(new JProperty("hideout_rooms")); } } var container = account.JsonData["data"]?["hideout_rooms"] as JContainer; container.Add(updateRoom); //account.JsonData["data"]?["hideout_rooms"]?.OfType<JContainer>().a } } if (jobj.SelectToken("data.hideout_rooms")?.HasValues ?? false) { var rooms = jobj.SelectToken("data.hideout_rooms").OfType <JContainer>().ToList(); foreach (var item in rooms) { var roomToUpdate = account.JsonData["data"]?["hideout_rooms"]?.OfType <JContainer>().FirstOrDefault(room => room["id"]?.Value <int>() == item["id"]?.Value <int>()); if (roomToUpdate != null) { roomToUpdate.Merge(item); item.Remove(); } } //var hideoutRooms = jobj.Descendants().OfType<JProperty>().FirstOrDefault(prop => prop.Name == "hideout_rooms"); //if (hideoutRooms != null) //{ // hideoutRooms.Remove(); //} } var settings = new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Union }; account.JsonData.Merge(jobj, settings); account.MainData = account.JsonData.ToObject <JsonRoot>(); }
public WorldbossPlugin(HzAccount account) : base(account) { StartAttackCommand = new AsyncRelayCommand <WorldbossEvent>(async e => await this.StartWorldbossAttackAsync(e.id), e => Account.ActiveWorker == null && e.status == WorldbossEventStatus.Started); }
public ChooseCurrencyWindow(HzAccount account) { InitializeComponent(); this.account = account; this.DataContext = null; }
public VoucherPlugin(HzAccount account) : base(account) { }
public GoalPlugin(HzAccount account) : base(account) { }
public BoosterPlugin(HzAccount account) : base(account) { BuyBoosterCommand = new AsyncRelayCommand <Booster>( async(booster) => await this.BuyBoosterAsync(booster), CanBuyBooster); }
/// <summary>Adds the account.</summary> /// <param name="account">The account.</param> public static void AddAccount(HzAccount account) { SynContext.Send((o) => Accounts.Add(account), null); }
public HzServiceBase(HzAccount account) { Account = account; }