Пример #1
0
		public CityList( PlayerList player, int city )
		{
			this.player = player;
			this.city = city;

			construction = new Construction();
			slaves = new citySlavery( player, city );
			nonLabor = new peopleNonLabor( player, city );
			hatrLastCalcul = -1;
		}
Пример #2
0
		public Memory( PlayerList olayer, int length ) 
		{ 
			this.player = olayer;
			list = new structures.memory[ length ]; 
		} 
Пример #3
0
		public void transfertToPlayer( PlayerList nextOwner )
		{
	//		state = (byte)enums.cityState.dead;

	/*		nextOwner.cityNumber ++;
				
			if ( nextOwner.cityNumber >= nextOwner.cityList.Length )
			{
				CityList[] cityListBuffer = nextOwner.cityList;
				nextOwner.cityList = new CityList[ cityListBuffer.Length + 5 ];

				for ( int i = 0; i < cityListBuffer.Length; i ++ )
					nextOwner.cityList[ i ] = cityListBuffer[ i ];
			}

			newCity = new CityList( nextOwner, nextOwner.cityNumber );*/

			CityList newCity = nextOwner.addCity();

			//		getTreasure( nextOwner.player, player, game.grid[ xDest, yDest ].city );

			#region get treasure

				byte[] posTechno = new byte[ Statistics.technologies.Length ];
				byte nbr = 0;
				for ( int i = 1; i < Statistics.technologies.Length; i ++ )
					if ( 
						nextOwner.technos[ i ].researched &&
						!player.technos[ i ].researched
						)
					{
						posTechno[ nbr ] = (byte)i;
						nbr ++;
					}

				if ( nbr > 0 )
				{
					Random r = new Random();

					byte technoChose = posTechno[ r.Next( nbr - 1 ) + 1 ];

					nextOwner.technos[ technoChose ].researched = true;
				}

				if ( 
					( 
						player.cityList[ city ].population > 6 || 
						player.cityList[ city ].isCapitale 
					) &&
					player.technos[ (byte)Form1.technoList.mapMaking ].researched 
					)
				{
					for ( int x = 0; x < Form1.game.width; x ++ )
						for ( int y = 0; y < Form1.game.height; y ++ )
							if ( Form1.game.grid[ x, y ].territory - 1 == player.player || player.discovered[ x, y ] )
								nextOwner.discovered[ x, y ] = true;
				}
				else if ( 
					player.cityList[ city ].population > 3 &&
					player.technos[ (byte)Form1.technoList.mapMaking ].researched  )
				{
					for ( int x = 0; x < Form1.game.width; x ++ )
						for ( int y = 0; y < Form1.game.height; y ++ )
							if ( Form1.game.grid[ x, y ].territory - 1 == player.player )
								nextOwner.discovered[ x, y ] = true;
				}
		#endregion

			labor.removeAllLabor( player.player, city );

			newCity.buildingList = this.buildingList;
			newCity.foodReserve = this.foodReserve;
			newCity.name = this.name;
			newCity.population = this.population;
			newCity.X = this.X;
			newCity.Y = this.Y;
			newCity.originalOwner = this.originalOwner;

			state = (byte)enums.cityState.dead;

			//	game.grid[ xDest, yDest ].territory - 1 = owner;
			player.game.grid[ X, Y ].city = newCity.city;

			if ( 
				nextOwner.economyType == (byte)enums.economies.slaveryRacial && 
				newCity.population > 0 
				)
			{
				int slavesToTransfert = newCity.population / 2;
				nextOwner.slaves.addSlave( slavesToTransfert );
				newCity.population -= (byte)slavesToTransfert;
				System.Windows.Forms.MessageBox.Show( 
					String.Format( language.getAString( language.order.slaveryAquiredFromCity ), slavesToTransfert, newCity.name ), 
					language.getAString( language.order.slaveryTitle ) 
					);
			}

			ai.chooseConstruction( nextOwner.player, nextOwner.cityNumber );

			player.game.frontier.setFrontiers();

			newCity.laborPos = new Point[ 0 ];
			labor.addAllLabor( nextOwner.player, nextOwner.cityNumber );
			newCity.setHasDirectAccessToRessource();

			bool oneCityLeft = false;
			for ( int i = 1; i <= player.cityNumber; i ++ )
				if ( player.cityList[ i ].state != (byte)enums.cityState.dead )
				{
					oneCityLeft = true;
					break;
				}

			if ( !oneCityLeft )
			{
				player.kill( nextOwner );
			}
			else if ( this.isCapitale )
			{
				bool found = false;
				for ( int c = 1; c <= player.cityNumber && !found; c ++ )
					if ( player.cityList[ c ].state != (byte)enums.cityState.dead )
					{
						found = true; 
						player.cityList[ c ].isCapitale = true; 
					}

				if ( !found )
					System.Windows.Forms.MessageBox.Show( "error in finding a capital" );
			}

			if ( player.player == Form1.game.curPlayerInd )
				open.cityFrm( newCity );	//owner, city, this );

		//		openCityFrm( owner, nextOwner.cityNumber );

		}
