private void CheckShards(LogicManager logic) { DateTime date = DateTime.Now; Dictionary <ShardType, Shard> shards = logic.Memory.PlayerShards(); foreach (KeyValuePair <ShardType, Shard> pair in shards) { ShardType key = pair.Key; Shard state = pair.Value; Shard oldState; if (currentShards.TryGetValue(key, out oldState)) { byte value = state.Gained; byte oldValue = oldState.Gained; int valueLevel = state.Level; int oldValueLevel = oldState.Level; if (value != oldValue || valueLevel != oldValueLevel) { AddEntryUnlocked(new ValueLogEntry(date, LogObject.Abilities, oldState, state)); currentShards[key] = state; } } else { currentShards[key] = state; } } }
private void OnShardUse(ShardType shartType) { if (shartType == ShardType.small) { float newMeter = lightMeter.MeterValue + 25f; lightMeter.UseMeter(newMeter); CheckForPain(10); fatigueMeter.UseMeter(10); } else if (shartType == ShardType.medium) { float newMeter = lightMeter.MeterValue + 50f; lightMeter.UseMeter(newMeter); CheckForPain(20); fatigueMeter.UseMeter(20); } else if (shartType == ShardType.large) { float newMeter = lightMeter.MeterValue + 100f; lightMeter.UseMeter(newMeter); CheckForPain(30); fatigueMeter.UseMeter(30); } }
private ShardInfo GetShardInfo(ShardType shardType, CookieContainer cookie) { Account.CheckAuth(); var uri = new Uri(string.Format("{0}/api/v2/dispatcher?{2}={1}", CloudDomain, Account.AuthToken, "token")); var request = (HttpWebRequest)WebRequest.Create(uri.OriginalString); request.CookieContainer = Account.Cookies; request.Method = "GET"; request.ContentType = DefaultRequestType; request.Accept = "application/json"; request.UserAgent = UserAgent; using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode == HttpStatusCode.OK) { cookie = request.CookieContainer; var responseText = ReadResponseAsText(response); var shardTypeDescription = shardType.GetType().GetField(shardType.ToString()).GetCustomAttribute <DescriptionAttribute>(false).Description; var shardResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <ShardResponse>(responseText); var shardElement = shardResponse.body[shardTypeDescription][0]; return(new ShardInfo() { Type = shardType, Url = shardElement.url, Count = int.Parse(shardElement.count) }); } else { throw new Exception($"{response.StatusCode}: {response.StatusDescription}"); } } }
/// <summary> /// Get shard info that to do post get request. Can be use for anonymous user. /// </summary> /// <param name="shardType">Shard type as numeric type.</param> /// <param name="useAnonymousUser">To get anonymous user.</param> /// <param name="cookie">Generated cookie.</param> /// <returns>Shard info.</returns> private ShardInfo GetShardInfo(ShardType shardType, bool useAnonymousUser, out CookieContainer cookie) { this.CheckAuth(); var uri = new Uri(string.Format("{0}/api/v2/dispatcher?{2}={1}", ConstSettings.CloudDomain, !useAnonymousUser ? this.Account.AuthToken : 2.ToString(), !useAnonymousUser ? "token" : "api")); var request = (HttpWebRequest)WebRequest.Create(uri.OriginalString); request.Proxy = this.Account.Proxy; request.CookieContainer = !useAnonymousUser ? Account.Cookies : new CookieContainer(); request.Method = "GET"; request.ContentType = ConstSettings.DefaultRequestType; request.Accept = "application/json"; request.UserAgent = ConstSettings.UserAgent; using (var response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode == HttpStatusCode.OK) { cookie = request.CookieContainer; return((ShardInfo)JsonParser.Parse(this.ReadResponseAsText(response), PObject.Shard, shardType.GetEnumDescription())); } else { throw new Exception(); } } }
//public HttpWebRequest DownloadRequest(long instart, long inend, File file, ShardInfo shard) //{ // string downloadkey = string.Empty; // if (shard.Type == ShardType.WeblinkGet) // downloadkey = Authent.DownloadToken; // string url = shard.Type == ShardType.Get // ? $"{shard.Url}{Uri.EscapeDataString(file.FullPath)}" // : $"{shard.Url}{new Uri(ConstSettings.PublishFileLink + file.PublicLink).PathAndQuery.Remove(0, "/public".Length)}?key={downloadkey}"; // var request = (HttpWebRequest)WebRequest.Create(url); // request.Headers.Add("Accept-Ranges", "bytes"); // request.AddRange(instart, inend); // request.Proxy = HttpSettings.Proxy; // request.CookieContainer = Authent.Cookies; // request.Method = "GET"; // request.ContentType = MediaTypeNames.Application.Octet; // request.Accept = "*/*"; // request.UserAgent = HttpSettings.UserAgent; // request.AllowReadStreamBuffering = false; // request.Timeout = 15 * 1000; // return request; //} //public void BanShardInfo(ShardInfo banShard) //{ // if (!_bannedShards.Value.Any(bsh => bsh.Type == banShard.Type && bsh.Url == banShard.Url)) // { // Logger.Warn($"Shard {banShard.Url} temporarily banned"); // _bannedShards.Value.Add(banShard); // } //} /// <summary> /// Get shard info that to do post get request. Can be use for anonymous user. /// </summary> /// <param name="shardType">Shard type as numeric type.</param> /// <returns>Shard info.</returns> public override async Task <ShardInfo> GetShardInfo(ShardType shardType) { bool refreshed = false; for (int i = 0; i < 10; i++) { Thread.Sleep(80 * i); var ishards = await Task.Run(() => _cachedShards.Value); var ishard = ishards[shardType]; var banned = _bannedShards.Value; if (banned.All(bsh => bsh.Url != ishard.Url)) { if (refreshed) { Authent.ExpireDownloadToken(); } return(ishard); } _cachedShards.Expire(); refreshed = true; } Logger.Error("Cannot get working shard."); var shards = await Task.Run(() => _cachedShards.Value); var shard = shards[shardType]; return(shard); }
/// <summary> /// Get shard info that to do post get request. Can be use for anonymous user. /// </summary> /// <param name="shardType">Shard type as numeric type.</param> /// <returns>Shard info.</returns> public async Task <ShardInfo> GetShardInfo(ShardType shardType) { var shards = await Task.Run(() => _cachedShards.Value); var shard = shards[shardType]; return(shard); }
public static Sellable TwillenShard(ShardType shard) { UberId fakeId = new UberId((int)FakeUberGroups.TWILLEN_SHARD, (int)shard); if (pickupMap.TryGetValue(fakeId, out Pickup p) && p is Sellable) { return(p as Sellable); } Randomizer.Log($"Couldn't find a valid Sellable for {shard}..."); return(new Resource(ResourceType.Energy)); }
public override Task <ShardInfo> GetShardInfo(ShardType shardType) { //TODO: must hide shard functionality into repo after DownloadStream and UploadStream refact var shi = new ShardInfo { Url = _metaServer.Value.Url, Type = shardType }; return(Task.FromResult(shi)); }
public static void TwillenBuyShard(ShardType slot) { Sellable item = SeedController.TwillenShard(slot); if (SaveController.Data.TwillenSold.Contains(slot)) { Randomizer.Log($"TBS: not enough money or slot already sold "); return; } SaveController.Data.TwillenSold.Add(slot); item.Grant(); return; }
public void OnItemPicked(ShardType type) { if (type == ShardType.small) { items[0].PickItem(); } else if (type == ShardType.medium) { items[1].PickItem(); } else if (type == ShardType.large) { items[2].PickItem(); } }
public async Task <ShardEntity> Create(string address, int port, ShardType type, ShardFlags flags) { if (IsExists) { throw new ShardExistsException($"shard {this.GetPrimaryKeyString()} already exists; cannot create shard"); } State.Name = this.GetPrimaryKeyString(); State.Address = address ?? throw new ArgumentNullException(nameof(address)); State.Port = port; State.ShardType = type; State.ShardFlags = flags; State.Enabled = true; await WriteStateAsync(); // orleans will safe-copy this automatically return(State); }
public bool HasShard(ShardType type, int level) { //PlayerUberStateGroup.Instance.PlayerUberState.m_state.Shards.m_shardsList IntPtr shards = PlayerUberStateGroup.Read <IntPtr>(Program, 0xb8, 0x0, 0x18, 0x30, 0x20, 0x18); //.Count int count = Program.Read <int>(shards, 0x18); //.Items shards = Program.Read <IntPtr>(shards, 0x10); byte[] data = Program.Read(shards + 0x20, count * 0x8); for (int i = 0; i < count; i++) { //.Items[i] Shard shard = Program.Read <Shard>((IntPtr)BitConverter.ToUInt64(data, i * 0x8), 0x10); if (shard.Type == type) { return(shard.Gained == 1 && (level == 0 || shard.Level == level)); } } return(false); }
public override void ExecuteCommand(AuthServer server, string[] arguments) { if (arguments.Length < 5) { log.ErrorFormat("{0} requires 4 arguments", Name); } else { string name = arguments[1]; string address = arguments[2]; int port = int.Parse(arguments[3]); string type = arguments[4]; log.InfoFormat("creating new shard '{0}'", name); if (server.AuthDB.ExecuteQuery("select 1 from shard where name = ?", name, reader => { if (reader.Read()) { log.ErrorFormat("cannot create shard '{0}': a shard with this name already exists", name); return(false); } return(true); })) { // they should really add a type param overload of this method ShardType typeOrdinal = (ShardType)Enum.Parse(typeof(ShardType), type, true); int result = server.AuthDB.ExecuteNonQuery("insert into shard (name, address, port, type) values (?, ?, ?, ?)", new object[] { name, address, port, (byte)typeOrdinal }); if (result == 1) { log.InfoFormat("successfully created shard '{0}'", name); } else { log.ErrorFormat("failed to create account '{0}'. expected 1 update, got {1}", name, result); } } } }
public void SetShard(ShardType type, bool setTo = true) { //PlayerUberStateGroup.Instance.PlayerUberState.m_state.Shards.m_shardsList IntPtr shards = (IntPtr)PlayerUberStateGroup.Read <ulong>(Program, 0xb8, 0x0, 0x18, 0x30, 0x20, 0x18); //.Count int count = Program.Read <int>(shards, 0x18); //.Items shards = (IntPtr)Program.Read <ulong>(shards, 0x10); byte[] data = Program.Read(shards + 0x20, count * 0x8); for (int i = 0; i < count; i++) { //.Items[i] Shard shard = Program.Read <Shard>((IntPtr)BitConverter.ToUInt64(data, i * 0x8), 0x10); if (shard.Type == type) { shard.Gained = (byte)(setTo ? 1 : 0); // System.IO.File.AppendAllText("C:\\moon\\cs_log.txt", "Setting shard: " + shard.ToString() + "\n"); Program.Write((IntPtr)BitConverter.ToUInt64(data, i * 0x8), shard.ToBytes(), 0x10); return; } } }
public static bool TwillenBoughtShard(ShardType shard) { return(SaveController.Data.TwillenSold.Contains(shard)); }
/// <summary> /// Get shard info that to do post get request. /// </summary> /// <param name="shardType">Shard type as numeric type.</param> /// <returns>Shard info.</returns> private ShardInfo GetShardInfo(ShardType shardType) { CookieContainer cookie = null; return(this.GetShardInfo(shardType, false, out cookie)); }
public static string ame(ShardType st) { return(mapping.ContainsKey(st) ? mapping[st] : $"Unknown Shard {st}"); }
// Methods public bool Satisfies(ShardType shard) => default;
public extern static void set_shard(ShardType type, bool value);
public ShadowlordShard(ShardType shardType, int quantity, string longName, string equipMessage) : base(quantity, longName, longName, SHARD_SPRITE) { Debug.WriteLine("Shard: " + shardType.ToString()); Shard = shardType; EquipMessage = equipMessage; }
private void BuildRealmListPacket(AuthSession session, ByteBuffer packet) { int shardCount = session.Server.AuthDB.ExecuteQuery("select count(0) from shard where enabled = true", result => { if (result.Read()) { return(result.GetInt32(0)); } else { log.Error("got no results when querying for count on shard table"); return(0); } }); if (shardCount > byte.MaxValue) { log.WarnFormat("shard count {0} is being truncated to maximum client allowed value of {1}", shardCount, byte.MaxValue); shardCount = byte.MaxValue; } packet.Append(0); packet.Append((byte)shardCount); session.Server.AuthDB.ExecuteQuery("select name, address, port, recommended, type, last_ping from shard where enabled = true limit ?", byte.MaxValue, result => { while (result.Read()) { string name = result.GetString(0); string address = result.GetString(1) + ':' + result.GetInt32(2); DateTime lastPing = result.GetDateTime(5); ShardType type = (ShardType)result.GetByte(4); ShardFlags flags = ShardFlags.None; byte characterCount = 0; float population = 0.0f; byte category = 0; TimeSpan timeSinceLastPing = DateTime.Now - lastPing; if (timeSinceLastPing > new TimeSpan(0, 0, 0, 0, session.Server.AppConfig.ShardOfflineTimeoutMilliseconds)) { flags |= ShardFlags.Offline; } if (result.GetBoolean(3)) { flags |= ShardFlags.Recommended; } packet.Append((int)type); packet.Append((byte)flags); packet.Append(name); packet.Append(address); packet.Append(population); packet.Append(characterCount); packet.Append(category); packet.Append((byte)0); } return(true); }); packet.Append((short)2); }
private void CheckSplit(Split split, bool updateValues) { GameState state = Memory.GameState(); ShouldSplit = false; Paused = Memory.IsLoadingGame(state); if (split.Type == SplitType.GameStart) { Screen screen = Memory.TitleScreen(); int difficulty = Memory.Difficulty(); bool isStarted = difficulty != 4 && lastIntValue == 4 && screen == Screen.ProfileSelected; if (screen == Screen.ProfileSelected && lastScreen == Screen.SaveSlots) { Memory.SetDifficulty(4); } ShouldSplit = !lastBoolValue && isStarted; lastBoolValue = isStarted; lastIntValue = difficulty; lastScreen = screen; } else { if (!updateValues && ((state != GameState.Game && split.Type != SplitType.Hitbox) || Memory.Dead() || (Paused && state != GameState.Game))) { return; } switch (split.Type) { case SplitType.ManualSplit: break; case SplitType.Ability: SplitAbility ability = Utility.GetEnumValue <SplitAbility>(split.Value); if (ability == SplitAbility.FastTravel) { CheckUberIntValue(UberStateDefaults.fastTravel, 1); } else { CheckAbility(Utility.GetEnumValue <AbilityType>(split.Value)); } break; case SplitType.Shard: ShardType shardType = ShardType.Overcharge; bool hasShard = false; if (Enum.TryParse <ShardType>(split.Value, out shardType)) { hasShard = Memory.HasShard(shardType, 0); } else if (Enum.TryParse <ShardType>(split.Value.Substring(0, split.Value.Length - 1), out shardType)) { hasShard = Memory.HasShard(shardType, int.Parse(split.Value.Substring(split.Value.Length - 1))); } ShouldSplit = !lastBoolValue && hasShard; lastBoolValue = hasShard; break; case SplitType.AreaEnter: CheckArea(split, true); break; case SplitType.AreaLeave: CheckArea(split, false); break; case SplitType.WorldEvent: CheckWorldEvent(split); break; case SplitType.Wisp: CheckWisp(split); break; case SplitType.Boss: CheckBoss(split); break; case SplitType.Map: CheckMap(split); break; case SplitType.SpiritTrial: CheckSpiritTrial(split); break; case SplitType.Teleporter: CheckTeleporter(split); break; case SplitType.Hitbox: Vector4 hitbox = new Vector4(split.Value); CheckHitbox(hitbox); break; case SplitType.UberState: CheckBoolUberState(split); break; case SplitType.GameEnd: CheckHitbox(new Vector4("-4628.05,-6756,10,10")); break; case SplitType.Seed: CheckSeed(split); break; case SplitType.CreepHeart: Memory.UpdateUberState(UberStateDefaults.vineAClear); Memory.UpdateUberState(UberStateDefaults.vineBClear); Memory.UpdateUberState(UberStateDefaults.vineCClear); Memory.UpdateUberState(UberStateDefaults.vineDClear); Memory.UpdateUberState(UberStateDefaults.vineEClear); Memory.UpdateUberState(UberStateDefaults.vineFClear); Memory.UpdateUberState(UberStateDefaults.vineGClear); Memory.UpdateUberState(UberStateDefaults.vineHClear); int creepCount = UberStateDefaults.vineAClear.Value.Int + UberStateDefaults.vineBClear.Value.Int; creepCount += UberStateDefaults.vineCClear.Value.Int + UberStateDefaults.vineDClear.Value.Int; creepCount += UberStateDefaults.vineEClear.Value.Int + UberStateDefaults.vineFClear.Value.Int; creepCount += UberStateDefaults.vineGClear.Value.Int + UberStateDefaults.vineHClear.Value.Int; int splitCreeps = -1; int.TryParse(split.Value, out splitCreeps); ShouldSplit = lastIntValue != creepCount && creepCount == splitCreeps; lastIntValue = creepCount; break; case SplitType.Keystone: int keystones = Memory.Keystones(); int splitKeystones = -1; int.TryParse(split.Value, out splitKeystones); ShouldSplit = lastIntValue != keystones && keystones == splitKeystones; lastIntValue = keystones; break; case SplitType.Ore: int ore = Memory.Ore(); int splitOre = -1; int.TryParse(split.Value, out splitOre); ShouldSplit = lastIntValue != ore && ore == splitOre; lastIntValue = ore; break; case SplitType.HealthCell: Memory.UpdateUberState(UberStateDefaults.healthContainersCounter); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupKwolok); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupMouldwood); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupWindtorn); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupBaur); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupLagoon); int health = UberStateDefaults.healthContainersCounter.Value.Int - (UberStateDefaults.wispRewardPickupKwolok.Value.Bool ? 2 : 0); health -= (UberStateDefaults.wispRewardPickupMouldwood.Value.Bool ? 2 : 0) + (UberStateDefaults.wispRewardPickupWindtorn.Value.Bool ? 2 : 0); health -= (UberStateDefaults.wispRewardPickupBaur.Value.Bool ? 2 : 0) + (UberStateDefaults.wispRewardPickupLagoon.Value.Bool ? 2 : 0); int splitHealth = -1; int.TryParse(split.Value, out splitHealth); ShouldSplit = lastIntValue != health && health == splitHealth; lastIntValue = health; break; case SplitType.EnergyCell: Memory.UpdateUberState(UberStateDefaults.energyContainersCounter); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupKwolok); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupMouldwood); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupWindtorn); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupBaur); Memory.UpdateUberState(UberStateDefaults.wispRewardPickupLagoon); int energy = UberStateDefaults.energyContainersCounter.Value.Int - (UberStateDefaults.wispRewardPickupKwolok.Value.Bool ? 2 : 0); energy -= (UberStateDefaults.wispRewardPickupMouldwood.Value.Bool ? 2 : 0) + (UberStateDefaults.wispRewardPickupWindtorn.Value.Bool ? 2 : 0); energy -= (UberStateDefaults.wispRewardPickupBaur.Value.Bool ? 2 : 0) + (UberStateDefaults.wispRewardPickupLagoon.Value.Bool ? 2 : 0); int splitEnergy = -1; int.TryParse(split.Value, out splitEnergy); ShouldSplit = lastIntValue != energy && energy == splitEnergy; lastIntValue = energy; break; } if ((state != GameState.Game && split.Type != SplitType.Hitbox) || Memory.Dead() || (Paused && state != GameState.Game)) { ShouldSplit = false; } else if (DateTime.Now > splitLate) { ShouldSplit = true; splitLate = DateTime.MaxValue; } } }
public void ItemUsed(ShardType type) { onItemUse?.Invoke(type); }
public static int TwillenShardCost(ShardType shard) { return(SeedController.TwillenShard(shard).DefaultCost()); }
public static UberId BoughtState(this ShardType st) => new UberId(2, (int)st);
public static float GetCostMod(ShardType type) => shardCostMods.ContainsKey(type) ? shardCostMods[type] : 0f;
public abstract Task <ShardInfo> GetShardInfo(ShardType shardType);
private static bool KSOverride(ShardType s) => s == ShardType.Overcharge && !SeedController.KSDoorsOpen;
public static bool Bought(this ShardType st) => UberGet.value(st.BoughtState()).Bool;
public extern static bool has_shard(ShardType type);