public static List<Card> Shuffle (List<Card> DeckToShuffle) { Card tempCard = new Card(); Random r = new Random(); int randomNumber; for (int i = DeckToShuffle.Count - 1; i > 0; i--) { randomNumber = r.Next(0, i + 1); tempCard = DeckToShuffle[i]; DeckToShuffle[i] = DeckToShuffle[randomNumber]; DeckToShuffle[randomNumber] = tempCard; } return DeckToShuffle; }
public static List<Card> DealHand(List<Card> startDeck, string factionAbbreviation) { List<Card> dealtHand = new List<Card>(); List<Card> factionSearchResults = new List<Card>(); //Stack the deck with Min Faction Units //Create a list to store the faction search results factionSearchResults = (startDeck.FindAll(c => c.Faction == factionAbbreviation)).ToList<Card>(); factionSearchResults = Shuffle(factionSearchResults); //Add the MinFactionUnits to the start deck for (int f = 0; f < Global.gAppOptions.MinFactionUnits; f++) { Card c = new Card(); c = factionSearchResults[f]; dealtHand.Add(c); startDeck.Remove(c); } //Shuffle the player deck startDeck = Shuffle(startDeck); //don't pick randomly, just deal top StartingDeckSize-MinFactionUnits from shuffled deck above for (int deal = 0; deal < (Global.gAppOptions.StartingDeckSize - Global.gAppOptions.MinFactionUnits); deal++) { dealtHand.Add(startDeck[deal]); //player.Deck.RemoveAt(deal); } return dealtHand; }
public Player ProcessCardAbility(Card c, Player player, string row) { switch (c.Ability) { case "Spy": //add to opponent row Session["SpyAddToOpponent"] = c; //draw 2 cards if (player.Deck.Count > 2) { player.Hand.Add(Draw(player.Deck)); player.Hand.Add(Draw(player.Deck)); } break; case "Horn": if (c.Range == "Horn") { c.Range = row; } switch (c.Range) { case ("Close"): int hornCloseTotal = 0; player.PlayerBoardState.HornInCloseRow = true; foreach (Card cc in player.PlayerBoardState.CloseCombat) { if (!(cc.Hero)) { if (player.PlayerBoardState.IsSnowing && (cc.Power > 0)) { hornCloseTotal += 1 * 2; } else { hornCloseTotal += cc.Power * 2; } } else { hornCloseTotal += cc.Power; } } player.PlayerBoardState.CloseCombatTotal = hornCloseTotal; break; case "Ranged": int hornRangedTotal = 0; player.PlayerBoardState.HornInRangedRow = true; foreach (Card rc in player.PlayerBoardState.RangedCombat) { if (!(rc.Hero)) { if (player.PlayerBoardState.IsFoggy && (rc.Power > 0)) { hornRangedTotal += 1 * 2; } else { hornRangedTotal += rc.Power * 2; } } else { hornRangedTotal += rc.Power; } } player.PlayerBoardState.RangedCombatTotal = hornRangedTotal; break; case "Siege": int hornSiegeTotal = 0; player.PlayerBoardState.HornInSiegeRow = true; foreach(Card sc in player.PlayerBoardState.SiegeCombat) { if (!(sc.Hero)) { if (player.PlayerBoardState.IsRaining && (sc.Power > 0)) { hornSiegeTotal += 1 * 2; } else { hornSiegeTotal += sc.Power * 2; } } else { hornSiegeTotal += sc.Power; } } player.PlayerBoardState.SiegeCombatTotal = hornSiegeTotal; break; default: break; } break; case "Scorch": //Need access to other players rows break; case "Bond": List<Card> potentialBondMates = new List<Card>(); switch (c.Range) { case "Close": potentialBondMates = player.PlayerBoardState.CloseCombat.FindAll(pbm => pbm.Name == c.Name); if (potentialBondMates.Count > 1) //don't bond to yourself { //add half the bonded power. when the function returns, the default code will add the card.power //by adding the base value twice you're adding the bonded double player.PlayerBoardState.CloseCombatTotal += c.Power; //double yourself //foreach (Card pbmc in potentialBondMates) for (int x=0; x < (potentialBondMates.Count - 1); x++) { Card pbmc = new Card(); pbmc = potentialBondMates[x]; if (c.Name == pbmc.Name) { //add the existing bonded card again player.PlayerBoardState.CloseCombatTotal += pbmc.Power; } } } //potentialBondMates = player.PlayerBoardState.CloseCombat.FindAll(pbm => pbm.Name == c.Name); //if (potentialBondMates.Count > 0) //{ // player.PlayerBoardState.CloseCombatTotal += (c.Power); //} break; } break; case "Muster": break; case "Medic": break; case "Morale": break; default: break; } return player; }
void DatabaseRead() { // Create a utility to handle the SQL calls for this action. MSSqlUtility sqlUtil = new MSSqlUtility(); //Create an empty row list to be used as the all cards holder List<SqlRow> allCardsRows = new List<SqlRow>(); //Create an empty row list to be used as the all factions holder List<SqlRow> allFactionsRows = new List<SqlRow>(); //Create an empty row list to be used as the all leaders holder List<SqlRow> allLeadersRows = new List<SqlRow>(); try { allCardsRows = sqlUtil.ExecuteQuery(gAppOptions.SelectAllPlayerCards, connectionString, null); //READ LEADERS AND FACTIONS allFactionsRows = sqlUtil.ExecuteQuery(gAppOptions.SelectAllFactions, connectionString, null); allLeadersRows = sqlUtil.ExecuteQuery(gAppOptions.SelectAllLeaders, connectionString, null); //Build the Factions and build the list if (allFactionsRows != null) { foreach (SqlRow row in allFactionsRows) { //Assign the returned database values into the object FactionInfo faction = new FactionInfo(); faction.FactionName = ((string)row["factionName"]).Trim(); faction.FactionAbbr = ((string)row["factionAbbreviation"]).Trim(); faction.FactionPerk = ((string)row["factionPerk"]).Trim(); gAllFactions.Add(faction); } } //Build the Leaders and build the list if (allLeadersRows != null) { foreach (SqlRow row in allLeadersRows) { //Assign the returned database values into the object LeaderInfo leader = new LeaderInfo(); leader.LeaderName = ((string)row["leaderName"]).Trim(); leader.LeaderAbility = ((string)row["leaderAbility"]).Trim(); leader.LeaderFaction = ((string)row["leaderFaction"]).Trim(); leader.LeaderFactionAbbr = ((string)row["leaderFactionAbbreviation"]); gAllLeaders.Add(leader); } } //Build the motherlode deck by assigning the attributes from the database into the object attributes. //The TRY/CATCH is there to handle potential null values because C# null is not the same as DBNULL if (allCardsRows != null) { foreach (SqlRow row in allCardsRows) { Card card = new Card(); try { card.Name = ((string)row["cardName"]).Trim(); } catch { } try { card.Power = (int)row["cardPower"]; } catch { } try { card.Faction = ((string)row["cardFaction"]).Trim(); } catch { } try { card.Quote = ((string)row["cardQuote"]).Trim(); } catch { } try { card.Hero = (bool)(row["cardHero"]); } catch { } try { card.Range = ((string)row["cardRange"]).Trim(); } catch { } try { card.Ability = ((string)row["cardAbilities"]).Trim(); } catch { } try { card.Quote = ((string)row["cardQuote"]).Trim(); } catch { } //New logic to read image file from DB and build path. ImageFilePath try { string cardImageFileName = (string)row["cardImageFileName"]; card.ImageFilePath = "~/Content/Images/" + (cardImageFileName.Trim().Replace(" ", "%20")); } catch { } gAllCards.Add(card); } } } // end of Try-No Touchy catch { //Do we need to perform an action on catch? } }
public ActionResult PlayCard(Player player, int id, string row) { int closeHornModifier = 2; int rangedHornModifier = 2; int siegeHornModifier = 2; player = Session[player.PlayerGuid.ToString()] as Player; int playedCardId = id; Card c = new Card(); c = GetCardFromAPI(playedCardId); switch (c.Range) //very much need to add weather and special effects { case "Ranged": player.PlayerBoardState.RangedCombat.Add(c); if (player.PlayerBoardState.HornInRangedRow) { player.PlayerBoardState.RangedCombatTotal += c.Power * rangedHornModifier; } else { player.PlayerBoardState.RangedCombatTotal += c.Power; } //player.PlayerBoardState.RangedCombatTotal += c.Power; player = ProcessCardAbility(c, player, ""); break; case "Close": player.PlayerBoardState.CloseCombat.Add(c); if (player.PlayerBoardState.HornInCloseRow) { player.PlayerBoardState.CloseCombatTotal += c.Power * closeHornModifier; } else { player.PlayerBoardState.CloseCombatTotal += c.Power; } //player.PlayerBoardState.CloseCombatTotal += c.Power; player = ProcessCardAbility(c, player, ""); break; case "Siege": player.PlayerBoardState.SiegeCombat.Add(c); if (player.PlayerBoardState.HornInSiegeRow) { player.PlayerBoardState.SiegeCombatTotal += c.Power * siegeHornModifier; } else { player.PlayerBoardState.SiegeCombatTotal += c.Power; } //player.PlayerBoardState.SiegeCombatTotal += c.Power; player = ProcessCardAbility(c, player, ""); break; case "Weather": switch (c.Name) { case "Biting Frost": player.PlayerBoardState.IsSnowing = true; break; case "Torrential Rain": player.PlayerBoardState.IsRaining = true; break; case "Impenetrable Fog": player.PlayerBoardState.IsFoggy = true; break; case "Clear Weather": //player.PlayerBoardState.IsSnowing = false; //player.PlayerBoardState.IsRaining = false; //player.PlayerBoardState.IsFoggy = false; break; default: break; } break; case "Decoy": break; case "Horn": if (row == "Close") { player.PlayerBoardState.CloseCombat.Add(c); player.PlayerBoardState.CloseCombatTotal += c.Power; //DONT ALLOW DOUBLING HORNS!!!!! player = ProcessCardAbility(c, player, row); } if (row == "Ranged") { player.PlayerBoardState.RangedCombat.Add(c); player.PlayerBoardState.RangedCombatTotal += c.Power; //DONT ALLOW DOUBLING HORNS!!!!! player = ProcessCardAbility(c, player, row); } if (row == "Siege") { player.PlayerBoardState.SiegeCombat.Add(c); player.PlayerBoardState.SiegeCombatTotal += c.Power; //DONT ALLOW DOUBLING HORNS!!!!! player = ProcessCardAbility(c, player, row); } break; case "Scorch": break; default: //default will be replaced with other card types later break; } //Now process weather effects on ranges based on bool //Biting Frost-Sets NON HERO close combat cards to 1 power //TO DO //Check the BOND //sdsdsds if (player.PlayerBoardState.IsSnowing) { //if (player.PlayerBoardState.HornInCloseRow && (!(player.PlayerBoardState.IsSnowing))) //{ // closeHornModifier = 2; //} //else //{ // closeHornModifier = 1; //} int closeWeatherTotal = 0; foreach (Card cc in player.PlayerBoardState.CloseCombat) { //closeWeatherCardList.Add(cc); if (!(cc.Hero)) { closeWeatherTotal += 1 * closeHornModifier; } else { closeWeatherTotal += cc.Power; } } player.PlayerBoardState.CloseCombatTotal = closeWeatherTotal; } //Impenetrable Fog-Sets NON HERO ranged combat cards to 1 power if (player.PlayerBoardState.IsFoggy) { if (player.PlayerBoardState.HornInRangedRow &&(!(player.PlayerBoardState.IsFoggy))) { rangedHornModifier = 2; } else { rangedHornModifier = 1; } int rangedWeatherTotal = 0; foreach (Card cc in player.PlayerBoardState.RangedCombat) { //closeWeatherCardList.Add(cc); if (!(cc.Hero)) { rangedWeatherTotal += 1 * rangedHornModifier; } else { rangedWeatherTotal += cc.Power; } } player.PlayerBoardState.RangedCombatTotal = rangedWeatherTotal; } //Torrential Rain-Sets NON HERO siege combat cards to 1 power if (player.PlayerBoardState.IsRaining) { if (player.PlayerBoardState.HornInSiegeRow && (!(player.PlayerBoardState.IsRaining))) { siegeHornModifier = 2; } else { siegeHornModifier = 1; } int siegeWeatherTotal = 0; foreach (Card cc in player.PlayerBoardState.SiegeCombat) { if (!(cc.Hero)) { siegeWeatherTotal += 1 * siegeHornModifier; } else { siegeWeatherTotal += cc.Power; } } player.PlayerBoardState.SiegeCombatTotal = siegeWeatherTotal; } /////// //TO DO //BONDS ARE NOT RECALCULATED AFTER CLEAR WEATHER /////// //FIXED PLAY X PWR CARD. FROST. HORN. CLEAR. CARD IS 4. WTELF?!?!?! Error is in process math for horn process ends up 2*2. Hence power 4 if (player.PlayerBoardState.IsSnowing && c.Name == "Clear Weather") { //int closeClearWeatherTotal = 0; player.PlayerBoardState.IsSnowing = false; List<Card> tempCc = new List<Card>(); tempCc.AddRange(player.PlayerBoardState.CloseCombat.GetRange(0, player.PlayerBoardState.CloseCombat.Count)); player.PlayerBoardState.CloseCombatTotal = 0; player.PlayerBoardState.CloseCombat.Clear(); foreach (Card cc in tempCc) { player.PlayerBoardState.CloseCombat.Add(cc); player.PlayerBoardState.CloseCombatTotal += cc.Power; player = ProcessCardAbility(cc, player, ""); } //player.PlayerBoardState.CloseCombatTotal = closeClearWeatherTotal; } if (player.PlayerBoardState.IsFoggy && c.Name == "Clear Weather") { player.PlayerBoardState.IsFoggy = false; List<Card> tempRc = new List<Card>(); tempRc.AddRange(player.PlayerBoardState.RangedCombat.GetRange(0, player.PlayerBoardState.RangedCombat.Count)); player.PlayerBoardState.RangedCombatTotal = 0; player.PlayerBoardState.RangedCombat.Clear(); foreach (Card rc in tempRc) { player.PlayerBoardState.RangedCombat.Add(rc); player.PlayerBoardState.RangedCombatTotal += rc.Power; player = ProcessCardAbility(rc, player, ""); } //player.PlayerBoardState.RangedCombatTotal = rangedClearWeatherTotal; } if (player.PlayerBoardState.IsRaining && c.Name == "Clear Weather") { player.PlayerBoardState.IsRaining = false; List<Card> tempSc = new List<Card>(); tempSc.AddRange(player.PlayerBoardState.SiegeCombat.GetRange(0, player.PlayerBoardState.SiegeCombat.Count)); player.PlayerBoardState.SiegeCombatTotal = 0; player.PlayerBoardState.SiegeCombat.Clear(); foreach (Card sc in tempSc) { player.PlayerBoardState.SiegeCombat.Add(sc); player.PlayerBoardState.SiegeCombatTotal += sc.Power; player = ProcessCardAbility(sc, player, ""); } //player.PlayerBoardState.SiegeCombatTotal = siegeClearWeatherTotal; } //Session["Player"] = JsonConvert.SerializeObject(player); //return View(player); //Remove the played card from hand Card cardToRemove = new Card(); cardToRemove = player.Hand.Find(i => i.CardId == playedCardId); player.Hand.Remove(cardToRemove); //TempData["tempPlayer"] = player; Session[player.PlayerGuid.ToString()] = player; return Redirect("~/Board/BoardView/"); }
/// <summary> /// Return a card from the API from its id /// </summary> /// <param name="id"></param> /// <returns></returns> public Card GetCardFromAPI(int id) { Card c = new Card(); List<Card> cl = new List<Card>(); //Create web client to do call System.Net.WebClient client = new System.Net.WebClient(); //Create the url to pull from string cardUriString = Url.RouteUrl("", new { action = "byid", controller = "Card", id = id }, Request.Url.Scheme); //Get the card and deserialize string cardReturn = client.DownloadString(cardUriString); //c = JsonConvert.DeserializeObject(cardReturn); cl = JsonConvert.DeserializeObject<List<Card>>(cardReturn); c = cl[0]; return c; }
/// <summary> /// Adds a card from your deck to your hand /// </summary> /// <returns></returns> public ActionResult DrawFromDeck() { Player player = new Player(); player = Session[player.PlayerGuid.ToString()] as Player; Card drawnCard = new Card(); if (player.Deck.Count > 0) { drawnCard = (player.Deck[0]); player.Hand.Add(drawnCard); player.Deck.Remove(drawnCard); } //TempData["tempPlayer"] = player; Session[player.PlayerGuid.ToString()] = player; return Redirect("~/Board/BoardView/"); }
public ActionResult CreateDeck(Player player) { // Create the empty deck object, faction object and leader object. player.Deck = new List<Card>(); player.Faction = new FactionInfo(); player.Leader = new LeaderInfo(); //Sort out the selected leader and faction from the model. This was harder than it should have been. //Assign the selected leader name to the player.Leader player.Leader.LeaderName = player.SelectedLeader.LeaderName; //Since the drop down list only sends the value (and not the text) I have to query the list to determine what faction abbreviation the selected leader belongs to player.Leader.LeaderFactionAbbr = Player.DdLeaderList.Find(i => i.Text == player.SelectedLeader.LeaderName).Value; //Assign the selected faction abbreviation to the player.Leader player.Faction.FactionAbbr = player.Leader.LeaderFactionAbbr; //Since the drop down list only sends the value (and not the text) I have to query the list to determine what faction name the selected leader belongs to player.Faction.FactionName = Player.DdFactionList.Find(i => i.Value == player.Faction.FactionAbbr).Text; //Assign faction perk to player model player.Faction.FactionPerk = Global.gAllFactions.Find(i => i.FactionAbbr == player.Faction.FactionAbbr).FactionPerk; //Assign leader ability to player model player.Leader.LeaderAbility = Global.gAllLeaders.Find(i => i.LeaderName == player.Leader.LeaderName).LeaderAbility; //This is a place holder of the faction abbreviation used in the SQL queries. string factionAbbreviation = player.Faction.FactionAbbr; try { player.Deck = new List<Card>(); player.Deck = BuildDeck(factionAbbreviation); //Build the start deck //This is the initial draw the player starts with player.StartDeck = new List<Card>(); //Stack the deck with Min Faction Units //Create a list to store the faction search results List<Card> factionSearchResults = new List<Card>(); factionSearchResults = (player.Deck.FindAll(c => c.Faction == player.Faction.FactionAbbr)).ToList<Card>(); factionSearchResults = Shuffle(factionSearchResults); //Add the MinFactionUnits to the start deck for (int f = 0; f < Global.gAppOptions.MinFactionUnits; f++) { Card c = new Card(); c = factionSearchResults[f]; player.StartDeck.Add(c); player.Deck.Remove(c); } //Shuffle the player deck player.Deck = Shuffle(player.Deck); //don't pick randomly, just deal top StartingDeckSize-MinFactionUnits from shuffled deck above for (int deal = 0; deal < (Global.gAppOptions.StartingDeckSize - Global.gAppOptions.MinFactionUnits); deal++) { player.StartDeck.Add(player.Deck[deal]); player.Deck.RemoveAt(deal); } //Sort the deck based on card range (close, range, siege). This is because im neurotic. player.Deck.Sort((x, y) => string.Compare(x.Range, y.Range)); player.StartDeck.Sort((x, y) => string.Compare(x.Range, y.Range)); } catch (Exception err) { // We're not going to do anything on an exception, we'll just return the empty deck initialized above. } return View(player); }
public ActionResult PlayCard(Player player, int id, string row) { int closeHornModifier = 0; int rangedHornModifier = 0; int siegeHornModifier = 0; player = Session[player.PlayerGuid.ToString()] as Player; int playedCardId = id; Card c = new Card(); List<Card> cl = new List<Card>(); //Create web client to do call System.Net.WebClient client = new System.Net.WebClient(); //Create the url to pull from string cardUriString = Url.RouteUrl("", new { action = "byid", controller = "Card", id = playedCardId }, Request.Url.Scheme); //Get the card and deserialize string cardReturn = client.DownloadString(cardUriString); //c = JsonConvert.DeserializeObject(cardReturn); cl = JsonConvert.DeserializeObject<List<Card>>(cardReturn); c = cl[0]; switch (c.Range) //very much need to add weather and special effects { case "Ranged": player.PlayerBoardState.RangedCombat.Add(c); player.PlayerBoardState.RangedCombatTotal += c.Power; player = ProcessCardAbility(c, player, ""); break; case "Close": player.PlayerBoardState.CloseCombat.Add(c); player.PlayerBoardState.CloseCombatTotal += c.Power; player = ProcessCardAbility(c, player, ""); break; case "Siege": player.PlayerBoardState.SiegeCombat.Add(c); player.PlayerBoardState.SiegeCombatTotal += c.Power; player = ProcessCardAbility(c, player, ""); break; case "Weather": switch (c.Name) { case "Biting Frost": player.PlayerBoardState.IsSnowing = true; break; case "Torrential Rain": player.PlayerBoardState.IsRaining = true; break; case "Impenetrable Fog": player.PlayerBoardState.IsFoggy = true; break; case "Clear Weather": //player.PlayerBoardState.IsSnowing = false; //player.PlayerBoardState.IsRaining = false; //player.PlayerBoardState.IsFoggy = false; break; default: break; } break; case "Decoy": break; case "Horn": if (row == "Close") { player.PlayerBoardState.CloseCombat.Add(c); player.PlayerBoardState.CloseCombatTotal += c.Power; //DONT ALLOW DOUBLING HORNS!!!!! player = ProcessCardAbility(c, player, row); } if (row == "Ranged") { player.PlayerBoardState.RangedCombat.Add(c); player.PlayerBoardState.RangedCombatTotal += c.Power; //DONT ALLOW DOUBLING HORNS!!!!! player = ProcessCardAbility(c, player, row); } if (row == "Siege") { player.PlayerBoardState.SiegeCombat.Add(c); player.PlayerBoardState.SiegeCombatTotal += c.Power; //DONT ALLOW DOUBLING HORNS!!!!! player = ProcessCardAbility(c, player, row); } break; case "Scorch": break; default: //default will be replaced with other card types later break; } //Now process weather effects on ranges based on bool //Biting Frost-Sets NON HERO close combat cards to 1 power //TO DO //Check the BOND //TO DO adding commanders horn to weather affected row doubles original value not weather value //sdsdsds if (player.PlayerBoardState.IsSnowing) { if (player.PlayerBoardState.HornInCloseRow) { closeHornModifier = 2; } else { closeHornModifier = 1; } int closeWeatherTotal = 0; foreach (Card cc in player.PlayerBoardState.CloseCombat) { //closeWeatherCardList.Add(cc); if (!(cc.Hero)) { closeWeatherTotal += 1 * closeHornModifier; } else { closeWeatherTotal += cc.Power; } } player.PlayerBoardState.CloseCombatTotal = closeWeatherTotal; } //Impenetrable Fog-Sets NON HERO ranged combat cards to 1 power if (player.PlayerBoardState.IsFoggy) { if (player.PlayerBoardState.HornInRangedRow) { rangedHornModifier = 2; } else { rangedHornModifier = 1; } int rangedWeatherTotal = 0; foreach (Card cc in player.PlayerBoardState.RangedCombat) { //closeWeatherCardList.Add(cc); if (!(cc.Hero)) { rangedWeatherTotal += 1 * rangedHornModifier; } else { rangedWeatherTotal += cc.Power; } } player.PlayerBoardState.RangedCombatTotal = rangedWeatherTotal; } //Torrential Rain-Sets NON HERO siege combat cards to 1 power if (player.PlayerBoardState.IsRaining) { if (player.PlayerBoardState.HornInSiegeRow) { siegeHornModifier = 2; } else { siegeHornModifier = 1; } int siegeWeatherTotal = 0; foreach (Card cc in player.PlayerBoardState.SiegeCombat) { if (!(cc.Hero)) { siegeWeatherTotal += 1 * siegeHornModifier; } else { siegeWeatherTotal += cc.Power; } } player.PlayerBoardState.SiegeCombatTotal = siegeWeatherTotal; } /////// //TO DO //BONDS ARE NOT RECALCULATED AFTER CLEAR WEATHER /////// //sdfsdfds if (player.PlayerBoardState.IsSnowing && c.Name == "Clear Weather") { //int closeClearWeatherTotal = 0; List<Card> tempCc = new List<Card>(); tempCc.AddRange(player.PlayerBoardState.CloseCombat.GetRange(0, player.PlayerBoardState.CloseCombat.Count)); player.PlayerBoardState.CloseCombatTotal = 0; player.PlayerBoardState.CloseCombat.Clear(); foreach (Card cc in tempCc) { player.PlayerBoardState.CloseCombat.Add(cc); player.PlayerBoardState.CloseCombatTotal += cc.Power; player = ProcessCardAbility(cc, player, ""); } //player.PlayerBoardState.CloseCombatTotal = closeClearWeatherTotal; player.PlayerBoardState.IsSnowing = false; } if (player.PlayerBoardState.IsFoggy && c.Name == "Clear Weather") { List<Card> tempRc = new List<Card>(); tempRc.AddRange(player.PlayerBoardState.RangedCombat.GetRange(0, player.PlayerBoardState.RangedCombat.Count)); player.PlayerBoardState.RangedCombatTotal = 0; player.PlayerBoardState.RangedCombat.Clear(); foreach (Card rc in tempRc) { player.PlayerBoardState.RangedCombat.Add(rc); player.PlayerBoardState.RangedCombatTotal += rc.Power; player = ProcessCardAbility(rc, player, ""); } //player.PlayerBoardState.RangedCombatTotal = rangedClearWeatherTotal; player.PlayerBoardState.IsFoggy = false; } if (player.PlayerBoardState.IsRaining && c.Name == "Clear Weather") { List<Card> tempSc = new List<Card>(); tempSc.AddRange(player.PlayerBoardState.SiegeCombat.GetRange(0, player.PlayerBoardState.SiegeCombat.Count)); player.PlayerBoardState.SiegeCombatTotal = 0; player.PlayerBoardState.SiegeCombat.Clear(); foreach (Card sc in tempSc) { player.PlayerBoardState.SiegeCombat.Add(sc); player.PlayerBoardState.SiegeCombatTotal += sc.Power; player = ProcessCardAbility(sc, player, ""); } //player.PlayerBoardState.SiegeCombatTotal = siegeClearWeatherTotal; player.PlayerBoardState.IsRaining = false; } //Session["Player"] = JsonConvert.SerializeObject(player); //return View(player); //Remove the played card from hand Card cardToRemove = new Card(); cardToRemove = player.Hand.Find(i => i.CardId == playedCardId); player.Hand.Remove(cardToRemove); //TempData["tempPlayer"] = player; Session[player.PlayerGuid.ToString()] = player; return Redirect("~/Board/BoardView/"); }