Пример #1
0
 private Player(Player p)
 {
     _position = p._position;
     playernum = p.playernum;
     cards = p.cards;
     isAI = p.isAI;
     type = p.type;
 }
Пример #2
0
 public override GameState execute(GameState gs)
 {
     //Debug.Assert(debug_gs == null || debug_gs == gs, "Action used on an unintended gamestate");
     Player movedPlayer = new Player(dest, gs.currentPlayer());
     GameState result = gs.adjustPlayer(movedPlayer);
     result.advanceMove();
     return result;
 }
Пример #3
0
 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;
 }
Пример #4
0
 public static List<MoveToCardAction> actionsForPlayer(Player p)
 {
     List<MoveToCardAction> results = new List<MoveToCardAction>();
     foreach (City c in p.cards)
     {
         results.Add(new MoveToCardAction(p, c));
     }
     return results;
 }
Пример #5
0
 public override GameState execute(GameState current)
 {
     Player newPlayer = new Player(card, player);
     newPlayer = newPlayer.removeCard(card);
     GameState g = current.adjustPlayer(newPlayer);
     g.advanceMove();
     g = g.recalcBestCardHolder(g, newPlayer, card.color);
     return g;
 }
Пример #6
0
        public override GameState execute(GameState current)
        {
            Debug.Assert(debug_gs == null || debug_gs == current, "Action used on an unintended gamestate");

            Map newMap = current.map.addStation(position);
            GameState g = new GameState(current, newMap);
            player = player.removeCard(position);
            g.players[g.currentPlayerNum] = player;
            g.advanceMove();
            g = g.recalcBestCardHolder(g, player, position.color);
            return g;
        }
Пример #7
0
 public static List<MakeStationAction> actionsForPlayer(Player p, Map m)
 {
     List<MakeStationAction> results = new List<MakeStationAction>();
     foreach (City c in p.cards)
     {
         if (p.position == c && m.hasStation(c) == false && m.numStations != numberAllowed)
         {
             results.Add(new MakeStationAction(p, c));
         }
     }
     return results;
 }
Пример #8
0
 public GameState adjustPlayer(Player p)
 {
     GameState result = new GameState(this);
     result.players = new Player[numPlayers];
     for (int i = 0; i < numPlayers; i++)
     {
         result.players[i] = players[i];
     }
     Debug.Assert(p.playernum < numPlayers);
     result.players[p.playernum] = p;
     return result;
 }
Пример #9
0
 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);
 }
Пример #10
0
        public GameEngine(Player.Type hType, int difficultyLevel, Boolean allAI)
        {

            //initialize infection and player decks and map
            Map map = initializeCities();
            Deck<City> ideck = initializeInfectionDeck(map);
            //initialize player deck

            gs = new GameState(atlanta, map, 4, 4, ideck, initializePlayerDeck(map));
            gs.map = initializeBoard(map);
            if (!allAI)
            {
                gs.players[0].isAI = false;
            }

            foreach (Player p in gs.players)
            {
                gs = gs.drawPlayerCards(p, 5);
                List<City> drawn = gs.playerDeck.mostRecent(5);
                p.cards.AddRange(drawn);
                gs = gs.adjustPlayer(p);
            }


            List<int> cardLocations = makeEpidemicCards(gs.playerDeck.drawDeck.Count, difficultyLevel);

            for (int i = 0; i < cardLocations.Count; i++)
            {
                cardLocations[i] = cardLocations[i] + gs.playerDeck.cardWeAreOn + 1;
            }

            gs.playerDeck.epidemicCards = cardLocations;
            //ev = new HatesDisease(100);
            ev = new outbreakHater(true);

        }
Пример #11
0
 public MakeStationAction(Player p, City position)
 {
     this.position = position;
     this.player = p;
 }
Пример #12
0
 private TradeAction(Player from, Player to, City card)
 {
     this.from = from;
     this.to = to;
     this.card = card;
 }
Пример #13
0
 public MoveToCardAction(Player player, City card)
 {
     this.player = player;
     this.card = card;
 }
Пример #14
0
 public List<CureCityAction> getCureActionsFor(Player player)
 {
     List<CureCityAction> cures = new List<CureCityAction>();
     for (int i = 0; i < 4; i++)
     {
         DiseaseColor color = (DiseaseColor)i;
         if (diseaseLevel(player.position, color) > 0)
         {
             cures.Add(new CureCityAction(player.position, color));
         }
     }
     return cures;
 }
Пример #15
0
        public GameState drawPlayerCards(Player cp, int num = 2)
        {
            GameState newGS = new GameState(this);
            for (int i = 0; i < num; i++)
            {
                if (newGS.playerDeck.isNextCardEpidemic())
                {

                    newGS.epidemicCard();
                    newGS.playerDeck.cardWeAreOn++;
                }
                else
                {
                    newGS.playerDeck = newGS.playerDeck.draw(1);
                    if (newGS.playerDeck.isOverdrawn)
                    {
                        //we just lost
                        return newGS;
                    }
                    newGS = newGS.adjustPlayer(cp.addCard(newGS.playerDeck.mostRecent(1)[0]));
                    newGS.recalcForAddCard(cp, newGS.playerDeck.mostRecent(1)[0]);
                }
            }
            
            return newGS;
        }
Пример #16
0
        public GameState recalcBestCardHolder(GameState newGs, Player playerObj, DiseaseColor card)
        {
            int player = playerObj.playernum;
            if (bestCardHolder[(int)card].Key != player)
            {
                return newGs;
            }
            

            int bestColor = -1;
            int bestPlayer = -1;
            foreach (Player p in newGs.players)
            {
                int totalColor = 0;
                
                foreach (City c in p.cards)
                {
                    if(c.color == card) {
                        totalColor++;
                    }
                    if (totalColor > bestColor)
                    {
                        bestColor = totalColor;
                        bestPlayer = p.playernum;
                    }
                }
            }

            KeyValuePair<int, int>[] newbestCardHolder = new KeyValuePair<int, int>[4];
            for (int i = 0; i < 4; i++)
            {
                newbestCardHolder[i] = newGs.bestCardHolder[i]; 
            }
            newbestCardHolder[(int)card] = new KeyValuePair<int, int>(bestPlayer, bestColor);
            newGs.bestCardHolder = newbestCardHolder;
            return newGs;
        }
Пример #17
0
        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;
        }
Пример #18
0
 private void createPlayersHandLabels(Player curr)
 {
     float currentOffset = .010f;
     float x = .016f;
     foreach (City c in curr.cards)
     {
        // x += currentOffset;
         makeLabel(c.name, x, .019f, Color.HotPink, Color.Gray);
        currentOffset+= .010f;
     }
 }
Пример #19
0
 public Player(City newPosition, Player player)
     : this(player)
 {
     _position = newPosition;
 }
Пример #20
0
        public List<MoveAction> getMoveActionsFor(Player player)
        {
            if (cities[player.position.cityNumber].moveActions == null)
            {
                List<MoveAction> moves = new List<MoveAction>();
                foreach (City c in player.position.adjacent)
                {
                    moves.Add(new MoveAction(c));
                }
                if (cities[player.position.cityNumber].hasStation())
                {
                    foreach (City c in stations)
                    {
                        if (c == player.position)
                            continue;
                        // this turns out to be slow
                        if (player.position.isAdjacent(c))
                            continue;
                        moves.Add(new MoveAction(c));
                    }
                }
                cities[player.position.cityNumber].moveActions = moves;

            }
            return cities[player.position.cityNumber].moveActions;
        }