Example #1
0
        public override double GetDesirability()
        {
            if (!HasFreeSlot())
                return 0.0f;

            IPlayer me = map.GetPlayerMe();
            ISourceAll source = me.GetCollectSourcesNormal();
            int max = 0;
            bestKind = SourceBuildingKind.Count;

            for (int loop1 = 0; loop1 < 5; loop1++)
            {
                if (source[loop1] > max &&
                    me.GetMonasteryUpgrade((SourceBuildingKind)loop1) != UpgradeKind.SecondUpgrade)
                {
                    if (me.GetMonasteryUpgrade((SourceBuildingKind)loop1) == UpgradeKind.FirstUpgrade &&
                        map.IsBanAction(PlayerAction.InventSecondUpgrade))
                        continue;

                    max = source[loop1];
                    bestKind = (SourceBuildingKind)loop1;
                }
            }

            double bestSourceDesirability = ((max - 40) / 60.0) / 2.0;
            if (bestSourceDesirability < 0.0)
                return 0.0;
            if (bestSourceDesirability > 1.0)
                bestSourceDesirability = 1.0;

            return bestSourceDesirability;
        }
Example #2
0
        public HexaModel(int value, HexaKind kind, SourceKind sourceKind, SourceBuildingKind buildingKind,SourceAll sourceBuildingCost)
        {
            if (kind == HexaKind.Water)
            {
                this.hexaID = -1;
            } else
                this.hexaID = ++counter;

            this.sourceBuildingCost = sourceBuildingCost;

            this.kind = kind;
            this.sourceKind = sourceKind;
            this.buildingKind = buildingKind;

            this.startSource = value;
            this.towns = new TownModel[(int) TownPos.Count];
            this.roads = new RoadModel[(int)RoadPos.Count];
            this.townOwner = new Boolean[(int)TownPos.Count];
            this.roadOwner = new Boolean[(int)RoadPos.Count];

            sourceDisaster = false;
            sourceMiracle = false;
            hexaDestroy = false;
            captureIs = false;
            capturePlayer = null;
        }
Example #3
0
        public MonasteryError CanInventUpgrade(SourceBuildingKind source)
        {
            UpgradeKind kind;
            switch (owner.GetMonasteryUpgrade(source))
            {
                case UpgradeKind.NoUpgrade: kind = UpgradeKind.FirstUpgrade; break;
                case UpgradeKind.FirstUpgrade: kind = UpgradeKind.SecondUpgrade; break;
                default: kind = UpgradeKind.NoUpgrade; break;
            }

            if (kind == UpgradeKind.SecondUpgrade &&
               Settings.banSecondUpgrade)
                return MonasteryError.BanSecondUpgrade;

            BuyingUpgradeError error = GameState.map.GetMapController().CanBuyUpgradeInSpecialBuilding(townID, hexaID, kind, (int)source);

            switch (error)
            {
                case BuyingUpgradeError.YouAlreadyHaveSecondUpgrade:
                    GameState.map.GetMapController().SetLastError(Strings.ERROR_HAVE_SECOND_UPGRADE);
                    return MonasteryError.HaveSecondUpgrade;
                case BuyingUpgradeError.NoSources:
                    GameState.map.GetMapController().SetLastError(Strings.ERROR_NO_SOURCES);
                    return MonasteryError.NoSources;
                case BuyingUpgradeError.MaxUpgrades:
                    GameState.map.GetMapController().SetLastError(Strings.ERROR_MAX_UPGRADES);
                    return MonasteryError.MaxUpgrades;
                case BuyingUpgradeError.OK: return MonasteryError.OK;
            }

            return MonasteryError.OK;
        }
Example #4
0
 public ActiveState()
 {
     activeLicenceKind = LicenceKind.SecondLicence;
     activeRoad = null;
     activeTown = null;
     activeHexa = null;
     activeTownPos = 255;
     activeSourceKind = SourceKind.Count;
     activeUpgradeKind = UpgradeKind.SecondUpgrade;
     activeSourceBuildingKind = SourceBuildingKind.Count;
     activePlayer = null;
 }
