/// <summary> /// /// </summary> /// <param name="guild"></param> /// <param name="taxCollectorDAO"></param> /// <returns></returns> public TaxCollectorEntity CreateTaxCollector(GuildInstance guild, TaxCollectorDAO taxCollectorDAO) { var taxCollector = new TaxCollectorEntity(guild, taxCollectorDAO); taxCollector.StartAction(GameActionTypeEnum.MAP); taxCollector.Map.SubArea.TaxCollector = taxCollector; m_taxCollectorById.Add(taxCollector.Id, taxCollector); return(taxCollector); }
/// <summary> /// /// </summary> public TaxCollectorEntity(GuildInstance guild, TaxCollectorDAO record) : base(EntityTypeEnum.TYPE_TAX_COLLECTOR, record.Id) { DatabaseRecord = record; Guild = guild; MapId = DatabaseRecord.MapId; CellId = DatabaseRecord.CellId; Defenders = new List<GuildMember>(); FarmedItems = new Dictionary<int, int>(); Statistics = new GenericStats(); Statistics.Merge(guild.Statistics.BaseStatistics); SpellBook = SpellBookFactory.Instance.Create(this); Storage = new TaxCollectorInventory(this); }
/// <summary> /// /// </summary> public TaxCollectorEntity(GuildInstance guild, TaxCollectorDAO record) : base(EntityTypeEnum.TYPE_TAX_COLLECTOR, record.Id) { DatabaseRecord = record; Guild = guild; MapId = DatabaseRecord.MapId; CellId = DatabaseRecord.CellId; Defenders = new List <GuildMember>(); FarmedItems = new Dictionary <int, int>(); Statistics = new GenericStats(); Statistics.Merge(guild.Statistics.BaseStatistics); SpellBook = SpellBookFactory.Instance.Create(this); Storage = new TaxCollectorInventory(this); }
/// <summary> /// /// </summary> /// <param name="member"></param> public void HireTaxCollector(GuildMember member) { if (member.Character == null) return; member.Character.AddMessage(() => { if (member.Character.Map.SubArea.TaxCollector != null) { member.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_MAX_TAXCOLLECTOR_BY_SUBAREA_REACHED, 1)); // MAX COLLECTOR BY SUBAREA return; } if (member.Character.Inventory.Kamas < TaxCollectorPrice) { member.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_NOT_ENOUGH_KAMAS, TaxCollectorPrice)); return; } AddMessage(() => { if (!member.HasRight(GuildRightEnum.HIRE_TAXCOLLECTOR)) { member.SendHasNotEnoughRights(); return; } if (m_taxCollectors.Count >= Statistics.MaxTaxcollector) { member.Dispatch(WorldMessage.SERVER_ERROR_MESSAGE("Your guild has already hired the maximum TaxCollector.")); return; } var taxCollectorDAO = new TaxCollectorDAO() { Id = TaxCollectorRepository.Instance.NextTaxCollectorId, GuildId = Id, OwnerId = member.Id, Name = Util.Next(WorldConfig.TAXCOLLECTOR_MIN_NAME, WorldConfig.TAXCOLLECTOR_MAX_NAME), FirstName = Util.Next(WorldConfig.TAXCOLLECTOR_MIN_FIRSTNAME, WorldConfig.TAXCOLLECTOR_MAX_FIRSTNAME), MapId = member.Character.MapId, CellId = member.Character.CellId, Skin = WorldConfig.TAXCOLLECTOR_SKIN_BASE, SkinSize = WorldConfig.TAXCOLLECTOR_SKIN_SIZE_BASE, Kamas = 0, Experience = 0, }; TaxCollectorRepository.Instance.Created(taxCollectorDAO); foreach (var spell in Statistics.Spells.GetSpells()) if(spell.Level > 0) SpellBookEntryRepository.Instance.Create((int)EntityTypeEnum.TYPE_TAX_COLLECTOR, taxCollectorDAO.Id, spell.SpellId, spell.Level, 25); var taxCollector = EntityManager.Instance.CreateTaxCollector(this, taxCollectorDAO); AddTaxCollector(taxCollector); member.Character.AddMessage(() => { member.Character.Inventory.SubKamas(TaxCollectorPrice); member.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.INFO, InformationEnum.INFO_KAMAS_LOST, TaxCollectorPrice)); }); base.Dispatch(WorldMessage.GUILD_TAXCOLLECTOR_HIRED(taxCollector, member.Character.Name)); }); }); }
/// <summary> /// /// </summary> /// <param name="member"></param> public void HireTaxCollector(GuildMember member) { if (member.Character == null) { return; } member.Character.AddMessage(() => { if (member.Character.Map.SubArea.TaxCollector != null) { member.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_MAX_TAXCOLLECTOR_BY_SUBAREA_REACHED, 1)); // MAX COLLECTOR BY SUBAREA return; } if (member.Character.Inventory.Kamas < TaxCollectorPrice) { member.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_NOT_ENOUGH_KAMAS, TaxCollectorPrice)); return; } AddMessage(() => { if (!member.HasRight(GuildRightEnum.HIRE_TAXCOLLECTOR)) { member.SendHasNotEnoughRights(); return; } if (m_taxCollectors.Count >= Statistics.MaxTaxcollector) { member.Dispatch(WorldMessage.SERVER_ERROR_MESSAGE("Your guild has already hired the maximum TaxCollector.")); return; } var taxCollectorDAO = new TaxCollectorDAO() { Id = TaxCollectorRepository.Instance.NextTaxCollectorId, GuildId = Id, OwnerId = member.Id, Name = Util.Next(WorldConfig.TAXCOLLECTOR_MIN_NAME, WorldConfig.TAXCOLLECTOR_MAX_NAME), FirstName = Util.Next(WorldConfig.TAXCOLLECTOR_MIN_FIRSTNAME, WorldConfig.TAXCOLLECTOR_MAX_FIRSTNAME), MapId = member.Character.MapId, CellId = member.Character.CellId, Skin = WorldConfig.TAXCOLLECTOR_SKIN_BASE, SkinSize = WorldConfig.TAXCOLLECTOR_SKIN_SIZE_BASE, Kamas = 0, Experience = 0, }; TaxCollectorRepository.Instance.Created(taxCollectorDAO); foreach (var spell in Statistics.Spells.GetSpells()) { if (spell.Level > 0) { SpellBookEntryRepository.Instance.Create((int)EntityTypeEnum.TYPE_TAX_COLLECTOR, taxCollectorDAO.Id, spell.SpellId, spell.Level, 25); } } var taxCollector = EntityManager.Instance.CreateTaxCollector(this, taxCollectorDAO); AddTaxCollector(taxCollector); member.Character.AddMessage(() => { member.Character.Inventory.SubKamas(TaxCollectorPrice); member.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.INFO, InformationEnum.INFO_KAMAS_LOST, TaxCollectorPrice)); }); base.Dispatch(WorldMessage.GUILD_TAXCOLLECTOR_HIRED(taxCollector, member.Character.Name)); }); }); }