Пример #4
0
 public citySlavery(PlayerList player, int city)
 {
     this.player = player;
     this.city   = city;
     list        = new byte[0];
 }
Пример #5
0
		public UnitList( PlayerList player, int ind )
		{
			this.player = player;
			this.ind = ind;
		}
Пример #6
0
		public void kill( PlayerList killer )
		{
			kill();

			if ( ind == 1 )
				player.kill( killer );
		}
Пример #7
0
 public UnitList(PlayerList player, int ind)
 {
     this.player = player;
     this.ind    = ind;
 }
Пример #8
0
		public bool isAtPeaceWith( PlayerList other )
		{
			return !isAtWarWith( other ); //foreignRelation[ other.player ].politic == Form1.relationPolType.war;
		}
Пример #9
0
        public void kill(PlayerList killer)
        {
            dead = true;

            for (int i = 1; i <= unitNumber; i++)
            {
                if (!unitList[i].dead)
                {
                    unitList[i].kill();                       //unitDelete( ancientOwner, i );
                }
            }
            // safeguard
            for (int i = 0; i < game.caseImps.Length; i++)
            {
                if (game.caseImps[i].owner == player)
                {
                    caseImprovement.destroyCaseImps(i);
                }
            }

            if (killer.player == Form1.game.curPlayerInd)
            {
                System.Windows.Forms.MessageBox.Show(
                    String.Format(language.getAString(language.order.killYouKilled), new object[] {
                    playerName,
                    Statistics.civilizations[civType].name
                }
                                  )
                    //"You have destroyed " + playerName + " of " + Statistics.civilizations[ civType ].name + ".",
                    //"You won the war"
                    );
            }
            else if (this.isCurPlayer)
            {
                System.Windows.Forms.MessageBox.Show(
                    String.Format(language.getAString(language.order.killYouHaveBeenKilled), new object[] {
                    killer.playerName,
                    Statistics.civilizations[killer.civType].name
                }
                                  )
                    //	playerName + " of " + Statistics.civilizations[ civType ].name + " has been destroyed...",
                    //	killer.playerName + " won the war"
                    );
            }
            else if (
                game.curPlayer.foreignRelation[player].madeContact ||
                game.curPlayer.foreignRelation[killer.player].madeContact
                )
            {
                System.Windows.Forms.MessageBox.Show(
                    String.Format(language.getAString(language.order.killHasBeenKilledBy), new object[] {
                    playerName,
                    Statistics.civilizations[civType].name,
                    killer.playerName,
                    Statistics.civilizations[killer.civType].name
                }
                                  )
                    //	playerName + " of " + Statistics.civilizations[ civType ].name + " has been destroyed...",
                    //	killer.playerName + " won the war"
                    );
            }
        }
Пример #10
0
 public playerSlavery(PlayerList player)
 {
     transferts  = new transfertList[0];
     this.player = player;
 }
Пример #11
0
 public bool isAtPeaceWith(PlayerList other)
 {
     return(!isAtWarWith(other));              //foreignRelation[ other.player ].politic == Form1.relationPolType.war;
 }
