public void AddEntry(User user, HorseInstance horse) { if (Entries.Length + 1 > Slots) { if (Entries.Length + 1 > Slots) { byte[] enterFailed = PacketBuilder.CreateChat(Messages.ArenaFullErrorMessage, PacketBuilder.CHAT_BOTTOM_RIGHT); user.LoggedinClient.SendPacket(enterFailed); GameServer.UpdateArea(user.LoggedinClient); return; } } if (!UserHasHorseEntered(user)) { ArenaEntry arenaEntry = new ArenaEntry(); arenaEntry.EnteredUser = user; arenaEntry.EnteredHorse = horse; entries.Add(arenaEntry); } user.TakeMoney(EntryCost); byte[] enteredIntoCompetition = PacketBuilder.CreateChat(Messages.ArenaEnteredInto, PacketBuilder.CHAT_BOTTOM_RIGHT); user.LoggedinClient.SendPacket(enteredIntoCompetition); GameServer.UpdateAreaForAll(user.X, user.Y, true); return; }
public void AddEntry(User user, Horse.HorseInstance horse) { ArenaEntry arenaEntry = new ArenaEntry(); arenaEntry.EnteredUser = user; arenaEntry.EnteredHorse = horse; Entries.Add(arenaEntry); }
public static Arena FindArena(List <Mobile> players) { Preferences prefs = Preferences.Instance; if (prefs == null) { return(FindArena()); } if (m_Arenas.Count == 0) { return(null); } if (players.Count > 0) { Mobile first = players[0]; List <ArenaController> allControllers = ArenaController.Instances; for (int i = 0; i < allControllers.Count; ++i) { ArenaController controller = allControllers[i]; if (controller != null && !controller.Deleted && controller.Arena != null && controller.IsPrivate && controller.Map == first.Map && first.InRange(controller, 24)) { Multis.BaseHouse house = Multis.BaseHouse.FindHouseAt(controller); bool allNear = true; for (int j = 0; j < players.Count; ++j) { Mobile check = players[j]; bool isNear; if (house == null) { isNear = (controller.Map == check.Map && check.InRange(controller, 24)); } else { isNear = (Multis.BaseHouse.FindHouseAt(check) == house); } if (!isNear) { allNear = false; break; } } if (allNear) { return(controller.Arena); } } } } List <ArenaEntry> arenas = new List <ArenaEntry>(); for (int i = 0; i < m_Arenas.Count; ++i) { Arena arena = m_Arenas[i]; if (!arena.IsOccupied) { arenas.Add(new ArenaEntry(arena)); } } if (arenas.Count == 0) { return(m_Arenas[0]); } int tc = 0; for (int i = 0; i < arenas.Count; ++i) { ArenaEntry ae = arenas[i]; for (int j = 0; j < players.Count; ++j) { PreferencesEntry pe = prefs.Find(players[j]); if (pe.Disliked.Contains(ae.m_Arena.Name)) { ++ae.m_VotesAgainst; } else { ++ae.m_VotesFor; } } tc += ae.Value; } int rn = Utility.Random(tc); for (int i = 0; i < arenas.Count; ++i) { ArenaEntry ae = arenas[i]; if (rn < ae.Value) { return(ae.m_Arena); } rn -= ae.Value; } return(arenas[Utility.Random(arenas.Count)].m_Arena); }
private string getSwf(ArenaEntry entry) { HorseInfo.StatCalculator speedCalculator = new HorseInfo.StatCalculator(entry.EnteredHorse, HorseInfo.StatType.SPEED, entry.EnteredUser); HorseInfo.StatCalculator strengthCalculator = new HorseInfo.StatCalculator(entry.EnteredHorse, HorseInfo.StatType.STRENGTH, entry.EnteredUser); HorseInfo.StatCalculator enduranceCalculator = new HorseInfo.StatCalculator(entry.EnteredHorse, HorseInfo.StatType.ENDURANCE, entry.EnteredUser); HorseInfo.StatCalculator conformationCalculator = new HorseInfo.StatCalculator(entry.EnteredHorse, HorseInfo.StatType.CONFORMATION, entry.EnteredUser); switch (Type) { case "BEGINNERJUMPING": int bigJumps = Convert.ToInt32(Math.Round((double)strengthCalculator.Total / 100.0)) + 1; return("jumpingarena1.swf?BIGJUMPS=" + bigJumps + "&SPEEEDMAX=" + speedCalculator.Total + "&JUNK="); case "JUMPING": int bonus = entry.EnteredHorse.BasicStats.Health + entry.EnteredHorse.BasicStats.Hunger + entry.EnteredHorse.BasicStats.Thirst + entry.EnteredHorse.BasicStats.Shoes; return("jumpingarena2.swf?BONUS=" + bonus + "&STRENGTH=" + strengthCalculator.Total + "&SPEED=" + speedCalculator.Total + "&ENDURANCE=" + enduranceCalculator.Total + "&JUNK="); case "CONFORMATION": int baseScore = conformationCalculator.Total + ((entry.EnteredHorse.BasicStats.Groom > 750) ? 1000 : 500); string swf = "dressagearena.swf?BASESCORE=" + baseScore; int i = 1; foreach (ArenaEntry ent in Entries.ToArray()) { swf += "&HN" + i.ToString() + "=" + ent.EnteredUser.Username; if (ent.EnteredUser.Id == entry.EnteredUser.Id) { swf += "&POS=" + i.ToString(); } i++; } swf += "&JUNK="; return(swf); case "DRAFT": int draftAbility = Convert.ToInt32(Math.Round((((double)entry.EnteredHorse.BasicStats.Health * 2.0 + (double)entry.EnteredHorse.BasicStats.Shoes * 2.0) + (double)entry.EnteredHorse.BasicStats.Hunger + (double)entry.EnteredHorse.BasicStats.Thirst) / 6.0 + (double)strengthCalculator.Total + ((double)enduranceCalculator.Total / 2.0))); swf = "draftarena.swf?DRAFTABILITY=" + draftAbility; i = 1; foreach (ArenaEntry ent in Entries.ToArray()) { swf += "&HN" + i.ToString() + "=" + ent.EnteredUser.Username; if (ent.EnteredUser.Id == entry.EnteredUser.Id) { swf += "&POS=" + i.ToString(); } i++; } swf += "&J="; return(swf); case "RACING": int baseSpeed = Convert.ToInt32(Math.Round((((double)entry.EnteredHorse.BasicStats.Health * 2.0 + (double)entry.EnteredHorse.BasicStats.Shoes * 2.0) + (double)entry.EnteredHorse.BasicStats.Hunger + (double)entry.EnteredHorse.BasicStats.Thirst) / 6.0 + (double)speedCalculator.Total)); swf = "racingarena.swf?BASESPEED=" + baseSpeed + "&ENDURANCE=" + enduranceCalculator.Total; i = 1; foreach (ArenaEntry ent in Entries.ToArray()) { swf += "&HN" + i.ToString() + "=" + ent.EnteredUser.Username; if (ent.EnteredUser.Id == entry.EnteredUser.Id) { swf += "&POS=" + i.ToString(); } i++; } swf += "&JUNK="; return(swf); default: return("test.swf"); } }