public List <ColorIdentity> SelectAll() { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.Text; sqlCommand.CommandText = "select * from color_identity"; SqlDataReader sqlDataReader = Db.Select(sqlCommand); List <ColorIdentity> listColorIdentity = new List <ColorIdentity>(); if (sqlDataReader.HasRows) { while (sqlDataReader.Read()) { ColorIdentity colorIdentity = new ColorIdentity(); colorIdentity.Id = (Int32)sqlDataReader["id"]; colorIdentity.Value = (String)sqlDataReader["value"]; colorIdentity.Card = new CardDAO().SelectById((Int32)sqlDataReader["id_card"]); listColorIdentity.Add(colorIdentity); } sqlDataReader.Read(); return(listColorIdentity); } else { return(null); } }
public ColorIdentity SelectById(Int32 id) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.Text; sqlCommand.CommandText = "select * from color_identity where id = @id"; sqlCommand.Parameters.AddWithValue("@id", id); SqlDataReader sqlDataReader = Db.Select(sqlCommand); ColorIdentity colorIdentity = new ColorIdentity(); if (sqlDataReader.HasRows) { sqlDataReader.Read(); colorIdentity.Id = (Int32)sqlDataReader["id"]; colorIdentity.Value = (String)sqlDataReader["value"]; colorIdentity.Card = new CardDAO().SelectById((Int32)sqlDataReader["id_card"]); return(colorIdentity); } else { return(null); } }
public void Delete(ColorIdentity colorIdentity) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.Text; sqlCommand.CommandText = "delete from color_identity where id = @id"; sqlCommand.Parameters.AddWithValue("@id", colorIdentity.Id); Db.Execute(sqlCommand); }
public void Insert(ColorIdentity colorIdentity) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.Text; sqlCommand.CommandText = "insert into color_identity (value, id_card) values (@usd, @id_card)"; sqlCommand.Parameters.AddWithValue("@value", colorIdentity.Value); sqlCommand.Parameters.AddWithValue("@id_card", colorIdentity.Card.Id); Db.Execute(sqlCommand); }
public void Update(ColorIdentity colorIdentity) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.Text; sqlCommand.CommandText = "update color_identity set value = @value, id_card = @id_card where id = @id"; sqlCommand.Parameters.AddWithValue("@id", colorIdentity.Id); sqlCommand.Parameters.AddWithValue("@value", colorIdentity.Value); sqlCommand.Parameters.AddWithValue("@id_card", colorIdentity.Card.Id); Db.Execute(sqlCommand); }
private void SetColor() { if (colorOfIdentity == "ab" || colorOfIdentity == "ba") { colorOfIdentity = "ab"; } if (colorOfIdentity == "bc" || colorOfIdentity == "cb") { colorOfIdentity = "bc"; } if (colorOfIdentity == "ca" || colorOfIdentity == "ac") { colorOfIdentity = "ca"; } if (colorOfIdentity.Length > 2) { colorOfIdentity = colorOfIdentity.Substring(0, 2); } ColorIdentity.SetColor(colorOfIdentity, GetComponent <Image>()); }
public void SetColorOfCollector() { ColorIdentity.SetColor(collectorColorId, GetComponent <Image>()); }
public bool CanBlock(Card permanent) { // This permanent can't block if it is not a creature (Vehicles can only attack/block if they're creatures) if (!IsACreature) { return(false); } // A creature can't block if it's tapped if (IsTapped) { return(false); } // Can't block non-creatures (Vehicles can only attack/block if they're creatures) if (!permanent.IsACreature) { return(false); } #region Evasion Abilities #region Unblockable // Can't block unblockables. Seems pretty straightforward if (permanent.HasUnblockable) { return(false); } #endregion Unblockable #region Fear // Creatures with Fear can only be blocked by artifacts and black creatures if (permanent.HasFear) { if (!IsAnArtifact || ColorIdentity == null || ColorIdentity.Contains(ManaColor.Black)) { return(false); } } #endregion Fear #region Shadow // Only creatures with shadow can block attackers with shadow if (permanent.HasShadow) { if (!HasShadow) { return(false); } } #endregion Shadow #region Horsemanship // Only creatures with horsemanship can block attackers with horsemanship if (permanent.HasHorsemanship) { if (!HasHorsemanship) { return(false); } } #endregion Horsemanship #region Flying // Only creatures with Flying or Reach can block creatures with flying if (permanent.HasFlying) { if (!HasFlying && !HasReach) { return(false); } } #endregion Flying #region Land-walk // Creatures with Plainswalk can't be blocked if we control a Plains if (permanent.HasPlainswalk) { if (Controller.Battlefield.Lands.Any(c => c.Subtypes.Contains("Plains"))) { return(false); } } // Creatures with Islandwalk can't be blocked if we control a Island if (permanent.HasIslandwalk) { if (Controller.Battlefield.Lands.Any(c => c.Subtypes.Contains("Island"))) { return(false); } } // Creatures with Swampwalk can't be blocked if we control a Swamp if (permanent.HasSwampwalk) { if (Controller.Battlefield.Lands.Any(c => c.Subtypes.Contains("Swamp"))) { return(false); } } // Creatures with Mountainwalk can't be blocked if we control a Mountain if (permanent.HasMountainwalk) { if (Controller.Battlefield.Lands.Any(c => c.Subtypes.Contains("Mountain"))) { return(false); } } // Creatures with Forestwalk can't be blocked if we control a Forest if (permanent.HasForestwalk) { if (Controller.Battlefield.Lands.Any(c => c.Subtypes.Contains("Forest"))) { return(false); } } #endregion Land-walk #endregion Evasion Abilities // This creature can block that creature. It passed all the tests return(true); }
public void SetWallColor() { ColorIdentity.SetColor(colorIdentityOfWall, this.GetComponent <Image>()); }
public void SetColorOfGenerator() { ColorIdentity.SetColor(generatorColorId, GetComponent <Image>()); }
public static Set ConvertToModel(string json) { //deserialize json into import model var importSet = JsonConvert.DeserializeObject <ImportSet>(json); //use automapper to map into correct model var convertedModel = Mapper.Map <Set>(importSet); //TODO beautify //Manual mapping that I couldn't do in automapper #region manual mapping foreach (ImportCard card in importSet.Cards) { //verify that the card has a number if (card.MciNumber != null) { //first to allow for duplicates in data var newCard = convertedModel.Cards.First(x => x.Number == card.MciNumber); if (card.Supertypes != null) { foreach (string supertype in card.Supertypes) { var super = new CardSuperType(); super.Name = supertype; newCard.CardSuperType.Add(super); } } if (card.Types != null) { foreach (string type in card.Types) { var newType = new CardType(); newType.Name = type; newCard.CardType.Add(newType); } } if (card.Subtypes != null) { foreach (string subtype in card.Subtypes) { var sub = new CardSubType(); sub.Name = subtype; newCard.CardSubType.Add(sub); } } if (card.ColorIdentity != null) { foreach (string coloridentity in card.ColorIdentity) { var identity = new ColorIdentity(); Enum.TryParse(coloridentity, out EColorIdentity ciEnum); identity.Name = ciEnum; newCard.ColorIdentity.Add(identity); } } if (card.Colors != null) { foreach (string color in card.Colors) { var c = new Color(); Enum.TryParse(color, out EColor cEnum); c.Name = cEnum; newCard.Color.Add(c); } } if (card.Rarity != null) { var r = new Rarity(); Enum.TryParse(card.Rarity, out ERarity rEnum); r.Name = rEnum; newCard.Rarity = r; } if (card.Legalities != null) { var legal = new Legality(); foreach (ImportLegality legality in card.Legalities) { switch (legality.Format) { case "Vintage": if (legality.Legality == "Legal") { legal.Vintage = true; } break; case "Legacy": if (legality.Legality == "Legal") { legal.Legacy = true; } break; case "Commander": if (legality.Legality == "Legal") { legal.Commander = true; } break; case "Modern": if (legality.Legality == "Legal") { legal.Modern = true; } break; case "Standard": if (legality.Legality == "Legal") { legal.Standard = true; } break; case "Arena": if (legality.Legality == "Legal") { legal.Arena = true; } break; default: break; } } if (newCard.Rarity.Name == 0) { legal.Pauper = true; } newCard.Legality = legal; } if (card.Power == null) { newCard.Power = " "; } if (card.Toughness == null) { newCard.Toughness = " "; } } } #endregion return(convertedModel); }