public int GetRequiredTownHallLevel(int index)
        {
            if (index != 0 || LogicDataTables.GetTownHallLevelCount() < 1)
            {
                return(this.m_townHallLevel[index]);
            }

            for (int i = 0; i < LogicDataTables.GetTownHallLevelCount(); i++)
            {
                LogicTownhallLevelData townHallLevel = LogicDataTables.GetTownHallLevel(i);

                if (townHallLevel.GetUnlockedBuildingCount(this) > 0)
                {
                    return(i);
                }
            }

            return(this.m_townHallLevel[index]);
        }
Ejemplo n.º 2
0
        public LogicData CreateItem(CSVRow row)
        {
            LogicData data = null;

            switch (this.m_tableIndex)
            {
            case LogicDataType.BUILDING:
            {
                data = new LogicBuildingData(row, this);
                break;
            }

            case LogicDataType.LOCALE:
            {
                data = new LogicLocaleData(row, this);
                break;
            }

            case LogicDataType.RESOURCE:
            {
                data = new LogicResourceData(row, this);
                break;
            }

            case LogicDataType.CHARACTER:
            {
                data = new LogicCharacterData(row, this);
                break;
            }

            case LogicDataType.ANIMATION:
            {
                data = new LogicAnimationData(row, this);
                break;
            }

            case LogicDataType.PROJECTILE:
            {
                data = new LogicProjectileData(row, this);
                break;
            }

            case LogicDataType.BUILDING_CLASS:
            {
                data = new LogicBuildingClassData(row, this);
                break;
            }

            case LogicDataType.OBSTACLE:
            {
                data = new LogicObstacleData(row, this);
                break;
            }

            case LogicDataType.EFFECT:
            {
                data = new LogicEffectData(row, this);
                break;
            }

            case LogicDataType.PARTICLE_EMITTER:
            {
                data = new LogicParticleEmitterData(row, this);
                break;
            }

            case LogicDataType.EXPERIENCE_LEVEL:
            {
                data = new LogicExperienceLevelData(row, this);
                break;
            }

            case LogicDataType.TRAP:
            {
                data = new LogicTrapData(row, this);
                break;
            }

            case LogicDataType.ALLIANCE_BADGE:
            {
                data = new LogicAllianceBadgeData(row, this);
                break;
            }

            case LogicDataType.GLOBAL:
            case LogicDataType.CLIENT_GLOBAL:
            {
                data = new LogicGlobalData(row, this);
                break;
            }

            case LogicDataType.TOWNHALL_LEVEL:
            {
                data = new LogicTownhallLevelData(row, this);
                break;
            }

            case LogicDataType.ALLIANCE_PORTAL:
            {
                data = new LogicAlliancePortalData(row, this);
                break;
            }

            case LogicDataType.NPC:
            {
                data = new LogicNpcData(row, this);
                break;
            }

            case LogicDataType.DECO:
            {
                data = new LogicDecoData(row, this);
                break;
            }

            case LogicDataType.RESOURCE_PACK:
            {
                data = new LogicResourcePackData(row, this);
                break;
            }

            case LogicDataType.SHIELD:
            {
                data = new LogicShieldData(row, this);
                break;
            }

            case LogicDataType.MISSION:
            {
                data = new LogicMissionData(row, this);
                break;
            }

            case LogicDataType.BILLING_PACKAGE:
            {
                data = new LogicBillingPackageData(row, this);
                break;
            }

            case LogicDataType.ACHIEVEMENT:
            {
                data = new LogicAchievementData(row, this);
                break;
            }

            case LogicDataType.SPELL:
            {
                data = new LogicSpellData(row, this);
                break;
            }

            case LogicDataType.HINT:
            {
                data = new LogicHintData(row, this);
                break;
            }

            case LogicDataType.HERO:
            {
                data = new LogicHeroData(row, this);
                break;
            }

            case LogicDataType.LEAGUE:
            {
                data = new LogicLeagueData(row, this);
                break;
            }

            case LogicDataType.NEWS:
            {
                data = new LogicNewsData(row, this);
                break;
            }

            case LogicDataType.WAR:
            {
                data = new LogicWarData(row, this);
                break;
            }

            case LogicDataType.REGION:
            {
                data = new LogicRegionData(row, this);
                break;
            }

            case LogicDataType.ALLIANCE_BADGE_LAYER:
            {
                data = new LogicAllianceBadgeLayerData(row, this);
                break;
            }

            case LogicDataType.ALLIANCE_LEVEL:
            {
                data = new LogicAllianceLevelData(row, this);
                break;
            }

            case LogicDataType.HELPSHIFT:
            {
                data = new LogicHelpshiftData(row, this);
                break;
            }

            case LogicDataType.CREDIT:
            case LogicDataType.FAQ:
            case LogicDataType.VARIABLE:
            {
                data = new LogicData(row, this);
                break;
            }

            case LogicDataType.GEM_BUNDLE:
            {
                data = new LogicGemBundleData(row, this);
                break;
            }

            case LogicDataType.VILLAGE_OBJECT:
            {
                data = new LogicVillageObjectData(row, this);
                break;
            }

            case LogicDataType.CALENDAR_EVENT_FUNCTION:
            {
                data = new LogicCalendarEventFunctionData(row, this);
                break;
            }

            case LogicDataType.BOOMBOX:
            {
                data = new LogicBoomboxData(row, this);
                break;
            }

            case LogicDataType.EVENT_ENTRY:
            {
                data = new LogicEventEntryData(row, this);
                break;
            }

            case LogicDataType.DEEPLINK:
            {
                data = new LogicDeeplinkData(row, this);
                break;
            }

            case LogicDataType.LEAGUE_VILLAGE2:
            {
                data = new LogicLeagueVillage2Data(row, this);
                break;
            }

            default:
            {
                Debugger.Error("Invalid data table id: " + this.m_tableIndex);
                break;
            }
            }

            return(data);
        }
        public override void CreateReferences()
        {
            base.CreateReferences();

            this.m_buildingCaps       = new LogicArrayList <int>();
            this.m_buildingGearupCaps = new LogicArrayList <int>();
            this.m_trapCaps           = new LogicArrayList <int>();
            this.m_treasuryCaps       = new LogicArrayList <int>();

            LogicTownhallLevelData previousItem = null;

            if (this.GetInstanceID() > 0)
            {
                previousItem = (LogicTownhallLevelData)this.m_table.GetItemAt(this.GetInstanceID() - 1);
            }

            LogicDataTable buildingTable = LogicDataTables.GetTable(LogicDataType.BUILDING);

            for (int i = 0; i < buildingTable.GetItemCount(); i++)
            {
                LogicData item = buildingTable.GetItemAt(i);

                int cap    = this.GetIntegerValue(item.GetName(), 0);
                int gearup = this.GetIntegerValue(item.GetName() + "_gearup", 0);

                if (previousItem != null)
                {
                    if (cap == 0)
                    {
                        cap = previousItem.m_buildingCaps[i];
                    }

                    if (gearup == 0)
                    {
                        gearup = previousItem.m_buildingGearupCaps[i];
                    }
                }

                this.m_buildingCaps.Add(cap);
                this.m_buildingGearupCaps.Add(gearup);
            }

            LogicDataTable trapTable = LogicDataTables.GetTable(LogicDataType.TRAP);

            for (int i = 0; i < trapTable.GetItemCount(); i++)
            {
                int cap = this.GetIntegerValue(trapTable.GetItemAt(i).GetName(), 0);

                if (previousItem != null)
                {
                    if (cap == 0)
                    {
                        cap = previousItem.m_trapCaps[i];
                    }
                }

                this.m_trapCaps.Add(cap);
            }

            LogicDataTable resourceTable = LogicDataTables.GetTable(LogicDataType.RESOURCE);

            for (int i = 0; i < resourceTable.GetItemCount(); i++)
            {
                this.m_treasuryCaps.Add(this.GetIntegerValue("Treasury" + resourceTable.GetItemAt(i).GetName(), 0));
            }

            this.m_attackCost                      = this.GetIntegerValue("AttackCost", 0);
            this.m_attackCostVillage2              = this.GetIntegerValue("AttackCostVillage2", 0);
            this.m_resourceStorageLootPercentage   = this.GetIntegerValue("ResourceStorageLootPercentage", 0);
            this.m_darkElixirStorageLootPercentage = this.GetIntegerValue("DarkElixirStorageLootPercentage", 0);
            this.m_resourceStorageLootCap          = this.GetIntegerValue("ResourceStorageLootCap", 0);
            this.m_darkElixirStorageLootCap        = this.GetIntegerValue("DarkElixirStorageLootCap", 0);
            this.m_warPrizeResourceCap             = this.GetIntegerValue("WarPrizeResourceCap", 0);
            this.m_warPrizeDarkElixirCap           = this.GetIntegerValue("WarPrizeDarkElixirCap", 0);
            this.m_warPrizeAllianceExpCap          = this.GetIntegerValue("WarPrizeAllianceExpCap", 0);
            this.m_cartLootCapResource             = this.GetIntegerValue("CartLootCapResource", 0);
            this.m_cartLootReengagementResource    = this.GetIntegerValue("CartLootReengagementResource", 0);
            this.m_cartLootCapDarkElixir           = this.GetIntegerValue("CartLootCapDarkElixir", 0);
            this.m_cartLootReengagementDarkElixir  = this.GetIntegerValue("CartLootReengagementDarkElixir", 0);
            this.m_strengthMaxTroopTypes           = this.GetIntegerValue("StrengthMaxTroopTypes", 0);
            this.m_strengthMaxSpellTypes           = this.GetIntegerValue("StrengthMaxSpellTypes", 0);
            this.m_friendlyCost                    = this.GetIntegerValue("FriendlyCost", 0);
            this.m_packElixir                      = this.GetIntegerValue("PackElixir", 0);
            this.m_packGold             = this.GetIntegerValue("PackGold", 0);
            this.m_packDarkElixir       = this.GetIntegerValue("PackDarkElixir", 0);
            this.m_packGold2            = this.GetIntegerValue("PackGold2", 0);
            this.m_packElixir2          = this.GetIntegerValue("PackElixir2", 0);
            this.m_duelPrizeResourceCap = this.GetIntegerValue("DuelPrizeResourceCap", 0);
            this.m_changeTroopCost      = this.GetIntegerValue("ChangeTroopCost", 0);

            if ((uint)this.m_darkElixirStorageLootPercentage > 100 || (uint)this.m_darkElixirStorageLootPercentage > 100)
            {
                Debugger.Error("townhall_levels.csv: Invalid loot percentage!");
            }
        }