Example #5
0
        public override double GetDesirability()
        {
            if (!HasFreeSlot())
                return 0.0f;

            IPlayer me = map.GetPlayerMe();
            ISourceAll source = me.GetCollectSourcesNormal();
            int max = 0;
            bestKind = SourceBuildingKind.Count;

            for (int loop1 = 0; loop1 < 5; loop1++)
            {
                if (source[loop1] > max &&
                    me.GetMonasteryUpgrade((SourceBuildingKind)loop1) != UpgradeKind.SecondUpgrade)
                {
                    if (me.GetMonasteryUpgrade((SourceBuildingKind)loop1) == UpgradeKind.FirstUpgrade &&
                        map.CanInventUpgrade((SourceBuildingKind)loop1) == MonasteryError.BanSecondUpgrade)
                        continue;

                    max = source[loop1];
                    bestKind = (SourceBuildingKind)loop1;
                }
            }

            double bestSourceDesirability = ((max - 40) / 60.0) / 2.0;
            if (bestSourceDesirability < 0.0)
                return 0.0;
            if (bestSourceDesirability > 1.0)
                bestSourceDesirability = 1.0;

            double points;
            switch (map.GetPlayerMe().GetMonasteryUpgrade(bestKind))
            {
                case UpgradeKind.NoUpgrade :
                    points = map.GetActionPoints(PlayerPoints.UpgradeLvl1) + map.GetActionPoints(PlayerPoints.UpgradeLvl2);
                    break;
                case UpgradeKind.FirstUpgrade:
                    points = map.GetActionPoints(PlayerPoints.UpgradeLvl2);
                    break;
                default :
                    points = 0.0f;
                    break;
            }
            if (points > 1)
                points = 1.0;

            return kUpgrade * bestSourceDesirability + kPoints * points;
        }
Example #6
0
 internal bool InventUpgrade(SourceBuildingKind activeSourceBuildingKind)
 {
     if (mapController.InventUpgrade(activeSourceBuildingKind))
     {
         upgradeAmount++;
         return true;
     }
     else
     {
         if (mapController.CanInventUpgrade(activeSourceBuildingKind) == MonasteryError.BanSecondUpgrade)
             return false;
         throw new Exception("Inventing upgrade. " + mapController.GetLastError());
         //return false;
     }
 }
Example #7
0
 public UpgradeKind GetMonasteryUpgrade(SourceBuildingKind kind)
 {
     return upgradeMonastery[(int)kind];
 }
Example #8
0
 public InventUpgradeAtom(IMapController map, SourceBuildingKind kind, int depth)
     : base(map, depth, "Invent upgrade")
 {
     this.kind = kind;
 }
