using ServerCommon; using ServerCore; using ServerBase; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static ClientToGameMessage.Types; using static ServerMessage.Types; namespace GameServer { internal static class BuildingProfitNotifyHelper { public static bool send_GS2GS_NTF_MODIFY_BUILDING_PROFIT(int buildingMetaId, List<(int, CurrencyType, double)> profits) { var server_logic = GameServerApp.getServerLogic(); var message = new ServerMessage(); message.NtfModifyBuildingProfit = new GS2GS_NTF_MODIFY_BUILDING_PROFIT(); message.NtfModifyBuildingProfit.ExceptServerName = server_logic.getServerName(); message.NtfModifyBuildingProfit.BuildingMetaId = buildingMetaId; foreach (var (floor, currency_type, delta_amount) in profits) { if (!message.NtfModifyBuildingProfit.FloorProfits.TryGetValue(floor, out var floor_profits)) { floor_profits = new FloorProfitInfo(); message.NtfModifyBuildingProfit.FloorProfits[floor] = floor_profits; } var money = new Money(); money.Amount = delta_amount; floor_profits.Profits[(int)currency_type] = money; } var rabbit_mq = server_logic.getRabbitMqConnector() as RabbitMQ4Game; NullReferenceCheckHelper.throwIfNull(rabbit_mq, () => $"rabbit_mq is null !!!"); rabbit_mq.sendMessageToExchangeAllGame(message); return true; } public static bool send_GS2GS_NTF_MODIFY_BUILDING_PROFIT(int buildingMetaId, int floor, CurrencyType currencyType, double currencyAmount) { var modify_profits = new List<(int, CurrencyType, double)>(); modify_profits.Add((floor, currencyType, currencyAmount)); return send_GS2GS_NTF_MODIFY_BUILDING_PROFIT(buildingMetaId, modify_profits); } } }