public string GroupGetVisibility(int id) { Group g = Group.Find(id); DataNew.Entities.GroupVisibility vis = g.Visibility; switch (vis) { case DataNew.Entities.GroupVisibility.Everybody: return("all"); case DataNew.Entities.GroupVisibility.Nobody: return("none"); case DataNew.Entities.GroupVisibility.Owner: return("me"); case DataNew.Entities.GroupVisibility.Undefined: return("undefined"); case DataNew.Entities.GroupVisibility.Custom: if (g.Viewers.Count == 1 && g.Viewers[0] == g.Controller) { return("me"); } else { return("custom"); } default: throw new ArgumentOutOfRangeException(); } }
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 int GroupCard(int id, int index) { var c = Group.Find(id)[index]; if (c == null) { return(-1); } return(c.Id); }
public void GroupShuffle(int id) { var pile = (Pile)Group.Find(id); if (pile.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't shuffle {1} because they don't control it.", Player.LocalPlayer.Name, pile.Name)); } QueueAction(() => pile.Shuffle()); }
public bool GroupGetCollapsed(int id) { var g = Group.Find(id); if (!(g is Pile)) { return(false); } Pile pile = (Pile)g; return(pile.ViewState == GroupViewState.Collapsed); }
public void GroupSetCollapsed(int id, bool value) { var g = Group.Find(id); if (!(g is Pile)) { return; } Pile pile = (Pile)g; QueueAction(() => pile.Collapsed = value); }
public void GroupSetCollapsed(int id, bool value) { var g = Group.Find(id); if (!(g is Pile)) { return; } Pile pile = (Pile)g; QueueAction(() => pile.ViewState = (value == true) ? GroupViewState.Collapsed : GroupViewState.Pile); }
public void GroupLookAt(int id, int value, bool isTop) { var g = (Pile)Group.Find(id); if (g.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} can't look at {1} because they don't control it.", Player.LocalPlayer.Name, g.Name)); } PlayWindow playWindow = WindowManager.PlayWindow; if (playWindow == null) { return; } Octgn.Controls.ChildWindowManager manager = playWindow.wndManager; if (value > 0) { if (isTop) { QueueAction(() => manager.Show(new GroupWindow(@g, PilePosition.Top, value))); } else { QueueAction(() => manager.Show(new GroupWindow(@g, PilePosition.Bottom, value))); } } else if (value == 0) { int count; if (isTop) { count = QueueAction <int>(() => Dialog.InputPositiveInt("View top cards", "How many cards do you want to see?", 1)); QueueAction(() => manager.Show(new GroupWindow(@g, PilePosition.Top, count))); } else { count = QueueAction <int>(() => Dialog.InputPositiveInt("View bottom cards", "How many cards do you want to see?", 1)); QueueAction(() => manager.Show(new GroupWindow(@g, PilePosition.Bottom, count))); } } else { QueueAction(() => manager.Show(new GroupWindow(@g, PilePosition.All, 0))); } }
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 GroupRemoveViewer(int id, int pid) { Group group = Group.Find(id); Player player = Player.Find((byte)pid); if (group.Controller != Player.LocalPlayer) { Program.GameMess.Warning("{0} can't set visibility on {0} because they don't control it.", Player.LocalPlayer.Name, group.Name); return; } if (!group.Viewers.Contains(player)) { return; } else { QueueAction(() => group.RemoveViewer(player, true)); } }
public void GroupSetController(int id, int player) { var g = Group.Find(id); var p = Player.Find((byte)player); if (p == Player.LocalPlayer) { if (g.Controller == Player.LocalPlayer) { return; } QueueAction(() => g.TakeControl()); } else { if (g.Controller != Player.LocalPlayer) { return; } QueueAction(() => g.PassControlTo(p)); } }
public void GroupSetVisibility(int id, string v) { Group group = Group.Find(id); if (group.Controller != Player.LocalPlayer) { Program.GameMess.Warning("{0} can't set visibility on {0} because they don't control it.", Player.LocalPlayer.Name, group.Name); return; } QueueAction( () => { switch (v.ToLower()) { case "none": group.SetVisibility(false, true); return; case "all": group.SetVisibility(true, true); return; case "undefined": group.SetVisibility(null, true); return; case "me": group.SetVisibility(false, true); group.AddViewer(Player.LocalPlayer, true); return; default: Program.GameMess.Warning("Invalid visibility type '{0}'", v); return; } }); }
public string GroupCtor(int id) { return(PythonConverter.GroupCtor(Group.Find(id))); }
public int GroupController(int id) { return(Group.Find(id).Controller.Id); }
public int[] GroupViewers(int id) { return(Group.Find(id).Viewers.Select(p => (int)p.Id).ToArray()); }
public List <int> Create(string modelId, int groupId, int quantity) { var ret = new List <int>(); Guid modelGuid; if (!Guid.TryParse(modelId, out modelGuid)) { return(ret); } var model = Program.GameEngine.Definition.GetCardById(modelGuid); if (model == null) { return(ret); } var group = Group.Find(groupId); if (group == null) { return(ret); } if (group.Controller != Player.LocalPlayer) { Program.GameMess.Warning(String.Format("{0} Can't create card in {1} because they don't control it.", Player.LocalPlayer.Name, group.Name)); } QueueAction( () => { var gt = new GameEngine.GrpTmp(group, group.Visibility, group.Viewers.ToList()); group.SetVisibility(false, false); var ids = new int[quantity]; var keys = new Guid[quantity]; var sizes = new string[quantity]; for (int i = 0; i < quantity; ++i) { var card = model.ToPlayCard(Player.LocalPlayer); //ulong key = (ulong)Crypto.PositiveRandom() << 32 | model.Id.Condense(); //int id = Program.GameEngine.GenerateCardId(); ids[i] = card.Id; keys[i] = card.Type.Model.Id; sizes[i] = card.Size.Name; ret.Add(card.Id); group.AddAt(card, group.Count); } string pictureUri = model.GetPicture(); Dispatcher.CurrentDispatcher.BeginInvoke( new Func <string, BitmapImage>(ImageUtils.CreateFrozenBitmap), DispatcherPriority.Background, pictureUri); Program.Client.Rpc.CreateCard(ids, keys, sizes, group); switch (gt.Visibility) { case DataNew.Entities.GroupVisibility.Everybody: group.SetVisibility(true, false); break; case DataNew.Entities.GroupVisibility.Nobody: group.SetVisibility(false, false); break; default: foreach (Player p in gt.Viewers) { group.AddViewer(p, false); } break; } }); return(ret); // Comment for a test. }
public int GroupCount(int id) { return(Group.Find(id).Count); }
public int[] GroupCards(int id) { return(Group.Find(id).Select(c => c.Id).ToArray()); }