Пример #12
0
/*
 *              bool[] caseImprovementPossibleOnEachCont,
 *                      citiesPossibleOnEachCont;
 *
 *              public void setWideSetteling()
 *              {
 *                      caseImprovementPossibleOnEachCont = new bool[ 100 ];
 *                      citiesPossibleOnEachCont = new bool[ 100 ];
 *
 *                      for ( int x = 0; x < game.width; x ++ )
 *                              for ( int y = 0; y < game.height; y ++ )
 *                              {
 *                                      if ( !game.grid[ x, y ].water )
 *                                              if (
 *                                                      !citiesPossibleOnEachCont[ game.grid[ x, y ].continent - 1 ] &&
 *                                                      game.grid[ x, y ].canBuildCity
 *                                                      )
 *                                              {
 *                                              }
 *                                              else if (
 *                                                      !caseImprovementPossibleOnEachCont[ game.grid[ x, y ].continent - 1 ] //&&
 *                                              //	game.grid[ x, y ].canBuildCity
 *                                                      )
 *                                              {
 *                                              }
 *                              }
 *              }
 */
        #endregion

        public bool isAtWarWith(PlayerList other)
        {
            return(foreignRelation[other.player].politic == (byte)Form1.relationPolType.war);
        }
Пример #13
0
		public void kill( PlayerList killer )
		{
			dead = true;

			for ( int i = 1; i <= unitNumber; i ++ )
				if ( !unitList[ i ].dead )
					unitList[ i ].kill(); //unitDelete( ancientOwner, i );

			// safeguard
			for ( int i = 0; i < game.caseImps.Length; i ++ )
				if ( game.caseImps[ i ].owner == player )
					caseImprovement.destroyCaseImps( i );

			if ( killer.player == Form1.game.curPlayerInd )
				System.Windows.Forms.MessageBox.Show( 
					String.Format( language.getAString( language.order.killYouKilled ), new object[] { 
																										 playerName,
																										 Statistics.civilizations[ civType ].name
																									 }
					)
					//"You have destroyed " + playerName + " of " + Statistics.civilizations[ civType ].name + ".",  
					//"You won the war"
					);
			else if ( this.isCurPlayer )
				System.Windows.Forms.MessageBox.Show( 
					String.Format( language.getAString( language.order.killYouHaveBeenKilled ), new object[] { 
																										 killer.playerName,
																										 Statistics.civilizations[ killer.civType ].name
																									 }
					)
				//	playerName + " of " + Statistics.civilizations[ civType ].name + " has been destroyed...",  
				//	killer.playerName + " won the war"
					);
			else if ( 
				game.curPlayer.foreignRelation[ player ].madeContact || 
				game.curPlayer.foreignRelation[ killer.player ].madeContact 
				)
				System.Windows.Forms.MessageBox.Show( 
					String.Format( language.getAString( language.order.killHasBeenKilledBy ), new object[] { 
																										 playerName,
																										 Statistics.civilizations[ civType ].name,
																										 killer.playerName,
																										 Statistics.civilizations[ killer.civType ].name
																									 }
					)
				//	playerName + " of " + Statistics.civilizations[ civType ].name + " has been destroyed...",  
				//	killer.playerName + " won the war"
					);
		}
