コード例 #1
0
ファイル: CardAPI.cs プロジェクト: nightwolf93/Relentless
        public static Card AddCard(Client client, CardType cardType)
        {
            int lastId;
            DB.Database.Execute(client.connection, out lastId, true, true, "INSERT INTO account_cards VALUES (0, ?, ?, 1, 0, 0);", client.account.id, cardType.id);

            Card card = new Card();
            card.id       = lastId;
            card.typeId   = cardType.id;
            card.tradable = true;
            card.isToken  = false;
            card.level    = 0;

            client.account.cardMap.Add(card.id, card);

            return card;
        }
コード例 #2
0
ファイル: BattleAPI.cs プロジェクト: nightwolf93/Relentless
        public static bool EnoughResources(Battle battle, CardType cardType)
        {
            if (cardType.costDecay != 0)
            {
                if (battle.resources[(int)resourceType.decay, 0] >= cardType.costDecay)
                {
                    return true;
                }
            }
            else if (cardType.costEnergy != 0)
            {
                if (battle.resources[(int)resourceType.energy, 0] >= cardType.costEnergy)
                {
                    return true;
                }
            }
            else if (cardType.costGrowth != 0)
            {
                if (battle.resources[(int)resourceType.growth, 0] >= cardType.costGrowth)
                {
                    return true;
                }
            }
            else if (cardType.costOrder != 0)
            {
                if (battle.resources[(int)resourceType.order, 0] >= cardType.costOrder)
                {
                    return true;
                }
            }

            return false;
        }
コード例 #3
0
ファイル: RuleHandler.cs プロジェクト: nightwolf93/Relentless
        public static List<CardInfo.Data.SelectableTiles.TileSet> HandleCardSelect(Battle battle, CardType cardType)
        {
            List<CardInfo.Data.SelectableTiles.TileSet> tileSets = new List<CardInfo.Data.SelectableTiles.TileSet>();

            Battle opponentBattle = BattleAPI.GetOpponentBattle(battle);

            foreach (string ability in cardType.rulesList)
            {
                switch (ability)
                {
                    //Select all creatures and structures on both sides of the board
                    case "Animovore":
                    case "Atrophy":
                    case "BearPaw":
                    case "BlessingOfHaste":
                    case "Bloodboil":
                    case "Burn":
                    case "ChampionRing":
                    case "ClusterHex":
                    case "CrownOfStrength":
                    case "CurseAttacker":
                    case "DamageOneOnDamage":
                    case "ElanVital":
                    case "EmberBonds":
                    case "Focus":
                    case "FrostWind":
                    case "Hymn":
                    case "IllthornSeed":
                    case "IronWhip":
                    case "Kabonk":
                    case "Languid":
                    case "MagmaPack":
                    case "MireCurse":
                    case "PlateArmor":
                    case "Plating":
                    case "Pother":
                    case "PotionOfResistance":
                    case "Regeniture":
                    case "ResonantHelm":
                    case "Spark":
                    case "Speed":
                    case "StagHeart":
                    case "ThoughtTrap":
                    case "ThunderSurge":
                    case "ViolentDispersal":
                    case "VitriolAura":
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                for (int ii = 0; ii < 3; ii++)
                                {
                                    if (battle.board[ii, i] != null)
                                    {
                                        TileSet(tileSets, battle.color, ii, i);
                                    }
                                    if (opponentBattle.board[ii, i] != null)
                                    {
                                        TileSet(tileSets, opponentBattle.color, ii, i);
                                    }
                                }
                            }

                            break;
                        }

                    //Select all creatures on both sides of the board
                    case "BindingRoot":
                    case "BlastStrike":
                    case "BlindRage":
                    case "BrainLice":
                    case "DamningCurse":
                    case "DeathCapBerserk":
                    case "DecCountdownOnCreatureDeathEnch":
                    case "Desperation":
                    case "DivineMark":
                    case "DryadicPower":
                    case "EnergySiphon":
                    case "HexMarks":
                    case "InfectiousBlight":
                    case "LeechingRing":
                    case "MetalHeart":
                    case "Pestis":
                    case "RangersBane":
                    case "Redesign":
                    case "RoastedBeanPotion":
                    case "ShroudOfUnlife":
                    case "UnleashInnerPower":
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                for (int ii = 0; ii < 3; ii++)
                                {
                                    Creature creature         = battle.board[ii, i];
                                    Creature opponentCreature = opponentBattle.board[ii, i];

                                    if (creature != null && creature.kind == "CREATURE")
                                    {
                                        TileSet(tileSets, battle.color, ii, i);
                                    }
                                    if (opponentCreature != null && opponentCreature.kind == "CREATURE")
                                    {
                                        TileSet(tileSets, opponentBattle.color, ii, i);
                                    }
                                }
                            }

                            break;
                        }

                    //Select all structures on both sides of the board
                    case "Overdrive":
                    case "Rigged":
                    case "TickBomb":
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                for (int ii = 0; ii < 3; ii++)
                                {
                                    Creature creature         = battle.board[ii, i];
                                    Creature opponentCreature = opponentBattle.board[ii, i];

                                    if (creature != null && creature.kind == "STRUCTURE")
                                    {
                                        TileSet(tileSets, battle.color, ii, i);
                                    }
                                    if (opponentCreature != null && opponentCreature.kind == "STRUCTURE")
                                    {
                                        TileSet(tileSets, opponentBattle.color, ii, i);
                                    }
                                }
                            }

                            break;
                        }

                    //Select all creatures and structures on your side of the board
                    case "FaithBlessing":
                    case "Metempsychosis":
                    case "Nutrition":
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                for (int ii = 0; ii < 3; ii++)
                                {
                                    if (battle.board[ii, i] != null)
                                    {
                                        TileSet(tileSets, battle.color, ii, i);
                                    }
                                }
                            }

                            break;
                        }

                    //Select all creatures on your side of the board
                    case "Callback":
                    case "FertileSoil":
                    case "GrislyGraft":
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                for (int ii = 0; ii < 3; ii++)
                                {
                                    Creature creature = battle.board[ii, i];

                                    if (creature != null && creature.kind == "CREATURE")
                                    {
                                        TileSet(tileSets, battle.color, ii, i);
                                    }
                                }
                            }

                            break;
                        }

                    //Select all creatures and structures on your opponents side of the board
                    case "Pushback":
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                for (int ii = 0; ii < 3; ii++)
                                {
                                    if (opponentBattle.board[ii, i] != null)
                                    {
                                        TileSet(tileSets, battle.color, ii, i);
                                    }
                                }
                            }

                            break;
                        }
                }
            }

            return tileSets;
        }