Example #9
0
        public SourceBuildingModel(Player playerOwner, int townID, int hexaID)
            : base(playerOwner)
        {
            this.townID = townID;
            this.hexaID = hexaID;
            upgrade = UpgradeKind.NoUpgrade;

            TownModel town = GameState.map.GetTownByID(townID);
            int buildingPos = town.FindBuildingByHexaID(hexaID);
            HexaModel hexa = town.GetHexa(buildingPos);

            SourceAll sourceNormal = new SourceAll(0);
            int amountNormal = hexa.GetStartSource();
            switch (hexa.GetKind())
            {
                case HexaKind.Forest:
                    sourceNormal = new SourceAll(0, 0, 0, amountNormal, 0);
                    break;

                case HexaKind.Stone:
                    sourceNormal = new SourceAll(0, 0, amountNormal, 0, 0);
                    break;

                case HexaKind.Cornfield:
                    sourceNormal = new SourceAll(amountNormal, 0, 0, 0, 0);
                    break;

                case HexaKind.Pasture:
                    sourceNormal = new SourceAll(0, amountNormal, 0, 0, 0);
                    break;

                case HexaKind.Mountains:
                    sourceNormal = new SourceAll(0, 0, 0, 0, amountNormal);
                    break;
            }
            playerOwner.AddCollectSources(sourceNormal, new SourceAll(0));

            upgrade1cost = new SourceAll(0);
            upgrade2cost = new SourceAll(0);
            switch (hexa.GetKind())
            {
                case HexaKind.Mountains:
                    buildingKind = SourceBuildingKind.Mine;
                    titleBuilding = Strings.PROMT_TITLE_WANT_TO_BUILD_MINE;
                    upgrade1Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_1_MINE;
                    upgrade2Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_2_MINE;
                    upgrade1Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_1_MINE;
                    upgrade2Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_2_MINE;
                    upgrade0iconActive = GameResources.Inst().GetHudTexture(HUDTexture.IconMineActive);
                    upgrade0icon = GameResources.Inst().GetHudTexture(HUDTexture.IconMine);
                    upgrade1icon = GameResources.Inst().GetHudTexture(HUDTexture.IconMine1);
                    upgrade2icon = GameResources.Inst().GetHudTexture(HUDTexture.IconMine2);
                    break;
                case HexaKind.Forest:
                    buildingKind = SourceBuildingKind.Saw;
                    titleBuilding = Strings.PROMT_TITLE_WANT_TO_BUILD_SAW;
                    upgrade1Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_1_SAW;
                    upgrade2Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_2_SAW;
                    upgrade1Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_1_SAW;
                    upgrade2Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_2_SAW;
                    upgrade0iconActive = GameResources.Inst().GetHudTexture(HUDTexture.IconSawActive);
                    upgrade0icon = GameResources.Inst().GetHudTexture(HUDTexture.IconSaw);
                    upgrade1icon = GameResources.Inst().GetHudTexture(HUDTexture.IconSaw1);
                    upgrade2icon = GameResources.Inst().GetHudTexture(HUDTexture.IconSaw2);
                    break;
                case HexaKind.Cornfield:
                    buildingKind = SourceBuildingKind.Mill;
                    titleBuilding = Strings.PROMT_TITLE_WANT_TO_BUILD_MILL;
                    upgrade1Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_1_MILL;
                    upgrade2Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_2_MILL;
                    upgrade1Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_1_MILL;
                    upgrade2Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_2_MILL;
                    upgrade0iconActive = GameResources.Inst().GetHudTexture(HUDTexture.IconMillActive);
                    upgrade0icon = GameResources.Inst().GetHudTexture(HUDTexture.IconMill);
                    upgrade1icon = GameResources.Inst().GetHudTexture(HUDTexture.IconMill1);
                    upgrade2icon = GameResources.Inst().GetHudTexture(HUDTexture.IconMill2);
                    break;
                case HexaKind.Pasture:
                    buildingKind = SourceBuildingKind.Stepherd;
                    titleBuilding = Strings.PROMT_TITLE_WANT_TO_BUILD_STEPHERD;
                    upgrade1Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_1_STEPHERD;
                    upgrade2Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_2_STEPHERD;
                    upgrade1Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_1_STEPHERD;
                    upgrade2Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_2_STEPHERD;
                    upgrade0iconActive = GameResources.Inst().GetHudTexture(HUDTexture.IconStepherdActive);
                    upgrade0icon = GameResources.Inst().GetHudTexture(HUDTexture.IconStepherd);
                    upgrade1icon = GameResources.Inst().GetHudTexture(HUDTexture.IconStepherd1);
                    upgrade2icon = GameResources.Inst().GetHudTexture(HUDTexture.IconStepherd2);
                    break;
                case HexaKind.Stone:
                    buildingKind = SourceBuildingKind.Quarry;
                    titleBuilding = Strings.PROMT_TITLE_WANT_TO_BUILD_QUARRY;
                    upgrade1Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_1_QUARRY;
                    upgrade2Title = Strings.PROMPT_TITLE_WANT_TO_UPGRADE_2_QUARRY;
                    upgrade1Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_1_QUARRY;
                    upgrade2Description = Strings.PROMPT_DESCRIPTION_WANT_TO_UPGRADE_2_QUARRY;
                    upgrade0iconActive = GameResources.Inst().GetHudTexture(HUDTexture.IconQuarryActive);
                    upgrade0icon = GameResources.Inst().GetHudTexture(HUDTexture.IconQuarry);
                    upgrade1icon = GameResources.Inst().GetHudTexture(HUDTexture.IconQuarry1);
                    upgrade2icon = GameResources.Inst().GetHudTexture(HUDTexture.IconQuarry2);
                    break;
            }
        }
