예제 #1
0
        public static List <Card> ReadAllCards()
        {
            string strCommand = File.ReadAllText("Database/select_cards_script.sql");
            var    result     = new List <Card>();

            using (SQLiteConnection objConnection = new SQLiteConnection(strConnection))
            {
                objConnection.Open();
                using (SQLiteCommand command = new SQLiteCommand(strCommand, objConnection))
                {
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Card card;
                            var  type = (CardType)reader.GetInt32(3);
                            switch (type)
                            {
                            case CardType.MilitaryCard:
                                card = new MilitaryCard();
                                break;

                            case CardType.CultureCard:
                                card = new CultureCard();
                                break;

                            case CardType.ResourceCard:
                                card = new ResourceCard();
                                break;

                            case CardType.ScienceCard:
                                card = new ScienceCard();
                                break;

                            default:
                                card = new TradeCard();
                                break;
                            }
                            Read(reader, card);
                            result.Add(card);
                        }
                    }
                }
                objConnection.Close();
            }
            return(result);
        }
예제 #2
0
        public void TestAddingMilitaryCardToDb()
        {
            var card = new MilitaryCard
            {
                Title      = "Test military card",
                Strength   = 1,
                Brick      = 2,
                Cloth      = 0,
                Epoch      = 1,
                Glass      = 1,
                Gold       = 1,
                MinPlayers = 5,
                Papirus    = 1,
                Stone      = 0,
                Wood       = 0
            };

            DatabaseProvider.AddMilitaryCards(card);
        }
예제 #3
0
    private void CreateCommonCard()
    {
        // Data from server
        var cardData1 = new ScientificCard(
            "423",
            "Science",
            CommonCardData.CardType.COMMERCIAL_TRADE,
            1,
            new[]
        {
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.ORE, Amount = 1
            }
        },
            "",
            new ScienceEffect(new Resource.ScienceItem {
            Currency = Resource.Science.RUNE_2, Amount = 1
        }));

        //logic card creation
        var card1 = CardCreator.Create(cardData1);

        var cardData2 = new MilitaryCard(
            "213",
            "Military",
            CommonCardData.CardType.MILITARY,
            1,
            new[]
        {
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.STONE, Amount = 1
            }
        },
            "",
            new MilitaryEffect(2));

        //logic card creation
        var card2 = CardCreator.Create(cardData2);

        var cardData3 = new ProductionCard(
            "223",
            "Production",
            CommonCardData.CardType.PRODUCTION,
            1,
            null,
            "",
            new ProductionCardEffect(new[]
                                     { new Resource.CurrencyItem {
                                           Currency = Resource.CurrencyProducts.PAPYRUS, Amount = 1
                                       }, }));

        //logic card creation
        var card3 = CardCreator.Create(cardData3);


        //GLASS 1 PAPYRUS 1 LOOM 1 WOOD 1 ORE 1 STONE 1   glass_papyrus_loom_brick_wood_ore_stone

        var cardData4 = new CommercialMoneyCard(
            "223",
            "Trade",
            CommonCardData.CardType.COMMERCIAL_MONEY,
            1,
            new[]
        {
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.GLASS, Amount = 1
            },
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.GLASS, Amount = 1
            },
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.GLASS, Amount = 1
            },
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.GLASS, Amount = 1
            },
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.GLASS, Amount = 1
            },
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.GLASS, Amount = 1
            },
            new Resource.CurrencyItem {
                Currency = Resource.CurrencyProducts.GLASS, Amount = 1
            },
        },
            "",
            new MoneyEffect(5));

        //logic card creation
        var card4 = CardCreator.Create(cardData4);

        // card visualisation
        //CardVisualizationController.Instance.Visualize(card, transform);

        CardVisualizationController.Instance.AddInHandCards(new[] { card1, card2, card3, card4, card1, card2, card3 });
    }