Пример #14
0
        public void transfertToPlayer(PlayerList nextOwner)
        {
            //		state = (byte)enums.cityState.dead;

            /*		nextOwner.cityNumber ++;
             *
             *              if ( nextOwner.cityNumber >= nextOwner.cityList.Length )
             *              {
             *                      CityList[] cityListBuffer = nextOwner.cityList;
             *                      nextOwner.cityList = new CityList[ cityListBuffer.Length + 5 ];
             *
             *                      for ( int i = 0; i < cityListBuffer.Length; i ++ )
             *                              nextOwner.cityList[ i ] = cityListBuffer[ i ];
             *              }
             *
             *              newCity = new CityList( nextOwner, nextOwner.cityNumber );*/

            CityList newCity = nextOwner.addCity();

            //		getTreasure( nextOwner.player, player, game.grid[ xDest, yDest ].city );

            #region get treasure

            byte[] posTechno = new byte[Statistics.technologies.Length];
            byte   nbr       = 0;
            for (int i = 1; i < Statistics.technologies.Length; i++)
            {
                if (
                    nextOwner.technos[i].researched &&
                    !player.technos[i].researched
                    )
                {
                    posTechno[nbr] = (byte)i;
                    nbr++;
                }
            }

            if (nbr > 0)
            {
                Random r = new Random();

                byte technoChose = posTechno[r.Next(nbr - 1) + 1];

                nextOwner.technos[technoChose].researched = true;
            }

            if (
                (
                    player.cityList[city].population > 6 ||
                    player.cityList[city].isCapitale
                ) &&
                player.technos[(byte)Form1.technoList.mapMaking].researched
                )
            {
                for (int x = 0; x < Form1.game.width; x++)
                {
                    for (int y = 0; y < Form1.game.height; y++)
                    {
                        if (Form1.game.grid[x, y].territory - 1 == player.player || player.discovered[x, y])
                        {
                            nextOwner.discovered[x, y] = true;
                        }
                    }
                }
            }
            else if (
                player.cityList[city].population > 3 &&
                player.technos[(byte)Form1.technoList.mapMaking].researched)
            {
                for (int x = 0; x < Form1.game.width; x++)
                {
                    for (int y = 0; y < Form1.game.height; y++)
                    {
                        if (Form1.game.grid[x, y].territory - 1 == player.player)
                        {
                            nextOwner.discovered[x, y] = true;
                        }
                    }
                }
            }
            #endregion

            labor.removeAllLabor(player.player, city);

            newCity.buildingList  = this.buildingList;
            newCity.foodReserve   = this.foodReserve;
            newCity.name          = this.name;
            newCity.population    = this.population;
            newCity.X             = this.X;
            newCity.Y             = this.Y;
            newCity.originalOwner = this.originalOwner;

            state = (byte)enums.cityState.dead;

            //	game.grid[ xDest, yDest ].territory - 1 = owner;
            player.game.grid[X, Y].city = newCity.city;

            if (
                nextOwner.economyType == (byte)enums.economies.slaveryRacial &&
                newCity.population > 0
                )
            {
                int slavesToTransfert = newCity.population / 2;
                nextOwner.slaves.addSlave(slavesToTransfert);
                newCity.population -= (byte)slavesToTransfert;
                System.Windows.Forms.MessageBox.Show(
                    String.Format(language.getAString(language.order.slaveryAquiredFromCity), slavesToTransfert, newCity.name),
                    language.getAString(language.order.slaveryTitle)
                    );
            }

            ai.chooseConstruction(nextOwner.player, nextOwner.cityNumber);

            player.game.frontier.setFrontiers();

            newCity.laborPos = new Point[0];
            labor.addAllLabor(nextOwner.player, nextOwner.cityNumber);
            newCity.setHasDirectAccessToRessource();

            bool oneCityLeft = false;
            for (int i = 1; i <= player.cityNumber; i++)
            {
                if (player.cityList[i].state != (byte)enums.cityState.dead)
                {
                    oneCityLeft = true;
                    break;
                }
            }

            if (!oneCityLeft)
            {
                player.kill(nextOwner);
            }
            else if (this.isCapitale)
            {
                bool found = false;
                for (int c = 1; c <= player.cityNumber && !found; c++)
                {
                    if (player.cityList[c].state != (byte)enums.cityState.dead)
                    {
                        found = true;
                        player.cityList[c].isCapitale = true;
                    }
                }

                if (!found)
                {
                    System.Windows.Forms.MessageBox.Show("error in finding a capital");
                }
            }

            if (player.player == Form1.game.curPlayerInd)
            {
                open.cityFrm(newCity);                          //owner, city, this );
            }
            //		openCityFrm( owner, nextOwner.cityNumber );
        }
Пример #15
0
		public playerSlavery( PlayerList player )
		{
			transferts = new transfertList[ 0 ];
			this.player = player;
		}
Пример #16
0
 public Memory(PlayerList olayer, int length)
 {
     this.player = olayer;
     list        = new structures.memory[length];
 }
Пример #17
0
/*
		bool[] caseImprovementPossibleOnEachCont,
			citiesPossibleOnEachCont;

		public void setWideSetteling()
		{
			caseImprovementPossibleOnEachCont = new bool[ 100 ];
			citiesPossibleOnEachCont = new bool[ 100 ];

			for ( int x = 0; x < game.width; x ++ )
				for ( int y = 0; y < game.height; y ++ )
				{
					if ( !game.grid[ x, y ].water )
						if ( 
							!citiesPossibleOnEachCont[ game.grid[ x, y ].continent - 1 ] &&
							game.grid[ x, y ].canBuildCity 
							)
						{
						}
						else if ( 
							!caseImprovementPossibleOnEachCont[ game.grid[ x, y ].continent - 1 ] //&&
						//	game.grid[ x, y ].canBuildCity 
							)
						{
						}
				}
		}
*/
		#endregion

		public bool isAtWarWith( PlayerList other )
		{
			return foreignRelation[ other.player ].politic == (byte)Form1.relationPolType.war;
		}