Example #10
0
        public bool InventUpgrade(SourceBuildingKind source)
        {
            UpgradeKind kind;
            switch (owner.GetMonasteryUpgrade(source))
            {
                case UpgradeKind.NoUpgrade: kind = UpgradeKind.FirstUpgrade; break;
                case UpgradeKind.FirstUpgrade: kind = UpgradeKind.SecondUpgrade; break;
                default : return false;
            }

            return GameState.map.GetMapController().BuyUpgradeInSpecialBuilding(townID, hexaID, kind, (int) source);
        }
Example #11
0
        public ISourceAll GetPrice(SourceBuildingKind buildingKind, UpgradeKind upgradeKind)
        {
            if (upgradeKind == UpgradeKind.NoUpgrade)
                return new SourceAll(0);

            return GetPrice(GetPriceForMonasteryUpgrade(upgradeKind, buildingKind));
        }
Example #12
0
        public MonasteryError CanInventUpgrade(SourceBuildingKind building)
        {
            Player p = gm.GetActivePlayer();
            List<IMonastery> monastery = p.GetMonastery();

            foreach (IMonastery m in monastery)
            {
                switch (m.CanInventUpgrade(building))
                {
                    case MonasteryError.HaveSecondUpgrade:
                        SetLastError(Strings.ERROR_HAVE_SECOND_UPGRADE);
                        return MonasteryError.HaveSecondUpgrade;
                    case MonasteryError.NoSources:
                        SetLastError(Strings.ERROR_NO_SOURCES);
                        return MonasteryError.NoSources;
                    case MonasteryError.BanSecondUpgrade:
                        SetLastError(Strings.ERROR_BAN_SECOND_UPGRADE);
                        return MonasteryError.BanSecondUpgrade;
                    case MonasteryError.OK:
                        return MonasteryError.OK;
                    case MonasteryError.MaxUpgrades:          // May be free slot in another monastery
                        break;
                }
            }

            SetLastError(Strings.ERROR_MAX_UPGRADES);
            return MonasteryError.MaxUpgrades;
        }
Example #13
0
 private PriceKind GetPriceForMonasteryUpgrade(UpgradeKind upgradeKind, SourceBuildingKind buildingKind)
 {
     switch (upgradeKind)
     {
         case UpgradeKind.FirstUpgrade:
             switch (buildingKind)
             {
                 case SourceBuildingKind.Mill: return PriceKind.UMill1;
                 case SourceBuildingKind.Stepherd: return PriceKind.UStepherd1;
                 case SourceBuildingKind.Quarry: return PriceKind.UQuarry1;
                 case SourceBuildingKind.Saw: return PriceKind.USaw1;
                 case SourceBuildingKind.Mine: return PriceKind.UMine1;
             }
             break;
         case UpgradeKind.SecondUpgrade:
             switch (buildingKind)
             {
                 case SourceBuildingKind.Mill: return PriceKind.UMill2;
                 case SourceBuildingKind.Stepherd: return PriceKind.UStepherd2;
                 case SourceBuildingKind.Quarry: return PriceKind.UQuarry2;
                 case SourceBuildingKind.Saw: return PriceKind.USaw2;
                 case SourceBuildingKind.Mine: return PriceKind.UMine2;
             }
             break;
     }
     return PriceKind.UMill1;
 }
Example #14
0
        public bool InventUpgrade(SourceBuildingKind building)
        {
            Player p = gm.GetActivePlayer();
            List<IMonastery> monastery = p.GetMonastery();

            foreach (IMonastery m in monastery)
            {
                switch (m.CanInventUpgrade(building))
                {
                    case MonasteryError.BanSecondUpgrade:
                        return false;
                    case MonasteryError.HaveSecondUpgrade:
                        return false;
                    case MonasteryError.NoSources:
                        return false;
                    case MonasteryError.OK:
                        return m.InventUpgrade(building);
                    case MonasteryError.MaxUpgrades:          // May be free slot in another market
                        break;
                }
            }

            return false;
        }
Example #15
0
 internal void SetActiveObject(SourceBuildingKind kind)
 {
     activeState.activeSourceBuildingKind = kind;
 }