// 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); }
public Writable_MonsterCard GetWritable(ID <Readable_MonsterCard> monsterId) { WritableCard card; this.cardsDrawn.TryGetWritable(monsterId.AsType((ReadableCard)null), out card); return(card as Writable_MonsterCard); }
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); }
public Readable_MonsterCard Get_ReadableSnapshot(ID <Readable_MonsterCard> cardId) { // We don't store a collection of just the monsters, but we do store a collection of all the cards. // So, find the card with that ID and convert it to a Readable_MonsterCard return(this.Get_ReadableSnapshot(cardId.AsType((ReadableCard)null)) as Readable_MonsterCard); }