/*Ke pasa cuando se jalan varias cartas en el return*/ public clsCard drawCard(int count = 1) { clsCard c = null; if (Cards.Count < count && Refillfrom == null) { throw new Exception("Tie!"); } if (Cards.Count == 0) { Refill(); shuffle(); } while (count-- > 0) { c = (clsCard)Cards[0]; Cards.RemoveAt(0); Drawto.addCard(c); if (Cards.Count == 0) { Refill(); shuffle(); } } return(c); }
public void AddCard2Zone(string zonename, string cardname) { System.Xml.XmlNode c = null; System.Xml.XmlDocument doc = Container.doc; int cnt = 1; if (cardname == null) { return; } c = doc.SelectSingleNode("//card[@name='" + cardname + "']"); string p = Container.Path + doc.SelectSingleNode("/xml/Cards/set/@path").Value; if (c.Attributes.GetNamedItem("count") != null) { cnt = Convert.ToInt32(c.Attributes.GetNamedItem("count").Value); } for (int i = 0; i < cnt; i++) { clsCard card = new clsCard(c, p); Container.frm.Controls.Add(card.CardFront); Container.frm.Controls.Add(card.CardBack); Values[zonename].addCard(card); card.Card.BringToFront(); card.Card.Refresh(); card.CardFront.MouseDown += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseDown); card.CardFront.MouseMove += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseMove); card.CardFront.MouseUp += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseUp); card.CardBack.Tag = card; card.CardBack.MouseMove += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MM_Count); } }
public void PlayCard(object sender, EventArgs e) { if (CardActive == null) { return; } clsCard c = (clsCard)CardActive.Tag; c.Play(); }
public void KKillCard(object sender, EventArgs e) { if (CardActive == null) { return; } clsCard c = (clsCard)CardActive.Tag; c.Kill(true); }
public void LoadDeck(string name, int playerid) { System.Xml.XmlNode d = null, c; System.Xml.XmlDocument doc = Container.doc; string zonename = string.Empty, xpath = string.Empty; if (name == null) { return; } d = doc.SelectSingleNode("//deck[@name='" + name + "']"); zonename = d.Attributes.GetNamedItem("loadto").Value; string p = Container.Path + doc.SelectSingleNode("/xml/Cards/set/@path").Value; foreach (System.Xml.XmlNode n in d.ChildNodes) { for (int i = 0; i < Convert.ToInt32(n.Attributes.GetNamedItem("count").Value); i++) { xpath = "//card[@name='" + n.Attributes.GetNamedItem("name").Value + "' and @type!='" + n.Attributes.GetNamedItem("type").Value + "']"; c = doc.SelectSingleNode(xpath); if (c == null) { continue; } clsCard card = new clsCard(c, p); Container.frm.Controls.Add(card.CardFront); Container.frm.Controls.Add(card.CardBack); Values[zonename].addCard(card); card.Card.BringToFront(); card.Card.Refresh(); card.CardFront.MouseDown += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseDown); card.CardFront.MouseMove += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseMove); card.CardFront.MouseUp += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseUp); card.CardBack.MouseMove += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MM_Count); card.CardBack.Tag = card; if (Values[zonename].isplayable) { System.Windows.Forms.ContextMenu cm = new System.Windows.Forms.ContextMenu(); cm.MenuItems.Add("Play", new EventHandler(Container.frm.PlayCard)); card.CardFront.ContextMenu = cm; } } } }
/* Corregir que el container (=discard del jugador) tenga dueƱo*/ public void Buy() { if (cost > Container.container.Container.GetActivePlayer().Recruit) { return; } Container.Cards.Remove(this); /*arreglar con zonas, se uso esto para que la carta nueva quede en el mismo lugar*/ if (Container.Name == "hq") { clsCard c = Container.Drawfrom.drawCard(); c.x = x; c.y = y; } Container.Drawto.addCard(this); Owner = Container.container.Container.GetActivePlayer(); Owner.Recruit -= cost; Owner.Refresh(); }
public void AddCard2Zone(string zonename, string group, string type, int count = -1) { System.Xml.XmlNodeList nl = null; System.Xml.XmlDocument doc = Container.doc; string xpath = string.Empty; int cnt = 1; if (group == null) { return; } if (count == -1) { count = 100; } xpath = "//card["; if (group != string.Empty) { xpath += "@group='" + group + "'"; if (type != string.Empty) { xpath += " and "; } } if (type != string.Empty) { xpath += "@type='" + type + "']"; } nl = doc.SelectNodes(xpath); string p = Container.Path + doc.SelectSingleNode("/xml/Cards/set/@path").Value; foreach (System.Xml.XmlNode c in nl) { if (c.Attributes.GetNamedItem("count") != null) { cnt = Convert.ToInt32(c.Attributes.GetNamedItem("count").Value); } else { cnt = 1; } for (int i = 0; i < cnt; i++) { clsCard card = new clsCard(c, p); Container.frm.Controls.Add(card.CardFront); Container.frm.Controls.Add(card.CardBack); Values[zonename].addCard(card); card.Card.BringToFront(); card.Card.Refresh(); card.CardFront.MouseDown += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseDown); card.CardFront.MouseMove += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseMove); card.CardFront.MouseUp += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseUp); card.CardBack.Tag = card; card.CardBack.MouseMove += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MM_Count); } count--; if (count == 0) { break; } } }
public void addCard(clsCard c) { System.Windows.Forms.ContextMenu cm = null; if (isplayable) { cm = new System.Windows.Forms.ContextMenu(); cm.MenuItems.Add("Play", new EventHandler(container.Container.frm.PlayCard)); cm.MenuItems.Add("Play All", new EventHandler(container.Container.frm.PlayAllCards)); } else if (isbuyable) { cm = new System.Windows.Forms.ContextMenu(); cm.MenuItems.Add("Buy", new EventHandler(container.Container.frm.BuyCard)); } else if (iskillable) { cm = new System.Windows.Forms.ContextMenu(); cm.MenuItems.Add("Kill", new EventHandler(container.Container.frm.KillCard)); cm.MenuItems.Add("Kill+1", new EventHandler(container.Container.frm.KKillCard)); } c.CardFront.ContextMenu = cm; c.Owner = this.Owner; if (Cards.Count >= max) { this.drawCard(); } c.Container = this; c.y = y; if (rotate != 0) { c.Rotate(); } if (style == Style.tile || style == Style.tile34) { switch (tiledir) { case TileDir.right: c.x = x + xof; c.y = y; if (style == Style.tile34) { xof += 72; } else { xof += 96; } if (rotate != 0) { c.height = height; c.width = width; } break; case TileDir.left: c.x = x - xof; c.y = y; if (style == Style.tile34) { xof += 72; } else { xof += 99; } c.height = height; //c.width=width; break; case TileDir.top: c.x = x; c.y = y - yof; yof += 15; if (rotate != 0) { c.height = height; c.width = width; } break; } } else { c.x = x; c.width = width; c.height = height; } //if(c.visible!=visibility){ // c.Card.Visible=false; // c.Refresh(); //} c.visible = visibility; c.Card.Visible = true; c.Card.BringToFront(); c.Refresh(); Cards.Add(c); }