private static bool RevisarPalo(List <Pico> picos, List <Carta> listado, out string error) { error = string.Empty; for (int ip = 0; ip < 4; ip++) { Palo palo = (Palo)ip; if ((picos.Where(p => p.Palo == palo).Count() + listado.Where(p => p.Palo == palo).Count()) != 13) { error += $"Hay {picos.Where(p => p.Palo == palo).Count() + listado.Where(p => p.Palo == palo).Count()} cartas de {palo.ToString("g")}. "; } for (int i = 1; i <= 13; i++) { if (picos.Where(p => p.Palo == palo && p.Numero == i).Count() == 0 && listado.Where(p => p.Palo == palo && p.Numero == i).Count() == 0) { error += $"Falta la carta {i} de {palo.ToString("g") }. "; } if (picos.Where(p => p.Palo == palo && p.Numero == i).Count() > 1 || listado.Where(p => p.Palo == palo && p.Numero == i).Count() > 1 || picos.Where(p => p.Palo == palo && p.Numero == i).Count() >= 1 && listado.Where(p => p.Palo == palo && p.Numero == i).Count() >= 1 ) { error += $"La carta {i} de {palo.ToString("g") } está repetida. "; } } } return(string.IsNullOrEmpty(error)); }
/// <summary> /// Draw a Card /// </summary> /// <param name="spriteBatch">Game sprite batch</param> /// <param name="textures">texture to draw</param> public void Draw(SpriteBatch spriteBatch, Dictionary <String, Texture2D> textures) { Texture2D texture = textures[Rank.ToString() + Palo.ToString()]; Rectangle drawRectangle = this.drawRectangle; drawRectangle.X += (int)Math.Round((float)CardSize.Width / 2); drawRectangle.Y += (int)Math.Round((float)CardSize.Height / 2); float rotation = 0; if (Rotated) { rotation = (float)Math.PI / 2; } if (OnGame) { if (FaceUp) { spriteBatch.Draw(texture, drawRectangle, null, Color.White, rotation, new Vector2(texture.Width / 2, texture.Height / 2), SpriteEffects.None, 0); } else { spriteBatch.Draw(textures["back"], drawRectangle, null, Color.White, rotation, new Vector2(textures["back"].Width / 2, textures["back"].Height / 2), SpriteEffects.None, 0); } if (Touched) { spriteBatch.Draw(textures["frame_red"], drawRectangle, null, Color.White, rotation, new Vector2(textures["frame_red"].Width / 2, textures["frame_red"].Height / 2), SpriteEffects.None, 0); } } }
/// <summary> /// To String method /// </summary> /// <returns>Returns rank de suit</returns> public override string ToString() { return(Rank.ToString() + " de " + Palo.ToString()); }