/// <summary> /// Creates a <see cref="Octgn.Play.Card"/> from a <see cref="Octgn.DataNew.Entities.ICard"/> and stores its <see cref="Octgn.Play.CardIdentity"/> /// </summary> /// <param name="card"></param> /// <param name="player"></param> /// <returns></returns> public static Play.Card ToPlayCard(this ICard card, Play.Player player) { ulong key = card.GenerateKey(); int id = card.GenerateCardId(); var retCard = new Play.Card(player, id, key, Program.GameEngine.Definition.GetCardById(card.Id), true); return retCard; }
/// <summary> /// Creates a <see cref="Octgn.Play.Card"/> from a <see cref="Octgn.DataNew.Entities.ICard"/> and stores its <see cref="Octgn.Play.CardIdentity"/> /// </summary> /// <param name="card"></param> /// <param name="player"></param> /// <returns></returns> public static Play.Card ToPlayCard(this ICard card, Play.Player player) { ulong key = card.GenerateKey(); int id = card.GenerateCardId(); var retCard = new Play.Card(player, id, key, Program.GameEngine.Definition.GetCardById(card.Id), true); return(retCard); }
internal void LoadGroup(GroupSaveState g) { var group = Play.Group.Find(g.Id); group.Controller = Play.Player.Find(g.Controller); group.Viewers = g.Viewers.Select(Play.Player.Find).ToList(); group.Visibility = g.Visiblity; foreach (var c in g.Cards) { DataNew.Entities.Card model = null; if (c.Type != Guid.Empty) { model = Core.DataManagers.GameManager.Get() .GetById(Program.GameEngine.Definition.Id) .GetCardById(c.Type); } var owner = Play.Player.Find(c.Owner); var card = new Play.Card(owner, c.Id, (ulong)c.EncType, model, owner == Play.Player.LocalPlayer); if (group.Cards.Any(x => x.Id == card.Id) == false) { group.Add(card); } card.SwitchTo(owner, c.Alternate, false); card.Controller = Play.Player.Find(c.Controller); card.DeleteWhenLeavesGroup = c.DeleteWhenLeavesGroup; card.SetFaceUp(c.FaceUp); card.SetHighlight(c.HighlightColor); card.SetIndex(c.Index); card.Orientation = c.Orientation; card.SetOverrideGroupVisibility(c.OverrideGroupVisibility); card.SetTargetedBy(Play.Player.Find(c.TargetedBy)); card.TargetsOtherCards = c.TargetsOtherCards; card.X = c.X; card.Y = c.Y; foreach (var m in c.Markers) { card.SetMarker(card.Owner, m.Id, m.Name, m.Count, false); } foreach (var pp in c.PeekingPlayers.Select(Play.Player.Find)) { card.PeekingPlayers.Add(pp); } } }
public static Octgn.Play.CardIdentity CreateIdentity(this Play.Card card) { Play.CardIdentity ret = null; if (card.IsVisibleToAll()) { ret = card.Type; ret.Visible = true; } else { ret = new Play.CardIdentity(GenerateCardId()); //ret.Alias = ret.MySecret = true; ret.Key = ((ulong)Crypto.PositiveRandom()) << 32 | (uint)card.Type.Id; ret.Visible = false; } return(ret); }
internal void LoadGroup(GroupSaveState g, Play.Player fromPlayer, bool isTable = false) { var group = Play.Group.Find(g.Id); if (!isTable) { group.Controller = Play.Player.Find(g.Controller); } group.Viewers = g.Viewers.Select(Play.Player.Find).ToList(); group.Visibility = g.Visiblity; foreach (var c in g.Cards) { var owner = Play.Player.Find(c.Owner); DataNew.Entities.Card model = null; if (c.Type != Guid.Empty) { model = Core.DataManagers.GameManager.Get() .GetById(Program.GameEngine.Definition.Id) .GetCardById(c.Type); } var card = Play.Card.Find(c.Id); if (fromPlayer == owner && card != null) { //card.Type.Key = ulong.Parse(c.EncType); card.SetModel(model.Clone()); //card.Type = new CardIdentity(card.Id){Key=(ulong)c.EncType,Model = model.Clone(),MySecret = owner == Play.Player.LocalPlayer}; //Play.Card.Remove(card); //card = null; } if (card == null) { card = new Play.Card(owner, c.Id, model, owner == Play.Player.LocalPlayer, c.Size); } group.Remove(card); group.Add(card); card.Group = group; card.SwitchTo(owner, c.Alternate, false); card.Controller = Play.Player.Find(c.Controller); card.DeleteWhenLeavesGroup = c.DeleteWhenLeavesGroup; card.SetFaceUp(c.FaceUp); card.SetHighlight(c.HighlightColor); card.SetIndex(c.Index); card.Orientation = c.Orientation; card.SetOverrideGroupVisibility(c.OverrideGroupVisibility); card.SetTargetedBy(Play.Player.Find(c.TargetedBy)); card.TargetsOtherCards = c.TargetsOtherCards; card.X = c.X; card.Y = c.Y; card.PropertyOverrides = c.PropertyOverrides; foreach (var m in c.Markers) { card.SetMarker(card.Owner, m.Id, m.Name, m.Count, false); } foreach (var pp in c.PeekingPlayers.Select(Play.Player.Find)) { card.PeekingPlayers.Add(pp); } } group.OnCardsChanged(); }