public GameView(string userName, string userPassword, string filePath) { UserName = userName; UserPassword = userPassword; g = Game.Deserialize(filePath); FilePath = filePath; CreateAllViews(g); }
public GameView(string userName, string userPassword) { UserName = userName; UserPassword = userPassword; g = new Game(); FilePath = string.Empty; CreateAllViews(g); }
static void Main(string[] args) { Game g = new Game(); g.AdvanceTurn(); Console.WriteLine(g.GameSeason.ToString() + " " + g.GameYear.ToString()); g.Serialize("testOut.xml"); Game h = Game.Deserialize("testOut.xml"); Console.WriteLine(h.GameSeason.ToString() + " " + h.GameYear.ToString()); Console.ReadLine(); }
public EventDraw(Game.MajorPowers power, byte cardNumber, bool revealed = false) { Holder = power; CardNumber = cardNumber; if (power == Game.MajorPowers.Common) { IsRevealed = true; } else { IsRevealed = revealed; } }
public Tiles this[Game.MajorPowers power] { get { if (drawn.ContainsKey(power)) { return drawn[power]; } else { return new Tiles(0, 0, 0); } } set { drawn[power] = value; } }
public void Draw(Game.MajorPowers drawer) { int choose = random.Next(availableCards.Count); byte card = availableCards.ElementAt<byte>(choose); availableCards.Remove(card); List<EventDraw> currentHand; if (currentDraws.ContainsKey(drawer)) { currentHand = currentDraws[drawer]; } else { currentHand = new List<EventDraw>(); currentDraws[drawer] = currentHand; } currentHand.Add(new EventDraw(drawer, card)); if (availableCards.Count == 0) Reshuffle(); }
public bool Return(Game.MajorPowers power, byte denomination) { if (NeedRefresh()) return false; if (denomination == 0 || denomination > 3) return false; Tiles current = FaceUp; Tiles currentDrawn; if (drawn.ContainsKey(power)) { currentDrawn = drawn[power]; } else { return false; } if (denomination == 1) { if (currentDrawn.Item1 > 0) { drawn[power] = new Tiles((byte)(currentDrawn.Item1 - 1), currentDrawn.Item2, currentDrawn.Item3); FaceUp = new Tiles((byte)(current.Item1 + 1), current.Item2, current.Item3); } else { return false; } } else if (denomination == 2) { if (currentDrawn.Item2 > 0) { drawn[power] = new Tiles(currentDrawn.Item1, (byte)(currentDrawn.Item2 - 1), currentDrawn.Item3); FaceUp = new Tiles(current.Item1, (byte)(current.Item2 + 1), current.Item3); } else { return false; } } else { if (currentDrawn.Item3 > 0) { drawn[power] = new Tiles(currentDrawn.Item1, currentDrawn.Item2, (byte)(currentDrawn.Item3 - 1)); FaceUp = new Tiles(current.Item1, current.Item2, (byte)(current.Item3 + 1)); } else { return false; } } return true; }
public bool RandomDraw(Game.MajorPowers power) { if (NeedRefresh()) return false; Tiles old; int tile = random.Next((int) (faceDown.Item1 + faceDown.Item2 + faceDown.Item3)); if (tile < faceDown.Item1) { if (drawn.ContainsKey(power)) { old = drawn[power]; drawn[power] = new Tiles((byte) (old.Item1 + 1), old.Item2, old.Item3); } else { drawn[power] = new Tiles(1, 0, 0); } old = FaceDown; FaceDown = new Tiles((byte)(old.Item1 - 1), old.Item2, old.Item3); } else if (tile < faceDown.Item1 + faceDown.Item2) { if (drawn.ContainsKey(power)) { old = drawn[power]; drawn[power] = new Tiles(old.Item1, (byte)(old.Item2 + 1), old.Item3); } else { drawn[power] = new Tiles(0, 1, 0); } old = FaceDown; FaceDown = new Tiles(old.Item1, (byte)(old.Item2 - 1), old.Item3); } else { if (drawn.ContainsKey(power)) { old = drawn[power]; drawn[power] = new Tiles(old.Item1, old.Item2, (byte)(old.Item3 + 1)); } else { drawn[power] = new Tiles(0, 0, 1); } old = FaceDown; FaceDown = new Tiles(old.Item1, old.Item2, (byte)(old.Item3 - 1)); } return true; }
public List<EventDraw> this[Game.MajorPowers power] { get { return (currentDraws.ContainsKey(power) ? currentDraws[power] : null); } set { currentDraws[power] = value; } }
public SerializableTuple<byte, byte, byte> this[Game.MajorPowers power] { get { return deck[power]; } }
public List<EventDraw> this[Game.MajorPowers power] { get { return deck[power]; } set { deck[power] = value; } }
private void CreateAllViews(Game g) { tv = new TileView(g.Tiles); ev = new EventView(g.Events); uv = new PurgeView(g.Purges); pv = new PlayersView(this, g.Players); CreatePageViews(); NotifyAll(); }
public bool ReturnTile(Game.MajorPowers power, int denomination) { bool ok = g.Tiles.Return(power, (byte)denomination); if (ok) g.HasChanged = true; Notify("GameTurnChanged"); TileOverview.NotifyAll(); foreach (PageView pv in pageViews) pv.NotifyAll(); return ok; }
public bool DrawRandomTile(Game.MajorPowers power) { bool ok = g.Tiles.RandomDraw(power); if (ok) g.HasChanged = true; Notify("GameTurnChanged"); TileOverview.NotifyAll(); foreach (PageView pv in pageViews) pv.NotifyAll(); return ok; }
public void DrawOneEvent(Game.MajorPowers power) { g.Events.Draw(power); g.HasChanged = true; NotifyAll(); }