Beispiel #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));
 }
Beispiel #2
0
 public GainBonusManaEvent(Player plr, Colour colour)
     : base(plr, GameEventType.GAINBONUSMANA)
 {
     this.colour = colour;
 }
Beispiel #3
0
 public DrawEvent(Player plr, int cards)
     : base(plr, GameEventType.DRAW)
 {
     cardCount = cards;
 }
Beispiel #4
0
 public DrawEvent(Player plr)
     : base(plr, GameEventType.DRAW)
 {
     cardCount = 1;
 }
Beispiel #5
0
 public Card makeCard(Player p, CardId id)
 {
     return cardFactory.makeCard(p, id);
 }
Beispiel #6
0
 public UntopPlayerEvent(Player plr)
     : base(plr, GameEventType.UNTOPPLAYER)
 {
 }
Beispiel #7
0
 public StepEvent(Step step, Player activePlayer)
     : base(GameEventType.STEP)
 {
     this.step = step;
     this.activePlayer = activePlayer;
 }
Beispiel #8
0
 public PlayerEvent(Player plr, GameEventType type)
     : base(type)
 {
     player = plr;
 }
Beispiel #9
0
 public GameElement(Player p)
 {
     element = p;
     type = GameElementType.PLAYER;
 }
Beispiel #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++);
            }
        }
Beispiel #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();
        }
Beispiel #12
0
 public void shuffleDeck(Player p)
 {
     p.deck.shuffle(deckShuffler);
 }
Beispiel #13
0
 public List<Card> makeList(Player p, params CardId[] ids)
 {
     return ids.Select((a) => makeCard(p, a)).ToList(); //LINQ: pretty and readable
 }
Beispiel #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;
            }
Beispiel #15
0
 public GainLifeEvent(Player p, int l)
     : base(p, GameEventType.GAINLIFE)
 {
     life = l;
 }
Beispiel #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;
        }
Beispiel #17
0
 public GainManaOrbEvent(Player plr, int color)
     : base(plr, GameEventType.GAINMANAORB)
 {
     c = color;
 }
Beispiel #18
0
 public void setObservers(Player h, Player v, Pile s)
 {
     gamePanel.setObservers(h, v, s);
 }
Beispiel #19
0
 public ShuffleDeckEvent(Player plr)
     : base(plr, GameEventType.SHUFFLEDECK)
 {
 }
Beispiel #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));
 }
Beispiel #21
0
 public SummonTokenEvent(Player p, CardId id)
     : base(GameEventType.SUMMONTOKEN)
 {
     this.id = id;
     player = p;
 }
Beispiel #22
0
 public DamagePlayerEvent(Player plr, Card src, int dmg)
     : base(plr, GameEventType.DAMAGEPLAYER)
 {
     source = src;
     damage = dmg;
 }
Beispiel #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();
        }
Beispiel #24
0
 public void loadDeck(Player p, CardId[] cs)
 {
     List<Card> myDeck = cardFactory.makeList(hero, cs);
     p.loadDeck(myDeck);
 }