Пример #1
0
        private void CreateForestCamp(Session session, Packet packet)
        {
            uint   cityId;
            uint   forestId;
            ushort type;
            ushort labor;

            try
            {
                cityId   = packet.GetUInt32();
                forestId = packet.GetUInt32();
                type     = packet.GetUInt16();
                labor    = packet.GetUInt16();
            }
            catch (Exception)
            {
                ReplyError(session, packet, Error.Unexpected);
                return;
            }

            ICity city = session.Player.GetCity(cityId);

            if (city == null)
            {
                ReplyError(session, packet, Error.CityNotFound);
                return;
            }

            locker.Lock(forestManager.CallbackLockHandler,
                        new object[] { forestId },
                        city).Do(() =>
            {
                // Get the lumbermill
                IStructure lumbermill =
                    city.FirstOrDefault(structure => objectTypeFactory.IsStructureType("Wood", structure));

                if (lumbermill == null || lumbermill.Lvl == 0)
                {
                    ReplyError(session, packet, Error.LumbermillUnavailable);
                    return;
                }

                var buildaction = actionFactory.CreateForestCampBuildActiveAction(cityId,
                                                                                  lumbermill.ObjectId,
                                                                                  forestId,
                                                                                  type,
                                                                                  labor);
                Error ret = city.Worker.DoActive(structureCsvFactory.GetActionWorkerType(lumbermill),
                                                 lumbermill,
                                                 buildaction,
                                                 lumbermill.Technologies);
                if (ret == Error.ActionTotalMaxReached)
                {
                    ReplyError(session, packet, Error.LumbermillBusy);
                }
                else
                {
                    ReplyWithResult(session, packet, ret);
                }
            });
        }
Пример #2
0
        public virtual int BuildTime(int baseValue, ICity city, ITechnologyManager em)
        {
            IStructure university = city.FirstOrDefault(structure => ObjectTypeFactory.IsStructureType("University", structure));

            return((int)(baseValue * (100 - (university == null ? 0 : university.Stats.Labor) * 0.25) / 100));
        }