Beispiel #1
0
 public override GameSaveState Create(GameEngine engine, Play.Player fromPlayer)
 {
     // Still need to a way to send users their state back
     //  I'm thinking that the CardIdentity.Key could be
     //  encrypted with Crypto.Encrypt(something,pkey)
     //  and the server could store the player private key
     //  so that you only have to ask the server to decrypt
     //  the key and figure out the type
     // still need the card that's targeting this card or vise versa
     this.GlobalVariables = engine.GlobalVariables;
     this.StopTurn        = engine.StopTurn;
     //this.TurnPlayer = engine.TurnPlayer.Id;
     if (engine.TurnPlayer != null)
     {
         this.TurnPlayer = engine.TurnPlayer.Id;
     }
     this.TurnNumber = engine.TurnNumber;
     if (Play.Player.LocalPlayer == fromPlayer)
     {
         CurrentUniqueId = engine.CurrentUniqueId;
     }
     Players         = Play.Player.All.Where(x => x.Id != fromPlayer.Id).Select(x => new PlayerSaveState().Create(x, fromPlayer)).ToArray();
     Table           = new GroupSaveState().Create(Program.GameEngine.Table, fromPlayer);
     Table.Visiblity = GroupVisibility.Undefined;
     SessionId       = engine.SessionId;
     return(this);
 }
Beispiel #2
0
        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);
                }
            }
        }
Beispiel #3
0
        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();
        }