Ejemplo n.º 1
0
        public bool BuildIrrigation()
        {
            ITile tile = Map[X, Y];

            if (tile.Irrigation || tile.IsOcean)             // already irrigated or illogical: ignore
            {
                return(false);
            }

            // Changing terrain type
            if (tile.IrrigationChangesTerrain())
            {
                order = Order.Irrigate;
                SkipTurn(tile.IrrigationCost);
                return(true);
            }

            if (!tile.TerrainAllowsIrrigation())
            {
                if (Human == Owner)
                {
                    GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText("ERROR/NOIRR")));
                }
                return(false);
            }

            if (tile.AllowIrrigation() || tile.Type == Terrain.River)
            {
                order = Order.Irrigate;
                SkipTurn(tile.IrrigationCost);
                return(true);
            }

            if (Human == Owner)
            {
                GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText("ERROR/NOIRR")));
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool BuildIrrigation()
        {
            ITile tile = Map[X, Y];

            if (tile.Irrigation || tile.IsOcean)             // already irrigated or illogical: ignore
            {
                return(false);
            }

            // Changing terrain type
            if (tile.IrrigationChangesTerrain())
            {
                // TODO fire-eggs setting BuildingIrrigation to true should clear moves
                BuildingIrrigation = (Human == Owner && Settings.Instance.AutoSettlers) ? 1 : 4; // cheat for human
                MovesLeft          = 0;
                PartMoves          = 0;
                return(true);
            }

            //bool irrigate1 = (tile.GetBorderTiles().Any(t => (t.X == X || t.Y == Y) &&
            //                                                 (t.City == null) &&
            //                                                 (t.IsOcean || t.Irrigation || (t is River)))) ||
            //                 (tile is River);
            //bool irrigate1a =
            //    tile.CrossTiles().Any(t => !t.HasCity && (t.IsOcean || t.Irrigation || t.Type == Terrain.River)) ||
            //    tile.Type == Terrain.River;

            //Debug.Assert(irrigate1 == irrigate1a);

            //bool irrigate2 = tile.AllowIrrigation();
            //bool irrigate2a = tile.AllowIrrigation() || tile.Type == Terrain.River;
            //Debug.Assert(irrigate2a == irrigate1);

            //bool irrigate3 = !tile.IsOcean &&       // always false
            //                 !(tile.Irrigation) &&  // always false
            //                 ((tile is Desert) ||
            //                  (tile is Grassland) ||
            //                  (tile is Hills) ||
            //                  (tile is Plains) ||
            //                  (tile is River));

            //bool irrigate4 =
            //    (((tile is Desert) || (tile is Grassland) || (tile is Hills) || (tile is Plains) || (tile is River)) &&
            //     tile.City == null);
            //Debug.Assert(irrigate4 == irrigate3);

            if (!tile.TerrainAllowsIrrigation())
            {
                if (Human == Owner)
                {
                    GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText("ERROR/NOIRR")));
                }
                return(false);
            }

            if (tile.AllowIrrigation() || tile.Type == Terrain.River)
            {
                BuildingIrrigation = (Human == Owner && Settings.Instance.AutoSettlers) ? 1 : 3; // cheat for human
                MovesLeft          = 0;
                PartMoves          = 0;
                return(true);
            }

            if (Human == Owner)
            {
                GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText("ERROR/NOIRR")));
            }
            return(false);

////			if ((tile.GetBorderTiles().Any(t => (t.X == X || t.Y == Y) && (t.City == null) && (t.IsOcean || t.Irrigation || (t is River)))) || (tile is River))
//            if (tile.AllowIrrigation() || tile.Type == Terrain.River) // source of water for irrigation available
//            {
//				//if (!tile.IsOcean && !(tile.Irrigation) && ((tile is Desert) || (tile is Grassland) || (tile is Hills) || (tile is Plains) || (tile is River)))
//                if (tile.TerrainAllowsIrrigation()) // irrigation may be applied
//				{
//                    BuildingIrrigation = (Human == Owner && Settings.Instance.AutoSettlers) ? 1 : 3; // cheat for human
//                    MovesLeft = 0;
//					PartMoves = 0;
//					return true;
//				}
//				if (Human == Owner)
//					GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText("ERROR/NOIRR")));
//				return false;
//			}

//			{
//				if (((tile is Desert) || (tile is Grassland) || (tile is Hills) || (tile is Plains) || (tile is River)) && tile.City == null)
//				{
//					if (Human == Owner)
//						GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText("ERROR/NOWATER")));
//					return false;
//				}
//				if (Human == Owner)
//					GameTask.Enqueue(Message.Error("-- Civilization Note --", TextFile.Instance.GetGameText("ERROR/NOIRR")));
//			}
//			return false;
        }