public Table(BitPoker.Models.Contracts.Table table) { viewModel = new ViewModels.TableViewModel(table); this.DataContext = viewModel; InitializeComponent(); }
public void AddNewTable(UInt64 smallBlind, UInt64 bigBlind, UInt64 minBuyIn, UInt64 maxBuyIn, Int16 minPlayers, Int16 maxPlayers) { BitPoker.Models.Contracts.Table table = new BitPoker.Models.Contracts.Table() { SmallBlind = smallBlind, BigBlind = bigBlind, MinBuyIn = minBuyIn, MaxBuyIn = maxBuyIn, MinPlayers = minPlayers, MaxPlayers = maxPlayers, NetworkAddress = "p2p" }; if (!table.IsValid()) { throw new AggregateException("Invalid table params"); } //Check for duplicates using (BitPoker.Repository.ITableRepository tableRepo = new BitPoker.Repository.LiteDB.TableRepository(@"poker.db")) { tableRepo.Add(table); tableRepo.Save(); } }
public void Should_Get_Table_Redeem_Script() { //Arrange //Table as per the readme BitPoker.Models.Contracts.Table table = new BitPoker.Models.Contracts.Table(2, 2) { Id = new Guid("bf368921-346a-42d8-9cb8-621f9cad5e16"), BigBlind = 10000, SmallBlind = 5000, MinBuyIn = 100000, MaxBuyIn = 200000, MinPlayers = 2, MaxPlayers = 2, HashAlgorithm = "SHA256" }; BitPoker.Models.Peer alice = new BitPoker.Models.Peer() { BitcoinAddress = "msPJhg9GPzMN6twknwmSQvrUKZbZnk51Tv", NetworkAddress = "https://www.bitpoker.io/api/alice", UserAgent = "Mock", PublicKey = "041FA97EFD760F26E93E91E29FDDF3DDDDD3F543841CF9435BDC156FB73854F4BF22557798BA535A3EE89A62238C5AFC7F8BF1FA0985DC4E1A06C25209BAB78BD1" }; BitPoker.Models.Peer bob = new BitPoker.Models.Peer() { BitcoinAddress = "mhSW3EUNoVkD1ZQV1ZpnxdRMBjo648enyo", NetworkAddress = "http://localhost:5000", UserAgent = "Mock", PublicKey = "04F48396AC675B97EEB54E57554827CC2B937C2DAE285A9198F9582B15C920D91309BC567858DC63357BCD5D24FD8C041CA55DE8BAE62C7315B0BA66FE5F96C20D" }; table.Peers[0] = alice; table.Peers[1] = bob; //Act String actual = table.GetScriptScript(); //Assert const String expected = "2NCrqBsyEk3zXaGLaZ6cG1r6JqX2yjqNnvi"; Assert.AreEqual(expected, actual); }
public Models.Contracts.Table GetTable(Guid id) { using (HttpClient httpClient = new HttpClient()) { var json = httpClient.GetStringAsync(String.Format("{0}/api/table?id={1}", _apiUrl, id)).Result; BitPoker.Models.Contracts.Table result = JsonConvert.DeserializeObject <BitPoker.Models.Contracts.Table>(json); return(result); } }
/// <summary> /// Display messages and peform any actions /// </summary> /// <param name="composite"></param> public void ProcessMessage(CompositeType composite) { IRequest request = Newtonsoft.Json.JsonConvert.DeserializeObject <RPCRequest>(composite.Message); this.InComingRequests.Add(request); this.LastMessage = composite.Message; switch (request.Method) { case "NewPeer": NewPeerRequest newPeer = Newtonsoft.Json.JsonConvert.DeserializeObject <NewPeerRequest>(request.Params.ToString()); NetworkPlayers.Add(newPeer.Player); break; case "NewTable": //Peer has announced a new table BitPoker.Models.Contracts.Table newTable = Newtonsoft.Json.JsonConvert.DeserializeObject <BitPoker.Models.Contracts.Table>(request.Params.ToString()); TableViewModel newTableViewModel = new TableViewModel(newTable); //this.Tables.Add(newTableViewModel); break; case "GetTables": //Give me your tables using (BitPoker.Repository.ITableRepository tableRepo = new BitPoker.Repository.LiteDB.TableRepository("data.db")) { IEnumerable <BitPoker.Models.Contracts.Table> tables = tableRepo.All(); //now send IResponse response = new RPCResponse() { Id = request.Id, Result = tables }; this.SentRequests.Add(request); Backend.SendResponse(response); break; } case "GetTablesResponse": //Add resultant tables GetTablesResponse tableResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <GetTablesResponse>(request.Params.ToString()); foreach (BitPoker.Models.Contracts.Table table in tableResponse.Tables) { //TableViewModel tableViewModel = new TableViewModel(table); this.Tables.Add(table); } break; case "ActionMessage": ActionMessage actionMessage = Newtonsoft.Json.JsonConvert.DeserializeObject <ActionMessage>(request.Params.ToString()); //actionMessage.HandId; break; } }
public TableViewModel(BitPoker.Models.Contracts.Table table) { _table = table; //this.Client = new Clients.ChatBackend(); }