示例#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);
 }