public object CardAlternateProperty(int id, string alt, string property) { Card c = Card.Find(id); property = property.ToLowerInvariant(); return(c.GetProperty(property, "", StringComparison.InvariantCultureIgnoreCase, alt)); }
public string CardSet(int id) { Card c = Card.Find(id); string set = c.Type.Model.GetSet().Name; return(set); }
public string CardSetId(int id) { Card c = Card.Find(id); string setId = c.Type.Model.SetId.ToString(); return(setId); }
public int MarkerGetCount(int cardId, string markerName, string markerId) { Card card = Card.Find(cardId); Marker marker = card.FindMarker(markerId, markerName); return(marker == null ? 0 : marker.Count); }
//Set's the card's index to idx. Enforces a TableOnly rule, since the index's on other piles/groups are inverted. //ralig98 public void CardSetIndex(int CardId, int idx, bool TableOnly = false) { if (idx < 0) { Program.GameMess.Warning("Cannot setIndex({0}), number is less than 0", idx); return; } Card card = Card.Find(CardId); if (card.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't set index of {1} to Table because they don't control {1}.", Player.LocalPlayer.Name, card.Name)); } if (card.Group != Program.GameEngine.Table && card.Group.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't set index of {1} in {2} because they don't control it.", Player.LocalPlayer.Name, card, card.Group)); } if (!TableOnly || (TableOnly && card.Group is Table)) { QueueAction( () => { //Program.GameEngine.EventProxy.MuteEvents = true; card.MoveToTable((int)card.X, (int)card.Y, card.FaceUp, idx, true); //Program.GameEngine.EventProxy.MuteEvents = false; }); } }
// TODO: Replace this hack with an actual delete function. public void CardDelete(int cardId) { Card c = Card.Find(cardId); var card = c; if (c == null) { return; } if (card.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't delete {1} to Table because they don't control {1}.", Player.LocalPlayer.Name, card.Name)); } if (card.Group != Program.GameEngine.Table && card.Group.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't delete {1} from {2} because they don't control it.", Player.LocalPlayer.Name, card, card.Group)); } if (c.Controller != Player.LocalPlayer) { Program.GameMess.Warning("Cannot delete({0}), because you do not control it. ", cardId); return; } QueueAction(() => { if (c == null) { return; } Program.Client.Rpc.DeleteCard(c, Player.LocalPlayer); c.Group.Remove(c); }); }
public void CardSetAnchored(int cardId, bool anchored) { var card = Card.Find(cardId); if (card == null) { return; } if (card.Group.Definition.Id != Program.GameEngine.Definition.Table.Id) { Program.GameMess.Warning(String.Format("You can't anchor a card that's not on the table.")); return; } if (card.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't anchor {1} to Table because they don't control it.", Player.LocalPlayer.Name, card.Name)); return; } QueueAction(() => { if (card == null) { return; } card.SetAnchored(false, anchored); }); }
/// <summary>Creates new Cards as well as the corresponding CardIdentities. All cards are created in the same group.</summary> /// <param name="id">An array with the new CardIdentity ids.</param> /// <param name="type">An array containing the corresponding CardModel guids (encrypted)</param> /// <param name="group">The group, in which the cards are added.</param> /// <seealso cref="CreateCard(int[], ulong[], Group[])"> to add cards to several groups</seealso> public void CreateCard(int[] id, Guid[] type, string[] size, Group group) { var who = Player.Find((byte)(id[0] >> 16)); WriteReplayAction(who.Id); if (IsLocalPlayer(who)) { return; } for (var i = 0; i < id.Length; i++) { var owner = group.Owner; if (owner == null) { Program.GameMess.Warning("[CreateCard] Player not found."); return; } var c = Card.Find(id[0]); Program.GameMess.PlayerEvent(owner, "{0} creates {1} {2} in {3}'s {4}", owner.Name, id.Length, c == null ? "card" : (object)c, group.Owner.Name, group.Name); // Ignore cards created by oneself var card = new Card(owner, id[i], Program.GameEngine.Definition.GetCardById(type[i]), false, size[i]); group.AddAt(card, group.Count); } }
public void CardPosition(int id, out double x, out double y) { Card c = Card.Find(id); x = c.X; y = c.Y; }
public void CardMoveTo(int cardId, int groupId, int?position) { Card card = Card.Find(cardId); Group group = Group.Find(groupId); if (card.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't move {1} to {2} because they don't control {1}.", Player.LocalPlayer.Name, card.Name, card.Name)); } if (group.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't move {1} to {2} because they don't control {1}.", Player.LocalPlayer.Name, card.Name, group.Name)); } if (card.Group != Program.GameEngine.Table && card.Group.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't move {1} from {2} because they don't control it.", Player.LocalPlayer.Name, card, card.Group)); } QueueAction(() => { //Program.GameEngine.EventProxy.MuteEvents = true; if (position == null) { card.MoveTo(group, true, true); } else { card.MoveTo(group, true, position.Value, true); } //Program.GameEngine.EventProxy.MuteEvents = false; }); }
public string CardModel(int id) //Why is this public? I would expect the model to be private - (V)_V // Ur dumb that's why. { Card c = Card.Find(id); //if (!c.FaceUp || c.Type.Model == null) return null; return(c.Type.Model.Id.ToString()); }
public void CardPeek(int id) { Card c = Card.Find(id); QueueAction(() => { c.Peek(); }); }
/// <summary>Creates new cards on the table, as well as the corresponding CardIdentities.</summary> /// <param name="id">An array with the new CardIdentity ids</param> /// <param name="modelId"> </param> /// <param name="x">The x position of the cards on the table.</param> /// <param name="y">The y position of the cards on the table.</param> /// <param name="faceUp">Whether the cards are face up or not.</param> /// <param name="key"> </param> /// <param name="persist"> </param> public void CreateCardAt(int[] id, Guid[] modelId, int[] x, int[] y, bool faceUp, bool persist) { if (id.Length == 0) { Program.GameMess.Warning("[CreateCardAt] Empty id parameter."); return; } if (id.Length != x.Length || id.Length != y.Length || id.Length != modelId.Length) { Program.GameMess.Warning("[CreateCardAt] Inconsistent parameters length."); return; } var owner = Player.Find((byte)(id[0] >> 16)); if (owner == null) { Program.GameMess.Warning("[CreateCardAt] Player not found."); return; } WriteReplayAction(owner.Id); var table = Program.GameEngine.Table; // Bring cards created by oneself to top, for z-order consistency if (IsLocalPlayer(owner)) { for (var i = id.Length - 1; i >= 0; --i) { var card = Card.Find(id[i]); if (card == null) { Program.GameMess.Warning("[CreateCardAt] Card not found."); return; } table.SetCardIndex(card, table.Count + i - id.Length); } } else { for (var i = 0; i < id.Length; i++) { new CreateCard(owner, id[i], faceUp, Program.GameEngine.Definition.GetCardById(modelId[i]), x[i], y[i], !persist).Do(); } } if (modelId.All(m => m == modelId[0])) { Program.GameMess.PlayerEvent(owner, "creates {1} '{2}'", owner, modelId.Length, IsLocalPlayer(owner) || faceUp ? Program.GameEngine.Definition.GetCardById(modelId[0]).Name : "card"); } else { foreach (var m in modelId) { Program.GameMess.PlayerEvent(owner, "{0} creates a '{1}'", owner, IsLocalPlayer(owner) || faceUp ? Program.GameEngine.Definition.GetCardById(m).Name : "card"); } } }
public void CardSwitchTo(int id, string alternate) { var c = Card.Find(id); if (c == null) { return; } QueueAction(() => c.SwitchTo(Player.LocalPlayer, alternate, true)); }
public CardSize CardSize(int id) { var c = Card.Find(id); if (c == null) { return(null); } return(c.Size); }
public void MoveCardAt(Player player, int[] cards, int[] x, int[] y, int[] idx, bool[] faceUp, bool isScriptMove) { WriteReplayAction(player.Id); // Get the table control var table = Program.GameEngine.Table; var playCards = cards .Select(cardId => { var playCard = Card.Find(cardId); if (playCard == null) { Program.GameMess.Warning("Inconsistent state. Player {0} tried to move a card that does not exist.", player); Program.GameMess.GameDebug("Missing Card ID={0}", cardId); } return(playCard); }) .Where(playCard => playCard != null) .ToArray(); if (playCards.Length == 0) { return; } // Because every player may manipulate the table at the same time, the index may be out of bound if (playCards[0].Group == table) { for (var index = 0; index < idx.Length; index++) { if (idx[index] >= table.Count) { idx[index] = table.Count - 1; } } } else { for (var index = 0; index < idx.Length; index++) { if (idx[index] > table.Count) { idx[index] = table.Count; } } } // Ignore cards moved by the local player (already done, for responsiveness) if (IsLocalPlayer(player)) { return; } // Find the old position on the table, if any // Do the move new MoveCards(player, playCards, x, y, idx, faceUp, isScriptMove).Do(); }
public void CardSetFaceUp(int id, bool value) { Card card = Card.Find(id); if (card.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't flip up {1} because they don't control it.", Player.LocalPlayer.Name, card.Name)); } QueueAction(() => card.FaceUp = value); }
public void CardSetHighlight(int id, string color) { Card card = Card.Find(id); Color?value = color == null ? null : (Color?)ColorConverter.ConvertFromString(color); /*if (card.Controller != Player.LocalPlayer) * Program.GameMess.Warning(String.Format("{0} Can't highlight {1} because they don't control it.", Player.LocalPlayer.Name, card.Name)); */ // Will add in checks or controls to handle/allow this. - DS QueueAction(() => card.HighlightColor = value); }
public bool CardAnchored(int cardId) { var card = Card.Find(cardId); if (card == null) { return(false); } return(card.Anchored); }
public string CardAlternate(int id) { var c = Card.Find(id); if (c == null) { return(""); } //if ((!c.FaceUp && !c.PeekingPlayers.Contains(Player.LocalPlayer)) || c.Type.Model == null) return ""; return(c.Alternate()); }
public void CardResetProperties(int cardId) { var card = Card.Find(cardId); if (card == null) { Program.GameMess.Warning("Card " + cardId + " doesn't exist."); return; } card.ResetProperties(); }
public void CardSetProperty(int cardId, string name, string val) { var card = Card.Find(cardId); if (card == null) { Program.GameMess.Warning("Card " + cardId + " doesn't exist."); return; } card.SetProperty(name, val); }
public string CardGetHighlight(int id) { Color?colorOrNull = Card.Find(id).HighlightColor; if (colorOrNull == null) { return(null); } Color color = colorOrNull.Value; return(string.Format("#{0:x2}{1:x2}{2:x2}", color.R, color.G, color.B)); }
public object CardProperty(int id, string property) { Card c = Card.Find(id); property = property.ToLowerInvariant(); var value = c.GetProperty(property, "", StringComparison.InvariantCultureIgnoreCase, c.Alternate()); if (value is RichTextPropertyValue richText) { return(richText.ToString()); } return(value); }
public void CardSetOrientation(int id, int rot) { if (rot < 0 || rot > 3) { throw new IndexOutOfRangeException("orientation must be between 0 and 3"); } Card card = Card.Find(id); if (card.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't rotate {1} because they don't control it.", Player.LocalPlayer.Name, card.Name)); } QueueAction(() => card.Orientation = (CardOrientation)rot); }
//public Tuple<string, int> AskCard(string restriction) //{ // return QueueAction<Tuple<string, int>>(() => // { // //fix MAINWINDOW bug // var dlg = new CardDlg(restriction) { Owner = WindowManager.PlayWindow }; // if (!dlg.ShowDialog().GetValueOrDefault()) return null; // return Tuple.Create(dlg.SelectedCard.Id.ToString(), // dlg.Quantity); // }); //} public int?SelectCard(List <int> idList, string question, string title) { return(QueueAction <int?>(() => { var cardList = idList.Select(x => Card.Find(x)).ToList(); var dlg = new SelectCardsDlg(cardList, question, title) { Owner = WindowManager.PlayWindow }; if (!dlg.ShowDialog().GetValueOrDefault()) { return null; } return dlg.returnIndex; })); }
public void CardSelect(int id) { Card c = Card.Find(id); // At the moment, only table support multiple selection QueueAction(() => { if (c.Group is Table) { Selection.Add(c); } else { Selection.Clear(); } }); }
public void CardTarget(int id, bool active) { Card c = Card.Find(id); QueueAction(() => { //Program.GameEngine.EventProxy.MuteEvents = true; if (active) { c.Target(true); } else { c.Untarget(true); } //Program.GameEngine.EventProxy.MuteEvents = false; }); }
public static ControllableObject Find(int id) { switch ((byte)(id >> 24)) { case 0: return(Card.Find(id)); case 1: return(Group.Find(id)); case 2: //TODO: make counters controllable objects //return Counter.Find(id); return(null); default: return(null); } }
public void MarkerSetCount(int cardId, int count, string markerName, string markerId) { if (count < 0) { count = 0; } Card card = Card.Find(cardId); Guid guid = Guid.Parse(markerId); Marker marker = card.FindMarker(guid, markerName); int origCount = 0; /*if (card.Controller != Player.LocalPlayer) * Program.GameMess.Warning(String.Format("{0} Can't set markers on {1} because they don't control it.", Player.LocalPlayer.Name, card.Name)); */ // Will add in checks or controls to handle/allow this. -- DS QueueAction(() => { if (marker == null) { DataNew.Entities.Marker model = Program.GameEngine.GetMarkerModel(guid); model.Name = markerName; Program.Client.Rpc.AddMarkerReq(card, guid, markerName, (ushort)count, (ushort)origCount, true); card.AddMarker(model, (ushort)count); } else { origCount = marker.Count; if (origCount < count) { Program.Client.Rpc.AddMarkerReq(card, guid, markerName, (ushort)(count - origCount), (ushort)origCount, true); card.AddMarker(marker.Model, (ushort)(count - origCount)); } else if (origCount > count) { Program.Client.Rpc.RemoveMarkerReq(card, guid, markerName, (ushort)(origCount - count), (ushort)origCount, true); card.RemoveMarker(marker, (ushort)(origCount - count)); } } }); }