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