public void initialize() { map = new Map(); newYork = map.addCity("New York", DiseaseColor.BLUE); newark = map.addCity("Newark", DiseaseColor.BLUE); atlanta = map.addCity("Atlanta", DiseaseColor.BLUE); chicago = map.addCity("Chicago", DiseaseColor.BLUE); miami = map.addCity("Miami", DiseaseColor.ORANGE); City.makeAdjacent(newYork, newark); City.makeAdjacent(newark, atlanta); City.makeAdjacent(atlanta, newYork); City.makeAdjacent(newark, chicago); City.makeAdjacent(atlanta, miami); for (int i = 0; i < 3; i++) { map = map.addDisease(newYork); map = map.addDisease(newark); map = map.addDisease(atlanta); map = map.addDisease(miami); } }
public Boolean isAdjacent(City adj) { if (adjacent.Contains(adj)) { return true; } else return false; }
public Player(City position, int playernum, Boolean isAI = true, Type type = Type.NOBODY) { _position = position; this.playernum = playernum; this.isAI = isAI; this.cards = new List<City>(); this.type = type; }
public Player removeCard(City city) { Player newPlayer = new Player(this); newPlayer.cards = new List<City>(); newPlayer.cards.AddRange(cards); newPlayer.cards.Remove(city); return newPlayer; }
public void CityConstructorTest() { string name = "New York"; DiseaseColor color = DiseaseColor.BLACK; City target = new City(name, color, 1); Assert.AreEqual(name, target.name); Assert.AreEqual(color, target.color); }
public void initialize() { map = new Map(); atlanta = map.addCity("Atlanta", DiseaseColor.BLUE); newyork = map.addCity("NewYork", DiseaseColor.BLUE); City.makeAdjacent(atlanta, newyork); gs = new GameState(atlanta, map); }
private Player(Player p) { _position = p._position; playernum = p.playernum; cards = p.cards; isAI = p.isAI; type = p.type; }
public static void makeAdjacent(City one, City two) { if (one.isAdjacent(two)) { throw new Exception(one.name + " and " + two.name +"Already adjacent"); } one.addAdjacent(two); two.addAdjacent(one); }
public void moveExecuteTest() { City atlanta = new City("Atlanta", DiseaseColor.BLUE, 0); City newyork = new City("NewYork", DiseaseColor.BLUE, 1); City.makeAdjacent(atlanta, newyork); GameState gs = new GameState(atlanta, null); MoveAction action = new MoveAction(newyork); GameState newGs = action.execute(gs); Assert.AreEqual(newyork, newGs.currentPlayer().position); Assert.AreEqual(atlanta, gs.currentPlayer().position); }
// инициализирует данные и создаёт лист City public List<City> Create() { List<City> listcity = new List<City>();// Список city DataTable dt= new DataTable(); DataTable dt2=new DataTable(); //подключение к БД _mySQLMethods LoadBase= new _mySQLMethods("127.0.0.1","pandemic_bd","root",""); _mySQLMethods LoadBase2 = new _mySQLMethods("127.0.0.1", "pandemic_bd", "root", ""); dt = LoadBase.Display("SELECT * FROM neighbors");// таблица соседей dt2 = LoadBase2.Display("SELECT * FROM city");// таблица городов(координаты, цвет) for (int i = 0; i < dt.Rows.Count/2; i++) { City city = new City();// временный город(для записи) city.NameCity = dt.Rows[i][0].ToString();//Запись имени города // запись соседей city.Neighbor=new List<string>(); string s = dt.Rows[i][1].ToString(); string[] zn = new string[] { " " }; string[] mas = s.Split(zn, StringSplitOptions.None); foreach (var ma in mas) { city.Neighbor.Add(ma); } listcity.Add(city);//Заполнение листа City } //запись координат городов for (int i = 0; i < dt2.Rows.Count; i++) { foreach (var city in listcity) { if (city.NameCity==dt2.Rows[i][0].ToString()) { city.CityPosX = Convert.ToInt32(dt2.Rows[i][1].ToString()); city.CityPosY = Convert.ToInt32(dt2.Rows[i][2].ToString()); } } } return listcity; }
public void initialize() { newYork = new City("New York", DiseaseColor.BLUE,0); newark = new City("Newark", DiseaseColor.BLUE, 1); atlanta = new City("Atlanta", DiseaseColor.BLUE, 2); chicago = new City("Chicago", DiseaseColor.BLUE, 3); miami = new City("Miami", DiseaseColor.ORANGE, 4); List<City> cities = new List<City>(); cities.Add(newYork); cities.Add(newark); cities.Add(atlanta); cities.Add(chicago); cities.Add(miami); deck = new Deck<City>(cities, false); }
public GameState(City startCity, Map map, int num_players = 1, int num_moves = 4, Deck<City> infectDeck = null, Deck<City> playerDeck = null) { players = new Player[num_players]; for (int i = 0; i < num_players; i++) { players[i] = new Player(startCity, i); } this.map = map; this.numPlayers = num_players; this.numMoves = num_moves; this.infectionDeck = infectDeck; this.playerDeck = playerDeck; this.turnAction = new TurnAction(); this.curesFound = new bool[4]; for (int i = 0; i < 4; i++) { this.curesFound[i] = false; } bestCardHolder = new KeyValuePair<int,int>[4]; bestCardHolder[(int)DiseaseColor.BLACK] = new KeyValuePair<int, int>(0, 0); bestCardHolder[(int)DiseaseColor.BLUE] = new KeyValuePair<int, int>(0, 0); bestCardHolder[(int)DiseaseColor.YELLOW] = new KeyValuePair<int, int>(0, 0); bestCardHolder[(int)DiseaseColor.ORANGE] = new KeyValuePair<int, int>(0, 0); }
public MakeStationAction(Player p, City position) { this.position = position; this.player = p; }
private TradeAction(Player from, Player to, City card) { this.from = from; this.to = to; this.card = card; }
private void createPlayersLabels(City currentCity, GameState gs, int yOffset) { int currentOffset = 0; foreach (Player p in gs.players) { if (p.position == currentCity) { makePlayer(p.ToString(), currentCity.relativeX, currentCity.relativeY, currentOffset, yOffset); currentOffset++; } } }
private void createDiseaseLabels(City currentCity, GameState gs) { int currentOffset = 1; foreach (DiseaseColor color in Enum.GetValues(typeof(DiseaseColor)).Cast<DiseaseColor>()) { Color f = City.toForeColor(color); Color b = City.toBackColor(color); if (color == currentCity.color) { makeLabel(gs.map.diseaseLevel(currentCity, color).ToString(), currentCity, 0, 0, f, b); } else { int level = gs.map.diseaseLevel(currentCity, color); if(level > 0) { makeLabel(level.ToString(), currentCity, currentOffset, 0, f, b); currentOffset++; } } } }
private void addAdjacent(City adj) { adjacent.Add(adj); }
public CureCityAction(City position, DiseaseColor color) { this.position = position; this.color = color; }
public LikesCity(City city) { this.city = city; }
private void makeLabel(String label, City city, int offsetX, int offsetY, Color f, Color b) { Label label2 = new Label(); label2.AutoSize = true; label2.Location = new System.Drawing.Point((int)(city.relativeX * board.Width) + offsetX*15, (int)(city.relativeY * board.Height) + offsetY*15); label2.Size = new System.Drawing.Size(35, 13); label2.Text = label; label2.ForeColor = f; label2.BackColor = b; this.Controls.Add(label2); this.Controls.SetChildIndex(label2, 1); toRemove.Add(label2); }
public void initialize() { map = new Map(); newyork = map.addCity("NewYork", DiseaseColor.BLUE); newark = map.addCity("Newark", DiseaseColor.BLUE); newark1 = map.addCity("Newark1", DiseaseColor.BLUE); newark2 = map.addCity("Newark2", DiseaseColor.BLUE); newark3 = map.addCity("Newark3", DiseaseColor.BLUE); newark4 = map.addCity("Newark4", DiseaseColor.BLUE); newark5 = map.addCity("Newark5", DiseaseColor.BLUE); newark6 = map.addCity("Newark6", DiseaseColor.BLUE); newark7 = map.addCity("Newark7", DiseaseColor.BLUE); newark8 = map.addCity("Newark8", DiseaseColor.BLUE); newark9 = map.addCity("Newark9", DiseaseColor.BLUE); newark10 = map.addCity("Newark10", DiseaseColor.BLUE); City.makeAdjacent(newyork, newark); gs = new GameState(newyork, map); }
private Map initializeCities() { //north america Map m = new Map(); atlanta = m.addCity("Atlanta", DiseaseColor.BLUE, 0.115f, 0.415f); City newYork = m.addCity("New York", DiseaseColor.BLUE, 0.219f, 0.356f); City chicago = m.addCity("Chicago", DiseaseColor.BLUE, 0.088f, 0.341f); City washington = m.addCity("Washington", DiseaseColor.BLUE, 0.201f, 0.431f); City toronto = m.addCity("Toronto", DiseaseColor.BLUE, 0.159f, 0.361f); City sanFran = m.addCity("San Fransisco", DiseaseColor.BLUE, 0.025f, 0.383f); City losAngeles = m.addCity("Los Angeles", DiseaseColor.YELLOW, 0.037f, 0.485f); City miami = m.addCity("Miami", DiseaseColor.YELLOW, 0.178f, 0.510f); City mexicoCity = m.addCity("Mexico City", DiseaseColor.YELLOW, 0.096f, 0.527f); City.makeAdjacent(newYork, washington); City.makeAdjacent(newYork, toronto); City.makeAdjacent(washington, atlanta); City.makeAdjacent(washington, miami); City.makeAdjacent(washington, toronto); City.makeAdjacent(toronto, chicago); City.makeAdjacent(chicago, losAngeles); City.makeAdjacent(chicago, sanFran); City.makeAdjacent(chicago, mexicoCity); City.makeAdjacent(chicago, atlanta); City.makeAdjacent(sanFran, losAngeles); City.makeAdjacent(mexicoCity, losAngeles); City.makeAdjacent(atlanta, miami); City.makeAdjacent(mexicoCity, miami); //South America City bogota = m.addCity("Bogota", DiseaseColor.YELLOW, 0.167f, 0.597f); City lima = m.addCity("Lima", DiseaseColor.YELLOW, 0.133f, 0.699f); City buenosAires = m.addCity("Buenos Aires", DiseaseColor.YELLOW, 0.216f, 0.802f); City santiago = m.addCity("Santiago", DiseaseColor.YELLOW, 0.155f, 0.818f); City saopaulo = m.addCity("Sau Paulo", DiseaseColor.YELLOW, 0.252f, 0.724f); //Africa City lagos = m.addCity("Lagos", DiseaseColor.YELLOW, 0.372f, 0.578f); City kinshasa = m.addCity("Kinshasa", DiseaseColor.YELLOW, 0.410f, 0.660f); City johannesburg = m.addCity("Johannesburg", DiseaseColor.YELLOW, 0.438f, 0.756f); City khartoum = m.addCity("Khartoum", DiseaseColor.YELLOW, 0.458f, 0.578f); //Europe City madrid = m.addCity("Madrid", DiseaseColor.BLUE, 0.319f, 0.399f); City london = m.addCity("London", DiseaseColor.BLUE, 0.325f, 0.289f); City paris = m.addCity("Paris", DiseaseColor.BLUE, 0.379f, 0.346f); City essen = m.addCity("Essen", DiseaseColor.BLUE, 0.391f, 0.258f); City stpetersburg = m.addCity("St. Petersburg", DiseaseColor.BLUE, 0.460f, 0.246f); City milan = m.addCity("Milan", DiseaseColor.BLUE, 0.428f, 0.333f); //Middle East/India/Moscow City moscow = m.addCity("Moscow", DiseaseColor.BLACK, 0.505f, 0.300f); City istanbul = m.addCity("Istanbul", DiseaseColor.BLACK, 0.449f, 0.392f); City algiers = m.addCity("Algiers", DiseaseColor.BLACK, 0.380f, 0.455f); City cairo = m.addCity("Cairo", DiseaseColor.BLACK, 0.437f, 0.491f); City baghdad = m.addCity("Baghdad", DiseaseColor.BLACK, 0.499f, 0.436f); City riyadh = m.addCity("Riyadh", DiseaseColor.BLACK, 0.508f, 0.534f); City karachi = m.addCity("Karachi", DiseaseColor.BLACK, 0.549f, 0.464f); City mumbai = m.addCity("Mumbai", DiseaseColor.BLACK, 0.561f, 0.569f); City dehli = m.addCity("Dehli", DiseaseColor.BLACK, 0.606f, 0.430f); City kolkata = m.addCity("Kolkata", DiseaseColor.BLACK, 0.655f, 0.469f); City tehran = m.addCity("Tehran", DiseaseColor.BLACK, 0.546f, 0.371f); City chennai = m.addCity("Chennai", DiseaseColor.BLACK, 0.617f, 0.621f); //Asia City bangkok = m.addCity("Bangkok", DiseaseColor.ORANGE, 0.661f, 0.570f); City hongkong = m.addCity("Hong Kong", DiseaseColor.ORANGE, 0.704f, 0.511f); City jakarta = m.addCity("Jakarta", DiseaseColor.ORANGE, 0.668f, 0.679f); City sydney = m.addCity("Sydney", DiseaseColor.ORANGE, 0.820f, 0.801f); City hochi = m.addCity("Ho Chi Minh City", DiseaseColor.ORANGE, 0.715f, 0.612f); City manila = m.addCity("Manila", DiseaseColor.ORANGE, 0.771f, 0.610f); City shanghai = m.addCity("Shanghai", DiseaseColor.ORANGE, 0.695f, 0.429f); City taipei = m.addCity("Taipei", DiseaseColor.ORANGE, 0.766f, 0.509f); City osaka = m.addCity("Osaka", DiseaseColor.ORANGE, 0.798f, 0.467f); City tokyo = m.addCity("Tokyo", DiseaseColor.ORANGE, 0.794f, 0.388f); City seoul = m.addCity("Seoul", DiseaseColor.ORANGE, 0.757f, 0.344f); City beijing = m.addCity("Beijing", DiseaseColor.ORANGE, 0.688f, 0.340f); City.makeAdjacent(bogota, miami); City.makeAdjacent(bogota, mexicoCity); City.makeAdjacent(bogota, saopaulo); City.makeAdjacent(bogota, buenosAires); City.makeAdjacent(bogota, lima); City.makeAdjacent(lima, mexicoCity); City.makeAdjacent(lima, santiago); City.makeAdjacent(buenosAires, saopaulo); City.makeAdjacent(saopaulo, lagos); City.makeAdjacent(saopaulo, madrid); City.makeAdjacent(lagos, khartoum); City.makeAdjacent(lagos, kinshasa); City.makeAdjacent(kinshasa, khartoum); City.makeAdjacent(kinshasa, johannesburg); City.makeAdjacent(khartoum, cairo); City.makeAdjacent(khartoum, johannesburg); City.makeAdjacent(madrid, newYork); City.makeAdjacent(madrid, algiers); City.makeAdjacent(madrid, paris); City.makeAdjacent(madrid, london); City.makeAdjacent(london, paris); City.makeAdjacent(london, newYork); City.makeAdjacent(london, essen); City.makeAdjacent(paris, essen); City.makeAdjacent(paris, milan); City.makeAdjacent(paris, algiers); City.makeAdjacent(essen, milan); City.makeAdjacent(essen, stpetersburg); City.makeAdjacent(stpetersburg, moscow); City.makeAdjacent(stpetersburg, istanbul); City.makeAdjacent(moscow, tehran); City.makeAdjacent(moscow, baghdad); City.makeAdjacent(moscow, istanbul); City.makeAdjacent(istanbul, baghdad); City.makeAdjacent(istanbul, cairo); City.makeAdjacent(istanbul, algiers); City.makeAdjacent(algiers, cairo); City.makeAdjacent(cairo, baghdad); City.makeAdjacent(cairo, riyadh); City.makeAdjacent(baghdad, tehran); City.makeAdjacent(baghdad, karachi); City.makeAdjacent(baghdad, riyadh); City.makeAdjacent(riyadh, karachi); City.makeAdjacent(karachi, dehli); City.makeAdjacent(karachi, mumbai); City.makeAdjacent(dehli, kolkata); City.makeAdjacent(dehli, mumbai); City.makeAdjacent(dehli, chennai); City.makeAdjacent(mumbai, chennai); City.makeAdjacent(kolkata, chennai); City.makeAdjacent(kolkata, bangkok); City.makeAdjacent(kolkata, hongkong); City.makeAdjacent(tehran, dehli); City.makeAdjacent(tehran, karachi); City.makeAdjacent(chennai, bangkok); City.makeAdjacent(chennai, jakarta); City.makeAdjacent(bangkok, hongkong); City.makeAdjacent(bangkok, jakarta); City.makeAdjacent(bangkok, hochi); City.makeAdjacent(hongkong, shanghai); City.makeAdjacent(hongkong, taipei); City.makeAdjacent(hongkong, manila); City.makeAdjacent(hongkong, hochi); City.makeAdjacent(jakarta, hochi); City.makeAdjacent(jakarta, sydney); City.makeAdjacent(sydney, losAngeles); City.makeAdjacent(hochi, manila); City.makeAdjacent(manila, taipei); City.makeAdjacent(manila, sydney); City.makeAdjacent(manila, sanFran); City.makeAdjacent(shanghai, beijing); City.makeAdjacent(shanghai, seoul); City.makeAdjacent(shanghai, tokyo); City.makeAdjacent(shanghai, taipei); City.makeAdjacent(taipei, osaka); City.makeAdjacent(osaka, tokyo); City.makeAdjacent(tokyo, seoul); City.makeAdjacent(tokyo, sanFran); City.makeAdjacent(seoul, beijing); m = m.addStation(atlanta); return m; }
private Map initializeCitiesTest() { //north america //TODO rename CanadaCity to whatever. Add San Fran Map m = new Map(); atlanta = m.addCity("Atlanta", DiseaseColor.BLUE, 0.219f, 0.357f); City newYork = m.addCity("NewYork", DiseaseColor.BLUE, 0.191f, 0.334f); City chicago = m.addCity("Chicago", DiseaseColor.BLUE, 0.088f, 0.341f); City washington = m.addCity("Washington", DiseaseColor.BLUE, 0.201f, 0.431f); City canadaCity = m.addCity("Toronto", DiseaseColor.BLUE, 0.139f, 0.342f); City sanFran = m.addCity("San Fransisco", DiseaseColor.BLUE, 0.025f, 0.383f); City losAngeles = m.addCity("Los Angeles", DiseaseColor.YELLOW, 0.034f, 0.459f); City miami = m.addCity("Miami", DiseaseColor.YELLOW, 0.154f, 0.482f); City mexicoCity = m.addCity("MexicoCity", DiseaseColor.YELLOW, 0.083f, 0.495f); City.makeAdjacent(newYork, washington); City.makeAdjacent(newYork, canadaCity); City.makeAdjacent(washington, atlanta); City.makeAdjacent(washington, miami); City.makeAdjacent(washington, canadaCity); City.makeAdjacent(canadaCity, chicago); City.makeAdjacent(chicago, losAngeles); City.makeAdjacent(chicago, sanFran); City.makeAdjacent(chicago, mexicoCity); City.makeAdjacent(chicago, atlanta); City.makeAdjacent(sanFran, losAngeles); City.makeAdjacent(mexicoCity, losAngeles); City.makeAdjacent(atlanta, miami); City.makeAdjacent(mexicoCity, miami); m = m.addDisease(losAngeles, 3); m = m.addDisease(losAngeles, 1); m = m.addDisease(chicago, 3); m = m.addDisease(chicago, 1); m = m.addStation(atlanta); m = m.addStation(newYork); return m; }
public GameState recalcForAddCard(Player playerWithCard, City card) { GameState gs = new GameState(this); if (playerWithCard.playernum != gs.bestCardHolder[(int)card.color].Key) { int numCol = 0; foreach (City c in playerWithCard.cards) { if (c.color == card.color) { numCol++; } } if (numCol > gs.bestCardHolder[(int)card.color].Value) { KeyValuePair<int, int>[] newbestCardHolder = new KeyValuePair<int, int>[4]; for (int i = 0; i < 4; i++) { newbestCardHolder[i] = gs.bestCardHolder[i]; } newbestCardHolder[(int)card.color] = new KeyValuePair<int, int>(playerWithCard.playernum, numCol); gs.bestCardHolder = newbestCardHolder; } } else { KeyValuePair<int, int>[] newbestCardHolder = new KeyValuePair<int, int>[4]; for (int i = 0; i < 4; i++) { newbestCardHolder[i] = gs.bestCardHolder[i]; } newbestCardHolder[(int)card.color] = new KeyValuePair<int, int>(playerWithCard.playernum, gs.bestCardHolder[(int)card.color].Value + 1); gs.bestCardHolder = newbestCardHolder; } return gs; }
public void CityAddAdj() { City newark = new City("Newark", DiseaseColor.BLUE, 1); City.makeAdjacent(newark, newYork); Assert.IsTrue(newYork.isAdjacent(newark)); }
public MoveToCardAction(Player player, City card) { this.player = player; this.card = card; }
public MoveAction(City dest) { this.dest = dest; }
public Player(City newPosition, Player player) : this(player) { _position = newPosition; }
public void TestLoseOutbreak() { map = new Map(); atlanta = map.addCity("Atlanta", DiseaseColor.BLUE); gs = new GameState(atlanta, map, 1, 4, new Deck<City>(map.allCities), new Deck<City>(map.allCities)); gs = new GameState(gs, gs.map.addDisease(atlanta, 3)); Assert.AreEqual(0, gs.map.outbreakCount); gs = new GameState(gs, gs.map.addDisease(atlanta, 1)); Assert.AreEqual(1, gs.map.outbreakCount); Assert.IsFalse(gs.hasLost()); for (int i = 0; i < 7; i++) { gs = new GameState(gs, gs.map.addDisease(atlanta, 1)); } Assert.AreEqual(8, gs.map.outbreakCount); Assert.IsFalse(gs.hasLost()); gs = new GameState(gs, gs.map.addDisease(atlanta, 1)); Assert.AreEqual(9, gs.map.outbreakCount); Assert.IsTrue(gs.hasLost()); }
public void initialize() { newYork = new City("New York", DiseaseColor.BLUE, 0); }