Beispiel #1
0
        // The reason we keep track of both read-only and modifiable entities is to decrease how much we have to clone if we want to copy the game
        public Writable_LifeTarget GetWritable(ID <Readable_LifeTarget> targetId)
        {
            // First check whether this is a player
            Writable_GamePlayer player;
            bool isPlayer = this.players.TryGetWritable(new ID <Readable_GamePlayer>(targetId.ToInt()), out player);

            if (isPlayer)
            {
                return(player);
            }

            // If a life target isn't a player, then it's a card
            // Get a writable dictionary of writable cards, and from it fetch this particular writable card
            // Request write-access to a particular card
            WritableCard card;

            card = this.cardsDrawn.GetWritable(targetId.AsType((ReadableCard)null));
            bool isCard = this.cardsDrawn.TryGetWritable(targetId.AsType((ReadableCard)null), out card);

            if (isCard)
            {
                return(card as Writable_LifeTarget);
            }
            // error: not found
            return(null);
        }
Beispiel #2
0
        public Readable_LifeTarget Get_ReadableSnapshot(ID <Readable_LifeTarget> targetId)
        {
            // First check whether this is a player
            Readable_GamePlayer player;
            bool isPlayer = this.players.TryGetReadable(new ID <Readable_GamePlayer>(targetId.ToInt()), out player);

            if (isPlayer)
            {
                return(player);
            }

            // If a life target isn't a player, then it's a card
            ReadableCard card   = this.cardsDrawn.GetReadable(targetId.AsType((ReadableCard)null));
            bool         isCard = this.cardsDrawn.TryGetReadable(targetId.AsType((ReadableCard)null), out card);

            if (isCard)
            {
                return(card as Readable_LifeTarget);
            }
            // error: not found
            return(null);
        }