private bool FindRoadSpots(CCPoint p, int FromCardSpot, ref List <CCPoint> CardList, ref List <PLayerScore> Score) { CardList.Add(p); int CardSpot = 0; if (FromCardSpot == 0) { CardSpot = 2; } if (FromCardSpot == 1) { CardSpot = 3; } if (FromCardSpot == 2) { CardSpot = 0; } if (FromCardSpot == 3) { CardSpot = 1; } Player pl = m_Board.HasAlien(p, CardSpot); if (pl != null) { PLayerScore PS = new PLayerScore(); PS.m_Player = pl; PS.m_Punt = m_PlacedCard; Score.Add(PS); } if (m_Board.GetCard(p).GetAttribute(4) == CardAttributes.None || m_Board.GetCard(p).GetAttribute(4) == CardAttributes.SpaceStation || m_Board.GetCard(p).GetAttribute(4) == CardAttributes.Satellite) { return(false); } for (int i = 0; i <= 3; i++) { if (i != CardSpot && m_CurrentCard.GetAttribute(i) == CardAttributes.RainbowRoad) { Player pll = m_Board.HasAlien(p, i); if (pll != null) { PLayerScore PS = new PLayerScore(); PS.m_Player = pll; PS.m_Punt = m_PlacedCard; Score.Add(PS); } CCPoint NextCardpos = p; if (i == 0) { NextCardpos.Y -= 1; } else if (i == 1) { NextCardpos.X -= 1; } else if (i == 2) { NextCardpos.Y += 1; } else if (i == 3) { NextCardpos.X += 1; } Card NextCard = m_Board.GetCard(NextCardpos); if (NextCard != null) { if (!CardList.Contains(NextCardpos)) { if (FindRoadSpots(NextCardpos, i, ref CardList, ref Score)) { return(true); } } else { return(false); } } else { return(true); } } } return(true); }
//Ruben's commented punten ding private void HandlePoints() { //Dit is een check om de kaart zelf + de 8 omringen kaarten te checken of er een satelite is en of ie klaar is for (int i = -1; i <= 1; i++) // doorloop de x waardes (-1 tot 1) { for (int j = -1; j <= 1; j++) // doorloop de y waardes (-1 tot 1) { CCPoint NewP = new CCPoint(m_PlacedCard.X + i, m_PlacedCard.Y + j); // PlacedCard is de laatste neergelegde card, dus daar lopoen we omheen + zichtzelf Card c = m_Board.GetCard(NewP); if (c != null) { HandleSateliteCard(NewP, c); } } } //Handle rainbow road, dit nog doen, is makkelijker denk ik if (m_CurrentCard.GetAttribute(4) == CardAttributes.None || m_CurrentCard.GetAttribute(4) == CardAttributes.SpaceStation || m_CurrentCard.GetAttribute(4) == CardAttributes.Satellite) { for (int i = 0; i <= 3; i++) { if (m_CurrentCard.GetAttribute(i) == CardAttributes.RainbowRoad) { CCPoint NextCardpos = m_PlacedCard; if (i == 0) { NextCardpos.Y -= 1; } else if (i == 1) { NextCardpos.X -= 1; } else if (i == 2) { NextCardpos.Y += 1; } else if (i == 3) { NextCardpos.X += 1; } if (m_Board.GetCard(NextCardpos) == null) { continue; } List <CCPoint> Cards = new List <CCPoint>(); Cards.Add(m_PlacedCard); List <PLayerScore> Score = new List <PLayerScore>(); Player pl = m_Board.HasAlien(m_PlacedCard, i); if (pl != null) { PLayerScore PS = new PLayerScore(); PS.m_Player = pl; PS.m_Punt = m_PlacedCard; Score.Add(PS); } if (FindRoadSpots(NextCardpos, i, ref Cards, ref Score) == false) { int CardScore = Cards.Count; Dictionary <Player, int> Dic = new Dictionary <Player, int>(); foreach (PLayerScore ps in Score) { if (!Dic.ContainsKey(ps.m_Player)) { Dic.Add(ps.m_Player, 0); } } foreach (PLayerScore ps in Score) { Dic[ps.m_Player] += 1; ps.m_Player.NumberOfAliens++; m_Board.RemoveAlien(ps.m_Punt); m_Scene.m_BoardLayer.RemoveAlien(ps.m_Punt); } List <Player> player = new List <Player>(); int HighestScore = 0; foreach (var v in Dic) { if (v.Value > HighestScore) { player.Clear(); HighestScore = v.Value; player.Add(v.Key); } else if (v.Value == HighestScore) { player.Add(v.Key); } } foreach (Player p in player) { p.Points += CardScore; } } } } } else { List <CCPoint> Cards = new List <CCPoint>(); List <PLayerScore> Score = new List <PLayerScore>(); bool Done = false; for (int i = 0; i <= 3; i++) { if (m_CurrentCard.GetAttribute(i) == CardAttributes.RainbowRoad) { CCPoint NextCardpos = m_PlacedCard; if (i == 0) { NextCardpos.Y -= 1; } else if (i == 1) { NextCardpos.X -= 1; } else if (i == 2) { NextCardpos.Y += 1; } else if (i == 3) { NextCardpos.X += 1; } if (m_Board.GetCard(NextCardpos) == null) { continue; } if (!Cards.Contains(m_PlacedCard)) { Cards.Add(m_PlacedCard); Player pl = m_Board.HasAlien(m_PlacedCard, i); if (pl != null) { PLayerScore PS = new PLayerScore(); PS.m_Player = pl; PS.m_Punt = m_PlacedCard; Score.Add(PS); } } Done = FindRoadSpots(NextCardpos, i, ref Cards, ref Score); if (Done) { break; } } } if (Done == false) { int CardScore = Cards.Count; Dictionary <Player, int> Dic = new Dictionary <Player, int>(); foreach (PLayerScore ps in Score) { if (!Dic.ContainsKey(ps.m_Player)) { Dic.Add(ps.m_Player, 0); } } foreach (PLayerScore ps in Score) { Dic[ps.m_Player] += 1; ps.m_Player.NumberOfAliens++; m_Board.RemoveAlien(ps.m_Punt); m_Scene.m_BoardLayer.RemoveAlien(ps.m_Punt); } List <Player> player = new List <Player>(); int HighestScore = 0; foreach (var v in Dic) { if (v.Value > HighestScore) { player.Clear(); HighestScore = v.Value; player.Add(v.Key); } else if (v.Value == HighestScore) { player.Add(v.Key); } } foreach (Player p in player) { p.Points += CardScore; } } } //Handle Castle bool FoundCastle = false; List <int> CastleSides = new List <int>(); for (int i = 0; i <= 3; i++) { if (m_CurrentCard.GetAttribute(i) == CardAttributes.SpaceStation) { FoundCastle = true; CastleSides.Add(i); } } if (FoundCastle) { if (m_CurrentCard.GetAttribute(4) == CardAttributes.SpaceStation || m_CurrentCard.GetAttribute(4) == CardAttributes.intersection) //Als midden een stations is dan moeten er meerdere kaarten bekeken worden, anders niet { List <CCPoint> Cards = new List <CCPoint>(); List <PLayerScore> Score = new List <PLayerScore>(); bool Done = false; foreach (int i in CastleSides) // Gewoon alle hokenen afgaan, in theorie kan dit dubbelop zijn, maar maakt opzich niet uit, zolang we de aliens optijd verwijderen is de 2e keer puntloos { int CardSpot = i; CCPoint NextCardpos = m_PlacedCard; if (CardSpot == 0) { NextCardpos.Y -= 1; } else if (CardSpot == 1) { NextCardpos.X -= 1; } else if (CardSpot == 2) { NextCardpos.Y += 1; } else if (CardSpot == 3) { NextCardpos.X += 1; } Card NextCard = m_Board.GetCard(NextCardpos); if (NextCard != null) { Cards.Add(m_PlacedCard); Player pl = m_Board.HasAlien(m_PlacedCard, CardSpot); if (pl != null) { PLayerScore PS = new PLayerScore(); PS.m_Player = pl; PS.m_Punt = m_PlacedCard; Score.Add(PS); } Done = FindCastleOpenSpots(NextCardpos, CardSpot, ref Cards, ref Score); if (Done) { break; } } else { Done = true; break; } } if (!Done) { int CardScore = 0; if (Cards.Count == 2) { CardScore = 2; } else { CardScore = Cards.Count * 2; } Dictionary <Player, int> Dic = new Dictionary <Player, int>(); foreach (PLayerScore ps in Score) { if (!Dic.ContainsKey(ps.m_Player)) { Dic.Add(ps.m_Player, 0); } } foreach (PLayerScore ps in Score) { Dic[ps.m_Player] += 1; ps.m_Player.NumberOfAliens++; m_Board.RemoveAlien(ps.m_Punt); m_Scene.m_BoardLayer.RemoveAlien(ps.m_Punt); } List <Player> player = new List <Player>(); int HighestScore = 0; foreach (var v in Dic) { if (v.Value > HighestScore) { player.Clear(); HighestScore = v.Value; player.Add(v.Key); } else if (v.Value == HighestScore) { player.Add(v.Key); } } foreach (Player p in player) { p.Points += CardScore; } } } else // Alleen zeides zijn stations, makkelijker { foreach (int i in CastleSides) // Gewoon alle hokenen afgaan, in theorie kan dit dubbelop zijn, maar maakt opzich niet uit, zolang we de aliens optijd verwijderen is de 2e keer puntloos { int CardSpot = i; CCPoint NextCardpos = m_PlacedCard; if (CardSpot == 0) { NextCardpos.Y -= 1; } else if (CardSpot == 1) { NextCardpos.X -= 1; } else if (CardSpot == 2) { NextCardpos.Y += 1; } else if (CardSpot == 3) { NextCardpos.X += 1; } Card NextCard = m_Board.GetCard(NextCardpos); if (NextCard != null) { List <PLayerScore> Score = new List <PLayerScore>(); Player pl = m_Board.HasAlien(m_PlacedCard, CardSpot); if (pl != null) { PLayerScore PS = new PLayerScore(); PS.m_Player = pl; PS.m_Punt = m_PlacedCard; Score.Add(PS); } List <CCPoint> Cards = new List <CCPoint>(); Cards.Add(m_PlacedCard); bool b = FindCastleOpenSpots(NextCardpos, CardSpot, ref Cards, ref Score); if (!b) // dus Kasteel heeft geen open dingen, check score { int CardScore = 0; if (Cards.Count == 2) { CardScore = 2; } else { CardScore = Cards.Count * 2; } Dictionary <Player, int> Dic = new Dictionary <Player, int>(); foreach (PLayerScore ps in Score) { if (!Dic.ContainsKey(ps.m_Player)) { Dic.Add(ps.m_Player, 0); } } foreach (PLayerScore ps in Score) { Dic[ps.m_Player] += 1; ps.m_Player.NumberOfAliens++; m_Board.RemoveAlien(ps.m_Punt); m_Scene.m_BoardLayer.RemoveAlien(ps.m_Punt); } List <Player> player = new List <Player>(); int HighestScore = 0; foreach (var v in Dic) { if (v.Value > HighestScore) { player.Clear(); HighestScore = v.Value; player.Add(v.Key); } else if (v.Value == HighestScore) { player.Add(v.Key); } } foreach (Player p in player) { p.Points += CardScore; } } } } } } }