private Player convertJsonPlayerToPlayer(JsonPlayer player) { List <string> playerItems = new List <string>(); foreach (var item in player.Items) { playerItems.Add(items[item]); } return(new Player { AccountID = player.AccountID, Assists = player.Assists, CurrentGold = player.Gold, Deaths = player.Deaths, Denies = player.Denies, GPM = player.GPM, Hero = heroes[player.HeroID], Items = playerItems.ToArray(), Kills = player.Kills, LastHits = player.LastHits, Level = player.Level, NetWorth = player.NetWorth, PositionX = player.PositionX, PositionY = player.PositionY, RespawnTime = player.RespawnTimer, Slot = player.Slot, UltimateCD = player.UltimateCD, UltimateState = player.UltimateState, XPM = player.XPM, }); }
public static Player ToPlayer(JsonPlayer jp) { List <Enchantment> buffs = new List <Enchantment>(); if (jp.Buffs != null) { foreach (JsonEnchantment je in jp.Buffs.Where(v => v != null)) { Enchantment e = Enchantment.ToEnchantment(je); if (e != null) { if (e.Attributes != null) { e.Attributes.SetValue(Attribute.CritChance, e.Attributes.GetValue(Attribute.CritChance) / 100); e.Attributes.SetValue(Attribute.HitChance, e.Attributes.GetValue(Attribute.HitChance) / 100); e.Attributes.SetValue(Attribute.AS, e.Attributes.GetValue(Attribute.AS) / 100); } buffs.Add(e); } } } return(new Player(null, Player.Classes.Warrior) { // TODO race, classe etc. Equipment = ToEquipment(jp.MH, jp.OH, jp.Ranged, jp.Equipment), Buffs = buffs, WindfuryTotem = jp.Buffs != null && jp.Buffs.Select(b => b.Name).Contains("Windfury Totem"), Cooldowns = jp.Cooldowns.Where(v => v.Value == true).Select(c => c.Key).ToList() }); }
public PlayerStat(JsonPlayer jsPlayer, Clan clan, DateTime Time) { ID = jsPlayer.id; deaths = jsPlayer.deaths; frags = jsPlayer.frags; level = jsPlayer.level; nick = jsPlayer.nick; this.clan = clan; this.Time = Time; }
public JsonSim(JsonPlayer player = null, JsonBoss boss = null, double fightLength = 300, double fightLengthMod = 0.2, int nbSim = 1000, double targetErrorPct = 0.5, bool targetError = true, bool logFight = false, List <string> simStatWeight = null, bool bossAutoLife = true, double bossLowLifeTime = 0) { Player = player; Boss = boss; FightLength = fightLength; FightLengthMod = fightLengthMod; NbSim = nbSim; TargetErrorPct = targetErrorPct; TargetError = targetError; LogFight = logFight; SimStatWeight = simStatWeight; BossAutoLife = bossAutoLife; BossLowLifeTime = bossLowLifeTime; }
IEnumerator LoginCoroutine(string LoginTxt, string PassTxt) { WWWForm wwwf = new WWWForm(); wwwf.AddField("sql", "SELECT a.*, max(b.score) as score FROM user a, game b WHERE a.id = b.id_user AND LOWER(a.login) = '" + LoginTxt.ToLower() + "'", System.Text.Encoding.UTF8); using (var w = UnityWebRequest.Post("https://systemplugin.com/spacewar/sql.php", wwwf)) { yield return(w.SendWebRequest()); if (w.isNetworkError || w.isHttpError) { Debug.Log(w.error); } else { var json = JSON.Parse(w.downloadHandler.text); Debug.Log(json); var status = json["status"]; if (status == "success") { JsonPlayer playerContainer = JsonUtility.FromJson <JsonPlayer>(w.downloadHandler.text); if (ifPassword.text == playerContainer.data[0].password) { txt.text = "Login efetuado com sucesso!"; PlayerPrefs.SetString("nick", playerContainer.data[0].nick); PlayerPrefs.SetString("id_user", playerContainer.data[0].id + ""); PlayerPrefs.SetInt("record", playerContainer.data[0].score); buttom.SetActive(false); yield return(new WaitForSeconds(2f)); SceneManager.LoadScene("menu"); } else { txt.text = "Senha invalida!"; } } else { txt.text = "Usuario não encontrado no banco de dados!"; } } } }
IEnumerator listaDeTop(int i) { WWWForm wwwf = new WWWForm(); wwwf.AddField("sql", "SELECT a.*, max(b.score) as score FROM user a, game b where a.id = b.id_user group by id order by score DESC LIMIT " + i, System.Text.Encoding.UTF8); using (var w = UnityWebRequest.Post("https://systemplugin.com/spacewar/sql.php", wwwf)) { yield return(w.SendWebRequest()); if (w.isNetworkError || w.isHttpError) { Debug.Log(w.error); } else { var json = JSON.Parse(w.downloadHandler.text); Debug.Log(json); var status = json["status"]; if (status == "success") { JsonPlayer playerContainer = JsonUtility.FromJson <JsonPlayer>(w.downloadHandler.text); txt1.text = ""; txt2.text = ""; if (playerContainer.data.Length > 0) { foreach (JsonPlayer.Player item in playerContainer.data) { txt1.text += item.nick + "\n"; txt2.text += item.score + "\n"; } } } } } }
/// <summary> /// 获取一个玩家对象 /// </summary> /// <param name="userId">用户ID</param> /// <returns></returns> public GamePlayer GetPlayer(Guid userId) { lock ( _sync ) { JsonPlayer player; if (players.TryGetValue(userId, out player)) { return(player); } var filepath = Path.ChangeExtension(Path.Combine(playersDirectory, userId.ToString("D")), _extensions); var data = JsonDataItem.LoadData(filepath, new { Nickname = NameService.AllocateName(), Initiation = GameHost.GameRules.GetInitiation(), Init = true, Resources = new ItemCollection() }); player = new JsonPlayer(this, userId, data); player.Init(); return(players[userId] = player); } }
public static Player ToPlayer(JsonPlayer jp, bool tanking = false) { List <Enchantment> buffs = new List <Enchantment>(); if (jp.Buffs != null) { foreach (JsonEnchantment je in jp.Buffs.Where(v => v != null)) { Enchantment e = Enchantment.ToEnchantment(je); if (e != null) { if (e.Attributes != null) { e.Attributes.SetValue(Attribute.CritChance, e.Attributes.GetValue(Attribute.CritChance) / 100); e.Attributes.SetValue(Attribute.HitChance, e.Attributes.GetValue(Attribute.HitChance) / 100); e.Attributes.SetValue(Attribute.Haste, e.Attributes.GetValue(Attribute.Haste) / 100); e.Attributes.SetValue(Attribute.SpellHitChance, e.Attributes.GetValue(Attribute.SpellHitChance) / 100); e.Attributes.SetValue(Attribute.SpellCritChance, e.Attributes.GetValue(Attribute.SpellCritChance) / 100); } buffs.Add(e); } } } bool windfurytotem = jp.Buffs != null && jp.Buffs.Any(b => b.Name.ToLower().Contains("windfury totem")); List <string> cooldowns = jp.Cooldowns.Where(v => v.Value == true).Select(c => c.Key).ToList(); switch (ToClass(jp.Class)) { case Player.Classes.Druid: return(new Druid(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking) { WindfuryTotem = windfurytotem, Cooldowns = cooldowns }); case Player.Classes.Hunter: return(new Hunter(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking) { WindfuryTotem = windfurytotem, Cooldowns = cooldowns }); case Player.Classes.Paladin: return(new Paladin(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking) { WindfuryTotem = windfurytotem, Cooldowns = cooldowns }); case Player.Classes.Priest: return(new Priest(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking) { WindfuryTotem = windfurytotem, Cooldowns = cooldowns }); case Player.Classes.Rogue: return(new Rogue(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking) { WindfuryTotem = windfurytotem, Cooldowns = cooldowns }); case Player.Classes.Shaman: return(new Shaman(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking) { WindfuryTotem = windfurytotem, Cooldowns = cooldowns }); case Player.Classes.Warlock: return(new Warlock(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking) { WindfuryTotem = windfurytotem, Cooldowns = cooldowns }); case Player.Classes.Warrior: return(new Warrior(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking) { WindfuryTotem = windfurytotem, Cooldowns = cooldowns }); default: throw new NotImplementedException("This class isn't supported yet : " + ToClass(jp.Class)); } }
public static JsonPlayer BuildJsonPlayer(AbstractSingleActor player, ParsedEvtcLog log, RawFormatSettings settings, Dictionary <string, JsonLog.SkillDesc> skillDesc, Dictionary <string, JsonLog.BuffDesc> buffDesc, Dictionary <string, JsonLog.DamageModDesc> damageModDesc, Dictionary <string, HashSet <long> > personalBuffs) { var jsonPlayer = new JsonPlayer(); JsonActorBuilder.FillJsonActor(jsonPlayer, player, log, settings, skillDesc, buffDesc); IReadOnlyList <PhaseData> phases = log.FightData.GetNonDummyPhases(log); // jsonPlayer.Account = player.Account; jsonPlayer.Weapons = player.GetWeaponSets(log).ToArray(); jsonPlayer.Group = player.Group; jsonPlayer.Profession = player.Spec.ToString(); jsonPlayer.FriendlyNPC = player is NPC; jsonPlayer.NotInSquad = player is PlayerNonSquad; GuildEvent guildEvent = log.CombatData.GetGuildEvents(player.AgentItem).FirstOrDefault(); if (guildEvent != null) { jsonPlayer.GuildID = guildEvent.APIString; } jsonPlayer.ActiveTimes = phases.Select(x => player.GetActiveDuration(log, x.Start, x.End)).ToList(); jsonPlayer.HasCommanderTag = player is Player p && p.IsCommander(log); // jsonPlayer.Support = phases.Select(phase => JsonStatisticsBuilder.BuildJsonPlayerSupport(player.GetToPlayerSupportStats(log, phase.Start, phase.End))).ToArray(); var targetDamage1S = new IReadOnlyList <int> [log.FightData.Logic.Targets.Count][]; var targetPowerDamage1S = new IReadOnlyList <int> [log.FightData.Logic.Targets.Count][]; var targetConditionDamage1S = new IReadOnlyList <int> [log.FightData.Logic.Targets.Count][]; var targetBreakbarDamage1S = new IReadOnlyList <double> [log.FightData.Logic.Targets.Count][]; var dpsTargets = new JsonStatistics.JsonDPS[log.FightData.Logic.Targets.Count][]; var statsTargets = new JsonStatistics.JsonGameplayStats[log.FightData.Logic.Targets.Count][]; var targetDamageDist = new IReadOnlyList <JsonDamageDist> [log.FightData.Logic.Targets.Count][]; for (int j = 0; j < log.FightData.Logic.Targets.Count; j++) { AbstractSingleActor target = log.FightData.Logic.Targets[j]; var graph1SDamageList = new IReadOnlyList <int> [phases.Count]; var graph1SPowerDamageList = new IReadOnlyList <int> [phases.Count]; var graph1SConditionDamageList = new IReadOnlyList <int> [phases.Count]; var graph1SBreakbarDamageList = new IReadOnlyList <double> [phases.Count]; var targetDamageDistList = new IReadOnlyList <JsonDamageDist> [phases.Count]; for (int i = 0; i < phases.Count; i++) { PhaseData phase = phases[i]; if (settings.RawFormatTimelineArrays) { graph1SDamageList[i] = player.Get1SDamageList(log, phase.Start, phase.End, target, DamageType.All); graph1SPowerDamageList[i] = player.Get1SDamageList(log, phase.Start, phase.End, target, DamageType.Power); graph1SConditionDamageList[i] = player.Get1SDamageList(log, phase.Start, phase.End, target, DamageType.Condition); graph1SBreakbarDamageList[i] = player.Get1SBreakbarDamageList(log, phase.Start, phase.End, target); } targetDamageDistList[i] = JsonDamageDistBuilder.BuildJsonDamageDistList( player.GetJustActorDamageEvents(target, log, phase.Start, phase.End).GroupBy(x => x.SkillId).ToDictionary(x => x.Key, x => x.ToList()), player.GetJustActorBreakbarDamageEvents(target, log, phase.Start, phase.End).GroupBy(x => x.SkillId).ToDictionary(x => x.Key, x => x.ToList()), log, skillDesc, buffDesc ); } if (settings.RawFormatTimelineArrays) { targetDamage1S[j] = graph1SDamageList; targetPowerDamage1S[j] = graph1SPowerDamageList; targetConditionDamage1S[j] = graph1SConditionDamageList; targetBreakbarDamage1S[j] = graph1SBreakbarDamageList; } targetDamageDist[j] = targetDamageDistList; dpsTargets[j] = phases.Select(phase => JsonStatisticsBuilder.BuildJsonDPS(player.GetDPSStats(target, log, phase.Start, phase.End))).ToArray(); statsTargets[j] = phases.Select(phase => JsonStatisticsBuilder.BuildJsonGameplayStats(player.GetOffensiveStats(target, log, phase.Start, phase.End))).ToArray(); } if (settings.RawFormatTimelineArrays) { jsonPlayer.TargetDamage1S = targetDamage1S; jsonPlayer.TargetPowerDamage1S = targetPowerDamage1S; jsonPlayer.TargetConditionDamage1S = targetConditionDamage1S; jsonPlayer.TargetBreakbarDamage1S = targetBreakbarDamage1S; Dictionary <long, BuffsGraphModel> buffGraphs = player.GetBuffGraphs(log); if (buffGraphs.TryGetValue(SkillIDs.NumberOfClones, out BuffsGraphModel states)) { jsonPlayer.ActiveClones = JsonBuffsUptimeBuilder.GetBuffStates(states); } } jsonPlayer.TargetDamageDist = targetDamageDist; jsonPlayer.DpsTargets = dpsTargets; jsonPlayer.StatsTargets = statsTargets; if (!log.CombatData.HasBreakbarDamageData) { jsonPlayer.TargetBreakbarDamage1S = null; } // jsonPlayer.BuffUptimes = GetPlayerJsonBuffsUptime(player, phases.Select(phase => player.GetBuffs(BuffEnum.Self, log, phase.Start, phase.End)).ToList(), log, settings, buffDesc, personalBuffs); jsonPlayer.SelfBuffs = GetPlayerBuffGenerations(phases.Select(phase => player.GetBuffs(BuffEnum.Self, log, phase.Start, phase.End)).ToList(), log, buffDesc); jsonPlayer.GroupBuffs = GetPlayerBuffGenerations(phases.Select(phase => player.GetBuffs(BuffEnum.Group, log, phase.Start, phase.End)).ToList(), log, buffDesc); jsonPlayer.OffGroupBuffs = GetPlayerBuffGenerations(phases.Select(phase => player.GetBuffs(BuffEnum.OffGroup, log, phase.Start, phase.End)).ToList(), log, buffDesc); jsonPlayer.SquadBuffs = GetPlayerBuffGenerations(phases.Select(phase => player.GetBuffs(BuffEnum.Squad, log, phase.Start, phase.End)).ToList(), log, buffDesc); // jsonPlayer.BuffUptimesActive = GetPlayerJsonBuffsUptime(player, phases.Select(phase => player.GetActiveBuffs(BuffEnum.Self, log, phase.Start, phase.End)).ToList(), log, settings, buffDesc, personalBuffs); jsonPlayer.SelfBuffsActive = GetPlayerBuffGenerations(phases.Select(phase => player.GetActiveBuffs(BuffEnum.Self, log, phase.Start, phase.End)).ToList(), log, buffDesc); jsonPlayer.GroupBuffsActive = GetPlayerBuffGenerations(phases.Select(phase => player.GetActiveBuffs(BuffEnum.Group, log, phase.Start, phase.End)).ToList(), log, buffDesc); jsonPlayer.OffGroupBuffsActive = GetPlayerBuffGenerations(phases.Select(phase => player.GetActiveBuffs(BuffEnum.OffGroup, log, phase.Start, phase.End)).ToList(), log, buffDesc); jsonPlayer.SquadBuffsActive = GetPlayerBuffGenerations(phases.Select(phase => player.GetActiveBuffs(BuffEnum.Squad, log, phase.Start, phase.End)).ToList(), log, buffDesc); // IReadOnlyList <Consumable> consumables = player.GetConsumablesList(log, 0, log.FightData.FightEnd); if (consumables.Any()) { var consumablesJSON = new List <JsonConsumable>(); foreach (Consumable food in consumables) { if (!buffDesc.ContainsKey("b" + food.Buff.ID)) { buffDesc["b" + food.Buff.ID] = JsonLogBuilder.BuildBuffDesc(food.Buff, log); } consumablesJSON.Add(JsonConsumableBuilder.BuildJsonConsumable(food)); } jsonPlayer.Consumables = consumablesJSON; } // IReadOnlyList <DeathRecap> deathRecaps = player.GetDeathRecaps(log); if (deathRecaps.Any()) { jsonPlayer.DeathRecap = deathRecaps.Select(x => JsonDeathRecapBuilder.BuildJsonDeathRecap(x)).ToList(); } // jsonPlayer.DamageModifiers = JsonDamageModifierDataBuilder.GetDamageModifiers(phases.Select(x => player.GetDamageModifierStats(null, log, x.Start, x.End)).ToList(), log, damageModDesc); jsonPlayer.DamageModifiersTarget = JsonDamageModifierDataBuilder.GetDamageModifiersTarget(player, log, damageModDesc, phases); if (log.CombatData.HasEXTHealing) { jsonPlayer.EXTHealingStats = EXTJsonPlayerHealingStatsBuilder.BuildPlayerHealingStats(player, log, settings, skillDesc, buffDesc); } if (log.CombatData.HasEXTBarrier) { jsonPlayer.EXTBarrierStats = EXTJsonPlayerBarrierStatsBuilder.BuildPlayerBarrierStats(player, log, settings, skillDesc, buffDesc); } return(jsonPlayer); }
public JsonPlayerMute(ulong _steamid, string _displayName, string _reason) { player = new JsonPlayer(_steamid, _displayName); reason = _reason; }
public JsonOnlinePlayer(ulong _steamid, string _displayName, string _ipAddress) { player = new JsonPlayer(_steamid, _displayName); ipAddress = _ipAddress; }
public JsonPlayerChatMessage(BasePlayer _player, string _displayName, string _message) { player = new JsonPlayer(_player.userID, _displayName); message = _message; }
/// <summary> /// 获取一个玩家对象 /// </summary> /// <param name="userId">用户ID</param> /// <returns></returns> public GamePlayer GetPlayer( Guid userId ) { lock ( _sync ) { JsonPlayer player; if ( players.TryGetValue( userId, out player ) ) return player; var filepath = Path.ChangeExtension( Path.Combine( playersDirectory, userId.ToString( "D" ) ), _extensions ); var data = JsonDataItem.LoadData( filepath, new { Nickname = NameService.AllocateName(), Initiation = GameHost.GameRules.GetInitiation(), Init = true, Resources = new ItemCollection() } ); player = new JsonPlayer( this, userId, data ); player.Init(); return players[userId] = player; } }