public async Task <IHttpActionResult> PutDealMethod(int id, DealMethod dealMethod) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != dealMethod.Id) { return(BadRequest()); } db.Entry(dealMethod).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DealMethodExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Deals all cards in the deck between players based on the deal method. /// </summary> /// <param name="dealMethod"></param> /// <param name="playersCount"></param> public void DealAllCards(DealMethod dealMethod, int playersCount) { // Deal cards // Hard-coded for 2 players at this time var cardDictionary = this.Deck.DealAll(dealMethod, playersCount); this.Player1.UpdatePlayerHand(cardDictionary[1]); this.Player2.UpdatePlayerHand(cardDictionary[2]); }
public async Task <IHttpActionResult> GetDealMethod(int id) { DealMethod dealMethod = await db.DealMethods.FindAsync(id); if (dealMethod == null) { return(NotFound()); } return(Ok(dealMethod)); }
public async Task <IHttpActionResult> PostDealMethod(DealMethod dealMethod) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DealMethods.Add(dealMethod); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = dealMethod.Id }, dealMethod)); }
public async Task <IHttpActionResult> DeleteDealMethod(int id) { DealMethod dealMethod = await db.DealMethods.FindAsync(id); if (dealMethod == null) { return(NotFound()); } db.DealMethods.Remove(dealMethod); await db.SaveChangesAsync(); return(Ok(dealMethod)); }
override public bool Init(string script) { if (base.Init(script)) { s1 = CardCollectMethodParser.Parse(mapMethod["s1"]); s2 = ShuffleMethodParser.Parse(mapMethod["s2"]); s3 = DealMethodParser.Parse(mapMethod["s3"]); if (s1 != null && s2 != null && s3 != null) { return true; } } return false; }
override public bool Init(string script) { if (base.Init(script)) { s1 = CardCollectMethodParser.Parse(mapMethod["s1"]); s2 = ShuffleMethodParser.Parse(mapMethod["s2"]); s3 = DealMethodParser.Parse(mapMethod["s3"]); if (s1 != null && s2 != null && s3 != null) { return(true); } } return(false); }
/// <summary> /// Dealing all cards of the deck between players. /// Remember to shuffle the deck first. /// </summary> /// <param name="method"></param> /// <param name="noPlayers"></param> /// <returns></returns> public Dictionary <int, List <Card> > DealAll(DealMethod method, int noPlayers) { // Dealing all cards between players based on the given method Dictionary <int, List <Card> > cardDictionary = new Dictionary <int, List <Card> >(); switch (method) { case DealMethod.Even: cardDictionary = DealCardsEven(noPlayers); break; case DealMethod.EveryFive: // not implemented yet break; default: // assert : not come here break; } return(cardDictionary); }
private void ScanMethod(object[] per) { DealMethod?.Invoke(per[0].ToString()); }
/// <summary> /// Shuffles the deck first; then deals all cards in the deck between players based on the deal method. /// </summary> /// <param name="dealMethod"></param> /// <param name="playersCount"></param> public void ShuffleAndDeal(DealMethod dealMethod, int playersCount) { this.ShuffleDeck(); this.DealAllCards(dealMethod, playersCount); }