public override void Process(Level level) { //Clan creation Alliance alliance = ObjectManager.CreateAlliance(0); alliance.SetAllianceName(m_vAllianceName); alliance.SetAllianceDescription(m_vAllianceDescription); alliance.SetAllianceType(m_vAllianceType); alliance.SetRequiredScore(m_vRequiredScore); alliance.SetAllianceBadgeData(m_vAllianceBadgeData); //alliance.SetAllianceOrigin(m_vAllianceOrigin); alliance.SetWarFrequency(m_vWarFrequency); //Set player clan //ObjectManager.OnlinePlayers.TryGetValue(p.Client, out player); level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); AllianceMemberEntry member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); member.SetRole(2); alliance.AddAllianceMember(member); var joinAllianceCommand = new JoinAllianceCommand(); joinAllianceCommand.SetAlliance(alliance); var availableServerCommandMessage = new AvailableServerCommandMessage(this.Client); availableServerCommandMessage.SetCommandId(1); availableServerCommandMessage.SetCommand(joinAllianceCommand); PacketManager.ProcessOutgoingPacket(availableServerCommandMessage); }
public override void Process(Level level) { var alliance = ObjectManager.GetAlliance(m_vAllianceId); if (alliance != null) { if(!alliance.IsAllianceFull()) { level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); AllianceMemberEntry member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); member.SetRole(1); alliance.AddAllianceMember(member); var joinAllianceCommand = new JoinAllianceCommand(); joinAllianceCommand.SetAlliance(alliance); var availableServerCommandMessage = new AvailableServerCommandMessage(this.Client); availableServerCommandMessage.SetCommandId(1); availableServerCommandMessage.SetCommand(joinAllianceCommand); PacketManager.ProcessOutgoingPacket(availableServerCommandMessage); PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(this.Client, alliance)); if(alliance.GetScore() == 10000) { alliance.SetScore(0); } int percentuale = (level.GetPlayerAvatar().GetScore()) / (2); alliance.SetScore(alliance.GetScore() + percentuale); } } }
public void LoadFromJSON(string jsonString) { JObject jsonObject = JObject.Parse(jsonString); m_vAllianceId = jsonObject["alliance_id"].ToObject <long>(); m_vAllianceName = jsonObject["alliance_name"].ToObject <string>(); m_vAllianceBadgeData = jsonObject["alliance_badge"].ToObject <int>(); m_vAllianceType = jsonObject["alliance_type"].ToObject <int>(); if (jsonObject["required_score"] != null) { m_vRequiredScore = jsonObject["required_score"].ToObject <int>(); } m_vScore = jsonObject["score"].ToObject <int>(); m_vAllianceDescription = jsonObject["description"].ToObject <string>(); m_vAllianceExperience = jsonObject["alliance_experience"].ToObject <int>(); m_vAllianceLevel = jsonObject["alliance_level"].ToObject <int>(); if (jsonObject["won_wars"] != null) { m_vWonWars = jsonObject["won_wars"].ToObject <int>(); } if (jsonObject["lost_wars"] != null) { m_vLostWars = jsonObject["lost_wars"].ToObject <int>(); } if (jsonObject["draw_wars"] != null) { m_vDrawWars = jsonObject["draw_wars"].ToObject <int>(); } if (jsonObject["war_frequency"] != null) { m_vWarFrequency = jsonObject["war_frequency"].ToObject <int>(); } if (jsonObject["alliance_origin"] != null) { m_vAllianceOrigin = jsonObject["alliance_origin"].ToObject <int>(); } JArray jsonMembers = (JArray)jsonObject["members"]; foreach (JObject jsonMember in jsonMembers) { long id = jsonMember["avatar_id"].ToObject <long>(); AllianceMemberEntry member = new AllianceMemberEntry(id); member.Load(jsonMember); m_vAllianceMembers.Add(id, member); } }
public void AddAllianceMember(AllianceMemberEntry entry) { this.m_vAllianceMembers.Add(entry.GetAvatarId(), entry); }
public void LoadFromJson(string jsonString) { var jsonObject = JObject.Parse(jsonString); m_vAllianceId = jsonObject["alliance_id"].ToObject <long>(); m_vAllianceName = jsonObject["alliance_name"].ToObject <string>(); m_vAllianceBadgeData = jsonObject["alliance_badge"].ToObject <int>(); m_vAllianceType = jsonObject["alliance_type"].ToObject <int>(); m_vRequiredScore = jsonObject["required_score"].ToObject <int>(); m_vAllianceDescription = jsonObject["description"].ToObject <string>(); m_vAllianceExperience = jsonObject["alliance_experience"].ToObject <int>(); m_vAllianceLevel = jsonObject["alliance_level"].ToObject <int>(); m_vWarLogPublic = jsonObject["war_log_public"].ToObject <byte>(); m_vFriendlyWar = jsonObject["friendly_war"].ToObject <byte>(); m_vWonWars = jsonObject["won_wars"].ToObject <int>(); m_vLostWars = jsonObject["lost_wars"].ToObject <int>(); m_vDrawWars = jsonObject["draw_wars"].ToObject <int>(); m_vWarFrequency = jsonObject["war_frequency"].ToObject <int>(); m_vAllianceOrigin = jsonObject["alliance_origin"].ToObject <int>(); var jsonMembers = (JArray)jsonObject["members"]; foreach (var jToken in jsonMembers) { var jsonMember = (JObject)jToken; var id = jsonMember["avatar_id"].ToObject <long>(); var player = ResourcesManager.GetPlayer(id); var member = new AllianceMemberEntry(id); m_vScore = m_vScore + player.GetPlayerAvatar().GetScore(); member.Load(jsonMember); m_vAllianceMembers.Add(id, member); } m_vScore = m_vScore / 2; var jsonMessages = (JArray)jsonObject["chatMessages"]; if (jsonMessages != null) { foreach (JToken jToken in jsonMessages) { JObject jsonMessage = (JObject)jToken; StreamEntry.StreamEntry se = new StreamEntry.StreamEntry(); if (jsonMessage["type"].ToObject <int>() == 1) { se = new TroopRequestStreamEntry(); } else if (jsonMessage["type"].ToObject <int>() == 2) { se = new ChatStreamEntry(); } else if (jsonMessage["type"].ToObject <int>() == 3) { se = new InvitationStreamEntry(); } else if (jsonMessage["type"].ToObject <int>() == 4) { se = new AllianceEventStreamEntry(); } else if (jsonMessage["type"].ToObject <int>() == 5) { se = new ShareStreamEntry(); } se.Load(jsonMessage); m_vChatMessages.Add(se); } } }
public void LoadFromJSON(string jsonString) { JObject jsonObject = JObject.Parse(jsonString); m_vAllianceId = jsonObject["alliance_id"].ToObject<long>(); m_vAllianceName = jsonObject["alliance_name"].ToObject<string>(); m_vAllianceBadgeData = jsonObject["alliance_badge"].ToObject<int>(); m_vAllianceType = jsonObject["alliance_type"].ToObject<int>(); if (jsonObject["required_score"] != null) m_vRequiredScore = jsonObject["required_score"].ToObject<int>(); m_vScore = jsonObject["score"].ToObject<int>(); m_vAllianceDescription = jsonObject["description"].ToObject<string>(); m_vAllianceExperience = jsonObject["alliance_experience"].ToObject<int>(); m_vAllianceLevel = jsonObject["alliance_level"].ToObject<int>(); if (jsonObject["won_wars"] != null) m_vWonWars = jsonObject["won_wars"].ToObject<int>(); if (jsonObject["lost_wars"] != null) m_vLostWars = jsonObject["lost_wars"].ToObject<int>(); if (jsonObject["draw_wars"] != null) m_vDrawWars = jsonObject["draw_wars"].ToObject<int>(); if (jsonObject["war_frequency"] != null) m_vWarFrequency = jsonObject["war_frequency"].ToObject<int>(); if (jsonObject["alliance_origin"] != null) m_vAllianceOrigin = jsonObject["alliance_origin"].ToObject<int>(); JArray jsonMembers = (JArray)jsonObject["members"]; foreach (JObject jsonMember in jsonMembers) { long id = jsonMember["avatar_id"].ToObject<long>(); AllianceMemberEntry member = new AllianceMemberEntry(id); member.Load(jsonMember); m_vAllianceMembers.Add(id, member); } }
public void AddAllianceMember(AllianceMemberEntry entry) { m_vAllianceMembers.Add(entry.GetAvatarId(), entry); }
public void LoadFromJSON(string jsonString) { var jsonObject = JObject.Parse(jsonString); m_vAllianceId = jsonObject["alliance_id"].ToObject <long>(); m_vAllianceName = jsonObject["alliance_name"].ToObject <string>(); m_vAllianceBadgeData = jsonObject["alliance_badge"].ToObject <int>(); m_vAllianceType = jsonObject["alliance_type"].ToObject <int>(); if (jsonObject["required_score"] != null) { m_vRequiredScore = jsonObject["required_score"].ToObject <int>(); } // m_vScore = jsonObject["score"].ToObject<int>(); m_vAllianceDescription = jsonObject["description"].ToObject <string>(); m_vAllianceExperience = jsonObject["alliance_experience"].ToObject <int>(); m_vAllianceLevel = jsonObject["alliance_level"].ToObject <int>(); if (jsonObject["won_wars"] != null) { m_vWonWars = jsonObject["won_wars"].ToObject <int>(); } if (jsonObject["lost_wars"] != null) { m_vLostWars = jsonObject["lost_wars"].ToObject <int>(); } if (jsonObject["draw_wars"] != null) { m_vDrawWars = jsonObject["draw_wars"].ToObject <int>(); } if (jsonObject["war_frequency"] != null) { m_vWarFrequency = jsonObject["war_frequency"].ToObject <int>(); } if (jsonObject["alliance_origin"] != null) { m_vAllianceOrigin = jsonObject["alliance_origin"].ToObject <int>(); } var jsonMembers = (JArray)jsonObject["members"]; foreach (JObject jsonMember in jsonMembers) { var id = jsonMember["avatar_id"].ToObject <long>(); var token = UCS.Core.ResourcesManager.GetPlayer(id).GetPlayerAvatar().GetUserToken(); var member = new AllianceMemberEntry(id); var scorem = new Level(id, token); m_vScore = m_vScore + scorem.GetPlayerAvatar().GetScore(); member.Load(jsonMember); m_vAllianceMembers.Add(id, member); } m_vScore = m_vScore / 2; var jsonMessages = (JArray)jsonObject["chatMessages"]; if (jsonMessages != null) { foreach (JObject jsonMessage in jsonMessages) { var se = new StreamEntry(); switch (jsonMessage["type"].ToObject <int>()) { case 1: se = new TroopRequestStreamEntry(); break; case 2: se = new ChatStreamEntry(); break; case 3: se = new InvitationStreamEntry(); break; case 4: se = new AllianceEventStreamEntry(); break; case 5: se = new ShareStreamEntry(); break; } se.Load(jsonMessage); m_vChatMessages.Add(se); } } }
public void LoadFromJSON(string jsonString) { var jsonObject = JObject.Parse(jsonString); m_vAllianceId = jsonObject["alliance_id"].ToObject<long>(); m_vAllianceName = jsonObject["alliance_name"].ToObject<string>(); m_vAllianceBadgeData = jsonObject["alliance_badge"].ToObject<int>(); m_vAllianceType = jsonObject["alliance_type"].ToObject<int>(); if (jsonObject["required_score"] != null) m_vRequiredScore = jsonObject["required_score"].ToObject<int>(); m_vScore = jsonObject["score"].ToObject<int>(); m_vAllianceDescription = jsonObject["description"].ToObject<string>(); m_vAllianceExperience = jsonObject["alliance_experience"].ToObject<int>(); m_vAllianceLevel = jsonObject["alliance_level"].ToObject<int>(); if (jsonObject["won_wars"] != null) m_vWonWars = jsonObject["won_wars"].ToObject<int>(); if (jsonObject["lost_wars"] != null) m_vLostWars = jsonObject["lost_wars"].ToObject<int>(); if (jsonObject["draw_wars"] != null) m_vDrawWars = jsonObject["draw_wars"].ToObject<int>(); if (jsonObject["war_frequency"] != null) m_vWarFrequency = jsonObject["war_frequency"].ToObject<int>(); if (jsonObject["alliance_origin"] != null) m_vAllianceOrigin = jsonObject["alliance_origin"].ToObject<int>(); var jsonMembers = (JArray)jsonObject["members"]; foreach (JObject jsonMember in jsonMembers) { var id = jsonMember["avatar_id"].ToObject<long>(); var member = new AllianceMemberEntry(id); var scorem = new Level(id); m_vScore = m_vScore + scorem.GetPlayerAvatar().GetScore(); member.Load(jsonMember); m_vAllianceMembers.Add(id, member); } var jsonMessages = (JArray)jsonObject["chatMessages"]; if (jsonMessages != null) { foreach (JObject jsonMessage in jsonMessages) { var se = new StreamEntry(); switch (jsonMessage["type"].ToObject<int>()) { case 4: se = new AllianceEventStreamEntry(); break; case 2: se = new ChatStreamEntry(); break; } se.Load(jsonMessage); m_vChatMessages.Add(se); } } }
public void AddAllianceMember(AllianceMemberEntry entry) => m_vAllianceMembers.Add(entry.AvatarId, entry);
public void LoadFromJSON(string jsonString) { JObject jObject = JObject.Parse(jsonString); this.m_vAllianceId = jObject["alliance_id"].ToObject <long>(); this.m_vAllianceName = jObject["alliance_name"].ToObject <string>(); this.m_vAllianceBadgeData = jObject["alliance_badge"].ToObject <int>(); this.m_vAllianceType = jObject["alliance_type"].ToObject <int>(); if (jObject["required_score"] != null) { this.m_vRequiredScore = jObject["required_score"].ToObject <int>(); } this.m_vAllianceDescription = jObject["description"].ToObject <string>(); this.m_vAllianceExperience = jObject["alliance_experience"].ToObject <int>(); this.m_vAllianceLevel = jObject["alliance_level"].ToObject <int>(); if (jObject["won_wars"] != null) { this.m_vWonWars = jObject["won_wars"].ToObject <int>(); } if (jObject["lost_wars"] != null) { this.m_vLostWars = jObject["lost_wars"].ToObject <int>(); } if (jObject["draw_wars"] != null) { this.m_vDrawWars = jObject["draw_wars"].ToObject <int>(); } if (jObject["war_frequency"] != null) { this.m_vWarFrequency = jObject["war_frequency"].ToObject <int>(); } if (jObject["alliance_origin"] != null) { this.m_vAllianceOrigin = jObject["alliance_origin"].ToObject <int>(); } using (IEnumerator <JToken> enumerator = ((JArray)jObject["members"]).GetEnumerator()) { while (enumerator.MoveNext()) { JObject jObject2 = (JObject)enumerator.Current; long num = jObject2["avatar_id"].ToObject <long>(); AllianceMemberEntry allianceMemberEntry = new AllianceMemberEntry(num); Level level = new Level(num); this.m_vScore += level.GetPlayerAvatar().GetScore(); allianceMemberEntry.Load(jObject2); this.m_vAllianceMembers.Add(num, allianceMemberEntry); } } this.m_vScore /= 2; JArray jArray = (JArray)jObject["chatMessages"]; if (jArray != null) { using (IEnumerator <JToken> enumerator = jArray.GetEnumerator()) { while (enumerator.MoveNext()) { JObject jObject3 = (JObject)enumerator.Current; StreamEntry streamEntry = new StreamEntry(); switch (jObject3["type"].ToObject <int>()) { case 1: streamEntry = new TroopRequestStreamEntry(); break; case 2: streamEntry = new ChatStreamEntry(); break; case 3: streamEntry = new InvitationStreamEntry(); break; case 4: streamEntry = new AllianceEventStreamEntry(); break; case 5: streamEntry = new ShareStreamEntry(); break; } streamEntry.Load(jObject3); this.m_vChatMessages.Add(streamEntry); } } } }