예제 #1
0
 public GameState()
 {
     cardFactory = new CardFactory();
     hero = new Player(this, LocationPlayer.HERO);
     villain = new Player(this, LocationPlayer.VILLAIN);
     stack = new Pile(new Location(LocationPile.STACK, LocationPlayer.NOONE));
 }
예제 #2
0
 public GainBonusManaEvent(Player plr, Colour colour)
     : base(plr, GameEventType.GAINBONUSMANA)
 {
     this.colour = colour;
 }
예제 #3
0
 public DrawEvent(Player plr, int cards)
     : base(plr, GameEventType.DRAW)
 {
     cardCount = cards;
 }
예제 #4
0
 public DrawEvent(Player plr)
     : base(plr, GameEventType.DRAW)
 {
     cardCount = 1;
 }
예제 #5
0
 public Card makeCard(Player p, CardId id)
 {
     return cardFactory.makeCard(p, id);
 }
예제 #6
0
 public UntopPlayerEvent(Player plr)
     : base(plr, GameEventType.UNTOPPLAYER)
 {
 }
예제 #7
0
 public StepEvent(Step step, Player activePlayer)
     : base(GameEventType.STEP)
 {
     this.step = step;
     this.activePlayer = activePlayer;
 }
예제 #8
0
 public PlayerEvent(Player plr, GameEventType type)
     : base(type)
 {
     player = plr;
 }
예제 #9
0
 public GameElement(Player p)
 {
     element = p;
     type = GameElementType.PLAYER;
 }
예제 #10
0
        private void mulligan(Player p, int handSize)
        {
            p.setLife(25);
            Choice c;
            int life = 1;
            while (true)
            {
                while (p.hand.count > 0)
                {
                    moveCardTo(p.hand.peek(), p.deck);
                }
                shuffleDeck(p);
                for (int i = 0; i < handSize; i++)
                {
                    moveCardTo(p.deck.peek(), p.hand);
                }

                if (p.getLife() < 16)
                {
                    break;
                }

                if (p.isHero)
                {
                    c = gameInterface.getChoice("Do you want to mulligan?", Choice.Yes, Choice.No);
                    gameInterface.sendSelection((int)c);
                }
                else
                {
                    gameInterface.setContext("Opponent is mulliganing.");
                    c = (Choice)gameInterface.demandSelection();
                    gameInterface.clearContext();
                }
                if (c != Choice.Yes)
                {
                    break;
                }
                p.setLifeRelative(-life++);
            }
        }
예제 #11
0
        public void start(bool home)
        {
            CardId[] heroCards = loadDeck();
            gameInterface.sendDeck(heroCards);
            CardId[] villainCards = gameInterface.demandDeck();
            homePlayer = home ? game.hero : game.villain;
            awayPlayer = home ? game.villain : game.hero;
            game.loadDeck(homePlayer, home ? heroCards : villainCards);
            game.loadDeck(awayPlayer, !home ? heroCards : villainCards);

            int seed;
            bool goingFirst;
            if (home)
            {
                Random r = new Random();
                seed = r.Next();
                gameInterface.sendSelection(seed);
                Choice c = gameInterface.getChoice("Do you want to go first?", Choice.Yes, Choice.No);
                gameInterface.sendSelection((int)c);
                goingFirst = c == Choice.Yes;
            }
            else
            {
                gameInterface.setContext("Get outflipped bwoi");
                seed = gameInterface.demandSelection();
                Choice c = (Choice)gameInterface.demandSelection();
                goingFirst = c == Choice.No;
                gameInterface.clearContext();
            }
            deckShuffler = new Random(seed);
            shuffleDeck(homePlayer);
            shuffleDeck(awayPlayer);
            game.setHeroStarting(goingFirst);
            mulligan(game.activePlayer, 4);
            mulligan(game.inactivePlayer, 5);
            loop();
        }
예제 #12
0
 public void shuffleDeck(Player p)
 {
     p.deck.shuffle(deckShuffler);
 }
예제 #13
0
 public List<Card> makeList(Player p, params CardId[] ids)
 {
     return ids.Select((a) => makeCard(p, a)).ToList(); //LINQ: pretty and readable
 }
예제 #14
0
            public Card makeCard(Player owner, CardId id)
            {
                int i = ctr++;
                Card c = new Card(id);
                c.setId(i);
                c.owner = owner;
                c.controller = owner;
                cards.Add(i, c);
                if (owner.isHero)
                {
                    hero.Add(c);
                }
                else
                {
                    villain.Add(c);
                }

                return c;
            }
예제 #15
0
 public GainLifeEvent(Player p, int l)
     : base(p, GameEventType.GAINLIFE)
 {
     life = l;
 }
예제 #16
0
        public List<PlayerButton> getPlayerButton(Player p)
        {
            List<PlayerButton> r = new List<PlayerButton>();

            foreach (Observer o in p.getObservers())
            {
                if (o is PlayerPanel)
                {
                    r.Add(((PlayerPanel)o).playerPortrait);
                }
            }

            return r;
        }
예제 #17
0
 public GainManaOrbEvent(Player plr, int color)
     : base(plr, GameEventType.GAINMANAORB)
 {
     c = color;
 }
예제 #18
0
 public void setObservers(Player h, Player v, Pile s)
 {
     gamePanel.setObservers(h, v, s);
 }
예제 #19
0
 public ShuffleDeckEvent(Player plr)
     : base(plr, GameEventType.SHUFFLEDECK)
 {
 }
예제 #20
0
 public void showGraveyard(Player p)
 {
     FML f = new FML((a) => { gameElementPressed(new GameElement(a.Card)); }, (a, b) => { }, () => { }, (c) => setFocusCard(c.Card));
     CardPanel l = new CardPanel(() => new CardButton(f), new LayoutArgs(false, false),p.graveyard);
     GUI.showWindow(l, new WindowedPanelArgs("Graveyard", true, true, false));
 }
예제 #21
0
 public SummonTokenEvent(Player p, CardId id)
     : base(GameEventType.SUMMONTOKEN)
 {
     this.id = id;
     player = p;
 }
예제 #22
0
 public DamagePlayerEvent(Player plr, Card src, int dmg)
     : base(plr, GameEventType.DAMAGEPLAYER)
 {
     source = src;
     damage = dmg;
 }
예제 #23
0
        public void notifyObserver(Observable o, object args)
        {
            player = (Player)o;
            playerPortrait.player = player;

            updateManaDisplay();

            safeSetText(health, player.getLife().ToString());
            safeSetText(deck, player.deck.count.ToString());
            safeSetText(hand, player.hand.count.ToString());
            safeSetText(yard, player.graveyard.count.ToString());

            Invalidate();
        }
예제 #24
0
 public void loadDeck(Player p, CardId[] cs)
 {
     List<Card> myDeck = cardFactory.makeList(hero, cs);
     p.loadDeck(myDeck);
 }