BCAllowBuy.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Linq;
  2. using System.Threading.Tasks;
  3. using BossBase;
  4. using DataCenter;
  5. namespace BossCommand
  6. {
  7. public class BCAllowBuy: ABossCommand
  8. {
  9. public BCAllowBuy(IMessageChannel iMessageChannel, DataCenterEntities entities):
  10. base(iMessageChannel, entities)
  11. {
  12. }
  13. public string Guid { get; set; }
  14. public override async Task<object> DoAsync()
  15. {
  16. this.SendMessage(new CMSG_Boss_Gm
  17. {
  18. Message = string.Format("forbidden_buy_item {0} 0", this.Guid)
  19. });
  20. var smsgBossCommandResponse = await 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. Entities.SaveChanges();
  36. return ErrorCode.RESPONSE_SUCCESS;
  37. }
  38. return smsgBossCommandResponse.ErrorCode;
  39. }
  40. }
  41. }