コード例 #4
0
ファイル: Initialise.cs プロジェクト: nightwolf93/Relentless
        public static void Assets()
        {
            Console.WriteLine("\nLoading Assets...");

            SQLResult avatarTypeResult = DB.Database.Select(Variables.connection, false, false, "SELECT * FROM avatar_types");

            for (int i = 0; i < avatarTypeResult.Count; i++)
            {
                AvatarType avatarType = new AvatarType();
                avatarType.id       = avatarTypeResult.Read<int>   (i, "id");
                avatarType.type     = avatarTypeResult.Read<string>(i, "type");
                avatarType.part     = avatarTypeResult.Read<string>(i, "part");
                avatarType.filename = avatarTypeResult.Read<string>(i, "filename");
                avatarType.set      = avatarTypeResult.Read<string>(i, "set");

                Variables.avatarTypeMap.Add(avatarType.id, avatarType);
            }

            Console.WriteLine("Avatar Types   - Loaded {0}", Variables.avatarTypeMap.Count);

            SQLResult cardTypeResult = DB.Database.Select(Variables.connection, false, false, "SELECT * FROM card_types");

            for (int i = 0; i < cardTypeResult.Count; i++)
            {
                CardType cardType = new CardType();
                cardType.id                    = cardTypeResult.Read<int>   (i, "id");
                cardType.kind                  = cardTypeResult.Read<string>(i, "kind");
                cardType.name                  = cardTypeResult.Read<string>(i, "name");
                cardType.description           = cardTypeResult.Read<string>(i, "description");
                cardType.flavor                = cardTypeResult.Read<string>(i, "flavor");
                cardType.rarity                = cardTypeResult.Read<int>   (i, "rarity");
                cardType.hp                    = cardTypeResult.Read<int>   (i, "hp");
                cardType.ap                    = cardTypeResult.Read<int>   (i, "ap");
                cardType.ac                    = cardTypeResult.Read<int>   (i, "ac");
                cardType.costDecay             = cardTypeResult.Read<int>   (i, "costDecay");
                cardType.costOrder             = cardTypeResult.Read<int>   (i, "costOrder");
                cardType.costGrowth            = cardTypeResult.Read<int>   (i, "costGrowth");
                cardType.costEnergy            = cardTypeResult.Read<int>   (i, "costEnergy");
                cardType.cardImage             = cardTypeResult.Read<int>   (i, "cardImage");
                cardType.animationPreviewImage = cardTypeResult.Read<int>   (i, "animationPreviewImage");
                cardType.animationPreviewInfo  = cardTypeResult.Read<string>(i, "animationPreviewInfo");
                cardType.animationBundle       = cardTypeResult.Read<int>   (i, "animationBundle");
                cardType.targetArea            = cardTypeResult.Read<string>(i, "targetArea");
                cardType.sound                 = cardTypeResult.Read<string>(i, "sound");
                cardType.soundProjectile       = cardTypeResult.Read<string>(i, "soundProjectile");
                cardType.available             = cardTypeResult.Read<int>   (i, "available");

                foreach (string subType in cardTypeResult.Read<string>(i, "subTypesStr").Split(','))
                {
                    cardType.subTypes.Add(subType);
                }

                string[] ruleListArray = cardTypeResult.Read<string>(i, "rulesList").Split('|');

                if (ruleListArray.Length != 1)
                {
                    for (int ii = 1; ii < ruleListArray.Length; ii++)
                    {
                        cardType.rulesList.Add(ruleListArray[ii]);
                    }
                }

                string[] abilityArray = cardTypeResult.Read<string>(i, "abilities").Split('|');

                if (abilityArray.Length != 1)
                {
                    for (int ii = 0; ii < Convert.ToInt16(abilityArray[0]); ii++)
                    {
                        Ability ability = new Ability();
                        ability.name        = abilityArray[(ii * 7) + 2];
                        ability.description = abilityArray[(ii * 7) + 3];
                        ability.costDecay   = Convert.ToInt16(abilityArray[(ii * 7) + 4]);
                        ability.costEnergy  = Convert.ToInt16(abilityArray[(ii * 7) + 5]);
                        ability.costGrowth  = Convert.ToInt16(abilityArray[(ii * 7) + 6]);
                        ability.costOrder   = Convert.ToInt16(abilityArray[(ii * 7) + 7]);

                        cardType.abilities.Add(abilityArray[(ii * 7) + 1], ability);
                    }
                }

                string[] passiveRuleArray = cardTypeResult.Read<string>(i, "passiveRules").Split('|');

                if (passiveRuleArray.Length != 1)
                {
                    for (int ii = 0; ii < Convert.ToInt16(passiveRuleArray[0]); ii++)
                    {
                        cardType.passiveRules.Add(passiveRuleArray[(ii * 2) + 1], passiveRuleArray[(ii * 2) + 2]);
                    }
                }

                Variables.cardTypeMap.Add(cardType.id, cardType);

                if (cardType.costDecay != 0)
                {
                    Variables.cardTypeDecayMap.Add(cardType.id, cardType);
                }
                if (cardType.costEnergy != 0)
                {
                    Variables.cardTypeEnergyMap.Add(cardType.id, cardType);
                }
                if (cardType.costGrowth != 0)
                {
                    Variables.cardTypeGrowthMap.Add(cardType.id, cardType);
                }
                if (cardType.costOrder != 0)
                {
                    Variables.cardTypeOrderMap.Add(cardType.id, cardType);
                }
            }

            Console.WriteLine("Card Types     - Loaded {0} ({1} Decay, {2} Energy, {3} Growth, {4} Order)",
                Variables.cardTypeMap.Count, Variables.cardTypeDecayMap.Count, Variables.cardTypeEnergyMap.Count, Variables.cardTypeGrowthMap.Count, Variables.cardTypeOrderMap.Count);

            SQLResult deckTypeResult = DB.Database.Select(Variables.connection, false, false, "SELECT * FROM deck_types");

            for (int i = 0; i < deckTypeResult.Count; i++)
            {
                string deckName = deckTypeResult.Read<string>(i, "name");

                if (!Variables.deckTypeMap.ContainsKey(deckName))
                {
                    Variables.deckTypeMap.Add(deckName, new List<int>());
                }

                List<int> cardList = Variables.deckTypeMap[deckName];

                cardList.Add(deckTypeResult.Read<int>(i, "card"));
            }

            Console.WriteLine("Deck Types     - Loaded {0}", Variables.deckTypeMap.Count);

            SQLResult storeItemResult = DB.Database.Select(Variables.connection, false, false, "SELECT * FROM store_items");

            for (int i = 0; i < storeItemResult.Count; i++)
            {
                StoreItem storeItem = new StoreItem();
                storeItem.itemId      = storeItemResult.Read<int>   (i, "itemId");
                storeItem.itemType    = storeItemResult.Read<string>(i, "itemType");
                storeItem.itemName    = storeItemResult.Read<string>(i, "itemName");
                storeItem.description = storeItemResult.Read<string>(i, "description");
                storeItem.costGold    = storeItemResult.Read<int>   (i, "costGold");
                storeItem.costShards  = storeItemResult.Read<int>   (i, "costShards");

                if (storeItemResult.Read<int>(i, "isPublic") == 1)
                {
                    storeItem.isPublic = true;
                }
                else
                {
                    storeItem.isPublic = false;
                }

                Variables.storeItemMap.Add(storeItem.itemId, storeItem);
            }

            Console.WriteLine("Store Items    - Loaded {0}", Variables.storeItemMap.Count);

            SQLResult trialResult = DB.Database.Select(Variables.connection, false, false, "SELECT * FROM tower_info");

            for (int i = 0; i < trialResult.Count; i++)
            {
                Trial trial = new Trial();
                trial.id          = trialResult.Read<int>   (i, "id");
                trial.name        = trialResult.Read<string>(i, "name");
                trial.goldReward  = trialResult.Read<int>   (i, "goldReward");
                trial.description = trialResult.Read<string>(i, "description");
                trial.difficulty  = trialResult.Read<string>(i, "difficulty");
                trial.flavour     = trialResult.Read<string>(i, "flavour");

                Variables.trialMap.Add(trial.id, trial);
            }

            Console.WriteLine("Trial Missions - Loaded {0}", Variables.trialMap.Count);
        }