public override int Execute(LogicLevel level)
        {
            if (level.GetVillageType() == 1)
            {
                if (level.IsUnitsTrainedVillage2())
                {
                    if (level.GetState() == 1)
                    {
                        if (this.m_buyResourceCount > 0)
                        {
                            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

                            if (playerAvatar.GetUnusedResourceCap(LogicDataTables.GetGold2Data()) < this.m_buyResourceCount)
                            {
                                return(-1);
                            }

                            int buyResourceCost = LogicGamePlayUtil.GetResourceDiamondCost(this.m_buyResourceCount, LogicDataTables.GetGold2Data());

                            if (playerAvatar.HasEnoughDiamonds(buyResourceCost, true, level))
                            {
                                return(-2);
                            }

                            playerAvatar.UseDiamonds(buyResourceCost);
                            playerAvatar.GetChangeListener().DiamondPurchaseMade(5, LogicDataTables.GetGold2Data().GetGlobalID(), this.m_buyResourceCount, buyResourceCost,
                                                                                 level.GetVillageType());
                            playerAvatar.CommodityCountChangeHelper(0, LogicDataTables.GetGold2Data(), this.m_buyResourceCount);
                        }

                        level.GetGameListener().MatchmakingVillage2CommandExecuted();
                        return(0);
                    }

                    return(-3);
                }

                return(-24);
            }

            return(-32);
        }
        public override int Execute(LogicLevel level)
        {
            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

            if (playerAvatar != null)
            {
                LogicGameObjectManager gameObjectManager = level.GetGameObjectManagerAt(1);

                if (gameObjectManager.GetTownHall() == null)
                {
                    LogicJSONObject jsonObject = level.GetGameListener().ParseCompressedHomeJSON(this.m_compressedHomeJSON, this.m_compressedHomeJSON.Length);

                    level.SetLoadingVillageType(1);

                    this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("buildings2"), 1);
                    this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("obstacles2"), 1);
                    this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("traps2"), 1);
                    this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("decos2"), 1);

                    level.SetLoadingVillageType(-1);

                    if (playerAvatar.GetResourceCount(LogicDataTables.GetGold2Data()) == 0)
                    {
                        playerAvatar.CommodityCountChangeHelper(0, LogicDataTables.GetGold2Data(), LogicDataTables.GetGlobals().GetStartingGold2());
                    }

                    if (playerAvatar.GetResourceCount(LogicDataTables.GetElixir2Data()) == 0)
                    {
                        playerAvatar.CommodityCountChangeHelper(0, LogicDataTables.GetElixir2Data(), LogicDataTables.GetGlobals().GetStartingElixir2());
                    }
                }

                return(0);
            }

            return(-1);
        }