コード例 #1
0
ファイル: HouseMgr.cs プロジェクト: mynew4/DAoC
		public static bool UpgradeHouse(House house, InventoryItem deed)
		{
			int newModel = 0;
			switch (deed.Id_nb)
			{
				case "housing_alb_cottage_deed":
					newModel = 1;
					break;
				case "housing_alb_house_deed":
					newModel = 2;
					break;
				case "housing_alb_villa_deed":
					newModel = 3;
					break;
				case "housing_alb_mansion_deed":
					newModel = 4;
					break;
				case "housing_mid_cottage_deed":
					newModel = 5;
					break;
				case "housing_mid_house_deed":
					newModel = 6;
					break;
				case "housing_mid_villa_deed":
					newModel = 7;
					break;
				case "housing_mid_mansion_deed":
					newModel = 8;
					break;
				case "housing_hib_cottage_deed":
					newModel = 9;
					break;
				case "housing_hib_house_deed":
					newModel = 10;
					break;
				case "housing_hib_villa_deed":
					newModel = 11;
					break;
				case "housing_hib_mansion_deed":
					newModel = 12;
					break;
			}

			if (newModel == 0)
				return false;

			// remove all players from the home before we upgrade it
			foreach (GamePlayer player in house.GetAllPlayersInHouse())
			{
				player.LeaveHouse();
			}

			// if there is a consignment merchant, we have to re-initialize since we changed the house
			var merchant = GameServer.Database.SelectObject<HouseConsignmentMerchant>("HouseNumber = '" + house.HouseNumber + "'");
			long oldMerchantMoney = 0;
			if (merchant != null)
			{
				oldMerchantMoney = merchant.Money;
			}

			RemoveHouseItems(house);

			// change the model of the house
			house.Model = newModel;

			// re-add the merchant if there was one
			if (merchant != null)
			{
				house.AddConsignment(oldMerchantMoney);
			}

			// save the house, and broadcast an update
			house.SaveIntoDatabase();
			house.SendUpdate();

			return true;
		}
コード例 #2
0
ファイル: HouseMgr.cs プロジェクト: mynew4/DAoC
		public static void AddHouse(House house)
		{
			// try and get the houses for the given region
			Dictionary<int, House> housesByRegion;
			_houseList.TryGetValue(house.RegionID, out housesByRegion);

			if (housesByRegion == null)
				return;

			// if the house doesn't exist yet, add it
			if (!housesByRegion.ContainsKey(house.HouseNumber))
			{
				housesByRegion.Add(house.HouseNumber, house);
			}
			else
			{
				// replace the existing lot with our new house
				housesByRegion[house.HouseNumber] = house;
			}

			if (house.Model == 0)
			{
				// if this is a lot marker purchase then reset all permissions and customization
				RemoveHouseItems(house);
				RemoveHousePermissions(house);
				ResetHouseData(house);
			}
			else
			{
				// create a new set of permissions
				for (int i = HousingConstants.MinPermissionLevel; i < HousingConstants.MaxPermissionLevel + 1; i++)
				{
					if (house.PermissionLevels.ContainsKey(i))
					{
						var oldPermission = house.PermissionLevels[i];
						if (oldPermission != null)
						{
							GameServer.Database.DeleteObject(oldPermission);
						}
					}

					// create a new, blank permission
					var permission = new DBHousePermissions(house.HouseNumber, i);
					house.PermissionLevels.Add(i, permission);

					// add the permission to the database
					GameServer.Database.AddObject(permission);
				}
			}

			// save the house, broadcast an update
			house.SaveIntoDatabase();
			house.SendUpdate();
		}