void Awake() { playerList = GameObject.FindWithTag(Tags.gameController).GetComponent<PlayerList>(); crystalBarUI = GameObject.Find("Camera_GUI").GetComponent<CrystalBarUI>(); requestSent = false; eatingInProgress = false; }
public ServerStatus(ServerVersion version, PlayerList players, string description, string icon) { Version = version; Players = players; Description = description; Icon = icon; }
public FormInformation(PlayerList AI) { InitializeComponent(); this.Icon = new Icon("Poker.ico"); this.AI=AI; counter = 0; }
public void SetUp() { playerList = new PlayerList(); localClient = new LocalClient(MockRepository.GenerateStub<IPlayer>()); clientFactoryDelegate = () => createdClient; clientFactory = new ClientSideClientFactory(clientFactoryDelegate, playerList, localClient); }
// Use this for initialization void Start() { Time.timeScale = 1; Screen.sleepTimeout = SleepTimeout.NeverSleep; playerList = GameObject.FindGameObjectWithTag ("Player List").GetComponent<PlayerList> (); Players.Clear (); for (int j = 0; j < GOList.Length; j++) { Players.Add(playerList.players[j]); } // if GOLocation spot is not declare, will use our own transform instead. if (GOLocationSpot== null){ GOLocationSpot = transform; } // start by hiding all foreach(GameObject _go in GOList) { // we move it to the right location _go.transform.position = GOLocationSpot.position; // and we hide it for now. _go.SetActive(false); } for (int i = 0; i < Players.Count; i++) { GameObject player = (GameObject)Instantiate(Players[i].playerIcon, GOLocationSpot.position, Quaternion.Euler(0,210,0)); } // now show the first ShowID(0); }
public HandHistory(GameDescriptor gameDescription) : base() { HandActions = new List<HandAction>(); Players = new PlayerList(); ComumnityCards = BoardCards.ForPreflop(); GameDescription = gameDescription; }
public Pot(int amount, PlayerList playersInPot) { this.Amount = amount; this.playersInPot = playersInPot; minimumAllInAmount = 0; playersAllInCount = 0; amountInPotBeforeAllIn = 0; agressorIndex = -1; }
public Form1() { InitializeComponent(); playerList = new PlayerList(); playerAmount = 0; rand = new Random(); text = ""; b = new Bitmap(pbCards.Width, pbCards.Height); g = Graphics.FromImage(b); }
public void AddingPlayersToPlayerListRaisesPlayerJoinedEvent() { bool eventRaised = false; IPlayerList playerList = new PlayerList(); IPlayer player = MockRepository.GenerateStub<IPlayer>(); playerList.PlayerAdded += (newPlayer) => { if (newPlayer == player) eventRaised = true; }; playerList.Add(player); Assert.IsTrue(eventRaised); }
public PlayersViewModel(Battlefield3Server server, Action<Action> synchronousInvoker) : base(synchronousInvoker) { this.server = server; this.players = server.PlayerList; this.InitializePlayers(this.players.Players); this.NewPlayer = new Player(); Initialize(); }
public void ShouldAllowIterationOverPlayerList() { PlayerList playerList = new PlayerList() { MockRepository.GenerateStub<IPlayer>(), MockRepository.GenerateStub<IPlayer>() }; int count = 0; foreach (var player in playerList) { count++; } Assert.AreEqual(2, count); }
void Awake() { playerList = GameObject.FindWithTag(Tags.gameController).GetComponent<PlayerList>(); increaseStatValue = Random.Range(minimumValueRange, maximumValueRange); if(minimumValueRange > maximumValueRange) { int tempValueRange = maximumValueRange; maximumValueRange = minimumValueRange; minimumValueRange = tempValueRange; } timer = 0; eatingInProgress = false; }
public void SetupPlayer(PlayerList playerList) { this.number = playerList.number; if(playerList.type == ControllerType.Gamepad){ this.controller = new ControllerGamepad(life, playerList.controller); } else if(playerList.type == ControllerType.Keyboard) { this.controller = new ControllerKeyboard(life); } Skin skin = gameObject.GetComponentInChildren<Skin>() as Skin; if(skin) skin.Skining(this.number); (GetComponentInChildren<TakeDamage>() as TakeDamage).Setup(gameObject); }
//the all important constructors public FormPoker() { InitializeComponent(); this.Icon = new Icon("Poker.ico"); timerCount = 0; screenWidth = Screen.PrimaryScreen.Bounds.Width; screenHeight = Screen.PrimaryScreen.Bounds.Height; width_ratio = (screenWidth / this.Width); height_ratio = (screenHeight / this.Height); SizeF scale = new SizeF(width_ratio, height_ratio); pbMain.Scale(scale); this.Size = pbMain.Size; foreach (Control control in this.Controls) { control.Font = new Font(control.Font.Name, control.Font.SizeInPoints * height_ratio * width_ratio, control.Font.Style); } cardWidth = Convert.ToInt32(71f * width_ratio); cardHeight = Convert.ToInt32(96f * height_ratio); user = new UserAccount(); Random rand = new Random(); Player me = new Player(playerName, BuyInAmount); playerList = new PlayerList(); playerList.Add(me); lblName.Text = me.Name; List<int> AI = new List<int>(playerAmount); for (int i = 0; i < 3; i++) { AI.Add(i); } for (int i = 0; i < 4 - playerAmount; i++) { AI.Remove(rand.Next(AI.Count)); } AI = shuffle(AI); for (int i = 1; i < playerAmount; i++) { playerList.Add(new AIPlayer(BuyInAmount, difficulty, AI[i - 1])); //labelListName[i].Text = playerList[i].Name; } FormInformation Information = new FormInformation(playerList); Information.StartPosition = FormStartPosition.CenterScreen; Information.ShowDialog(); Information.Dispose(); pokerTable = new Table(playerList); SoundPlayer sound = new SoundPlayer(); }
private void button10_Click(object sender, EventArgs e) { pokerTable.getPlayers().Clear(); numberOFPlayers = Convert.ToInt32(nudAmount.Value); PlayerList players = new PlayerList(); Random rand = new Random(); for (int i = 0; i < numberOFPlayers; i++) { players.Add(new Player("Player " + (i + 1), 10000)); } players[0].ChipStack = 10000; players[1].ChipStack = 9000; players[2].ChipStack = 9500; players[3].ChipStack = 9500; pokerTable = new Table(players); Print(); }
void Awake() { GameData.SERVER_NAME = "Server Name"; GameData.PLAYER_NAME = "Player Name"; GameData.NUMBER_OF_PLAYERS_A = 0; GameData.NUMBER_OF_PLAYERS_A = 0; DontDestroyOnLoad(this); networkView.group = 1; Application.LoadLevel(GameData.LEVEL_DISCONNECTED); MasterServer.ClearHostList(); MasterServer.RequestHostList("GodlyCubesLight"); //TODO: globalna zmienna w GameDAta playerListComponent = GetComponent<PlayerList>(); }
public void Initialise(Client client) { Debug.Log("Initialise"); Client = client; Client.MessageHandler.OnMessage += OnMessage; // Game state logic and views States.Add(new PreGameState(client, PreGameView)); States.Add(new RoundBeginState(client, RoundBeginView)); States.Add(new DrawingState(client, DrawingView)); States.Add(new AnsweringState(client, AnsweringView)); States.Add(new ChoosingState(client, ChoosingView)); States.Add(new ResultsState(client, ResultsView)); States.Add(new ScoresState(client, ScoresView)); States.Add(new FinalScoresState(client, FinalScoresView)); States.Add(new GameOverState(client, RoundEndView)); // Drawing canvas Canvas = CanvasView.gameObject.AddComponent<DrawingCanvas>(); Canvas.Initialise(Client, CanvasView); StateHandlers.Add(Canvas); // Player List that appears on the right PlayerList = new PlayerList(client, PlayerListView); MessageHandlers.Add(PlayerList); StateHandlers.Add(PlayerList); // Game View StateHandlers.Add(View); TransitionHandlers.Add(View); // Timer MessageHandlers.Add(Timer); StateHandlers.Add(Timer); // Transition Message StateEndHandlers.Add(Transition); StateHandlers.Add(Transition); ChangeState(GameState.PreGame); }
public Table() { players = new PlayerList(); deck = new Deck(); rand = new Random(); mainPot = new Pot(); sidePots = new List<Pot>(); smallBlind = new Blind(); bigBlind = new Blind(); roundCounter = 0; turnCount = 0; dealerPosition = rand.Next(players.Count); //set blind amount and position smallBlind.Amount = 500; bigBlind.Amount = 1000; mainPot.SmallBlind = 500; mainPot.BigBlind = 1000; smallBlind.position = dealerPosition + 1; bigBlind.position = dealerPosition + 2; currentIndex = dealerPosition; }
public void LaunchGame(PlayerList[] playersList, int traitorIndex) { int i = 0; foreach (PlayerList playerList in playersList) { Player p = Instantiate(playerPrefab, new Vector2(-9999f, -9999f), Quaternion.identity) as Player; p.SetupPlayer(playerList); players.Add(p); if (i == traitorIndex) { p.isTraitor = true; Debug.Log(i + " IS TRAITOR"); } i++; } inGame = true; if(floor == 0) NextLevel(); }
/// <summary> /// Returns a set of players with best draw including player /// cards and cards on table /// </summary> public PlayerList GetBestDrawPlayers(PlayerList players) { PlayerList currentBestDrawPlayers = new PlayerList(); Draw bestDrawSoFar = null; // Get best draw types by comparing all players draws. foreach (Player player in players) { if (!player.HasCards()) continue; Draw currentDraw = GetDraw(player.GetAllCards()); try { // save the current draw if it is better than the previuosly best found draw if (!GetBestDraw(currentDraw, bestDrawSoFar).Equals(bestDrawSoFar)){ currentBestDrawPlayers.Clear(); currentBestDrawPlayers.Add(player); bestDrawSoFar = currentDraw; } } catch (TieDrawException) { currentBestDrawPlayers.Add(player); } } return currentBestDrawPlayers; }
protected override PlayerList ParsePlayers(string[] handLines) { // line 3 onward has all seated player // Seat 1: ovechkin08 (2000€) // Seat 4: R.BAGGIO (2000€) // *** ANTE/BLINDS *** var playerList = new PlayerList(); for (int i = 2; i < handLines.Length; i++) { // when the line starts with stars, we already have all players if (handLines[i].StartsWith("***")) break; int colonIndex = handLines[i].IndexOf(':'); int parenIndex = handLines[i].IndexOf('('); string name = handLines[i].Substring(colonIndex + 2, parenIndex - 2 - colonIndex - 1); int seatNumber = Int32.Parse(handLines[i].Substring(5, colonIndex - 5)); string amount = (handLines[i].Substring(parenIndex + 1, handLines[i].Length - parenIndex - 2)); playerList.Add(new Player(name, decimal.Parse(amount, NumberStyles.AllowCurrencySymbol | NumberStyles.Number, _numberFormatInfo), seatNumber)); } for (int i = handLines.Length - 1; i >= 0; i--) { // Loop backward looking for lines like: // Seat 3: xGras (button) won 6.07€ // Seat 4: KryptonII (button) showed [Qd Ah] and won 42.32€ with One pair : Aces // Seat 1: Hitchhiker won 0.90€ // Seat 3: le parano (big blind) mucked string handLine = handLines[i]; if (!handLine.StartsWith("Seat")) { break; } string name = GetPlayerNameFromHandLine(handLine); int openSquareIndex = handLine.LastIndexOf('['); int closeSquareIndex = handLine.LastIndexOf(']'); string holeCards = ""; if(openSquareIndex > -1 && closeSquareIndex > -1) { holeCards = handLine.Substring(openSquareIndex + 1, closeSquareIndex - openSquareIndex -1); } Player player = playerList.First(p => p.PlayerName.Equals(name)); player.HoleCards = HoleCards.FromCards(holeCards.Replace(" ", "").Replace(",", "")); } return playerList; }
private TabControl ConstructMainTabControl() { // Main log list var logList = new LogList(ApiData, LogDataProcessor, UploadProcessor, ImageProvider, LogNameProvider); LogCollectionsRecreated += (sender, args) => logList.DataStore = logsFiltered; LogDataProcessor.Processed += (sender, args) => { bool last = args.CurrentScheduledItems == 0; if (last || gridRefreshCooldown.TryUse(DateTime.Now)) { Application.Instance.AsyncInvoke(() => { logList.ReloadData(); }); } }; // Player list var playerList = new PlayerList(ApiData, LogDataProcessor, UploadProcessor, ImageProvider, LogNameProvider); FilteredLogsUpdated += (sender, args) => playerList.UpdateDataFromLogs(logsFiltered); // Guild list var guildList = new GuildList(ApiData, LogDataProcessor, UploadProcessor, ImageProvider, LogNameProvider); FilteredLogsUpdated += (sender, args) => guildList.UpdateDataFromLogs(logsFiltered); // Statistics var statistics = new StatisticsSection(ImageProvider, LogNameProvider); FilteredLogsUpdated += (sender, args) => statistics.UpdateDataFromLogs(logsFiltered.ToList()); // Game data collecting var gameDataCollecting = new GameDataCollecting(logList); var gameDataPage = new TabPage { Text = "Game data", Content = gameDataCollecting, Visible = Settings.ShowDebugData }; Settings.ShowDebugDataChanged += (sender, args) => gameDataPage.Visible = Settings.ShowDebugData; // Service status var serviceStatus = new DynamicLayout { Spacing = new Size(10, 10), Padding = new Padding(5) }; serviceStatus.BeginHorizontal(); { serviceStatus.Add(new GroupBox { Text = "Uploads", Content = new BackgroundProcessorDetail { BackgroundProcessor = UploadProcessor } }, xscale: true); serviceStatus.Add(new GroupBox { Text = "Guild Wars 2 API", Content = new BackgroundProcessorDetail { BackgroundProcessor = ApiProcessor } }, xscale: true); serviceStatus.Add(new GroupBox { Text = "Log parsing", Content = new BackgroundProcessorDetail { BackgroundProcessor = LogDataProcessor } }, xscale: true); } serviceStatus.AddRow(null); var servicePage = new TabPage { Text = "Services", Content = serviceStatus, Visible = Settings.ShowDebugData }; Settings.ShowDebugDataChanged += (sender, args) => servicePage.Visible = Settings.ShowDebugData; var tabs = new TabControl(); tabs.Pages.Add(new TabPage { Text = "Logs", Content = logList }); tabs.Pages.Add(new TabPage { Text = "Players", Content = playerList }); tabs.Pages.Add(new TabPage { Text = "Guilds", Content = guildList }); tabs.Pages.Add(new TabPage { Text = "Statistics", Content = statistics }); tabs.Pages.Add(gameDataPage); tabs.Pages.Add(servicePage); // This is needed to avoid a Gtk platform issue where the tab is changed to the last one. Shown += (sender, args) => tabs.SelectedIndex = 1; return(tabs); }
internal void AddPlayer(Player player) { PlayerList.Add(player); }
protected override PlayerList ParsePlayers(string[] handLines) { PlayerList playerList = new PlayerList(); int lastLineRead = -1; // We start on line index 2 as first 2 lines are table and limit info. for (int lineNumber = 2; lineNumber < handLines.Length - 1; lineNumber++) { string line = handLines[lineNumber]; if (line.StartsWith(@"Seat ") == false) { lastLineRead = lineNumber; break; } // seat info expected in format: // Seat 1: thaiJhonny ($16.08 in chips) int spaceIndex = line.IndexOf(' '); int colonIndex = line.IndexOf(':', spaceIndex + 1); // we need to find the ( before the number. players can have ( in their name so we need to go backwards and skip the last one int openParenIndex = line.LastIndexOf('('); int spaceAfterOpenParen = line.IndexOf(' ', openParenIndex + 2); // add 2 so we skip the $ and first # always int seatNumber = int.Parse(line.Substring(spaceIndex + 1, colonIndex - (spaceIndex + 1) )); string playerName = line.Substring(colonIndex + 2, (openParenIndex - 1) - (colonIndex + 2)); string stackString = line.Substring(openParenIndex + 2, spaceAfterOpenParen - (openParenIndex + 2)); decimal stack = decimal.Parse(stackString, DecimalSeperator); playerList.Add(new Player(playerName, stack, seatNumber)); } if (lastLineRead == -1) { throw new PlayersException(string.Empty, "Didn't break out of the seat reading block."); } // Looking for the showdown info which looks like this //*** SHOW DOWN *** //JokerTKD: shows [2s 3s Ah Kh] (HI: a pair of Sixes) //DOT19: shows [As 8h Ac Kd] (HI: two pair, Aces and Sixes) //DOT19 collected $24.45 from pot //No low hand qualified //*** SUMMARY *** bool inShowdownBlock = false; for (int lineNumber = lastLineRead + 1; lineNumber < handLines.Length - 1; lineNumber++) { string line = handLines[lineNumber]; if (line.StartsWith(@"*** SUM")) { break; } if (line.StartsWith(@"*** SH")) { inShowdownBlock = true; } if (inShowdownBlock == false) { continue; } int firstSquareBracket = line.IndexOf('[', 6); if (firstSquareBracket == -1) { continue; } int lastSquareBracket = line.IndexOf(']', firstSquareBracket + 5); string cards = line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1)); string playerName = line.Substring(0, line.LastIndexLoopsBackward(':', lastSquareBracket)); playerList[playerName].HoleCards = HoleCards.FromCards(cards); } return playerList; }
private static async Task GameTimer() { await Delay(1000); var inGameList = new PlayerList().Where(p => Sync.Data.Has(User.GetPlayerServerId(p), "InGame")).ToList(); if (inGameList.Any()) { if (Sync.Data.Has(-1, "GameTimer") && (int)Sync.Data.Get(-1, "GameTimer") > 0) { if (MapManager.MapData.PlayTime == (int)Sync.Data.Get(-1, "GameTimer")) { await Delay(5000); } Sync.Data.Set(-1, "GameTimer", (int)Sync.Data.Get(-1, "GameTimer") - 1); int innocentAliveCount = 0; int traitorAliveCount = 0; foreach (var p in inGameList) { p.TriggerEvent("TTT:UpdateGameInfo", (int)Sync.Data.Get(-1, "GameTimer")); var playerId = User.GetPlayerServerId(p); if (!Sync.Data.Has(playerId, "playerType")) { continue; } if ((int)Sync.Data.Get(playerId, "playerType") == PlayerTypes.Innocent || (int)Sync.Data.Get(playerId, "playerType") == PlayerTypes.Detective) { if (!Sync.Data.Has(playerId, "isDead")) { innocentAliveCount++; } } else if ((int)Sync.Data.Get(playerId, "playerType") == PlayerTypes.Traitor) { if (!Sync.Data.Has(playerId, "isDead")) { traitorAliveCount++; } } } if (traitorAliveCount == 0) { StopGame(inGameList, PlayerTypes.Innocent); } else if (innocentAliveCount == 0) { StopGame(inGameList, PlayerTypes.Traitor); } else if ((int)Sync.Data.Get(-1, "GameTimer") < 1) { StopGame(inGameList, PlayerTypes.Innocent); } } } else if (Sync.Data.Has(-1, "GameTimer")) { Sync.Data.Reset(-1, "GameTimer"); } }
public static HandAction ParseBigBlindWithSpaces(string bbPost, PlayerList players) { string PlayerName = GetPlayerNameWithSpaces(bbPost, players); return(new HandAction(PlayerName, HandActionType.BIG_BLIND, ParseActionAmountAfterPlayer(bbPost), Street.Preflop)); }
void Teleport(Client player, string[] cmd, int iarg) { if (!player.AdminAny(Permissions.CreativeBuild | Permissions.CreativeFly)) { throw new ErrorException("Disabled"); } if (cmd.Length < 2) { throw new ShowHelpException(); } if (cmd.Length == 2) { Client toPlayer = PlayerList.GetPlayerByUsernameOrName(cmd [1]); if (toPlayer == null) { throw new ErrorException(cmd [1] + " not found"); } if (player.Session.Dimension != toPlayer.Session.Dimension) { //Does not work in vanilla yet, make warp player.Warp(toPlayer.Session.Position, toPlayer.Session.Dimension, toPlayer.Session.World); } else { player.Session.World.Send("tp " + player.MinecraftUsername + " " + toPlayer.MinecraftUsername); } return; } if (cmd.Length == 3) { Client fromPlayer = PlayerList.GetPlayerByUsernameOrName(cmd [1]); Client toPlayer = PlayerList.GetPlayerByUsernameOrName(cmd [2]); if (toPlayer == null || fromPlayer == null) { if (fromPlayer == null) { player.TellSystem(Chat.Red, cmd [1] + " not found"); } if (toPlayer == null) { player.TellSystem(Chat.Red, cmd [2] + " not found"); } return; } if (fromPlayer.Session.Dimension != toPlayer.Session.Dimension) { //Does not work in vanilla yet, make warp fromPlayer.Warp(toPlayer.Session.Position, toPlayer.Session.Dimension, toPlayer.Session.World); } else { player.Session.World.Send("tp " + fromPlayer.MinecraftUsername + " " + toPlayer.MinecraftUsername); } return; } //Here we have at least 3 args(cmd.length >= 4) if (cmd.Length < 4) { throw new UsageException("Missing: /tp x y z [dim]"); } CoordDouble pos = new CoordDouble(cmd [1], cmd [2], cmd [3]); Dimensions dimension = player.Session.Dimension; if (cmd.Length > 4) { dimension = (Dimensions)int.Parse(cmd [4]); } player.TellSystem(Chat.Purple, "warping to " + pos); player.Warp(pos, dimension, player.Session.World); }
public Winner(PlayerList playerList) { numOfPlayers = playerList.getPlayerNum(); this.playerList = playerList; }
public void Reset() { PlayerList.Clear(); }
protected override PlayerList ParsePlayers(string[] handLines) { int seatCount = Int32.Parse(NumPlayersRegex.Match(handLines[5]).Value); PlayerList playerList = new PlayerList(); for (int i = 0; i < seatCount; i++) { string handLine = handLines[6 + i]; // Expected format: // Seat 1: Velmonio ( $1.05 ) int colonIndex = handLine.IndexOf(':'); int openParenIndex = handLine.IndexOf('('); int seat = int.Parse(handLine.Substring(5, colonIndex - 5)); string playerName = handLine.Substring(colonIndex + 2, openParenIndex - colonIndex - 3); decimal amount = ParseAmount(handLine.Substring(openParenIndex + 3, handLine.Length - openParenIndex - 3 - 2)); playerList.Add(new Player(playerName, amount, seat)); } // Add hole-card info for (int i = handLines.Length - 2; i >= 0; i--) { string handLine = handLines[i]; if (handLine[0] == '*') { break; } if (handLine.EndsWith("]") && char.IsDigit(handLine[handLine.Length - 3]) == false) { // lines such as: // slyguyone2 shows [ Jd, As ] int openSquareIndex = handLine.IndexOf('['); string cards = handLine.Substring(openSquareIndex + 2, handLine.Length - openSquareIndex - 2 - 2); HoleCards holeCards = HoleCards.FromCards(cards.Replace(",", "").Replace(" ", "")); string playerName = handLine.Substring(0, openSquareIndex - 7); Player player = playerList.First(p => p.PlayerName.Equals(playerName)); player.HoleCards = holeCards; } } return playerList; }
protected override PlayerList ParsePlayers(string[] handLines) { PlayerList playerList = new PlayerList(); int lastLineRead = -1; // We start on line index 5 as first 5 lines are table and limit info. const int playerListStart = 5; const int playerListEnd = playerListStart + 10; //there may at most be 10 players for (int lineNumber = playerListStart; lineNumber < playerListEnd; lineNumber++) { string line = handLines[lineNumber]; char startChar = line[0]; char endChar = line[line.Length - 1]; //Seat 4: thaiJhonny ( $1,404 USD ) if (endChar != ')') { lastLineRead = lineNumber; break; } // seat info expected in format: //Seat 4: thaiJhonny ( $1,404 USD ) const int seatNumberStartIndex = 5; int seatNumber = FastInt.Parse(line, seatNumberStartIndex); int playerNameStartIndex = line.IndexOf(':', seatNumberStartIndex) + 2; // we need to find the ( before the number. players can have ( in their name so we need to go backwards and skip the last one int openParenIndex = line.LastIndexOf('('); string playerName = line.Substring(playerNameStartIndex, openParenIndex - playerNameStartIndex - 1); decimal stack = ParseDecimal(line, openParenIndex + 3); playerList.Add(new Player(playerName, stack, seatNumber)); } if (lastLineRead == -1) { throw new PlayersException(string.Empty, "Didn't break out of the seat reading block."); } // Looking for the showdown info which looks like this // Player1 checks // Player2 shows [ 8h, 5h, Ad, 3d ]high card Ace. // Player1 shows [ 9h, Qd, Qs, 6d ]three of a kind, Queens. // Player1 wins $72 USD from the main pot with three of a kind, Queens. for (int lineNumber = handLines.Length - 1; lineNumber > 0; lineNumber--) { //jimmyhoo: shows [7h 6h] (a full house, Sevens full of Jacks) //EASSA: mucks hand //jimmyhoo collected $562 from pot string line = handLines[lineNumber]; //Skip when player mucks and collects //EASSA: mucks hand char lastChar = line[line.Length - 1]; if (lastChar != '.') { break; } if (!line.Contains(" show")) { continue; } int lastSquareBracket = line.LastIndexOf(']'); if (lastSquareBracket == -1) { continue; } int firstSquareBracket = line.LastIndexOf('[', lastSquareBracket); // can show single cards: // Zaza5573: shows [Qc] if (line[firstSquareBracket + 3] == ']') { continue; } int nameEndIndex = GetNameEndIndex(line);// line.IndexOf(' '); string playerName = line.Remove(nameEndIndex); string cards = line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1)); playerList[playerName].HoleCards = HoleCards.FromCards(cards); } return(playerList); }
protected override PlayerList ParsePlayers(string[] handLines) { PlayerList playerList = new PlayerList(); for (int i = 2; i <= handLines.Length - 1; i++) { string handLine = handLines[i]; if (string.IsNullOrWhiteSpace(handLine) || handLine.StartsWith("Dealer:")) { break; } int firstSpaceIndex = handLine.IndexOf(' '); int openParenIndex = handLine.LastIndexOf('('); string seatInfo = handLine.Substring(openParenIndex + 1, handLine.Length - openParenIndex - 2); string[] seatData = seatInfo.Split(' '); int seatNumber = int.Parse(seatData[seatData.Length - 1]); decimal amount = decimal.Parse(seatData[1], System.Globalization.CultureInfo.InvariantCulture); string playerName = handLine.Substring(0, firstSpaceIndex); playerList.Add(new Player(playerName, amount, seatNumber)); } // Get the hole cards for (int i = handLines.Length - 1; i >= 0; i--) { string handLine = handLines[i]; if (string.IsNullOrWhiteSpace(handLine)) { continue; } if (handLine.StartsWith("Dealer:")) { break; } //IFeelFree shows: Kh - Tc if (handLine.Contains("shows:")) { int colonIndex = handLine.IndexOf(':'); string holeCards = handLine.Substring(colonIndex + 1, handLine.Length - colonIndex - 1); string playerName = handLine.Substring(0, handLine.IndexOf(' ')); Player player = playerList.First(p => p.PlayerName.Equals(playerName)); player.HoleCards = HoleCards.FromCards(holeCards.Replace(" ", "").Replace("-", "")); } //hellowkit didn't show hand (3h - Ad) else if (handLine[handLine.Length - 1] == ')' && handLine.Contains("didn't show hand")) { int openParenIndex = handLine.LastIndexOf('('); string holeCards = handLine.Substring(openParenIndex + 1, handLine.Length - openParenIndex - 2); string playerName = handLine.Substring(0, handLine.IndexOf(' ')); Player player = playerList.First(p => p.PlayerName.Equals(playerName)); player.HoleCards = HoleCards.FromCards(holeCards.Replace(" ", "").Replace("-", "")); } } return playerList; }
private HandAction GetHandActionFromEventElement(XElement eventElement, Street currentStreet, PlayerList playerList) { string actionString = eventElement.Attribute("type").Value; int actionNumber = Int32.Parse(eventElement.Attribute("sequence").Value); decimal value = 0; if (eventElement.Attribute("amount") != null) { value = decimal.Parse(eventElement.Attribute("amount").Value, System.Globalization.CultureInfo.InvariantCulture); } Player matchingPlayer = GetPlayerBySeatId(playerList, -1); if (eventElement.Attribute("player") != null) { string playerValue = eventElement.Attribute("player").Value; if (playerValue.Length > 1) { matchingPlayer = GetPlayerByName(playerList, playerValue); } else { int seatId = Int32.Parse(playerValue); matchingPlayer = GetPlayerBySeatId(playerList, seatId); } } string playerName = matchingPlayer.PlayerName; HandActionType actionType; switch (actionString) { case "FOLD": actionType = HandActionType.FOLD; break; case "SMALL_BLIND": actionType = HandActionType.SMALL_BLIND; break; case "BIG_BLIND": actionType = HandActionType.BIG_BLIND; break; case "RETURN_BLIND": actionType = HandActionType.RETURNED; break; case "INITIAL_BLIND": actionType = HandActionType.POSTS; break; case "CALL": actionType = HandActionType.CALL; break; case "CHECK": actionType = HandActionType.CHECK; break; case "BET": actionType = HandActionType.BET; break; case "ALL_IN": return(new HandAction(playerName, HandActionType.ALL_IN, value, currentStreet, true, actionNumber)); case "SHOW": actionType = HandActionType.SHOW; break; case "MUCK": actionType = HandActionType.MUCKS; break; case "GAME_CANCELLED": actionType = HandActionType.GAME_CANCELLED; break; case "SIT_OUT": case "SITTING_OUT": actionType = HandActionType.SITTING_OUT; break; case "SIT_IN": actionType = HandActionType.RETURNED; break; case "RAISE": actionType = HandActionType.RAISE; break; case "RABBIT": actionType = HandActionType.RABBIT; break; case "CHAT": actionType = HandActionType.CHAT; break; default: throw new Exception(string.Format("Encountered unknown Action Type: {0} w/ line \r\n{1}", actionString, eventElement)); } return(new HandAction(playerName, actionType, value, currentStreet, actionNumber)); }
private WinningsAction GetWinningsActionFromWinnerElement(XElement winnerElement, PlayerList playerList) { int winnerSeatId = Int32.Parse(winnerElement.Attribute("player").Value); int potNumber = Int32.Parse(winnerElement.Attribute("potnumber").Value) - 1; decimal amount = decimal.Parse(winnerElement.Attribute("amount").Value, System.Globalization.CultureInfo.InvariantCulture); Player matchingPlayer = GetPlayerBySeatId(playerList, winnerSeatId); return(new WinningsAction(matchingPlayer.PlayerName, WinningsActionType.WINS, amount, potNumber)); }
public FormPoker(string playerName, int BuyInAmount, int playerAmount, int difficulty, UserAccount user) { InitializeComponent(); this.Icon = new Icon("Poker.ico"); this.playerName = playerName; if (playerName == null) throw new ArgumentOutOfRangeException(); if (playerAmount < 2) throw new ArgumentOutOfRangeException(); this.difficulty = difficulty; if (difficulty > 2) throw new ArgumentOutOfRangeException(); this.BuyInAmount = BuyInAmount; this.playerAmount = playerAmount; timerCount = 0; //code to resize screen screenWidth = Screen.PrimaryScreen.Bounds.Width; screenHeight = Screen.PrimaryScreen.Bounds.Height; width_ratio = (screenWidth / 1366f); height_ratio = (screenHeight / 768f); SizeF scale = new SizeF(width_ratio, height_ratio); this.Scale(scale); foreach (Control control in this.Controls) { control.Font = new Font(control.Font.Name, control.Font.SizeInPoints * height_ratio * width_ratio, control.Font.Style); } cardWidth = Convert.ToInt32(71f * width_ratio); cardHeight = Convert.ToInt32(96f * height_ratio); this.user = new UserAccount(user); //add 3 archetytes randomly to list Random rand = new Random(); Player me = new Player(playerName, BuyInAmount); playerList = new PlayerList(); playerList.Add(me); lblName.Text = me.Name; List<int> AI = new List<int>(playerAmount); for (int i = 0; i < 3; i++) { AI.Add(i); } for (int i = 0; i < 4 - playerAmount; i++) { AI.Remove(rand.Next(AI.Count)); } AI = shuffle(AI); for (int i = 1; i < playerAmount; i++) { playerList.Add(new AIPlayer(BuyInAmount, difficulty, AI[i - 1])); //labelListName[i].Text = playerList[i].Name; } FormInformation Information = new FormInformation(playerList); Information.StartPosition = FormStartPosition.CenterScreen; Information.ShowDialog(); Information.Dispose(); pokerTable = new Table(playerList); }
public void AddLocalPlayer(EnemyPlayer enemy) { PlayerList.Add(enemy); UnityEngine.Debug.Log("Added player " + enemy.Name + ", now at count: " + PlayerList.Count); NotifyObservers(PlayerList.Count); }
protected override PlayerList ParsePlayers(string[] handLines) { int currentLine = 1; PlayerList plist = new PlayerList(); //Parsing playerlist for (int i = 0; i < 10; i++) { //<PLAYER NAME="fatima1975" SEAT="6" AMOUNT="4.27"></PLAYER> string Line = handLines[i + 1]; if (Line[1] != 'P') { currentLine = i + 1; break; } const int playerNameStartIndex = 14; int playerNameEndIndex = Line.IndexOf('\"', playerNameStartIndex); string playerName = Line.Substring(playerNameStartIndex, playerNameEndIndex - playerNameStartIndex); playerName = WebUtility.HtmlDecode(playerName); if (playerName == "UNKNOWN" || playerName == "") { continue; } int seatStartIndex = playerNameEndIndex + 8; int seatEndIndex = Line.IndexOf('\"', seatStartIndex); int seatNumber = FastInt.Parse(Line, seatStartIndex); int stackStartIndex = seatEndIndex + 10; int stackEndIndex = Line.IndexOf('\"', stackStartIndex); decimal stack = decimal.Parse(Line.Substring(stackStartIndex, stackEndIndex - stackStartIndex), provider); var state = GetXMLAttributeValue(Line, "STATE"); bool sitout = IsSitOutState(state); plist.Add(new Player(playerName, stack, seatNumber) { IsSittingOut = sitout }); } //Parsing dealt cards for (int i = currentLine; i < handLines.Length; i++) { string Line = handLines[i]; char firstChar = Line[1]; if (firstChar == 'A') { //<ACTION TYPE="HAND_BLINDS" PLAYER="ItalyToast" KIND="HAND_BB" VALUE="200.00"></ACTION> //<ACTION TYPE="HAND_DEAL" PLAYER="AllinAnna"> const int actionTypeCharIndex = 19; char actionTypeChar = Line[actionTypeCharIndex]; if (actionTypeChar == 'D') { string playerName = GetPlayerXMLAttributeValue(Line); ParseDealtHand(handLines, i, plist[playerName]); } } if (firstChar == 'S') { currentLine = i + 1; break; } } //Parse Showdown cards int showDownIndex = GetShowdownStartIndex(handLines); if (showDownIndex != -1) { Player currentPlayer = null; for (int i = showDownIndex; i < handLines.Length; i++) { string Line = handLines[i]; char firstChar = Line[1]; //<SHOWDOWN NAME="HAND_SHOWDOWN" POT="895.02" RAKE="15.00" MAINPOT="895.02" LEFTPOT="" RIGHTPOT="" STARTING="Player4"> //<RESULT PLAYER="Player4" WIN="0.00" HAND="$(STR_G_WIN_PAIR) $(STR_G_CARDS_DEUCES)" WINCARDS="40 1 0 9 45 "> //<CARD LINK="46"></CARD> //<CARD LINK="1"></CARD> //<CARD LINK="9"></CARD> //<CARD LINK="47"></CARD></RESULT> if (firstChar == 'R') { string playerName = GetPlayerXMLAttributeValue(Line); var player = plist[playerName]; if (!player.hasHoleCards) { currentPlayer = player; } else { currentPlayer = null; } continue; } //<CARD LINK="9"></CARD> if (firstChar == 'C' && currentPlayer != null) { Card?parsedCard = ParseCard(Line); if (parsedCard.HasValue) { if (currentPlayer.HoleCards == null) { currentPlayer.HoleCards = HoleCards.NoHolecards(); } currentPlayer.HoleCards.AddCard(parsedCard.Value); } } } } return(plist); }
private static async Task BriefingTimer() { await Delay(1000); var inGameList = new PlayerList().Where(p => Sync.Data.Has(User.GetPlayerServerId(p), "InGame")).ToList(); if (inGameList.Any()) { if (Sync.Data.Has(-1, "BriefingTimer") && (int)Sync.Data.Get(-1, "BriefingTimer") > 0) { Sync.Data.Set(-1, "BriefingTimer", (int)Sync.Data.Get(-1, "BriefingTimer") - 1); foreach (var p in inGameList) { p.TriggerEvent("TTT:UpdateBriefingInfo", (int)Sync.Data.Get(-1, "BriefingTimer")); } if ((int)Sync.Data.Get(-1, "BriefingTimer") < 1) { int traitor1 = -1; int traitor2 = -1; int traitor3 = -1; int traitor4 = -1; int detective1 = -1; int detective2 = -1; var rand = new Random(); traitor1 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); if (inGameList.Count > 7 && inGameList.Count <= 10) { traitor2 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); //detective1 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); } else if (inGameList.Count > 10 && inGameList.Count <= 16) { traitor2 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); traitor3 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); //detective1 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); } else if (inGameList.Count > 16) { traitor2 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); traitor3 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); traitor4 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); //detective1 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); //detective2 = User.GetPlayerServerId(inGameList[rand.Next(inGameList.Count)]); } Sync.Data.Set(-1, "GameTimer", MapManager.MapData.PlayTime); Sync.Data.Reset(-1, "BriefingTimer"); foreach (var p in inGameList) { p.TriggerEvent("TTT:StartGame", traitor1, traitor2, traitor3, traitor4, detective1, detective2, MapManager.MapData.PlayTime, (int)Sync.Data.Get(-1, "CameraType")); } } } } else if (Sync.Data.Has(-1, "BriefingTimer")) { Sync.Data.Reset(-1, "BriefingTimer"); } }
protected override PlayerList ParsePlayers(string[] handLines) { //Expected Start //Game started at: 2014/2/28 15:59:51 //Game ID: 258592968 2/4 Gabilite (JP) - CAP - Max - 2 (Hold'em) //Seat 4 is the button //Seat 1: xx59704 (159.21). //Seat 4: Xavier2500 (110.40). //... PlayerList playerList = new PlayerList(); int CurrentLineIndex = 3; //The first line after the player list always starts with "Player " while (handLines[CurrentLineIndex][0] == 'S') { string playerLine = handLines[CurrentLineIndex++]; const int seatNumberStart = 5; int colonIndex = playerLine.IndexOf(':', seatNumberStart + 1); int SeatNumber = int.Parse(playerLine.Substring(seatNumberStart, colonIndex - seatNumberStart)); //Parsing playerName //PlayerName can contain '(' & ')' int NameStartIndex = colonIndex + 2; int NameEndIndex = playerLine.LastIndexOfFast(" ("); string playerName = playerLine.Substring(NameStartIndex, NameEndIndex - NameStartIndex); int stackSizeStartIndex = NameEndIndex + 2; int stackSizeEndIndex = playerLine.Length - 2; string stack = playerLine.Substring(stackSizeStartIndex, stackSizeEndIndex - stackSizeStartIndex); //string playerName = playerLine.Substring(NameStartIndex, stackSizeStartIndex - NameStartIndex - 2); playerList.Add(new Player(playerName, decimal.Parse(stack, System.Globalization.CultureInfo.InvariantCulture), SeatNumber)); } //HandHistory format: //... //Player NoahSDsDad has small blind (2) //Player xx45809 sitting out //Player megadouche sitting out //Player xx59704 wait BB //Parsing Sitouts and HoleCards for (int i = CurrentLineIndex; i < handLines.Length; i++) { const int NameStartIndex = 7; string line = handLines[i]; bool receivingCards = false; int NameEndIndex; string playerName; //Uncalled bet (20) returned to zz7 if (line[0] == 'U') { break; } switch (line[line.Length - 1]) { //Player bubblebubble received card: [2h] case ']': receivingCards = true; break; case '.': //Player bubblebubble is timed out. if (line[line.Length - 2] == 't') { continue; } receivingCards = true; break; case ')': continue; case 'B': //Player bubblebubble wait BB NameEndIndex = line.Length - 8; //" wait BB".Length playerName = line.Substring(NameStartIndex, NameEndIndex - NameStartIndex); playerList[playerName].IsSittingOut = true; break; case 't': //Player xx45809 sitting out if (line[line.Length - 2] == 'u') { NameEndIndex = line.Length - 12; //" sitting out".Length playerName = line.Substring(NameStartIndex, NameEndIndex - NameStartIndex); if (playerName == "") //"Player sitting out" { continue; } playerList[playerName].IsSittingOut = true; break; } //Player TheKunttzz posts (0.25) as a dead bet else { continue; } default: throw new ArgumentException("Unhandled Line: " + line); } if (receivingCards) { CurrentLineIndex = i; break; } } //Parse HoleCards for (int i = CurrentLineIndex; i < handLines.Length; i++) { const int NameStartIndex = 7; string line = handLines[i]; char endChar = line[line.Length - 1]; if (endChar == '.') { continue; } else if (endChar == ']') { int NameEndIndex = line.LastIndexOfFast(" rec", line.Length - 12); string playerName = line.Substring(NameStartIndex, NameEndIndex - NameStartIndex); char rank = line[line.Length - 3]; char suit = line[line.Length - 2]; var player = playerList[playerName]; if (!player.hasHoleCards) { player.HoleCards = HoleCards.NoHolecards(); } if (rank == '0') { rank = 'T'; } player.HoleCards.AddCard(new Card(rank, suit)); continue; } else { break; } } //Expected End //*Player xx59704 shows: Straight to 8 [7s 4h]. Bets: 110.40. Collects: 220.30. Wins: 109.90. //Player Xavier2500 shows: Two pairs. Js and 8s [10h 8c]. Bets: 110.40. Collects: 0. Loses: 110.40. //Game ended at: for (int i = handLines.Length - playerList.Count - 1; i < handLines.Length - 1; i++) { const int WinningStartOffset = 1; const int PlayerMinLength = 7; // = "Player ".Length string summaryLine = handLines[i]; int playerNameStartIndex = PlayerMinLength + (summaryLine[0] == '*' ? WinningStartOffset : 0); int playerNameEndIndex = summaryLine.IndexOf(' ', playerNameStartIndex); int ShowIndex = summaryLine.IndexOfFast(" shows: "); if (ShowIndex != -1) { string playerName = summaryLine.Substring(playerNameStartIndex, ShowIndex - playerNameStartIndex); int pocketStartIndex = summaryLine.IndexOf('[', playerNameEndIndex) + 1; int pocketEndIndex = summaryLine.IndexOf(']', pocketStartIndex); Player showdownPlayer = playerList[playerName]; if (!showdownPlayer.hasHoleCards) { string cards = summaryLine.Substring(pocketStartIndex, pocketEndIndex - pocketStartIndex); cards = cards.Replace("10", "T"); showdownPlayer.HoleCards = HoleCards.FromCards(cards); } } } return(playerList); }
public void ParsePlayers_WaitingBB() { //Seat 1: Garzvorgh (12.79). //Seat 2: Cellar door (16.60). //Seat 3: Tr0m (25.35). //Seat 4: bubblebubble (25.80). //Seat 5: Dutch1066 (10.52). //Seat 6: ButtonSmasher (10.14). //Player ButtonSmasher has small blind (0.10) //Player Garzvorgh has big blind (0.25) //Player bubblebubble is timed out. //Player bubblebubble wait BB PlayerList players = new PlayerList() { new Player("Garzvorgh", 12.79m, 1), new Player("Cellar door", 16.60m, 2), new Player("Tr0m", 25.35m, 3), new Player("bubblebubble", 25.80m, 4) { IsSittingOut = true }, new Player("Dutch1066", 10.52m, 5), new Player("ButtonSmasher", 10.14m, 6) }; TestParsePlayers("WaitingBB", players); }
void AllBack(Client player, string[] cmd, int iarg) { player.TellSystem(Chat.Purple, "Bringin back all from the /con"); PlayerList.SetRealWorldForAllInConstruct(); }
public void Leer() { myPlayerList = JsonUtility.FromJson <PlayerList>(textJSON.text); print(myPlayerList); }
protected override Player ParseUser(string[] handLines, PlayerList playerList) { throw new NotImplementedException(); }
/// <summary> /// Constructor. /// </summary> public MainMenu() { PlayersList = Players; #region cleanup unused kvps int tmp_kvp_handle = StartFindKvp(""); bool cleanupVersionChecked = false; List <string> tmp_kvp_names = new List <string>(); while (true) { string k = FindKvp(tmp_kvp_handle); if (string.IsNullOrEmpty(k)) { break; } if (k == "vmenu_cleanup_version") { if (GetResourceKvpInt("vmenu_cleanup_version") >= currentCleanupVersion) { cleanupVersionChecked = true; } } } EndFindKvp(tmp_kvp_handle); if (!cleanupVersionChecked) { SetResourceKvpInt("vmenu_cleanup_version", currentCleanupVersion); foreach (string kvp in tmp_kvp_names) { if (currentCleanupVersion == 1) { if (!kvp.StartsWith("settings_") && !kvp.StartsWith("vmenu") && !kvp.StartsWith("veh_") && !kvp.StartsWith("ped_") && !kvp.StartsWith("mp_ped_")) { DeleteResourceKvp(kvp); Debug.WriteLine($"[vMenu] Old unused KVP cleaned up: {kvp}."); } } } Debug.WriteLine("[vMenu] Cleanup of old unused KVP items completed."); } #endregion if (EnableExperimentalFeatures || DebugMode) { RegisterCommand("testped", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) => { PedHeadBlendData data = Game.PlayerPed.GetHeadBlendData(); Debug.WriteLine(JsonConvert.SerializeObject(data, Formatting.Indented)); }), false); RegisterCommand("tattoo", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) => { if (args != null && args[0] != null && args[1] != null) { Debug.WriteLine(args[0].ToString() + " " + args[1].ToString()); TattooCollectionData d = Game.GetTattooCollectionData(int.Parse(args[0].ToString()), int.Parse(args[1].ToString())); Debug.WriteLine("check"); Debug.Write(JsonConvert.SerializeObject(d, Formatting.Indented) + "\n"); } }), false); } RegisterCommand("vmenuclient", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) => { if (args != null) { if (args.Count > 0) { if (args[0].ToString().ToLower() == "debug") { DebugMode = !DebugMode; Notify.Custom($"Debug mode is now set to: {DebugMode}."); // Set discord rich precense once, allowing it to be overruled by other resources once those load. if (DebugMode) { SetRichPresence($"Debugging vMenu {Version}!"); } else { SetRichPresence($"Enjoying FiveM!"); } } else if (args[0].ToString().ToLower() == "gc") { GC.Collect(); Debug.Write("Cleared memory.\n"); } else if (args[0].ToString().ToLower() == "dump") { Notify.Info("A full config dump will be made to the console. Check the log file. This can cause lag!"); Debug.WriteLine("\n\n\n########################### vMenu ###########################"); Debug.WriteLine($"Running vMenu Version: {Version}, Experimental features: {EnableExperimentalFeatures}, Debug mode: {DebugMode}."); Debug.WriteLine("\nDumping a list of all KVPs:"); int handle = StartFindKvp(""); List <string> names = new List <string>(); while (true) { string k = FindKvp(handle); if (string.IsNullOrEmpty(k)) { break; } //if (!k.StartsWith("settings_") && !k.StartsWith("vmenu") && !k.StartsWith("veh_") && !k.StartsWith("ped_") && !k.StartsWith("mp_ped_")) //{ // DeleteResourceKvp(k); //} names.Add(k); } EndFindKvp(handle); Dictionary <string, dynamic> kvps = new Dictionary <string, dynamic>(); foreach (var kvp in names) { int type = 0; // 0 = string, 1 = float, 2 = int. if (kvp.StartsWith("settings_")) { if (kvp == "settings_voiceChatProximity") // float { type = 1; } else if (kvp == "settings_clothingAnimationType") // int { type = 2; } } else if (kvp == "vmenu_cleanup_version") // int { type = 2; } switch (type) { case 0: var s = GetResourceKvpString(kvp); if (s.StartsWith("{") || s.StartsWith("[")) { kvps.Add(kvp, JsonConvert.DeserializeObject(s)); } else { kvps.Add(kvp, GetResourceKvpString(kvp)); } break; case 1: kvps.Add(kvp, GetResourceKvpFloat(kvp)); break; case 2: kvps.Add(kvp, GetResourceKvpInt(kvp)); break; } } Debug.WriteLine(@JsonConvert.SerializeObject(kvps, Formatting.None) + "\n"); Debug.WriteLine("\n\nDumping a list of allowed permissions:"); Debug.WriteLine(@JsonConvert.SerializeObject(Permissions, Formatting.None)); Debug.WriteLine("\n\nDumping vmenu server configuration settings:"); var settings = new Dictionary <string, string>(); foreach (var a in Enum.GetValues(typeof(Setting))) { settings.Add(a.ToString(), GetSettingsString((Setting)a)); } Debug.WriteLine(@JsonConvert.SerializeObject(settings, Formatting.None)); Debug.WriteLine("\nEnd of vMenu dump!"); Debug.WriteLine("\n########################### vMenu ###########################"); } } else { Notify.Custom($"vMenu is currently running version: {Version}."); } } }), false); // Set discord rich precense once, allowing it to be overruled by other resources once those load. if (DebugMode) { SetRichPresence($"Debugging vMenu {Version}!"); } if (GetCurrentResourceName() != "vMenu") { Exception InvalidNameException = new Exception("\r\n\r\n[vMenu] INSTALLATION ERROR!\r\nThe name of the resource is not valid. Please change the folder name from '" + GetCurrentResourceName() + "' to 'vMenu' (case sensitive) instead!\r\n\r\n\r\n"); try { throw InvalidNameException; } catch (Exception e) { Log(e.Message); } TriggerEvent("chatMessage", "^3IMPORTANT: vMenu IS NOT SETUP CORRECTLY. PLEASE CHECK THE SERVER LOG FOR MORE INFO."); MenuController.MainMenu = null; MenuController.DontOpenAnyMenu = true; MenuController.DisableMenuButtons = true; } else { Tick += OnTick; } try { SetClockDate(DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year); } catch (InvalidTimeZoneException timeEx) { Debug.WriteLine($"[vMenu] [Error] Could not set the in-game day, month and year because of an invalid timezone(?)."); Debug.WriteLine($"[vMenu] [Error] InvalidTimeZoneException: {timeEx.Message}"); Debug.WriteLine($"[vMenu] [Error] vMenu will continue to work normally."); } }
private static async Task LobbyTimer() { await Delay(1000); var lobbyList = new PlayerList().Where(p => Sync.Data.Has(User.GetPlayerServerId(p), "Lobby")).ToList(); if (lobbyList.Any()) { if (Sync.Data.Has(-1, "StartTimer") && (int)Sync.Data.Get(-1, "StartTimer") > 0) { Sync.Data.Set(-1, "StartTimer", (int)Sync.Data.Get(-1, "StartTimer") - 1); int voteCam1 = 0; int voteCam2 = 0; foreach (var player in new PlayerList()) { if (!Sync.Data.Has(User.GetPlayerServerId(player), "CameraType")) { continue; } if ((int)Sync.Data.Get(User.GetPlayerServerId(player), "CameraType") == 0) { voteCam1++; } else { voteCam2++; } } foreach (var p in lobbyList) { p.TriggerEvent("TTT:UpdateLobbyInfo", (int)Sync.Data.Get(-1, "StartTimer"), voteCam1, voteCam2, lobbyList.Count); } if ((int)Sync.Data.Get(-1, "StartTimer") > 15) { if (lobbyList.Count / 2 <= voteCam1 + voteCam2) { Sync.Data.Set(-1, "StartTimer", 10); } } if ((int)Sync.Data.Get(-1, "StartTimer") < 1) { Sync.Data.Reset(-1, "StartTimer"); Sync.Data.Set(-1, "CameraType", voteCam1 > voteCam2 ? 0 : 1); if (await MapManager.LoadMap(MapManager.GetMap(), lobbyList)) { var weatherList = new List <string> { "EXTRASUNNY", "CLEAR", "CLOUDS", "SMOG", "FOGGY", "OVERCAST", "CLEARING", "XMAS" }; var rand = new Random(); string weatherMap = weatherList[rand.Next(weatherList.Count)]; int hourMap = rand.Next(23); Sync.Data.Set(-1, "BriefingTimer", MapManager.MapData.Briefing); foreach (var p in lobbyList) { Sync.Data.Set(User.GetPlayerServerId(p), "InGame", true); p.TriggerEvent("TTT:StartBriefing", MapManager.MapData.Name, MapManager.MapData.Briefing, MapManager.MapData.CenterX, MapManager.MapData.CenterY, MapManager.MapData.CenterZ, MapManager.MapData.MaxRadius, MapManager.MapData.CanSwim, MapManager.MapData.EnableScope, weatherMap, hourMap); } } else { MapManager.SetMap(MapManager.MapList.First()); StopGame(lobbyList, PlayerTypes.Unknown); } foreach (var player in new PlayerList()) { Sync.Data.Reset(User.GetPlayerServerId(player), "CameraType"); Sync.Data.Reset(User.GetPlayerServerId(player), "Lobby"); } } } } else if (Sync.Data.Has(-1, "StartTimer")) { Sync.Data.Reset(-1, "StartTimer"); } }
protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { if (firstActivation) { //Set up UI SetTitle("比赛", ViewController.AnimationType.None); showBackButton = true; _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModel>().First(); _menuLightsManager = Resources.FindObjectsOfTypeAll <MenuLightsManager>().First(); _soloFreePlayFlowCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First(); _resultsViewController = Resources.FindObjectsOfTypeAll <ResultsViewController>().First(); _scoreLights = _soloFreePlayFlowCoordinator.GetField <MenuLightsPresetSO>("_resultsClearedLightsPreset"); _defaultLights = _soloFreePlayFlowCoordinator.GetField <MenuLightsPresetSO>("_defaultLightsPreset"); _songSelection = BeatSaberUI.CreateViewController <SongSelection>(); _songSelection.SongSelected += SongSelection_SongSelected; _splashScreen = BeatSaberUI.CreateViewController <SplashScreen>(); _songDetail = BeatSaberUI.CreateViewController <SongDetail>(); _songDetail.PlayPressed += SongDetail_didPressPlayButtonEvent; _songDetail.DifficultyBeatmapChanged += SongDetail_didChangeDifficultyBeatmapEvent; _playerList = BeatSaberUI.CreateViewController <PlayerList>(); } if (addedToHierarchy) { TournamentMode = Match == null; if (TournamentMode) { _splashScreen.StatusText = $"正在连接服务器 \"{Host.Name}\"..."; ProvideInitialViewControllers(_splashScreen); } else { //If we're not in tournament mode, then a client connection has already been made //by the room selection screen, so we can just assume Plugin.client isn't null //NOTE: This is *such* a hack. Oh my god. isHost = Match.Leader == Plugin.client.Self; _songSelection.SetSongs(SongUtils.masterLevelList); _playerList.Players = Match.Players; _splashScreen.StatusText = "请等待房主选择歌曲..."; if (isHost) { ProvideInitialViewControllers(_songSelection, _playerList); } else { ProvideInitialViewControllers(_splashScreen, _playerList); } } } //The ancestor sets up the server event listeners //It would be possible to recieve an event that does a ui update after this call //and before the rest of the ui is set up, if we did this at the top. //So, we do it last base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling); }
public void Leave(Player pPlayer) { PlayerList.Remove(pPlayer); BroadcastGame(); }
public void SortByScore() { PlayerList.Sort((p1, p2) => p1.CurrentScore.CompareTo(p2.CurrentScore)); }
public World(IServiceProvider serviceProvider, GraphicsDevice graphics, AlexOptions options, Camera camera, INetworkProvider networkProvider) { Graphics = graphics; Camera = camera; Options = options; PhysicsEngine = new PhysicsManager(this); ChunkManager = new ChunkManager(serviceProvider, graphics, this); EntityManager = new EntityManager(graphics, this, networkProvider); Ticker = new TickManager(); PlayerList = new PlayerList(); ChunkManager.Start(); var settings = serviceProvider.GetRequiredService <IOptionsProvider>(); var profileService = serviceProvider.GetRequiredService <IPlayerProfileService>(); var resources = serviceProvider.GetRequiredService <ResourceManager>(); EventDispatcher = serviceProvider.GetRequiredService <IEventDispatcher>(); string username = string.Empty; Skin skin = profileService?.CurrentProfile?.Skin; if (skin == null) { resources.ResourcePack.TryGetBitmap("entity/alex", out var rawTexture); var t = TextureUtils.BitmapToTexture2D(graphics, rawTexture); skin = new Skin() { Texture = t, Slim = true }; } if (!string.IsNullOrWhiteSpace(profileService?.CurrentProfile?.Username)) { username = profileService.CurrentProfile.Username; } Player = new Player(graphics, serviceProvider.GetRequiredService <Alex>().InputManager, username, this, skin, networkProvider, PlayerIndex.One, camera); Player.KnownPosition = new PlayerLocation(GetSpawnPoint()); Camera.MoveTo(Player.KnownPosition, Vector3.Zero); Options.FieldOfVision.ValueChanged += FieldOfVisionOnValueChanged; Camera.FOV = Options.FieldOfVision.Value; PhysicsEngine.AddTickable(Player); if (networkProvider is BedrockClient) { Player.SetInventory(new BedrockInventory(46)); } // Player.Inventory.IsPeInventory = true; /*if (ItemFactory.TryGetItem("minecraft:diamond_sword", out var sword)) * { * Player.Inventory[Player.Inventory.SelectedSlot] = sword; * Player.Inventory.MainHand = sword; * } * else * { * Log.Warn($"Could not get diamond sword!"); * }*/ EventDispatcher.RegisterEvents(this); FormManager = new BedrockFormManager(networkProvider, serviceProvider.GetRequiredService <GuiManager>(), serviceProvider.GetService <Alex>().InputManager); SkyRenderer = new SkyBox(serviceProvider, graphics, this); //SkyLightCalculations = new SkyLightCalculations(); UseDepthMap = options.VideoOptions.Depthmap; options.VideoOptions.Depthmap.Bind((old, newValue) => { UseDepthMap = newValue; }); ServerType = (networkProvider is BedrockClient) ? ServerType.Bedrock : ServerType.Java; }
public void UpdateCityOfPlayer(string playerId, string cityName) { PlayerList.Find(e => e.playerId.Equals(playerId))?.UpdateCurCityName(cityName); }
protected override PlayerList ParsePlayers(string[] handLines) { PlayerList playerList = new PlayerList(); int lastLineRead = -1; // We start on line index 2 as first 2 lines are table and limit info. for (int lineNumber = 2; lineNumber < handLines.Length - 1; lineNumber++) { string line = handLines[lineNumber]; char startChar = line[0]; char endChar = line[line.Length - 1]; //Seat 1: thaiJhonny ($16.08 in chips) if (endChar != ')') { lastLineRead = lineNumber; break; } // seat info expected in format: //Seat 1: thaiJhonny ($16.08 in chips) const int seatNumberStartIndex = 4; int spaceIndex = line.IndexOf(' ', seatNumberStartIndex); int colonIndex = line.IndexOf(':', spaceIndex + 1); int seatNumber = FastInt.Parse(line, spaceIndex + 1); // we need to find the ( before the number. players can have ( in their name so we need to go backwards and skip the last one int openParenIndex = line.LastIndexOf('('); int spaceAfterOpenParen = line.IndexOf(' ', openParenIndex); // add 2 so we skip the $ and first # always string playerName = line.Substring(colonIndex + 2, (openParenIndex - 1) - (colonIndex + 2)); string stackString = line.Substring(openParenIndex + 2, spaceAfterOpenParen - (openParenIndex + 2)); decimal stack = decimal.Parse(stackString, System.Globalization.CultureInfo.InvariantCulture); playerList.Add(new Player(playerName, stack, seatNumber)); } if (lastLineRead == -1) { throw new PlayersException(string.Empty, "Didn't break out of the seat reading block."); } // Looking for the showdown info which looks like this //*** SHOW DOWN *** //JokerTKD: shows [2s 3s Ah Kh] (HI: a pair of Sixes) //DOT19: shows [As 8h Ac Kd] (HI: two pair, Aces and Sixes) //DOT19 collected $24.45 from pot //No low hand qualified //*** SUMMARY *** int summaryIndex = GetSummaryStartIndex(handLines, lastLineRead); int showDownIndex = GetShowDownStartIndex(handLines, lastLineRead, summaryIndex); //Starting from the bottom to parse faster if (showDownIndex != -1) { for (int lineNumber = showDownIndex + 1; lineNumber < summaryIndex; lineNumber++) { //jimmyhoo: shows [7h 6h] (a full house, Sevens full of Jacks) //EASSA: mucks hand //jimmyhoo collected $562 from pot string line = handLines[lineNumber]; //Skip when player mucks and collects //EASSA: mucks hand char lastChar = line[line.Length - 1]; if (lastChar == 'd' || lastChar == 't') { continue; } int lastSquareBracket = line.LastIndexLoopsBackward(']', line.Length - 1); if (lastSquareBracket == -1) { continue; } int firstSquareBracket = line.LastIndexOf('[', lastSquareBracket); // can show single cards: // Zaza5573: shows [Qc] if (line[firstSquareBracket + 3] == ']') { continue; } int colonIndex = line.LastIndexOf(':', firstSquareBracket); if (colonIndex == -1) { // players with [ in their name // [PS_UA]Tarik collected $18.57 from pot continue; } string playerName = line.Substring(0, colonIndex); string cards = line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1)); playerList[playerName].HoleCards = HoleCards.FromCards(cards); } } return playerList; }
protected override PlayerList ParsePlayers(string[] handLines) { /* * <player seat="3" name="RodriDiaz3" chips="$2.25" dealer="0" win="$0" bet="$0.08" rebuy="0" addon="0" /> * <player seat="8" name="Kristi48ru" chips="$6.43" dealer="1" win="$0.23" bet="$0.16" rebuy="0" addon="0" /> * or * <player seat="5" name="player5" chips="$100000" dealer="0" win="$0" bet="$0" /> */ string[] playerLines = GetPlayerLinesFromHandLines(handLines); PlayerList playerList = new PlayerList(); for (int i = 0; i < playerLines.Length; i++) { string playerName = GetNameFromPlayerLine(playerLines[i]); decimal stack = GetStackFromPlayerLine(playerLines[i]); int seat = GetSeatNumberFromPlayerLine(playerLines[i]); playerList.Add(new Player(playerName, stack, seat) { IsSittingOut = true }); } XDocument xDocument = GetXDocumentFromLines(handLines); List <XElement> actionElements = xDocument.Element("root").Element("session").Element("game").Elements("round").Elements("action"). ToList(); foreach (Player player in playerList) { List <XElement> playerActions = actionElements.Where(action => action.Attribute("player").Value.Equals(player.PlayerName)).ToList(); if (playerActions.Count == 0) { //Players are marked as sitting out by default, we don't need to update continue; } //Sometimes the first and only action for a player is to sit out - we should still treat them as sitting out bool playerSitsOutAsAction = playerActions[0].Attribute("type").Value == "8"; if (playerSitsOutAsAction) { continue; } player.IsSittingOut = false; } /* * Grab known hole cards for players and add them to the player * <cards type="Pocket" player="pepealas5">CA CK</cards> */ string[] cardLines = GetCardLinesFromHandLines(handLines); for (int i = 0; i < cardLines.Length; i++) { string handLine = cardLines[i]; handLine = handLine.TrimStart(); //To make sure we know the exact character location of each card, turn 10s into Ts (these are recognized by our parser) //Had to change this to specific cases so we didn't accidentally change player names handLine = handLine.Replace("10 ", "T "); handLine = handLine.Replace("10<", "T<"); //We only care about Pocket Cards if (handLine[13] != 'P') { continue; } //When players fold, we see a line: //<cards type="Pocket" player="pepealas5">X X</cards> //or: //<cards type="Pocket" player="playername"></cards> //We skip these lines if (handLine[handLine.Length - 9] == 'X' || handLine[handLine.Length - 9] == '>') { continue; } int playerNameStartIndex = 29; int playerNameEndIndex = handLine.IndexOf('"', playerNameStartIndex) - 1; string playerName = handLine.Substring(playerNameStartIndex, playerNameEndIndex - playerNameStartIndex + 1); Player player = playerList.First(p => p.PlayerName.Equals(playerName)); int playerCardsStartIndex = playerNameEndIndex + 3; int playerCardsEndIndex = handLine.Length - 9; string playerCardString = handLine.Substring(playerCardsStartIndex, playerCardsEndIndex - playerCardsStartIndex + 1); string[] cards = playerCardString.Split(' '); if (cards.Length > 1) { player.HoleCards = HoleCards.NoHolecards(player.PlayerName); foreach (string card in cards) { //Suit and rank are reversed in these strings, so we flip them around before adding player.HoleCards.AddCard(new Card(card[1], card[0])); } } } return(playerList); }
private Rep() { _players = new PlayerList(); }
public World(IServiceProvider serviceProvider, GraphicsDevice graphics, AlexOptions options, NetworkProvider networkProvider) { Graphics = graphics; Options = options; PhysicsEngine = new PhysicsManager(this); ChunkManager = new ChunkManager(serviceProvider, graphics, this); EntityManager = new EntityManager(graphics, this, networkProvider); Ticker = new TickManager(); PlayerList = new PlayerList(); Ticker.RegisterTicked(this); Ticker.RegisterTicked(EntityManager); //Ticker.RegisterTicked(PhysicsEngine); Ticker.RegisterTicked(ChunkManager); ChunkManager.Start(); var profileService = serviceProvider.GetRequiredService <IPlayerProfileService>(); var resources = serviceProvider.GetRequiredService <ResourceManager>(); EventDispatcher = serviceProvider.GetRequiredService <IEventDispatcher>(); string username = string.Empty; PooledTexture2D texture; if (Alex.PlayerTexture != null) { texture = TextureUtils.BitmapToTexture2D(graphics, Alex.PlayerTexture); } else { resources.ResourcePack.TryGetBitmap("entity/alex", out var rawTexture); texture = TextureUtils.BitmapToTexture2D(graphics, rawTexture); } Skin skin = profileService?.CurrentProfile?.Skin; if (skin == null) { skin = new Skin() { Texture = texture, Slim = true }; } if (!string.IsNullOrWhiteSpace(profileService?.CurrentProfile?.Username)) { username = profileService.CurrentProfile.Username; } Player = new Player(graphics, serviceProvider.GetRequiredService <Alex>().InputManager, username, this, skin, networkProvider, PlayerIndex.One); Camera = new EntityCamera(Player); if (Alex.PlayerModel != null) { EntityModelRenderer modelRenderer = new EntityModelRenderer(Alex.PlayerModel, texture); if (modelRenderer.Valid) { Player.ModelRenderer = modelRenderer; } } Player.KnownPosition = new PlayerLocation(GetSpawnPoint()); Options.FieldOfVision.ValueChanged += FieldOfVisionOnValueChanged; Camera.FOV = Options.FieldOfVision.Value; PhysicsEngine.AddTickable(Player); EventDispatcher.RegisterEvents(this); var guiManager = serviceProvider.GetRequiredService <GuiManager>(); InventoryManager = new InventoryManager(guiManager); SkyRenderer = new SkyBox(serviceProvider, graphics, this); options.VideoOptions.RenderDistance.Bind( (old, newValue) => { Camera.SetRenderDistance(newValue); }); Camera.SetRenderDistance(options.VideoOptions.RenderDistance); }
public override void LoadControllers() { Controllers = PlayerList.Load("text/discord/controllers.txt"); }
protected override PlayerList ParsePlayers(string[] handLines) { /* <player seat="3" name="RodriDiaz3" chips="$2.25" dealer="0" win="$0" bet="$0.08" rebuy="0" addon="0" /> <player seat="8" name="Kristi48ru" chips="$6.43" dealer="1" win="$0.23" bet="$0.16" rebuy="0" addon="0" /> */ string[] playerLines = GetPlayerLinesFromHandLines(handLines); PlayerList playerList = new PlayerList(); for (int i = 0; i < playerLines.Length; i++) { string playerName = GetNameFromPlayerLine(playerLines[i]); decimal stack = GetStackFromPlayerLine(playerLines[i]); int seat = GetSeatNumberFromPlayerLine(playerLines[i]); playerList.Add(new Player(playerName, stack, seat) { IsSittingOut = true }); } XDocument xDocument = GetXDocumentFromLines(handLines); List<XElement> actionElements = xDocument.Element("root").Element("session").Element("game").Elements("round").Elements("action"). ToList(); foreach (Player player in playerList) { List<XElement> playerActions = actionElements.Where(action => action.Attribute("player").Value.Equals(player.PlayerName)).ToList(); if (playerActions.Count == 0) { //Players are marked as sitting out by default, we don't need to update continue; } //Sometimes the first and only action for a player is to sit out - we should still treat them as sitting out bool playerSitsOutAsAction = playerActions[0].Attribute("type").Value == "8"; if (playerSitsOutAsAction) { continue; } player.IsSittingOut = false; } /* * Grab known hole cards for players and add them to the player * <cards type="Pocket" player="pepealas5">CA CK</cards> */ string[] cardLines = GetCardLinesFromHandLines(handLines); for (int i = 0; i < cardLines.Length; i++) { string handLine = cardLines[i]; handLine = handLine.TrimStart(); //To make sure we know the exact character location of each card, turn 10s into Ts (these are recognized by our parser) //Had to change this to specific cases so we didn't accidentally change player names handLine = handLine.Replace("10 ", "T "); handLine = handLine.Replace("10<", "T<"); //We only care about Pocket Cards if (handLine[13] != 'P') { continue; } //When players fold, we see a line: <cards type="Pocket" player="pepealas5">X X</cards>, we should skip these lines if (handLine[handLine.Length - 9] == 'X') { continue; } int playerNameStartIndex = 29; int playerNameEndIndex = handLine.IndexOf('"', playerNameStartIndex) - 1; string playerName = handLine.Substring(playerNameStartIndex, playerNameEndIndex - playerNameStartIndex + 1); Player player = playerList.First(p => p.PlayerName.Equals(playerName)); int playerCardsStartIndex = playerNameEndIndex + 3; int playerCardsEndIndex = handLine.Length - 9; string playerCardString = handLine.Substring(playerCardsStartIndex, playerCardsEndIndex - playerCardsStartIndex + 1); string[] cards = playerCardString.Split(' '); foreach (string card in cards) { //Suit and rank are reversed in these strings, so we flip them around before adding player.HoleCards.AddCard(new Card(card[1], card[0])); } } return playerList; }
protected override PlayerList ParsePlayers(string[] handLines) { PlayerList playerList = new PlayerList(); for (int i = 1; i < 12; i++) { string handLine = handLines[i]; var sittingOut = false; if (handLine.StartsWith("Seat ") == false) { break; } if (handLine.EndsWith(")") == false) { // handline is like Seat 6: ffbigfoot ($0.90), is sitting out handLine = handLine.Substring(0, handLine.Length - 16); sittingOut = true; } //Seat 1: CardBluff ($109.65) int colonIndex = handLine.IndexOf(':', 5); int parenIndex = handLine.IndexOf('(', colonIndex + 2); int seat = Int32.Parse(handLine.Substring(colonIndex - 2, 2)); string name = handLine.Substring(colonIndex + 2, parenIndex - 1 - colonIndex - 2); string stackSizeString = handLine.Substring(parenIndex + 1, handLine.Length - 1 - parenIndex - 1); decimal amount = decimal.Parse(stackSizeString, NumberStyles.AllowCurrencySymbol | NumberStyles.Number, NumberFormatInfo); playerList.Add(new Player(name, amount, seat) { IsSittingOut = sittingOut }); } // OmahaHiLo has a different way of storing the hands at showdown, so we need to separate bool isOmahaHiLo = ParseGameType(handLines).Equals(GameType.PotLimitOmahaHiLo); int ShowStartIndex = -1; const int FirstPossibleShowActionIndex = 13; for (int i = FirstPossibleShowActionIndex; i < handLines.Length; i++) { string line = handLines[i]; if (line[line.Length - 1] == ']' && line.Contains(" shows [")) { ShowStartIndex = i; break; } if (line.StartsWith(@"*** SUM", StringComparison.Ordinal) && isOmahaHiLo) { ShowStartIndex = i; break; } else if (line.StartsWith(@"*** SH", StringComparison.Ordinal) && !isOmahaHiLo) { ShowStartIndex = i; break; } } if (ShowStartIndex != -1) { for (int lineNumber = ShowStartIndex; lineNumber < handLines.Length; lineNumber++) { string line = handLines[lineNumber]; int firstSquareBracket = line.LastIndexOf('['); if (firstSquareBracket == -1) { continue; } // can show single cards if (line[firstSquareBracket + 3] == ']') { continue; } int lastSquareBracket = line.LastIndexLoopsBackward(']', line.Length - 1); int colonIndex = line.LastIndexLoopsBackward(':', lastSquareBracket); string playerName; //if (isOmahaHiLo) //{ // seat = line.Substring(5, colonIndex - 5); // playerName = playerList.First(p => p.SeatNumber.Equals(Convert.ToInt32(seat))).PlayerName; //} //else //{ int playerNameEndIndex = line.IndexOf(" shows", StringComparison.Ordinal); if (playerNameEndIndex == -1) break; playerName = line.Substring(0, playerNameEndIndex); //} string cards = line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1)); playerList[playerName].HoleCards = HoleCards.FromCards(cards); } } return playerList; }
protected override List <HandAction> ParseHandActions(string[] handLines, GameType gameType, out List <WinningsAction> winners) { const int MinimumLinesWithoutActions = 8; //Allocate the full list so we we dont get a reallocation for every add() List <HandAction> handActions = new List <HandAction>(handLines.Length - MinimumLinesWithoutActions); winners = new List <WinningsAction>(); Street currentStreet = Street.Preflop; PlayerList playerList = ParsePlayers(handLines); bool PlayerWithSpaces = playerList.FirstOrDefault(p => p.PlayerName.Contains(" ")) != null; //Skipping PlayerList int ActionsStart = GetActionStart(handLines); //Parsing Fixed Actions if (PlayerWithSpaces) { ActionsStart = SkipSitOutLines(handLines, ActionsStart); handActions.Add(ParseSmallBlindWithSpaces(handLines[ActionsStart++], playerList)); ActionsStart = SkipSitOutLines(handLines, ActionsStart); handActions.Add(ParseBigBlindWithSpaces(handLines[ActionsStart++], playerList)); } else { ActionsStart = SkipSitOutLines(handLines, ActionsStart); handActions.Add(ParseSmallBlind(handLines[ActionsStart++])); ActionsStart = SkipSitOutLines(handLines, ActionsStart); handActions.Add(ParseBigBlind(handLines[ActionsStart++])); } ActionsStart = ParsePosts(handLines, handActions, ActionsStart); //Skipping all "received a card." ActionsStart = SkipDealer(handLines, ActionsStart); //ParseActions for (int i = ActionsStart; i < handLines.Length; i++) { string actionLine = handLines[i]; if (actionLine[0] == 'P') { var action = ParseRegularAction(actionLine, currentStreet, playerList, handActions, PlayerWithSpaces); if (action != null) { handActions.Add(action); } } else if (actionLine[0] == '*') { //*** FLOP ***: [10s 9c 2c] currentStreet = ParseNextStreet(actionLine); } else if (actionLine[0] == 'U') { const string UncalledBet = ") returned to "; string playerName = actionLine.Substring(actionLine.IndexOfFast(UncalledBet) + UncalledBet.Length); handActions.Add(new HandAction(playerName, HandActionType.UNCALLED_BET, ParseActionAmountBeforePlayer(actionLine), currentStreet)); } else if (actionLine[0] == '-') { ActionsStart = i++; break; } } //expected Summary //------ Summary ------ //Pot: 14.95. Rake 0.80 //Board: [5c 8s 4h 10c 10s] for (int i = ActionsStart + 2; i < handLines.Length; i++) { string actionLine = handLines[i]; //Parse winning action if (actionLine[0] == '*') { var action = ParseWinningsAction(actionLine, playerList, PlayerWithSpaces); winners.Add(action); } } return(handActions); }
public int GetRankOfPlayer(string playerId) { // ignoring found = null since this gets handled in main func anyways return(GetRankOfPlayer(PlayerList.Find(p => p.playerId.Equals(playerId)))); }
public static HandAction ParseRegularAction(string line, Street currentStreet, PlayerList playerList, List <HandAction> actions, bool PlayerWithSpaces) { string PlayerName = PlayerWithSpaces ? GetPlayerNameWithSpaces(line, playerList) : GetPlayerNameWithoutSpaces(line); int actionIDIndex = actionPlayerNameStartIndex + PlayerName.Length + 1; char actionID = line[actionIDIndex]; switch (actionID) { //Player PersnicketyBeagle folds case 'f': return(new HandAction(PlayerName, HandActionType.FOLD, 0, currentStreet)); case 'r': return(new HandAction(PlayerName, HandActionType.RAISE, ParseActionAmountAfterPlayer(line), currentStreet)); //checks or calls case 'c': //Player butta21 calls (20) //Player jayslowplay caps (3.50) //Player STOPCRYINGB79 checks char actionID2 = line[actionIDIndex + 2]; if (actionID2 == 'e') { return(new HandAction(PlayerName, HandActionType.CHECK, 0, currentStreet)); } else if (actionID2 == 'l') { return(new HandAction(PlayerName, HandActionType.CALL, ParseActionAmountAfterPlayer(line), currentStreet)); } else if (actionID2 == 'p') { var capAmount = ParseActionAmountAfterPlayer(line); var capActionType = AllInActionHelper.GetAllInActionType(PlayerName, capAmount, currentStreet, actions); return(new HandAction(PlayerName, capActionType, capAmount, currentStreet, true)); } else { throw new NotImplementedException("HandActionType: " + line); } case 'b': if (currentStreet == Street.Preflop) { return(new HandAction(PlayerName, HandActionType.RAISE, ParseActionAmountAfterPlayer(line), currentStreet)); } else { return(new HandAction(PlayerName, HandActionType.BET, ParseActionAmountAfterPlayer(line), currentStreet)); } //Player PersnicketyBeagle allin (383) case 'a': var allinAmount = ParseActionAmountAfterPlayer(line); var allinActionType = AllInActionHelper.GetAllInActionType(PlayerName, allinAmount, currentStreet, actions); return(new HandAction(PlayerName, allinActionType, allinAmount, currentStreet, true)); case 'm': //Player PersnicketyBeagle mucks cards case 'i': //Player ECU7184 is timed out. return(null); } throw new HandActionException(line, "HandActionType: " + line); }