BCForbiddenBuy.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using BossBase;
  6. using DataCenter;
  7. using Helper;
  8. namespace BossCommand
  9. {
  10. public class BCForbiddenBuy: ABossCommand
  11. {
  12. public BCForbiddenBuy(IMessageChannel iMessageChannel, DataCenterEntities entities):
  13. base(iMessageChannel, entities)
  14. {
  15. }
  16. public string Guid { get; set; }
  17. public override async Task<object> DoAsync()
  18. {
  19. this.SendMessage(new CMSG_Boss_Gm { Message = string.Format("forbidden_buy_item {0} {1}", this.Guid, 365 * 24 * 3600) });
  20. var smsgBossCommandResponse = await this.RecvMessage<SMSG_Boss_Command_Response>();
  21. if (smsgBossCommandResponse.ErrorCode == ErrorCode.RESPONSE_SUCCESS)
  22. {
  23. return ErrorCode.RESPONSE_SUCCESS;
  24. }
  25. if (smsgBossCommandResponse.ErrorCode == ErrorCode.BOSS_PLAYER_NOT_FOUND)
  26. {
  27. decimal character_guid = decimal.Parse(this.Guid);
  28. var removeBuffs = Entities.t_city_buff.Where(
  29. c => c.buff_id == BuffId.BUFF_FORBIDDEN_PLAYER_BUY_ITEM &&
  30. c.character_guid == character_guid);
  31. foreach (var removeBuff in removeBuffs)
  32. {
  33. Entities.t_city_buff.Remove(removeBuff);
  34. }
  35. var newBuff = new t_city_buff
  36. {
  37. buff_guid = RandomHelper.RandUInt64(),
  38. buff_id = BuffId.BUFF_FORBIDDEN_PLAYER_BUY_ITEM,
  39. buff_time = 0,
  40. buff_values = "{}".ToByteArray(),
  41. character_guid = decimal.Parse(this.Guid),
  42. create_time = DateTime.Now,
  43. modify_time = DateTime.Now,
  44. stack = 1
  45. };
  46. Entities.t_city_buff.Add(newBuff);
  47. Entities.SaveChanges();
  48. return ErrorCode.RESPONSE_SUCCESS;
  49. }
  50. return smsgBossCommandResponse.ErrorCode;
  51. }
  52. }
  53. }