public static void PlayCardInfo(Client client, string jsonPacketData) { client.packetMap.Remove("PlayCardInfo"); PlayCardInfo playCardInfo = JsonConvert.DeserializeObject<PlayCardInfo>(jsonPacketData); Battle battle = BattleAPI.GetBattle(client.account.username); if (battle.handMap.ContainsKey(playCardInfo.card)) { Card card = battle.handMap[playCardInfo.card]; CardType cardType = CardAPI.GetCardType(card.typeId); CardInfo cardInfo = new CardInfo(); cardInfo.card = card; if (BattleAPI.EnoughResources(battle, cardType)) { cardInfo.hasEnoughResources = true; cardInfo.isPlayable = true; if (cardType.kind == "CREATURE" || cardType.kind == "STRUCTURE") { List<CardInfo.Data.SelectableTiles.TileSet> tileSets = new List<CardInfo.Data.SelectableTiles.TileSet>(); for (int i = 0; i < 5; i++) { for (int ii = 0; ii < 3; ii++) { if (battle.board[ii, i] == null) { CardInfo.Data.SelectableTiles.TileSet tileSet = new CardInfo.Data.SelectableTiles.TileSet(); tileSet.color = battle.color; tileSet.position = i + "," + ii; tileSets.Add(tileSet); } } } cardInfo.data.selectableTiles.tileSets.Add(tileSets); } else { cardInfo.data.selectableTiles.tileSets.Add(RuleHandler.HandleCardSelect(battle, cardType)); } if (cardType.targetArea == String.Empty) { cardType.targetArea = "TILE"; } else { cardInfo.data.targetArea = cardType.targetArea; } } else { cardInfo.hasEnoughResources = false; cardInfo.isPlayable = false; cardInfo.alerts.Add("Not enough resources"); } client.Send(cardInfo); } else { Console.WriteLine("{0} requested card information on card {1} which they don't have in hand!", client.account.username, playCardInfo.card); } }
private static void TileSet(List<CardInfo.Data.SelectableTiles.TileSet> tileSets, string color, int posX, int posY) { CardInfo.Data.SelectableTiles.TileSet tileSet = new CardInfo.Data.SelectableTiles.TileSet(); tileSet.color = color; tileSet.position = posY + "," + posX; tileSets.Add(tileSet); }