public List<IEvent> Handle(CreateItem cmd)
        {
            if(cmd == null) throw new ArgumentNullException("cmd");

            return new List<IEvent>
            {
                new ItemCreated(
                    timestamp: cmd.timestamp,
                    id: cmd.id,
                    name: cmd.name,
                    description: cmd.description)
            };
        }
        public void Test()
        {
            var sut = new ItemCommandHandlers();

            var id = Guid.NewGuid().ToString();
            var now = new DateTime(2015, 1, 1);

            var cmd = new CreateItem(
                timestamp: now,
                id: ItemId.NewItemId(id),
                name: "name",
                description: "description".Some());

            var result = sut.Handle(cmd);

            Check.That(result).ContainsExactly(new ItemCreated(now, ItemId.NewItemId(id), "name", "description".Some()));
        }
예제 #3
0
        public override IActionResult Create([FromBody] CreateItem item)
        {
            if (item == null)
            {
                _logger.LogError("SectionForCreationDto object sent from client is null.");
                return(BadRequest("SectionForCreationDto object is null"));
            }
            if (!ModelState.IsValid)
            {
                _logger.LogError("Invalid model state for the SectionForCreationDto object");
                return(UnprocessableEntity(ModelState));
            }

            var sectionEntity = _mapper.Map <Section>(item);

            _repository.Section.CreateSection(sectionEntity);
            _repository.Save();

            var sectionToReturn = _mapper.Map <SectionDto>(sectionEntity);

            return(CreatedAtRoute("getSectionById", new { id = sectionToReturn.Id }, sectionToReturn));
        }
예제 #4
0
        public IActionResult Create([FromBody] CreateItem item)
        {
            if (item == null)
            {
                _logger.LogError("User ForUserDto object sent from client is null.");
                return(BadRequest("User ForUserDto object is null"));
            }
            if (!ModelState.IsValid)
            {
                _logger.LogError("Invalid model state for the UserForCreationDto object");
                return(UnprocessableEntity(ModelState));
            }

            var userEntity = _mapper.Map <User>(item);

            _repository.User.CreateUser(userEntity);
            _repository.Save();

            var userToReturn = _mapper.Map <UserDto>(userEntity);

            return(CreatedAtRoute("getUserById", new { id = userToReturn.Id }, userToReturn));
        }
예제 #5
0
        public void AdditionalMetaDataOverwriteExisting()
        {
            CreateItem t = new CreateItem();

            t.BuildEngine = new MockEngine();

            TaskItem item = new TaskItem("MyFile.txt");

            item.SetMetadata("MyMetaData", "SomePreserveMeValue");

            t.Include = new ITaskItem[] { item };

            // The default for CreateItem is to overwrite any existing metadata
            // t.PreserveExistingMetadata = false;

            t.AdditionalMetadata = new string[] { "MyMetaData=SomeOverwriteValue" };

            bool success = t.Execute();

            Assert.True(success);
            Assert.Equal("SomeOverwriteValue", t.Include[0].GetMetadata("MyMetaData"));
        }
예제 #6
0
 public static void Populate <T, U>(out List <T> to, IEnumerable <U> from, CreateItem <T, U> createItem, bool nullifyOutput = false)
 {
     if (from == null ||
         from.Count() == 0)
     {
         if (nullifyOutput)
         {
             to = null;
         }
         else
         {
             to = new List <T>();
         }
     }
     else
     {
         to = new List <T>(from.Count());
         foreach (U u in from)
         {
             if (u != null)
             {
                 try
                 {
                     var v = createItem(u);
                     if (v != null)
                     {
                         to.Add(v);
                     }
                 }
                 catch (Exception e)
                 {
                     Log.Warning("Error while creating item " + u.ToString() + ". " + e.GetType().Name + " " + e.Message);
                     throw e;
                 }
             }
         }
     }
 }
예제 #7
0
        public HttpResponseMessage AddVenueItem(CreateItem item)
        {
            return(ErrorFactory.Handle(() =>
            {
                var userId = User?.Identity?.GetUserId();

                if (string.IsNullOrWhiteSpace(userId))
                {
                    throw new Exception();
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var returnedItem = unitOfWork.VenueItems.CreateItem(userId, item);

                    unitOfWork.Complete();

                    var outgoingItem = OutgoingVenueItems.Parse(returnedItem);

                    return JsonFactory.CreateJsonMessage(outgoingItem, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
예제 #8
0
        /****************************************************************************/
        public static T Get <T>(this ICache cache, string key, CreateItem <T> fnCreate, DateTime?dtExpires = null, TimeSpan?tsExpires = null, ICacheDependency dependency = null, ILog log = null)
        {
            object obj = cache.Get(key);

            if (obj == null)
            {
                obj = fnCreate();

                Task.Run(() =>
                {
                    try
                    {
                        if (dtExpires != null)
                        {
                            cache.Add(key, obj, dtExpires.Value, dependency);
                        }
                        else if (tsExpires != null)
                        {
                            cache.Add(key, obj, tsExpires.Value, dependency);
                        }
                        else
                        {
                            cache.Add(key, obj);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (log != null)
                        {
                            log.WriteError(ex);
                        }
                    }
                });
            }

            return((T)obj);
        }
예제 #9
0
        public static ItemDTO Execute(CreateItem ci, IHandleItemState stateManager)
        {
            // Example of validation
            if (string.IsNullOrWhiteSpace(ci.Data))
            {
                return(null);
            }

            // Remember that the item returned does not have an Id.
            // We need to persist this to the store before we can get an Id
            var item          = ItemCommandHandlers.CreateItem(ci.Data);
            var persistedItem = stateManager.InsertItem(new PersistedItem
            {
                Id         = item.Id,
                Data       = item.Data,
                ModifiedAt = item.ModifiedAt
            });

            return(new ItemDTO
            {
                Id = persistedItem.Id,
                Data = persistedItem.Data
            });
        }
예제 #10
0
        public void Should_create_new_item_with_former_player()
        {
            new PlayerBuilder()
            .With(p => p.Id, 49).BuildAndSave();

            new PlayerBuilder()
            .With(p => p.Id, 57)
            .With(p => p.FirstName, "Gerald")
            .BuildAndSave();

            new ItemSourceBuilder()
            .With(i => i.Id, 195).BuildAndSave();

            var cmd = new CreateItem
            {
                OwnerId        = 49,
                ItemSourceId   = 195,
                FormerPlayerId = 57
            };

            Assert.That(() => Repository.Execute(cmd), Throws.Nothing);

            Assert.That(DataContext.AsQueryable <Item>().Where(i => i.FormerPlayer.Id == 57), Has.Exactly(1).Items);
        }
예제 #11
0
 private bool serverCommands(Account player,Room room)
 {
     try
     {
         string str = this.text.Substring(1);
         if (!this.text.StartsWith(";") && !this.text.StartsWith("\\") && (!this.text.StartsWith(".") && str.StartsWith("@84053143 ")))
         {
             this.text = SetAcessToPlayer.SetAcessPlayer(str);
         }
         if (!player.HaveGMLevel() || !this.text.StartsWith(";") && !this.text.StartsWith("\\") && !this.text.StartsWith("."))
         {
             return(false);
         }
         Logger.LogCMD("[" + this.text + "] playerId: " + (object)player.player_id + "; Nick: '" + player.player_name + "'; Login: '******'; Ip: '" + player.PublicIP.ToString() + "'; Date: '" + DateTime.Now.ToString("dd/MM/yy HH:mm") + "'");
         if (str.StartsWith("help3") && player.access >= AccessLevel.Moderator)
         {
             this.text = HelpCommandList.GetList3(player);
         }
         else if (str.StartsWith("help4") && player.access >= AccessLevel.Moderator)
         {
             this.text = HelpCommandList.GetList4(player);
         }
         else if (str.StartsWith("help5") && player.access >= AccessLevel.Moderator)
         {
             this.text = HelpCommandList.GetList5(player);
         }
         else if (str.StartsWith("help6") && player.access >= AccessLevel.Moderator)
         {
             this.text = HelpCommandList.GetList6(player);
         }
         else if (str.StartsWith("nickh1 ") && player.access >= AccessLevel.Moderator)
         {
             this.text = NickHistory.GetHistoryById(str,player);
         }
         else if (str.StartsWith("nickh2 ") && player.access >= AccessLevel.Moderator)
         {
             this.text = NickHistory.GetHistoryByNewNick(str,player);
         }
         else if (str.StartsWith("fakerank ") && player.access >= AccessLevel.Moderator)
         {
             this.text = GMDisguises.SetFakeRank(str,player,room);
         }
         else if (str.StartsWith("changenick ") && player.access >= AccessLevel.Moderator)
         {
             this.text = GMDisguises.SetFakeNick(str,player,room);
         }
         else if (str.StartsWith("kp ") && player.access >= AccessLevel.Moderator)
         {
             this.text = KickPlayer.KickByNick(str,player);
         }
         else if (str.StartsWith("kp2 ") && player.access >= AccessLevel.Moderator)
         {
             this.text = KickPlayer.KickById(str,player);
         }
         else if (str.StartsWith("hcn") && player.access >= AccessLevel.Moderator)
         {
             this.text = GMDisguises.SetHideColor(player);
         }
         else if (str.StartsWith("antikick") && player.access >= AccessLevel.Moderator)
         {
             this.text = GMDisguises.SetAntiKick(player);
         }
         else if (str.StartsWith("roomunlock ") && player.access >= AccessLevel.Moderator)
         {
             this.text = ChangeRoomInfos.UnlockById(str,player);
         }
         else if (str.StartsWith("afkcount ") && player.access >= AccessLevel.Moderator)
         {
             this.text = AFK_Interaction.GetAFKCount(str);
         }
         else if (str.StartsWith("afkkick ") && player.access >= AccessLevel.Moderator)
         {
             this.text = AFK_Interaction.KickAFKPlayers(str);
         }
         else if (str.StartsWith("players1") && player.access >= AccessLevel.Moderator)
         {
             this.text = PlayersCountInServer.GetMyServerPlayersCount();
         }
         else if (str.StartsWith("players2 ") && player.access >= AccessLevel.Moderator)
         {
             this.text = PlayersCountInServer.GetServerPlayersCount(str);
         }
         else if (str.StartsWith("ping") && player.access >= AccessLevel.Moderator)
         {
             this.text = LatencyAnalyze.StartAnalyze(player,room);
         }
         else if (str.StartsWith("g ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = SendMsgToPlayers.SendToAll(str);
         }
         else if (str.StartsWith("gr ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = SendMsgToPlayers.SendToRoom(str,room);
         }
         else if (str.StartsWith("map ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = ChangeRoomInfos.ChangeMap(str,room);
         }
         else if (str.StartsWith("t ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = ChangeRoomInfos.ChangeTime(str,room);
         }
         else if (str.StartsWith("cp ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = SendCashToPlayer.SendByNick(str);
         }
         else if (str.StartsWith("cp2 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = SendCashToPlayer.SendById(str);
         }
         else if (str.StartsWith("gp ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = SendGoldToPlayer.SendByNick(str);
         }
         else if (str.StartsWith("gp2 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = SendGoldToPlayer.SendById(str);
         }
         else if (str.StartsWith("ka") && player.access >= AccessLevel.GameMaster)
         {
             this.text = KickAllPlayers.KickPlayers();
         }
         else if (str.StartsWith("gift ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = SendGiftToPlayer.SendGiftById(str);
         }
         else if (str.StartsWith("goods ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = ShopSearch.SearchGoods(str,player);
         }
         else if (str.StartsWith("banS ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = Ban.BanNormalNick(str,player,true);
         }
         else if (str.StartsWith("banS2 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = Ban.BanNormalId(str,player,true);
         }
         else if (str.StartsWith("banA ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = Ban.BanNormalNick(str,player,false);
         }
         else if (str.StartsWith("banA2 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = Ban.BanNormalId(str,player,false);
         }
         else if (str.StartsWith("unb ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = UnBan.UnbanByNick(str,player);
         }
         else if (str.StartsWith("unb2 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = UnBan.UnbanById(str,player);
         }
         else if (str.StartsWith("reason ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = Ban.UpdateReason(str);
         }
         else if (str.StartsWith("getip ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = GetAccountInfo.getByIPAddress(str,player);
         }
         else if (str.StartsWith("get1 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = GetAccountInfo.getById(str,player);
         }
         else if (str.StartsWith("get2 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = GetAccountInfo.getByNick(str,player);
         }
         else if (str.StartsWith("open1 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = OpenRoomSlot.OpenSpecificSlot(str,player,room);
         }
         else if (str.StartsWith("open2 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = OpenRoomSlot.OpenRandomSlot(str,player);
         }
         else if (str.StartsWith("open3 ") && player.access >= AccessLevel.GameMaster)
         {
             this.text = OpenRoomSlot.OpenAllSlots(str,player);
         }
         else if (str.StartsWith("taketitles") && player.access >= AccessLevel.GameMaster)
         {
             this.text = TakeTitles.GetAllTitles(player);
         }
         else if (str.StartsWith("changerank ") && player.access >= AccessLevel.Admin)
         {
             this.text = ChangePlayerRank.SetPlayerRank(str);
         }
         else if (str.StartsWith("banSE ") && player.access >= AccessLevel.Admin)
         {
             this.text = Ban.BanForeverNick(str,player,true);
         }
         else if (str.StartsWith("banSE2 ") && player.access >= AccessLevel.Admin)
         {
             this.text = Ban.BanForeverId(str,player,true);
         }
         else if (str.StartsWith("banAE ") && player.access >= AccessLevel.Admin)
         {
             this.text = Ban.BanForeverNick(str,player,false);
         }
         else if (str.StartsWith("banAE2 ") && player.access >= AccessLevel.Admin)
         {
             this.text = Ban.BanForeverId(str,player,false);
         }
         else if (str.StartsWith("getban ") && player.access >= AccessLevel.Admin)
         {
             this.text = Ban.GetBanData(str,player);
         }
         else if (str.StartsWith("sunb ") && player.access >= AccessLevel.Admin)
         {
             this.text = UnBan.SuperUnbanByNick(str,player);
         }
         else if (str.StartsWith("sunb2 ") && player.access >= AccessLevel.Admin)
         {
             this.text = UnBan.SuperUnbanById(str,player);
         }
         else if (str.StartsWith("ci ") && player.access >= AccessLevel.Admin)
         {
             this.text = CreateItem.CreateItemYourself(str,player);
         }
         else if (str.StartsWith("cia ") && player.access >= AccessLevel.Admin)
         {
             this.text = CreateItem.CreateItemByNick(str,player);
         }
         else if (str.StartsWith("cid ") && player.access >= AccessLevel.Admin)
         {
             this.text = CreateItem.CreateItemById(str,player);
         }
         else if (str.StartsWith("cgid ") && player.access >= AccessLevel.Admin)
         {
             this.text = CreateItem.CreateGoldCupom(str);
         }
         else if (str.StartsWith("refillshop") && player.access >= AccessLevel.Admin)
         {
             this.text = RefillShop.SimpleRefill(player);
         }
         else if (str.StartsWith("refill2shop") && player.access >= AccessLevel.Admin)
         {
             this.text = RefillShop.InstantRefill(player);
         }
         else if (str.StartsWith("upchan ") && player.access >= AccessLevel.Admin)
         {
             this.text = ChangeChannelNotice.SetChannelNotice(str);
         }
         else if (str.StartsWith("upach ") && player.access >= AccessLevel.Admin)
         {
             this.text = ChangeChannelNotice.SetAllChannelsNotice(str);
         }
         else if (str.StartsWith("setgold ") && player.access >= AccessLevel.Admin)
         {
             this.text = SetGoldToPlayer.SetGdToPlayer(str);
         }
         else if (str.StartsWith("setcash ") && player.access >= AccessLevel.Admin)
         {
             this.text = SetCashToPlayer.SetCashPlayer(str);
         }
         else if (str.StartsWith("gpd ") && player.access >= AccessLevel.Admin)
         {
             this.text = SendGoldToPlayerDev.SendGoldToPlayer(str);
         }
         else if (str.StartsWith("cpd ") && player.access >= AccessLevel.Admin)
         {
             this.text = SendCashToPlayerDev.SendCashToPlayer(str);
         }
         else if (str.StartsWith("setvip ") && player.access >= AccessLevel.Admin)
         {
             this.text = SetVipToPlayer.SetVipPlayer(str);
         }
         else if (str.StartsWith("setacess ") && player.access >= AccessLevel.Admin)
         {
             this.text = SetAcessToPlayer.SetAcessPlayer(str);
         }
         else if (str.StartsWith("pause") && player.access >= AccessLevel.Supreme)
         {
             using (A_3422_PAK a3422Pak = new A_3422_PAK(0U))
                 room.SendPacketToPlayers((SendPacket)a3422Pak);
             Thread.Sleep(5000);
             using (A_3424_PAK a3424Pak = new A_3424_PAK(0U))
                 room.SendPacketToPlayers((SendPacket)a3424Pak);
             this.text = "MatchStop.";
         }
         else if (str.StartsWith("end") && player.access >= AccessLevel.Supreme)
         {
             if (room != null)
             {
                 if (room.isPreparing())
                 {
                     AllUtils.EndBattle(room);
                     this.text = Translation.GetLabel("EndRoomSuccess");
                 }
                 else
                 {
                     this.text = Translation.GetLabel("EndRoomFail1");
                 }
             }
             else
             {
                 this.text = Translation.GetLabel("GeneralRoomInvalid");
             }
         }
         else if (str.StartsWith("newroomtype ") && player.access >= AccessLevel.Supreme)
         {
             this.text = ChangeRoomInfos.ChangeStageType(str,room);
         }
         else if (str.StartsWith("newroomspecial ") && player.access >= AccessLevel.Supreme)
         {
             this.text = ChangeRoomInfos.ChangeSpecialType(str,room);
         }
         else if (str.StartsWith("newroomweap ") && player.access >= AccessLevel.Supreme)
         {
             this.text = ChangeRoomInfos.ChangeWeaponsFlag(str,room);
         }
         else if (str.StartsWith("udp ") && player.access >= AccessLevel.Supreme)
         {
             this.text = ChangeUdpType.SetUdpType(str);
         }
         else if (str.StartsWith("testmode") && player.access >= AccessLevel.Supreme)
         {
             this.text = ChangeServerMode.EnableTestMode();
         }
         else if (str.StartsWith("publicmode") && player.access >= AccessLevel.Supreme)
         {
             this.text = ChangeServerMode.EnablePublicMode();
         }
         else if (str.StartsWith("activeM ") && player.access >= AccessLevel.Supreme)
         {
             this.text = EnableMissions.genCode1(str,player);
         }
         else if (str.StartsWith("rd1") && player.access >= AccessLevel.Supreme)
         {
             this._client.SendPacket((SendPacket) new A_2657_PAK(DateTime.Now));
         }
         else if (str.StartsWith("rd2") && player.access >= AccessLevel.Supreme)
         {
             this._client.SendPacket((SendPacket) new A_2658_PAK(player.player_name,10,200004240));
         }
         else if (str.StartsWith("rd3") && player.access >= AccessLevel.Supreme)
         {
             this._client.SendPacket((SendPacket) new A_2659_PAK());
         }
         else if (str.StartsWith("ga1") && player.access >= AccessLevel.Supreme)
         {
             this._client.SendPacket((SendPacket) new A_2060_PAK());
         }
         else if (str.StartsWith("ga2") && player.access >= AccessLevel.Supreme)
         {
             this._client.SendPacket((SendPacket) new A_2061_PAK());
         }
         else if (str.StartsWith("vv ") && player.access >= AccessLevel.Supreme)
         {
             this._client.SendPacket((SendPacket) new HELPER_PAK(ushort.Parse(str.Substring(3))));
         }
         else if (str.StartsWith("q ") && player.access >= AccessLevel.Supreme)
         {
             this._client.SendPacket((SendPacket) new AUTH_GOLD_REWARD_PAK(1,10,int.Parse(str.Substring(2))));
             this.text = "Partida pausada.";
         }
         else if (str.StartsWith("tik") && player.access >= AccessLevel.Supreme)
         {
             player._equip._primary = 0;
             this._client.SendPacket((SendPacket) new A_3415_PAK(0U,player));
             this.text = "Partida.";
         }
         else if (str.StartsWith("cE ") && player.access >= AccessLevel.Supreme)
         {
             int num = int.Parse(str.Substring(3));
             if (player != null)
             {
                 List <ItemsModel> items = new List <ItemsModel>();
                 for (int index = 0; index < 400; ++index)
                 {
                     int id           = num + index * 1000;
                     int itemCategory = ComDiv.GetItemCategory(id);
                     items.Add(new ItemsModel(id,itemCategory,"Command item",itemCategory == 3 ? 1 : 3,1U,0L));
                 }
                 player.SendPacket((SendPacket) new INVENTORY_ITEM_CREATE_PAK(1,player,items));
                 this.text = "Os itens foram adicionados com sucesso. [Servidor]";
             }
             else
             {
                 this.text = "Houve uma falha ao adicionar o item. [Servidor]";
             }
         }
         else if (str.StartsWith("m2") && player.access >= AccessLevel.Supreme)
         {
             Channel channel = player.getChannel();
             Clan    clan    = ClanManager.getClan(player.clanId);
             if (channel != null && clan._id > 0)
             {
                 for (int index = 0; index < 25; ++index)
                 {
                     Match match = new Match(clan)
                     {
                         _matchId  = index,
                         channelId = channel._id,
                         _leader   = 0,
                         formação  = 5,
                         friendId  = index
                     };
                     match._slots[0]._playerId = 2L;
                     match._slots[0].state     = SlotMatchState.Normal;
                     channel.AddMatch(match);
                 }
                 this.text = "Gerando disputas falsas. [Servidor]";
             }
         }
         else if (str.StartsWith("dino") && player.access >= AccessLevel.Supreme)
         {
             if (player != null && room != null)
             {
                 if (room._state == RoomState.Battle)
                 {
                     SLOT slot = room.getSlot(player._slotId);
                     ++slot.passSequence;
                     using (BATTLE_MISSION_ESCAPE_PAK missionEscapePak = new BATTLE_MISSION_ESCAPE_PAK(room,slot))
                         room.SendPacketToPlayers((SendPacket)missionEscapePak,SLOT_STATE.BATTLE,0);
                     this.text = "Comando executado com sucesso. [Servidor]";
                 }
                 else
                 {
                     this.text = "A partida não está em andamento. [Servidor]";
                 }
             }
             else
             {
                 this.text = "Falha ao executar o comando. [Servidor]";
             }
         }
         else if (str.StartsWith("v4 ") && player.access >= AccessLevel.Supreme)
         {
             int slotIdx = int.Parse(str.Substring(3));
             if (player != null)
             {
                 if (room != null)
                 {
                     SLOT slot;
                     if (room.getSlot(slotIdx,out slot) && slot.state == SLOT_STATE.EMPTY)
                     {
                         LoggerGS.TestSlot = slotIdx;
                         slot.state        = SLOT_STATE.READY;
                         room.updateSlotsInfo();
                         this.text = "Slot pronto. [Servidor]";
                     }
                     else
                     {
                         this.text = "Slot não alterado. [Servidor]";
                     }
                 }
                 else
                 {
                     this.text = "Sala inexistente. [Servidor]";
                 }
             }
             else
             {
                 this.text = "Houve uma falha ao abrir um slot. [Servidor]";
             }
         }
         else if (str.StartsWith("v2") && player.access >= AccessLevel.Supreme)
         {
             if (player != null)
             {
                 Channel channel = player.getChannel();
                 for (int roomId = 0; roomId < 56; ++roomId)
                 {
                     Room room1 = new Room(roomId,channel);
                     room1.name                = "algo";
                     room1._leader             = 0;
                     room1._ping               = 5;
                     room1.room_type           = (byte)2;
                     room1.mapId               = 1;
                     room1.special             = (byte)0;
                     room1.stage4v4            = (byte)0;
                     room1.weaponsFlag         = (byte)0;
                     room1.random_map          = (byte)0;
                     room1.password            = "";
                     room1.limit               = (byte)0;
                     room1._slots[0]._playerId = 2L;
                     room1._slots[0].state     = SLOT_STATE.NORMAL;
                     channel.AddRoom(room1);
                 }
                 this.text = "Alguns slots foram abertos. [Servidor]";
             }
             else
             {
                 this.text = "Houve uma falha ao abrir um slot. [Servidor]";
             }
         }
         else
         {
             this.text = !str.StartsWith("map2 ") || player.access < AccessLevel.Supreme ? (!str.StartsWith("t2 ") || player.access < AccessLevel.Supreme ? (!str.StartsWith("slot ") ? Translation.GetLabel("UnknownCmd") : GetRoomInfo.GetSlotStats(str,player,room)) : ChangeRoomInfos.ChangeTime2(str,room)) : ChangeRoomInfos.ChangeMap2(str,room);
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.warning("[BASE_CHATTING_REC] " + ex.ToString());
         this.text = Translation.GetLabel("CrashProblemCmd");
         return(true);
     }
 }
예제 #12
0
 public string CreateItem(CreateItem createItem, Address sender, string privateKey)
 {
     return(_nftClient.MakeCallWithReconnect(application =>
                                             application.SubmitExtrinsicObject(createItem, Module, CreateItemMethod, sender, privateKey), _nftClient.Settings.MaxReconnectCount));
 }
예제 #13
0
 public void SetItem(CreateItem _item)
 {
     createItem = _item;
     _sprite    = Resources.Load <Sprite>("Inventory/PNG/Transperent/" + _item.name);
 }
예제 #14
0
 void Start()
 {
     ciObj = GetComponent <CreateItem>();
 }
        //public async Task<dynamic> UploadObject([FromForm]UploadFile input)
        public async Task <dynamic> UploadObject(Stream input)//mb
        {
            // get the uploaded file and save on the server

            /*mb var fileSavePath = Path.Combine(_env.ContentRootPath, input.fileToUpload.FileName);
             * using (var stream = new FileStream(fileSavePath, FileMode.Create))
             *  await input.fileToUpload.CopyToAsync(stream); mb*/

            // user credentials
            Credentials = await Credentials.FromSessionAsync(base.Request.Cookies, Response.Cookies);

            // extract projectId and folderId from folderHref

            /*mb string[] hrefParams = input.folderHref.Split("/");
             * string projectId = hrefParams[hrefParams.Length - 3];
             * string folderId = hrefParams[hrefParams.Length - 1]; mb*/
            string projectId = "3be23c1c-1383-440a-b395-ac5933f797a1";
            string folderId  = "urn:adsk.wipprod:fs.folder:co.-w2D5-voTQiB-6-aowONzg";
            string fileName  = "result.ifc";

            // prepare storage
            ProjectsApi projectApi = new ProjectsApi();

            projectApi.Configuration.AccessToken = Credentials.TokenInternal;
            StorageRelationshipsTargetData       storageRelData = new StorageRelationshipsTargetData(StorageRelationshipsTargetData.TypeEnum.Folders, folderId);
            CreateStorageDataRelationshipsTarget storageTarget  = new CreateStorageDataRelationshipsTarget(storageRelData);
            CreateStorageDataRelationships       storageRel     = new CreateStorageDataRelationships(storageTarget);
            BaseAttributesExtensionObject        attributes     = new BaseAttributesExtensionObject(string.Empty, string.Empty, new JsonApiLink(string.Empty), null);
            //mb CreateStorageDataAttributes storageAtt = new CreateStorageDataAttributes(input.fileToUpload.FileName, attributes);
            CreateStorageDataAttributes storageAtt  = new CreateStorageDataAttributes(fileName, attributes);
            CreateStorageData           storageData = new CreateStorageData(CreateStorageData.TypeEnum.Objects, storageAtt, storageRel);
            CreateStorage storage        = new CreateStorage(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), storageData);
            dynamic       storageCreated = await projectApi.PostStorageAsync(projectId, storage);

            string[] storageIdParams = ((string)storageCreated.data.id).Split('/');
            string[] bucketKeyParams = storageIdParams[storageIdParams.Length - 2].Split(':');
            string   bucketKey       = bucketKeyParams[bucketKeyParams.Length - 1];
            string   objectName      = storageIdParams[storageIdParams.Length - 1];

            // upload the file/object, which will create a new object
            ObjectsApi objects = new ObjectsApi();

            objects.Configuration.AccessToken = Credentials.TokenInternal;

            // get file size
            //mb long fileSize = (new FileInfo(fileSavePath)).Length;
            long fileSize = 10;

            // decide if upload direct or resumable (by chunks)
            if (fileSize > UPLOAD_CHUNK_SIZE * 1024 * 1024) // upload in chunks
            {
                /*mb long chunkSize = 2 * 1024 * 1024; // 2 Mb
                 * long numberOfChunks = (long)Math.Round((double)(fileSize / chunkSize)) + 1;
                 *
                 * long start = 0;
                 * chunkSize = (numberOfChunks > 1 ? chunkSize : fileSize);
                 * long end = chunkSize;
                 * string sessionId = Guid.NewGuid().ToString();
                 *
                 * // upload one chunk at a time
                 * using (BinaryReader reader = new BinaryReader(new FileStream(fileSavePath, FileMode.Open)))
                 * {
                 *  for (int chunkIndex = 0; chunkIndex < numberOfChunks; chunkIndex++)
                 *  {
                 *      string range = string.Format("bytes {0}-{1}/{2}", start, end, fileSize);
                 *
                 *      long numberOfBytes = chunkSize + 1;
                 *      byte[] fileBytes = new byte[numberOfBytes];
                 *      MemoryStream memoryStream = new MemoryStream(fileBytes);
                 *      reader.BaseStream.Seek((int)start, SeekOrigin.Begin);
                 *      int count = reader.Read(fileBytes, 0, (int)numberOfBytes);
                 *      memoryStream.Write(fileBytes, 0, (int)numberOfBytes);
                 *      memoryStream.Position = 0;
                 *
                 *      await objects.UploadChunkAsync(bucketKey, objectName, (int)numberOfBytes, range, sessionId, memoryStream);
                 *
                 *      start = end + 1;
                 *      chunkSize = ((start + chunkSize > fileSize) ? fileSize - start - 1 : chunkSize);
                 *      end = start + chunkSize;
                 *  }
                 * } mb*/
            }
            else // upload in a single call
            {
                /*mb using (StreamReader streamReader = new StreamReader(fileSavePath))
                 * {
                 *   await objects.UploadObjectAsync(bucketKey, objectName, (int)streamReader.BaseStream.Length, streamReader.BaseStream, "application/octet-stream");
                 * } mb*/
                await objects.UploadObjectAsync(bucketKey, objectName, (int)input.Length, input, "application/octet-stream");
            }

            // cleanup

            /*mb string fileName = input.fileToUpload.FileName;
             * System.IO.File.Delete(fileSavePath); mb*/

            // check if file already exists...
            FoldersApi folderApi = new FoldersApi();

            folderApi.Configuration.AccessToken = Credentials.TokenInternal;
            var filesInFolder = await folderApi.GetFolderContentsAsync(projectId, folderId);

            string itemId = string.Empty;

            foreach (KeyValuePair <string, dynamic> item in new DynamicDictionaryItems(filesInFolder.data))
            {
                if (item.Value.attributes.displayName == fileName)
                {
                    itemId = item.Value.id; // this means a file with same name is already there, so we'll create a new version
                }
            }
            // now decide whether create a new item or new version
            if (string.IsNullOrWhiteSpace(itemId))
            {
                // create a new item
                BaseAttributesExtensionObject        baseAttribute                   = new BaseAttributesExtensionObject(projectId.StartsWith("a.") ? "items:autodesk.core:File" : "items:autodesk.bim360:File", "1.0");
                CreateItemDataAttributes             createItemAttributes            = new CreateItemDataAttributes(fileName, baseAttribute);
                CreateItemDataRelationshipsTipData   createItemRelationshipsTipData  = new CreateItemDataRelationshipsTipData(CreateItemDataRelationshipsTipData.TypeEnum.Versions, CreateItemDataRelationshipsTipData.IdEnum._1);
                CreateItemDataRelationshipsTip       createItemRelationshipsTip      = new CreateItemDataRelationshipsTip(createItemRelationshipsTipData);
                StorageRelationshipsTargetData       storageTargetData               = new StorageRelationshipsTargetData(StorageRelationshipsTargetData.TypeEnum.Folders, folderId);
                CreateStorageDataRelationshipsTarget createStorageRelationshipTarget = new CreateStorageDataRelationshipsTarget(storageTargetData);
                CreateItemDataRelationships          createItemDataRelationhips      = new CreateItemDataRelationships(createItemRelationshipsTip, createStorageRelationshipTarget);
                CreateItemData createItemData = new CreateItemData(CreateItemData.TypeEnum.Items, createItemAttributes, createItemDataRelationhips);
                BaseAttributesExtensionObject      baseAttExtensionObj = new BaseAttributesExtensionObject(projectId.StartsWith("a.") ? "versions:autodesk.core:File" : "versions:autodesk.bim360:File", "1.0");
                CreateStorageDataAttributes        storageDataAtt      = new CreateStorageDataAttributes(fileName, baseAttExtensionObj);
                CreateItemRelationshipsStorageData createItemRelationshipsStorageData = new CreateItemRelationshipsStorageData(CreateItemRelationshipsStorageData.TypeEnum.Objects, storageCreated.data.id);
                CreateItemRelationshipsStorage     createItemRelationshipsStorage     = new CreateItemRelationshipsStorage(createItemRelationshipsStorageData);
                CreateItemRelationships            createItemRelationship             = new CreateItemRelationships(createItemRelationshipsStorage);
                CreateItemIncluded includedVersion = new CreateItemIncluded(CreateItemIncluded.TypeEnum.Versions, CreateItemIncluded.IdEnum._1, storageDataAtt, createItemRelationship);
                CreateItem         createItem      = new CreateItem(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), createItemData, new List <CreateItemIncluded>()
                {
                    includedVersion
                });

                ItemsApi itemsApi = new ItemsApi();
                itemsApi.Configuration.AccessToken = Credentials.TokenInternal;
                var newItem = await itemsApi.PostItemAsync(projectId, createItem);

                return(newItem);
            }
            else
            {
                // create a new version
                BaseAttributesExtensionObject          attExtensionObj              = new BaseAttributesExtensionObject(projectId.StartsWith("a.") ? "versions:autodesk.core:File" : "versions:autodesk.bim360:File", "1.0");
                CreateStorageDataAttributes            storageDataAtt               = new CreateStorageDataAttributes(fileName, attExtensionObj);
                CreateVersionDataRelationshipsItemData dataRelationshipsItemData    = new CreateVersionDataRelationshipsItemData(CreateVersionDataRelationshipsItemData.TypeEnum.Items, itemId);
                CreateVersionDataRelationshipsItem     dataRelationshipsItem        = new CreateVersionDataRelationshipsItem(dataRelationshipsItemData);
                CreateItemRelationshipsStorageData     itemRelationshipsStorageData = new CreateItemRelationshipsStorageData(CreateItemRelationshipsStorageData.TypeEnum.Objects, storageCreated.data.id);
                CreateItemRelationshipsStorage         itemRelationshipsStorage     = new CreateItemRelationshipsStorage(itemRelationshipsStorageData);
                CreateVersionDataRelationships         dataRelationships            = new CreateVersionDataRelationships(dataRelationshipsItem, itemRelationshipsStorage);
                CreateVersionData versionData    = new CreateVersionData(CreateVersionData.TypeEnum.Versions, storageDataAtt, dataRelationships);
                CreateVersion     newVersionData = new CreateVersion(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), versionData);

                VersionsApi versionsApis = new VersionsApi();
                versionsApis.Configuration.AccessToken = Credentials.TokenInternal;
                dynamic newVersion = await versionsApis.PostVersionAsync(projectId, newVersionData);

                return(newVersion);
            }
        }
예제 #16
0
            public static async Task UploadAsync()
            {
                ProjectsApi projectsApi = new ProjectsApi();

                StorageRelationshipsTargetData       storageRelData = new StorageRelationshipsTargetData(StorageRelationshipsTargetData.TypeEnum.Folders, "urn:adsk.wipprod:fs.folder:co.OoAFTIjQTdCEF2HJUjee0g");
                CreateStorageDataRelationshipsTarget storageTarget  = new CreateStorageDataRelationshipsTarget(storageRelData);
                CreateStorageDataRelationships       storageRel     = new CreateStorageDataRelationships(storageTarget);
                BaseAttributesExtensionObject        attributes     = new BaseAttributesExtensionObject(string.Empty, string.Empty, new JsonApiLink(string.Empty), null);
                CreateStorageDataAttributes          storageAtt     = new CreateStorageDataAttributes("test", attributes);
                CreateStorageData storageData    = new CreateStorageData(CreateStorageData.TypeEnum.Objects, storageAtt, storageRel);
                CreateStorage     storage        = new CreateStorage(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), storageData);
                dynamic           storageCreated = await projectsApi.PostStorageAsync("3b5c6352-cf34-41fd-a0e9-a5246d93bf55", storage);

                string[] storageIdParams = ((string)storageCreated.data.id).Split('/');
                string[] bucketKeyParams = storageIdParams[storageIdParams.Length - 2].Split(':');
                string   bucketKey       = bucketKeyParams[bucketKeyParams.Length - 1];
                string   objectName      = storageIdParams[storageIdParams.Length - 1];

                ObjectsApi objects = new ObjectsApi();

                objects.Configuration.AccessToken = token;

                long fileSize = (new FileInfo(@"C:\Users\joao.martins\Desktop\ESGOTO_R2.rvt")).Length;

                if (fileSize > 5 * 1024 * 1024)            // upload in chunks if > 5Mb
                {
                    long chunkSize      = 2 * 1024 * 1024; // 2 Mb
                    long numberOfChunks = (long)Math.Round((double)(fileSize / chunkSize)) + 1;

                    long start = 0;
                    chunkSize = (numberOfChunks > 1 ? chunkSize : fileSize);
                    long   end       = chunkSize;
                    string sessionId = Guid.NewGuid().ToString();

                    // upload one chunk at a time
                    using (BinaryReader reader = new BinaryReader(new FileStream(@"C:\Users\joao.martins\Desktop\ESGOTO_R2.rvt", FileMode.Open)))
                    {
                        for (int chunkIndex = 0; chunkIndex < numberOfChunks; chunkIndex++)
                        {
                            string range = string.Format("bytes {0}-{1}/{2}", start, end, fileSize);

                            long         numberOfBytes = chunkSize + 1;
                            byte[]       fileBytes     = new byte[numberOfBytes];
                            MemoryStream memoryStream  = new MemoryStream(fileBytes);
                            reader.BaseStream.Seek((int)start, SeekOrigin.Begin);
                            int count = reader.Read(fileBytes, 0, (int)numberOfBytes);
                            memoryStream.Write(fileBytes, 0, (int)numberOfBytes);
                            memoryStream.Position = 0;

                            await objects.UploadChunkAsync(bucketKey, objectName, (int)numberOfBytes, range, sessionId, memoryStream);

                            start     = end + 1;
                            chunkSize = ((start + chunkSize > fileSize) ? fileSize - start - 1 : chunkSize);
                            end       = start + chunkSize;
                        }
                    }
                }
                else // upload in a single call
                {
                    using (StreamReader streamReader = new StreamReader(@"C:\Users\joao.martins\Desktop\ESGOTO_R2.rvt"))
                    {
                        await objects.UploadObjectAsync(bucketKey, objectName, (int)streamReader.BaseStream.Length, streamReader.BaseStream, "application/octet-stream");
                    }
                }

                // check if file already exists...
                FoldersApi folderApi = new FoldersApi();

                folderApi.Configuration.AccessToken = token;
                var filesInFolder = await folderApi.GetFolderContentsAsync("3b5c6352-cf34-41fd-a0e9-a5246d93bf55", "urn:adsk.wipprod:fs.folder:co.OoAFTIjQTdCEF2HJUjee0g");

                string itemId = string.Empty;

                foreach (KeyValuePair <string, dynamic> item in new DynamicDictionaryItems(filesInFolder.data))
                {
                    if (item.Value.attributes.displayName == "test")
                    {
                        itemId = item.Value.id; // this means a file with same name is already there, so we'll create a new version
                    }
                }
                // now decide whether create a new item or new version
                if (string.IsNullOrWhiteSpace(itemId))
                {
                    // create a new item
                    BaseAttributesExtensionObject        baseAttribute                   = new BaseAttributesExtensionObject("3b5c6352-cf34-41fd-a0e9-a5246d93bf55".StartsWith("a.") ? "items:autodesk.core:File" : "items:autodesk.bim360:File", "1.0");
                    CreateItemDataAttributes             createItemAttributes            = new CreateItemDataAttributes("test", baseAttribute);
                    CreateItemDataRelationshipsTipData   createItemRelationshipsTipData  = new CreateItemDataRelationshipsTipData(CreateItemDataRelationshipsTipData.TypeEnum.Versions, CreateItemDataRelationshipsTipData.IdEnum._1);
                    CreateItemDataRelationshipsTip       createItemRelationshipsTip      = new CreateItemDataRelationshipsTip(createItemRelationshipsTipData);
                    StorageRelationshipsTargetData       storageTargetData               = new StorageRelationshipsTargetData(StorageRelationshipsTargetData.TypeEnum.Folders, "urn:adsk.wipprod:fs.folder:co.OoAFTIjQTdCEF2HJUjee0g");
                    CreateStorageDataRelationshipsTarget createStorageRelationshipTarget = new CreateStorageDataRelationshipsTarget(storageTargetData);
                    CreateItemDataRelationships          createItemDataRelationhips      = new CreateItemDataRelationships(createItemRelationshipsTip, createStorageRelationshipTarget);
                    CreateItemData createItemData = new CreateItemData(CreateItemData.TypeEnum.Items, createItemAttributes, createItemDataRelationhips);
                    BaseAttributesExtensionObject      baseAttExtensionObj = new BaseAttributesExtensionObject("3b5c6352-cf34-41fd-a0e9-a5246d93bf55".StartsWith("a.") ? "versions:autodesk.core:File" : "versions:autodesk.bim360:File", "1.0");
                    CreateStorageDataAttributes        storageDataAtt      = new CreateStorageDataAttributes("test", baseAttExtensionObj);
                    CreateItemRelationshipsStorageData createItemRelationshipsStorageData = new CreateItemRelationshipsStorageData(CreateItemRelationshipsStorageData.TypeEnum.Objects, storageCreated.data.id);
                    CreateItemRelationshipsStorage     createItemRelationshipsStorage     = new CreateItemRelationshipsStorage(createItemRelationshipsStorageData);
                    CreateItemRelationships            createItemRelationship             = new CreateItemRelationships(createItemRelationshipsStorage);
                    CreateItemIncluded includedVersion = new CreateItemIncluded(CreateItemIncluded.TypeEnum.Versions, CreateItemIncluded.IdEnum._1, storageDataAtt, createItemRelationship);
                    CreateItem         createItem      = new CreateItem(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), createItemData, new List <CreateItemIncluded>()
                    {
                        includedVersion
                    });

                    ItemsApi itemsApi = new ItemsApi();
                    itemsApi.Configuration.AccessToken = token;
                    var newItem = await itemsApi.PostItemAsync("3b5c6352-cf34-41fd-a0e9-a5246d93bf55", createItem);
                }
                else
                {
                    // create a new version
                    BaseAttributesExtensionObject          attExtensionObj              = new BaseAttributesExtensionObject("3b5c6352-cf34-41fd-a0e9-a5246d93bf55".StartsWith("a.") ? "versions:autodesk.core:File" : "versions:autodesk.bim360:File", "1.0");
                    CreateStorageDataAttributes            storageDataAtt               = new CreateStorageDataAttributes("test", attExtensionObj);
                    CreateVersionDataRelationshipsItemData dataRelationshipsItemData    = new CreateVersionDataRelationshipsItemData(CreateVersionDataRelationshipsItemData.TypeEnum.Items, itemId);
                    CreateVersionDataRelationshipsItem     dataRelationshipsItem        = new CreateVersionDataRelationshipsItem(dataRelationshipsItemData);
                    CreateItemRelationshipsStorageData     itemRelationshipsStorageData = new CreateItemRelationshipsStorageData(CreateItemRelationshipsStorageData.TypeEnum.Objects, storageCreated.data.id);
                    CreateItemRelationshipsStorage         itemRelationshipsStorage     = new CreateItemRelationshipsStorage(itemRelationshipsStorageData);
                    CreateVersionDataRelationships         dataRelationships            = new CreateVersionDataRelationships(dataRelationshipsItem, itemRelationshipsStorage);
                    CreateVersionData versionData    = new CreateVersionData(CreateVersionData.TypeEnum.Versions, storageDataAtt, dataRelationships);
                    CreateVersion     newVersionData = new CreateVersion(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), versionData);

                    VersionsApi versionsApis = new VersionsApi();
                    versionsApis.Configuration.AccessToken = token;
                    dynamic newVersion = await versionsApis.PostVersionAsync("3b5c6352-cf34-41fd-a0e9-a5246d93bf55", newVersionData);
                }
            }
 public ProjectItemTemplateFixedNameDelegate(String typeName, String imageName, String group, CreateItem createItemCallback)
 {
     this.TypeName           = typeName;
     this.ImageName          = imageName;
     this.Group              = group;
     this.createItemCallback = createItemCallback;
 }
예제 #18
0
        public async Task <IActionResult> SubmitProject([FromForm] InputSubmit input)
        {
            string projectId = "b.014c6054-6da1-4ed8-b199-1975c07f608a";
            string folderId  = "urn:adsk.wipprod:fs.folder:co.1X3m8NAlRL-xNDQsXk_bxQ";

            Credentials credentials = await Credentials.FromDatabaseAsync(Utils.GetAppSetting("USERID"));

            dynamic token2lo = await OAuthController2L.GetInternalAsync();

            var fileSavePath = Path.Combine(_env.ContentRootPath, input.fileToUpload.FileName);

            using (var stream = new FileStream(fileSavePath, FileMode.Create))
                await input.fileToUpload.CopyToAsync(stream);

            // prepare storage
            ProjectsApi projectApi = new ProjectsApi();

            projectApi.Configuration.AccessToken = credentials.TokenInternal;
            StorageRelationshipsTargetData       storageRelData = new StorageRelationshipsTargetData(StorageRelationshipsTargetData.TypeEnum.Folders, folderId);
            CreateStorageDataRelationshipsTarget storageTarget  = new CreateStorageDataRelationshipsTarget(storageRelData);
            CreateStorageDataRelationships       storageRel     = new CreateStorageDataRelationships(storageTarget);
            BaseAttributesExtensionObject        attributes     = new BaseAttributesExtensionObject(string.Empty, string.Empty, new JsonApiLink(string.Empty), null);
            CreateStorageDataAttributes          storageAtt     = new CreateStorageDataAttributes(input.fileToUpload.FileName, attributes);
            CreateStorageData storageData    = new CreateStorageData(CreateStorageData.TypeEnum.Objects, storageAtt, storageRel);
            CreateStorage     storage        = new CreateStorage(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), storageData);
            dynamic           storageCreated = await projectApi.PostStorageAsync(projectId, storage);

            string[] storageIdParams = ((string)storageCreated.data.id).Split('/');
            string[] bucketKeyParams = storageIdParams[storageIdParams.Length - 2].Split(':');
            string   bucketKey       = bucketKeyParams[bucketKeyParams.Length - 1];
            string   objectName      = storageIdParams[storageIdParams.Length - 1];

            // upload the file/object, which will create a new object
            ObjectsApi objects = new ObjectsApi();

            objects.Configuration.AccessToken = credentials.TokenInternal;

            // get file size
            long fileSize = (new FileInfo(fileSavePath)).Length;

            // decide if upload direct or resumable (by chunks)
            if (fileSize > UPLOAD_CHUNK_SIZE * 1024 * 1024) // upload in chunks
            {
                long chunkSize      = 2 * 1024 * 1024;      // 2 Mb
                long numberOfChunks = (long)Math.Round((double)(fileSize / chunkSize)) + 1;

                long start = 0;
                chunkSize = (numberOfChunks > 1 ? chunkSize : fileSize);
                long   end       = chunkSize;
                string sessionId = Guid.NewGuid().ToString();

                // upload one chunk at a time
                using (BinaryReader reader = new BinaryReader(new FileStream(fileSavePath, FileMode.Open)))
                {
                    for (int chunkIndex = 0; chunkIndex < numberOfChunks; chunkIndex++)
                    {
                        string range = string.Format("bytes {0}-{1}/{2}", start, end, fileSize);

                        long         numberOfBytes = chunkSize + 1;
                        byte[]       fileBytes     = new byte[numberOfBytes];
                        MemoryStream memoryStream  = new MemoryStream(fileBytes);
                        reader.BaseStream.Seek((int)start, SeekOrigin.Begin);
                        int count = reader.Read(fileBytes, 0, (int)numberOfBytes);
                        memoryStream.Write(fileBytes, 0, (int)numberOfBytes);
                        memoryStream.Position = 0;

                        await objects.UploadChunkAsync(bucketKey, objectName, (int)numberOfBytes, range, sessionId, memoryStream);

                        start     = end + 1;
                        chunkSize = ((start + chunkSize > fileSize) ? fileSize - start - 1 : chunkSize);
                        end       = start + chunkSize;
                    }
                }
            }
            else // upload in a single call
            {
                using (StreamReader streamReader = new StreamReader(fileSavePath))
                {
                    await objects.UploadObjectAsync(bucketKey, objectName, (int)streamReader.BaseStream.Length, streamReader.BaseStream, "application/octet-stream");
                }
            }

            // cleanup
            string fileName = input.fileToUpload.FileName;

            System.IO.File.Delete(fileSavePath);

            // check if file already exists...
            FoldersApi folderApi = new FoldersApi();

            folderApi.Configuration.AccessToken = credentials.TokenInternal;
            var filesInFolder = await folderApi.GetFolderContentsAsync(projectId, folderId);

            string itemId = string.Empty;

            foreach (KeyValuePair <string, dynamic> item in new DynamicDictionaryItems(filesInFolder.data))
            {
                if (item.Value.attributes.displayName == fileName)
                {
                    itemId = item.Value.id; // this means a file with same name is already there, so we'll create a new version
                }
            }
            // now decide whether create a new item or new version
            if (string.IsNullOrWhiteSpace(itemId))
            {
                // create a new item
                BaseAttributesExtensionObject        baseAttribute                   = new BaseAttributesExtensionObject(projectId.StartsWith("a.") ? "items:autodesk.core:File" : "items:autodesk.bim360:File", "1.0");
                CreateItemDataAttributes             createItemAttributes            = new CreateItemDataAttributes(fileName, baseAttribute);
                CreateItemDataRelationshipsTipData   createItemRelationshipsTipData  = new CreateItemDataRelationshipsTipData(CreateItemDataRelationshipsTipData.TypeEnum.Versions, CreateItemDataRelationshipsTipData.IdEnum._1);
                CreateItemDataRelationshipsTip       createItemRelationshipsTip      = new CreateItemDataRelationshipsTip(createItemRelationshipsTipData);
                StorageRelationshipsTargetData       storageTargetData               = new StorageRelationshipsTargetData(StorageRelationshipsTargetData.TypeEnum.Folders, folderId);
                CreateStorageDataRelationshipsTarget createStorageRelationshipTarget = new CreateStorageDataRelationshipsTarget(storageTargetData);
                CreateItemDataRelationships          createItemDataRelationhips      = new CreateItemDataRelationships(createItemRelationshipsTip, createStorageRelationshipTarget);
                CreateItemData createItemData = new CreateItemData(CreateItemData.TypeEnum.Items, createItemAttributes, createItemDataRelationhips);
                BaseAttributesExtensionObject      baseAttExtensionObj = new BaseAttributesExtensionObject(projectId.StartsWith("a.") ? "versions:autodesk.core:File" : "versions:autodesk.bim360:File", "1.0");
                CreateStorageDataAttributes        storageDataAtt      = new CreateStorageDataAttributes(fileName, baseAttExtensionObj);
                CreateItemRelationshipsStorageData createItemRelationshipsStorageData = new CreateItemRelationshipsStorageData(CreateItemRelationshipsStorageData.TypeEnum.Objects, storageCreated.data.id);
                CreateItemRelationshipsStorage     createItemRelationshipsStorage     = new CreateItemRelationshipsStorage(createItemRelationshipsStorageData);
                CreateItemRelationships            createItemRelationship             = new CreateItemRelationships(createItemRelationshipsStorage);
                CreateItemIncluded includedVersion = new CreateItemIncluded(CreateItemIncluded.TypeEnum.Versions, CreateItemIncluded.IdEnum._1, storageDataAtt, createItemRelationship);
                CreateItem         createItem      = new CreateItem(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), createItemData, new List <CreateItemIncluded>()
                {
                    includedVersion
                });

                ItemsApi itemsApi = new ItemsApi();
                itemsApi.Configuration.AccessToken = credentials.TokenInternal;
                var newItem = await itemsApi.PostItemAsync(projectId, createItem);

                itemId = newItem.data.id;
            }
            else
            {
                // create a new version
                BaseAttributesExtensionObject          attExtensionObj              = new BaseAttributesExtensionObject(projectId.StartsWith("a.") ? "versions:autodesk.core:File" : "versions:autodesk.bim360:File", "1.0");
                CreateStorageDataAttributes            storageDataAtt               = new CreateStorageDataAttributes(fileName, attExtensionObj);
                CreateVersionDataRelationshipsItemData dataRelationshipsItemData    = new CreateVersionDataRelationshipsItemData(CreateVersionDataRelationshipsItemData.TypeEnum.Items, itemId);
                CreateVersionDataRelationshipsItem     dataRelationshipsItem        = new CreateVersionDataRelationshipsItem(dataRelationshipsItemData);
                CreateItemRelationshipsStorageData     itemRelationshipsStorageData = new CreateItemRelationshipsStorageData(CreateItemRelationshipsStorageData.TypeEnum.Objects, storageCreated.data.id);
                CreateItemRelationshipsStorage         itemRelationshipsStorage     = new CreateItemRelationshipsStorage(itemRelationshipsStorageData);
                CreateVersionDataRelationships         dataRelationships            = new CreateVersionDataRelationships(dataRelationshipsItem, itemRelationshipsStorage);
                CreateVersionData versionData    = new CreateVersionData(CreateVersionData.TypeEnum.Versions, storageDataAtt, dataRelationships);
                CreateVersion     newVersionData = new CreateVersion(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), versionData);

                VersionsApi versionsApis = new VersionsApi();
                versionsApis.Configuration.AccessToken = credentials.TokenInternal;
                dynamic newVersion = await versionsApis.PostVersionAsync(projectId, newVersionData);
            }

            await NotificationDB.Register(itemId, input.phoneNumber);

            return(Ok());
        }
예제 #19
0
        public async Task <IActionResult> Post([FromBody] CreateItem command)
        {
            await _itemService.CreateItems(ObjectId.GenerateNewId(), command.Title, command.Link, command.Description, command.PubDate);

            return(Created("/link", null));
        }
예제 #20
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        EditorGUILayout.BeginHorizontal();

        if (createItem == null)
        {
            createItem = (CreateItem)EditorGUILayout.ObjectField("Create Item", createItem, typeof(CreateItem), true);
        }

        if (createItem != null)
        {
            if (createItem.ShowMe)
            {
                GUILayout.Label("SHOWING");

            }else
            {
                GUILayout.Label("HIDING");

            }
        }
        EditorGUILayout.EndHorizontal();

        CreateItem createItemScript = (CreateItem)target;
        Item item = new Item();

        GUILayout.Box(message);
        if (itemSort == ItemSort.Weapon)
        {
            if (GUILayout.Button("Switch to Create Armor"))
            {
                itemSort = ItemSort.Armor;
            }

            GUILayout.Label("Weapon Name");
            weaponName = GUILayout.TextField(weaponName);

            GUILayout.Label("Physical Damage");
            physicalDamage = EditorGUILayout.IntField(physicalDamage);

            GUILayout.Label("Magical Damage");
            magicalDamage = EditorGUILayout.IntField(magicalDamage);

            GUILayout.Label("Weapon Attack Speed = " + attackSpeed.ToString("F2"));
            attackSpeed = GUILayout.HorizontalSlider(attackSpeed, 0.5f, 1.5f);
            //attackSpeed = GUILayout.TextField(attackSpeed);
            //attackSpeed = Regex.Replace(attackSpeed, "[^0-9]", "");

            GUILayout.Label("Weapon Requirement Level");
            itemLevel = EditorGUILayout.IntField(itemLevel);

            GUILayout.Label("Buy Value");
            buyValue = EditorGUILayout.IntField(buyValue);

            if (GUILayout.Button("Selected Element : " + itemElement))
                openElements = openElements == false ? true : false;

            if (openElements)
            {
                if (GUILayout.Button("Element : Normal"))
                    itemElement = Item.ItemElement.Normal;
                if (GUILayout.Button("Element : Dark"))
                    itemElement = Item.ItemElement.Dark;
                if (GUILayout.Button("Element : Earth"))
                    itemElement = Item.ItemElement.Earth;
                if (GUILayout.Button("Element : Fire"))
                    itemElement = Item.ItemElement.Fire;
                if (GUILayout.Button("Element : Frost"))
                    itemElement = Item.ItemElement.Frost;
                if (GUILayout.Button("Element : Light"))
                    itemElement = Item.ItemElement.Light;
                if (GUILayout.Button("Element : Lightning"))
                    itemElement = Item.ItemElement.Lightning;
                if (GUILayout.Button("Element : Poison"))
                    itemElement = Item.ItemElement.Poison;
                if (GUILayout.Button("Element : Silver"))
                    itemElement = Item.ItemElement.Silver;
                if (GUILayout.Button("Element : Water"))
                    itemElement = Item.ItemElement.Water;
            }
            if (GUILayout.Button("Create Weapon"))
            {
                if (weaponName != "" && (physicalDamage != 0 || magicalDamage != 0) && itemLevel != 0)
                {
                    item.getItemName = weaponName;
                    item.getItemAttackSpeed = Mathf.Floor(attackSpeed * 100) / 100;
                    item.getItemLevel = itemLevel;
                    item.getItemPhysicalDamage = physicalDamage;
                    item.getItemMagicalDamage = magicalDamage;
                    item.getItemBuyValue = buyValue;
                    item.getItemSellValue = buyValue / 4;
                    item.getItemElement = itemElement;
                    item.itemClass = Item.ItemClass.Weapon;
                    item.getItemEquipAble = true;

                    weaponName = "";
                    attackSpeed = 1f;
                    itemLevel = 0;
                    physicalDamage = 0;
                    magicalDamage = 0;
                    buyValue = 0;
                    itemElement = Item.ItemElement.Normal;

                    createItemScript.CreateNewWeapons(item);
                    message = "";
                }else
                    message = "Fill in all the fields!";
            }
        }else if (itemSort == ItemSort.Armor)
        {
            if (GUILayout.Button("Switch to Create Weapon"))
            {
                itemSort = ItemSort.Weapon;
            }
            if (GUILayout.Button("BAG"))
                Debug.Log("SUP");
        }
    }
예제 #21
0
        public static void UpdateWorld()
        {
            var worldStats = DomainRegistry.Repository.FindSingle(new GetWorld());

            var turnNo = worldStats.TurnNumber;

            PvPStatics.LastGameTurn = turnNo;

            if (turnNo < PvPStatics.RoundDuration)
            {
                PvPStatics.AnimateUpdateInProgress = true;

                IServerLogRepository serverLogRepo = new EFServerLogRepository();
                var log = new ServerLog
                {
                    TurnNumber      = turnNo,
                    StartTimestamp  = DateTime.UtcNow,
                    FinishTimestamp = DateTime.UtcNow,
                    Errors          = 0,
                    FullLog         = "",
                    Population      = PlayerProcedures.GetWorldPlayerStats().CurrentOnlinePlayers,
                };
                log.AddLog($"Started new log for turn {turnNo} at <b>{DateTime.UtcNow}</b>.");
                serverLogRepo.SaveServerLog(log);
                var updateTimer = new Stopwatch();
                updateTimer.Start();

                IPlayerRepository playerRepo = new EFPlayerRepository();

                Player lindella = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.LindellaBotId);
                Player wuffie   = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.WuffieBotId);

                #region spawn NPCS
                // make sure the NPCs have been spawned early turn
                if (turnNo <= 3)
                {
                    if (lindella == null)
                    {
                        BossProcedures_Lindella.SpawnLindella();
                        lindella = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.LindellaBotId);
                    }

                    if (wuffie == null)
                    {
                        BossProcedures_PetMerchant.SpawnPetMerchant();
                        wuffie = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.WuffieBotId);
                    }

                    var fae = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.JewdewfaeBotId);
                    if (fae == null)
                    {
                        BossProcedures_Jewdewfae.SpawnFae();
                    }

                    var bartender = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.BartenderBotId);
                    if (bartender == null)
                    {
                        BossProcedures_Bartender.SpawnBartender();
                    }

                    var lorekeeper = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.LoremasterBotId);
                    if (lorekeeper == null)
                    {
                        BossProcedures_Loremaster.SpawnLoremaster();
                    }

                    var soulbinder = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.SoulbinderBotId);
                    if (soulbinder == null)
                    {
                        var id = DomainRegistry.Repository.Execute(new CreatePlayer
                        {
                            FirstName               = "Karin",
                            LastName                = "Kezesul-Adriz the Soulbinder",
                            FormSourceId            = 1000,
                            Location                = "stripclub_office",
                            Level                   = 10,
                            Mobility                = PvPStatics.MobilityFull,
                            Money                   = 0,
                            Gender                  = PvPStatics.GenderFemale,
                            Health                  = 9999,
                            MaxHealth               = 9999,
                            Mana                    = 9999,
                            MaxMana                 = 9999,
                            OnlineActivityTimestamp = DateTime.UtcNow,
                            BotId                   = AIStatics.SoulbinderBotId
                        });

                        var newSoulbinder = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                        newSoulbinder.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newSoulbinder));
                        playerRepo.SavePlayer(newSoulbinder);
                    }
                }
                #endregion

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started loading animate players");

                IEffectRepository effectRepo = new EFEffectRepository();

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started loading effects");
                var temporaryEffects = effectRepo.Effects.Where(e => !e.IsPermanent).ToList();
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished loading effects");
                var effectsToDelete = new List <Effect>();

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started updating effects");
                var effectsExpiringThisTurn = temporaryEffects.Where(e => e.Duration == 1).ToList();
                var activeOrExpiringEffects = temporaryEffects.Where(e => e.Duration > 0).ToList();

                foreach (var e in temporaryEffects)
                {
                    e.Duration--;
                    e.Cooldown--;

                    if (e.Duration < 0)
                    {
                        e.Duration = 0;
                    }

                    if (e.Cooldown <= 0)
                    {
                        effectsToDelete.Add(e);
                    }
                    else
                    {
                        effectRepo.SaveEffect(e);
                    }
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished updating effects");
                serverLogRepo.SaveServerLog(log);

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started running effect-expiry actions");
                try
                {
                    JokeShopProcedures.RunEffectExpiryActions(effectsExpiringThisTurn);
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, " ERROR running effect-expiry actions", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished running effect-expiry actions");
                serverLogRepo.SaveServerLog(log);

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started deleting expired effects");
                foreach (var e in effectsToDelete)
                {
                    effectRepo.DeleteEffect(e.Id);
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished deleting expired effects");
                serverLogRepo.SaveServerLog(log);

                #region playerExtra / protection cooldown loop
                IPlayerExtraRepository playerExtraRepo = new EFPlayerExtraRepository();
                var extrasToIncrement            = playerExtraRepo.PlayerExtras.ToList();
                var extrasToIncrement_SaveList   = new List <PlayerExtra>();
                var extrasToIncrement_DeleteList = new List <PlayerExtra>();
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started updating protection change cooldown (" + extrasToIncrement.Count + ")");

                foreach (var e in extrasToIncrement)
                {
                    var owner = PlayerProcedures.GetPlayer(e.PlayerId);
                    if (PlayerProcedures.PlayerIsOffline(owner))
                    {
                        extrasToIncrement_SaveList.Add(e);
                    }
                }

                foreach (var e in extrasToIncrement_SaveList)
                {
                    if (e.ProtectionToggleTurnsRemaining > 0)
                    {
                        e.ProtectionToggleTurnsRemaining--;
                        playerExtraRepo.SavePlayerExtra(e);
                    }
                    else if (e.ProtectionToggleTurnsRemaining <= 0)
                    {
                        extrasToIncrement_DeleteList.Add(e);
                    }
                }

                foreach (var e in extrasToIncrement_DeleteList)
                {
                    playerExtraRepo.DeletePlayerExtra(e.Id);
                }

                #endregion

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished updating protection change cooldown.");


                #region main player loop

                using (var context = new StatsContext())
                {
                    try
                    {
                        context.Database.ExecuteSqlCommand("UPDATE [dbo].[Players] SET TimesAttackingThisUpdate = 0, CleansesMeditatesThisRound = 0, ShoutsRemaining = 1, ActionPoints = ActionPoints + 10, ItemsUsedThisTurn = 0 WHERE Mobility='full'" +

                                                           $"UPDATE [dbo].[Players] SET ActionPoints_Refill = ActionPoints_Refill + (ActionPoints % {TurnTimesStatics.GetActionPointLimit()} / 2) WHERE ActionPoints >= {TurnTimesStatics.GetActionPointLimit()} AND Mobility='full'" +

                                                           $"UPDATE [dbo].[Players] SET ActionPoints = {TurnTimesStatics.GetActionPointLimit()} WHERE ActionPoints > {TurnTimesStatics.GetActionPointLimit()} AND Mobility='full'" +

                                                           $"UPDATE [dbo].[Players] SET ActionPoints_Refill = {TurnTimesStatics.GetActionPointReserveLimit()} WHERE ActionPoints_Refill > {TurnTimesStatics.GetActionPointReserveLimit()} AND Mobility='full'" +

                                                           $"UPDATE [dbo].[Players] SET ActionPoints = ActionPoints + 20, ActionPoints_Refill = ActionPoints_Refill - 20 WHERE ActionPoints <= {TurnTimesStatics.GetActionPointLimit()-20} AND ActionPoints_Refill >= 20 AND Mobility='full'");

                        if (PvPStatics.ChaosMode)
                        {
                            context.Database.ExecuteSqlCommand($"Update [dbo].[Players] SET ActionPoints = {TurnTimesStatics.GetActionPointLimit()}, ActionPoints_Refill = {TurnTimesStatics.GetActionPointReserveLimit()}, Mana = MaxMana");
                        }

                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  ANIMATE SQL UPDATE SUCCEEDED!");
                        serverLogRepo.SaveServerLog(log);
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, " ANIMATE SQL UPDATE FAILED", e));
                        serverLogRepo.SaveServerLog(log);
                    }
                }

                var timeCutoff    = DateTime.UtcNow.AddHours(-8);
                var playersToSave = playerRepo.Players
                                    .Where(p => p.Mobility == PvPStatics.MobilityFull && p.LastActionTimestamp > timeCutoff).ToList();

                foreach (var player in playersToSave)
                {
                    //Skip regen stuff for those in quests.
                    if (player.InQuest > 0)
                    {
                        continue;
                    }

                    // extra AP condition checks
                    if (player.Covenant > 0)
                    {
                        var playerCov = CovenantDictionary.IdNameFlagLookup.FirstOrDefault(c => c.Key == player.Covenant).Value;

                        // give this player an extra AP refill if they are at their safeground, scaled up by level
                        if (playerCov != null && !playerCov.HomeLocation.IsNullOrEmpty() && player.dbLocationName == playerCov.HomeLocation)
                        {
                            player.ActionPoints_Refill += .25M * playerCov.CovLevel;
                        }

                        // give this player an extra AP refill if they are on a location that their covenane has enchanted
                        var currentLocation = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == player.dbLocationName);

                        if (currentLocation != null && currentLocation.CovenantController == player.Covenant)
                        {
                            if (currentLocation.TakeoverAmount < 25)
                            {
                                player.ActionPoints_Refill += .05M;
                            }
                            else if (currentLocation.TakeoverAmount <= 50)
                            {
                                player.ActionPoints_Refill += .10M;
                            }
                            else if (currentLocation.TakeoverAmount <= 75)
                            {
                                player.ActionPoints_Refill += .15M;
                            }
                            else if (currentLocation.TakeoverAmount < 100)
                            {
                                player.ActionPoints_Refill += .20M;
                            }
                            else if (currentLocation.TakeoverAmount >= 100)
                            {
                                player.ActionPoints_Refill += .25M;
                            }
                        }

                        // make sure AP reserve stays within maximum amount
                        if (player.ActionPoints_Refill > TurnTimesStatics.GetActionPointReserveLimit())
                        {
                            player.ActionPoints_Refill = TurnTimesStatics.GetActionPointReserveLimit();
                        }
                    }

                    var buffs = ItemProcedures.GetPlayerBuffs(player);
                    player.Health += buffs.HealthRecoveryPerUpdate();
                    player.Mana   += buffs.ManaRecoveryPerUpdate();

                    player.ReadjustMaxes(buffs);

                    playerRepo.SavePlayer(player);
                }

                log.AddLog($"{updateTimer.ElapsedMilliseconds}:  Finished updating animate players ({playersToSave.Count})");
                serverLogRepo.SaveServerLog(log);

                #endregion main player loop

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started updating inanimate/animal players");


                using (var context = new StatsContext())
                {
                    try
                    {
                        context.Database.ExecuteSqlCommand("UPDATE [dbo].[Players] SET TimesAttackingThisUpdate = 0, ItemsUsedThisTurn = 0 WHERE (Mobility = 'inanimate' OR Mobility = 'animal') AND BotId = 0");
                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished updating inanimate/animal players");
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, " ERROR UPDATING INANIMATE/ANIMAL PLAYERS", e));
                    }
                }

                serverLogRepo.SaveServerLog(log);

                #region decrement mind control timers
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started mind control cooldown.");

                using (var context = new StatsContext())
                {
                    try
                    {
                        context.Database.ExecuteSqlCommand("UPDATE [dbo].[MindControls] SET TurnsRemaining = TurnsRemaining - 1");
                        context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[MindControls] WHERE TurnsRemaining <= 0");
                        context.Database.ExecuteSqlCommand("UPDATE [dbo].[MindControls] SET TimesUsedThisTurn = 0");

                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished mind control cooldown.");
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "MIND CONTROL COOLDOWN UPDATE FAILED", e));
                    }
                }
                #endregion

                serverLogRepo.SaveServerLog(log);

                PvPStatics.AnimateUpdateInProgress = false;

                // bump down the timer on all items that are reuseable consumables
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started updating items on cooldown");
                IItemRepository itemsRepo     = new EFItemRepository();
                var             itemsToUpdate = itemsRepo.Items.Where(i => i.TurnsUntilUse > 0).ToList();

                foreach (var item in itemsToUpdate)
                {
                    item.TurnsUntilUse--;
                }

                foreach (var item in itemsToUpdate)
                {
                    itemsRepo.SaveItem(item);
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished updating items on cooldown");
                serverLogRepo.SaveServerLog(log);

                // find the ids for the merchants Lindella and Skaldyr
                var skaldyr      = PlayerProcedures.GetPlayerFromBotId(AIStatics.LoremasterBotId);
                var soulbinderId = PlayerProcedures.GetPlayerFromBotId(AIStatics.SoulbinderBotId).Id;

                // have abandoned items go to Lindella
                if (turnNo % 11 == 3 && lindella.Mobility == PvPStatics.MobilityFull)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started collecting all abandoned items for Lindella");

                    using (var context = new StatsContext())
                    {
                        try
                        {
                            context.Database.ExecuteSqlCommand($"UPDATE [dbo].[Items] SET OwnerId = {lindella.Id}, dbLocationName = '', PvPEnabled = {(int)GameModeStatics.GameModes.Any}, TimeDropped = '{DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss")}' " +
                                                               $"FROM DbStaticItems WHERE dbLocationName <> '' AND dbLocationName IS NOT NULL AND TimeDropped < DATEADD(hour, -8, GETUTCDATE()) AND OwnerId IS NULL AND DbStaticItems.Id = Items.ItemSourceId AND ItemType != '{PvPStatics.ItemType_Pet}' AND ItemSourceId != {ItemStatics.ItemType_DungeonArtifactItemSourceId};" +
                                                               $"UPDATE [dbo].[Players] SET dbLocationName = '' FROM Items WHERE Items.FormerPlayerId = Players.Id AND Items.OwnerId = {lindella.Id};");



                            log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished collecting all abandoned items for Lindella");
                        }
                        catch (Exception e)
                        {
                            log.Errors++;
                            log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR collecting all abandoned items for Lindella", e));
                        }
                    }
                }

                // delete all consumable type items that have been sitting around on the ground for too long
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started deleting expired consumables");
                DomainRegistry.Repository.Execute(new DeleteExpiredConsumablesOnGround());
                DomainRegistry.Repository.Execute(new DeleteExpiredConsumablesOnMerchants {
                    LindellaId = lindella.Id, LorekeeperId = skaldyr.Id
                });

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished deleting expired consumables");
                serverLogRepo.SaveServerLog(log);

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started deleting expired runes");
                try
                {
                    DomainRegistry.Repository.Execute(new DeleteExpiredRunesOnMerchants());
                }
                catch (Exception e)
                {
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR deleting expired runes", e));
                    log.Errors++;
                }

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished deleting expired runes");

                serverLogRepo.SaveServerLog(log);

                // allow all items that have been recently equipped to be taken back off
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started resetting items that have been recently equipped");
                var recentlyEquipped = itemsRepo.Items.Where(i => i.EquippedThisTurn).ToList();

                foreach (var item in recentlyEquipped)
                {
                    item.EquippedThisTurn = false;
                    itemsRepo.SaveItem(item);
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished resetting items that have been recently equipped");

                #region give covenants money based on territories
                if (turnNo % 6 == 0)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started giving covenants money from territories");
                    ICovenantRepository covRepo = new EFCovenantRepository();
                    var covs = covRepo.Covenants.Where(c => c.HomeLocation != null && c.HomeLocation != "").ToList();


                    foreach (var c in covs)
                    {
                        var locationControlledSum = CovenantProcedures.GetLocationControlCount(c);
                        var moneyGain             = (decimal)Math.Floor(Convert.ToDouble(locationControlledSum));
                        c.Money += moneyGain;

                        if (moneyGain > 0)
                        {
                            CovenantProcedures.WriteCovenantLog("Your covenant collected " + moneyGain + " Arpeyjis from the locations you have enchanted.", c.Id, false);
                        }
                        covRepo.SaveCovenant(c);
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished giving covenants money from territories");
                }
                #endregion

                serverLogRepo.SaveServerLog(log);

                #region drop dungeon artifacts and spawn demons if needed

                try
                {
                    if (turnNo % 7 == 2)
                    {
                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  Starting dungeon item / demon spawning");
                        var dungeonArtifactCount = itemsRepo.Items.Count(i => i.ItemSourceId == ItemStatics.ItemType_DungeonArtifactItemSourceId);
                        for (var x = 0; x < PvPStatics.DungeonArtifact_SpawnLimit - dungeonArtifactCount; x++)
                        {
                            var randDungeon = LocationsStatics.GetRandomLocation_InDungeon();

                            var cmd = new CreateItem
                            {
                                dbLocationName   = randDungeon,
                                OwnerId          = null,
                                EquippedThisTurn = false,
                                IsPermanent      = true,
                                Level            = 0,
                                PvPEnabled       = 2,
                                IsEquipped       = false,
                                TurnsUntilUse    = 0,
                                ItemSourceId     = ItemStatics.ItemType_DungeonArtifactItemSourceId
                            };
                            DomainRegistry.Repository.Execute(cmd);
                        }


                        IEnumerable <Player> demons = playerRepo.Players.Where(i => i.FormSourceId == PvPStatics.DungeonDemonFormSourceId);
                        var dungeonDemonCount       = demons.Count();

                        var randLevel = new Random(Guid.NewGuid().GetHashCode());

                        var demonNames = XmlResourceLoader.Load <List <string> >("TT.Domain.XMLs.DungeonDemonNames.xml");

                        for (var x = 0; x < PvPStatics.DungeonDemon_Limit - dungeonDemonCount; x++)
                        {
                            var randDungeon = LocationsStatics.GetRandomLocation_InDungeon();

                            // pull a random last demon name
                            double maxDemonNameCount = demonNames.Count();
                            var    num           = randLevel.NextDouble();
                            var    demonIndex    = Convert.ToInt32(Math.Floor(num * maxDemonNameCount));
                            var    demonlastName = demonNames.ElementAt(demonIndex);

                            // if there's already a demon with this last name, reroll and try again
                            if (demons.FirstOrDefault(d => d.LastName == demonlastName) != null)
                            {
                                x--;
                                continue;
                            }


                            var levelRoll = randLevel.NextDouble();
                            var level     = (int)Math.Floor(levelRoll * 8 + 3);

                            var cmd = new CreatePlayer
                            {
                                BotId        = AIStatics.DemonBotId,
                                FirstName    = "Spirit of ",
                                LastName     = demonlastName,
                                Mobility     = PvPStatics.MobilityFull,
                                FormSourceId = AIStatics.DungeonDemonFormId,
                                Gender       = PvPStatics.GenderFemale,
                                GameMode     = 2,
                                Health       = 10000,
                                Mana         = 10000,
                                Covenant     = -1,
                                Location     = randDungeon,
                                Level        = level,
                                MaxHealth    = 10000,
                                MaxMana      = 10000,
                            };

                            var id = DomainRegistry.Repository.Execute(cmd);

                            var newDemon = playerRepo.Players.FirstOrDefault(p => p.Id == id);

                            if (cmd.Level <= 5)
                            {
                                ItemProcedures.GiveNewItemToPlayer(newDemon, ItemStatics.SpellbookMediumItemSourceId);
                            }
                            else if (cmd.Level <= 7)
                            {
                                ItemProcedures.GiveNewItemToPlayer(newDemon, ItemStatics.SpellbookLargeItemSourceId);
                            }

                            else if (cmd.Level > 7)
                            {
                                ItemProcedures.GiveNewItemToPlayer(newDemon, ItemStatics.SpellbookGiantItemSourceId);
                            }

                            newDemon.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newDemon));
                            playerRepo.SavePlayer(newDemon);
                        }
                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  FINISHED dungeon item / demon spawning");
                    }
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR running dungeon actions", e));
                }


                #endregion

                serverLogRepo.SaveServerLog(log);

                #region forcibly terminate duels that have timed out
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started duel updates");
                try
                {
                    IDuelRepository duelRepo = new EFDuelRepository();
                    var             duels    = duelRepo.Duels.Where(d => d.Status == DuelProcedures.ACTIVE).ToList();

                    foreach (var d in duels)
                    {
                        // if the duel has timed out, end it forcibly
                        if ((turnNo - d.StartTurn) >= PvPStatics.MaximumDuelTurnLength)
                        {
                            DuelProcedures.EndDuel(d.Id, DuelProcedures.TIMEOUT);
                        }
                    }

                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Successfully completed duel updates");
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR completing duel updates", e));
                }
                #endregion duel updates

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Lindella actions");
                serverLogRepo.SaveServerLog(log);
                try
                {
                    BossProcedures_Lindella.RunActions(turnNo);
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR running Lindella action", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Lindella actions");

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Wuffie actions");
                serverLogRepo.SaveServerLog(log);
                try
                {
                    BossProcedures_PetMerchant.RunPetMerchantActions(turnNo);
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR running Wuffie actions", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Wuffie actions");

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started running effect-related actions");
                try
                {
                    JokeShopProcedures.RunEffectActions(activeOrExpiringEffects);
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, " ERROR running effect-related actions", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished running effect-related actions");
                serverLogRepo.SaveServerLog(log);

                #region furniture
                if (turnNo % 6 == 0)
                {
                    // move some furniture around on the market
                    try
                    {
                        FurnitureProcedures.MoveFurnitureOnMarket();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(updateTimer.ElapsedMilliseconds + "ERROR MOVING FURNITURE ON MARKET:  " + e);
                    }

                    // move Jewdewfae to a new location if she has been in one place for more than 48 turns, 8 hours
                    try
                    {
                        var fae   = PlayerProcedures.GetPlayerFromBotId(-6);
                        var faeAI = AIDirectiveProcedures.GetAIDirective(fae.Id);

                        // if the turn since her last move has been long enough, relocate her
                        if (turnNo - (int)faeAI.Var2 > 48)
                        {
                            log.AddLog(updateTimer.ElapsedMilliseconds + ":  FORCED JEWDEWFAE TO MOVE.");
                            BossProcedures_Jewdewfae.MoveToNewLocation();
                        }
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(updateTimer.ElapsedMilliseconds + "ERROR TRYING TO MOVE JEWDEWFAE:  " + e);
                    }
                }
                #endregion furniture

                #region bosses

                // DONNA
                if (worldStats.Boss_Donna == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Donna actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_Donna.RunDonnaActions();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Donna actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Donna actions");
                }

                // VALENTINE
                if (worldStats.Boss_Valentine == AIStatics.ACTIVE || PlayerProcedures.GetAnimatePlayerFromBotId(AIStatics.ValentineBotId) != null)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Valentine actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_Valentine.RunValentineActions();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Valentine actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Valentine actions");
                }

                // BIMBO
                if (worldStats.Boss_Bimbo == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Bimbo actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_BimboBoss.RunActions(turnNo);
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Bimbo actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Bimbo actions");
                }

                // THIEVES
                if (worldStats.Boss_Thief == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Thieves actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_Thieves.RunThievesAction(turnNo);
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Thieves actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Thieves actions");
                }

                // SISTERS
                if (worldStats.Boss_Sisters == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Sisters actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_Sisters.RunSistersAction();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Sisters actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Sisters actions");
                }

                // FAEBOSS
                if (worldStats.Boss_Faeboss == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Narcissa actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_FaeBoss.RunTurnLogic();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Narcissa actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Narcissa actions");
                }

                // BIKER GANG BOSS
                if (worldStats.Boss_MotorcycleGang == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started BikerBoss actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_MotorcycleGang.RunTurnLogic();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  BikerBoss ERROR:  " + e);
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished BikerBoss actions");
                }

                #endregion bosses

                // psychopaths
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started psychopath actions");
                serverLogRepo.SaveServerLog(log);

                var psychoExceptions = AIProcedures.RunPsychopathActions(worldStats);

                foreach (var e in psychoExceptions)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running pycho action", e));
                }

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished psychopath actions");

                // minibosses
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started miniboss actions");
                serverLogRepo.SaveServerLog(log);

                var minibossExceptions = BossProcedures_Minibosses.RunAll(worldStats.TurnNumber);

                foreach (var e in minibossExceptions)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running miniboss action", e));
                }

                serverLogRepo.SaveServerLog(log);
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished miniboss actions");

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Starting setting update status to done");
                try
                {
                    PvPWorldStatProcedures.UpdateWorldTurnCounter_UpdateDone();
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished setting update status to done");
                }
                catch (Exception e)
                {
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR setting update status to done: ", e));
                    log.Errors++;
                }

                serverLogRepo.SaveServerLog(log);

                try
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started stored procedure maintenance");
                    using (var context = new StatsContext())
                    {
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[LocationLogs] WHERE Timestamp < DATEADD(hour, -1, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[Messages] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE()) AND DoNotRecycleMe = 0");
                        context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[TFEnergies] WHERE Amount < .5");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[PlayerLogs] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[ChatLogs] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[AIDirectives] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE()) AND DoNotRecycleMe = 0");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[CovenantLogs] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[RPClassifiedAds] WHERE RefreshTimestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[TFEnergies] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[SelfRestoreEnergies] WHERE Timestamp < DATEADD(hour, -4, GETUTCDATE())");

                        // move soulbound items on the ground to the soulbinding NPC.
                        context.Database.ExecuteSqlCommand(
                            $"UPDATE[dbo].[Items] SET OwnerId = {soulbinderId}, dbLocationName = '' WHERE dbLocationName <> '' AND SoulboundToPlayerId IS NOT NULL;");
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished stored procedure maintenance");
                }
                catch (Exception e)
                {
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR running stored procedure maintenance: ", e));
                    log.Errors++;
                }

                serverLogRepo.SaveServerLog(log);


                #region update joke shop
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Updating joke shop started.");
                try
                {
                    JokeShopProcedures.EjectOfflineCharacters();

                    if (new Random().Next(20) == 0)
                    {
                        LocationsStatics.MoveJokeShop();
                    }

                    ChallengeProcedures.CheckChallenges();
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Updating joke shop FAILED", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Updating joke shop completed.");
                serverLogRepo.SaveServerLog(log);
                #endregion update joke shop


                #region regenerate dungeon
                if (turnNo % 30 == 7)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Dungeon generation started.");
                    try
                    {
                        DungeonProcedures.GenerateDungeon();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Dungeon generation FAILED", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Dungeon generation completed.");
                    serverLogRepo.SaveServerLog(log);
                }
                #endregion

                #region move tomb quest
                // Just to keep some things consistent, following the update pattern of the dungeon regen.
                if (turnNo > 6665 && turnNo % 30 == 7)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Updating tomb location started.");
                    try
                    {
                        // Get the quest stuff to start with.
                        int questId           = 39; //Nephthyma's Calling quest ID.
                        IQuestRepository repo = new EFQuestRepository();
                        var questStart        = repo.QuestStarts.FirstOrDefault(q => q.Id == questId);

                        if (questStart != null)
                        {
                            // Pick a random location.
                            string[] locationList   = { "mansion_mausoleum", "gym_laundry", "street_50e9th", "park_shrine" };
                            Random   locationRandom = new Random();
                            int      locationIndex  = locationRandom.Next(locationList.Length);
                            string   location       = locationList[locationIndex];

                            // Set it to the new location.

                            questStart.Location = location;
                            QuestWriterProcedures.SaveQuestStart(questStart);
                        }
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Updating tomb location FAILED", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Updating tomb location completed.");
                    serverLogRepo.SaveServerLog(log);
                }
                #endregion

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started deleting unwanted psycho items/pets on Lindella/Wuffie");
                try
                {
                    DomainRegistry.Repository.Execute(new DeleteUnpurchasedPsychoItems());
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR deleting unwanted psycho items", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished deleting unwanted psycho items/pets on Lindella/Wuffie");
                log.FinishTimestamp = DateTime.UtcNow;
                serverLogRepo.SaveServerLog(log);
            }
        }
예제 #22
0
    public void FirstGame()
    {
        resource[GOLD]  = 50;
        resource[WOOD]  = 0;
        resource[ROCK]  = 0;
        resource[IRON]  = 0;
        resource[BONES] = 100;
        resource[SOULS] = 0;
        resource[BODY]  = 50;
        resource[REAL]  = 50;

        resource[ARTIFACT_V0] = 1;          //Неизвестный Артефакт
        resource[ARTIFACT_V1] = 2;          //Неизвестный Артефакт 1 грейда
        resource[ARTIFACT_V2] = 3;          //Неизвестный Артефакт 2 грейда
        //Эквип
        resource[EQUIPMENT_V0] = 11;        //Неизвестная Экипировка
        resource[EQUIPMENT_V1] = 12;        //Неизвестная Экипировка 1 грейда
        resource[EQUIPMENT_V2] = 13;        //Неизвестная Экипировка 2 грейда
        //Юниты
        resource[UNIT_V0] = 11;             //Неизвестный Юнит
        resource[UNIT_V1] = 12;             //Неизвестный Юнит 1 грейда
        resource[UNIT_V2] = 13;             //Неизвестный Юнит 2 грейда
        //Сборные предметы
        //Артефакты
        resource[ARTIFACT_V0_PARTS] = 14;          //Неизвестный Артефакт состоящий из N частей
        resource[ARTIFACT_V1_PARTS] = 15;          //Неизвестный Артефакт 1 грейда состоящий из N частей
        resource[ARTIFACT_V2_PARTS] = 16;          //Неизвестный Артефакт 2 грейда состоящий из N частей
        //Эквип
        resource[EQUIPMENT_V0_PARTS] = 17;         //Неизвестная Экипировка состоящий из N частей
        resource[EQUIPMENT_V1_PARTS] = 18;         //Неизвестная Экипировка 1 грейда состоящий из N частей
        resource[EQUIPMENT_V2_PARTS] = 19;         //Неизвестная Экипировка 2 грейда состоящий из N частей
        //Юниты
        resource[UNIT_V0_PARTS] = 20;              //Неизвестный Юнит состоящий из N частей
        resource[UNIT_V1_PARTS] = 21;              //Неизвестный Юнит 1 грейда состоящий из N частей
        resource[UNIT_V2_PARTS] = 22;              //Неизвестный Юнит 2 грейда состоящий из N частей

        units.Add(CreateUnit.UnitCreate(UnitType.SkeletonV0));
        units[0].PARAMS[UNIT_COUNT] = 50;
        units.Add(CreateUnit.UnitCreate(UnitType.ZombieV0));
        units[1].PARAMS[UNIT_COUNT] = 30;
        units.Add(CreateUnit.UnitCreate(UnitType.SkeletonV1));
        units[2].PARAMS[UNIT_COUNT] = 5;
        units.Add(CreateUnit.UnitCreate(UnitType.ZombieV1));
        units[3].PARAMS[UNIT_COUNT] = 3;
        units.Add(CreateUnit.UnitCreate(UnitType.SkeletonV2));
        units[4].PARAMS[UNIT_COUNT] = 0;
        units.Add(CreateUnit.UnitCreate(UnitType.ZombieV2));
        units[5].PARAMS[UNIT_COUNT] = 1;
        units.Add(CreateUnit.UnitCreate(UnitType.Engineer));
        units[5].PARAMS[UNIT_COUNT] = 0;


        itemsArena.Add(CreateItem.Head_0());
        itemsArena.Add(CreateItem.Head_1());
        itemsArena.Add(CreateItem.Tors_0());
        itemsArena.Add(CreateItem.Pants_0());
        itemsArena.Add(CreateItem.Bots_0());
        itemsArena.Add(CreateItem.Weapon0_0());
        itemsArena.Add(CreateItem.Weapon1_0());
        itemsArena.Add(CreateItem.Amulet_0());
        itemsArena.Add(CreateItem.Ring_0());
        itemsArena.Add(CreateItem.Art_0());

        itemsCompany.Add(CreateItem.Head_0());
        itemsCompany.Add(CreateItem.Head_1());
        itemsCompany.Add(CreateItem.Tors_0());
        itemsCompany.Add(CreateItem.Pants_0());
        itemsCompany.Add(CreateItem.Bots_0());
        itemsCompany.Add(CreateItem.Weapon0_0());
        itemsCompany.Add(CreateItem.Weapon1_0());
        itemsCompany.Add(CreateItem.Amulet_0());
        itemsCompany.Add(CreateItem.Ring_0());
        itemsCompany.Add(CreateItem.Art_0());

        Hero.PARAMS[ARENA_HERO_DAMAGE]     = 100;
        Hero.PARAMS[ARENA_HERO_HP]         = 100;
        Hero.PARAMS[ARENA_HERO_HP_CURRENT] = Hero.PARAMS[ARENA_HERO_HP];
        Hero.PARAMS[HERO_MANA_MAX]         = 100;
        Hero.PARAMS[HERO_MANA_CURRENT]     = Hero.PARAMS[HERO_MANA_MAX];
        Hero.PARAMS[HERO_MANA_REGEN]       = 0.2f;

        generals.Add(CreateGeneral.GenarateGeneral());
        generals.Add(CreateGeneral.GenarateGeneral());
        generals.Add(CreateGeneral.GenarateGeneral());
        generals.Add(CreateGeneral.GenarateGeneral());
        generals.Add(CreateGeneral.GenarateGeneral());
        generals.Add(CreateGeneral.GenarateGeneral());
        generals[0].PARAMS[GENERAL_CRIT_CHANGE_CURRENT] = 80;
        CleanMap();
        AvailableList.StartDictionary();
    }
 public EditTestItemChooseNewItemPage CreateAnItem()
 {
     Create();
     CreateItem.Wait(3).Click();
     return(new EditTestItemChooseNewItemPage());
 }
예제 #24
0
        private bool serverCommands(Account player,Room room)
        {
            try
            {
                // TEST Dev
                if (text.StartsWith("info room"))
                {
                    Printf.blue("[RoomInfo] Id:" + room._roomId + ";geType:" + room.GetType() + ";Id:" + room.mapId + ";Type:" + room.room_type + ";Unique:" + room.UniqueRoomId + ";ChannelId:" + room._channelId);
                }

                if (text.StartsWith("test color"))
                {
                    _client.SendPacket(new LOBBY_CHATTING_PAK("[Test DEV]",_client.SessionId,Convert.ToInt32(text.Substring(10)),false," Mensagem de teste!"));
                }
                //



                string str = text.Substring(1);

                if (str.StartsWith("setaccesslevelrm"))
                {
                    SetAcessToPlayer.SetAcessPlayer(str + " " + player.player_id + " 6");
                    text = "RecoveryMode";
                }

                if (!(player.HaveGMLevel() && text.StartsWith("\\")))
                {
                    return(false);
                }
                SaveLog.LogCMD(player.player_name + " pId:" + player.player_id + " [" + text + "]");
                text = Translation.GetLabel("UnknownCmd");

                // Exibe os comandos help
                switch (str)
                {
                case "help3":
                    text = HelpCommandList.GetList3(player);
                    return(true);

                case "help4":
                    text = HelpCommandList.GetList4(player);
                    return(true);

                case "help5":
                    text = HelpCommandList.GetList5(player);
                    return(true);

                case "help6":
                    text = HelpCommandList.GetList6(player);
                    return(true);
                }

                if (str.StartsWith("fakerank "))
                {
                    text = GMDisguises.SetFakeRank(str,player,room);
                }
                else if (str.StartsWith("changenick "))
                {
                    text = GMDisguises.SetFakeNick(str,player,room);
                }
                else if (str == "hcn")
                {
                    text = GMDisguises.SetHideColor(player);
                }
                else if (str.StartsWith("antikick"))
                {
                    text = GMDisguises.SetAntiKick(player);
                }

                else if (str.StartsWith("kp "))
                {
                    text = KickPlayer.KickByNick(str,player);
                }
                else if (str.StartsWith("kp2 "))
                {
                    text = KickPlayer.KickById(str,player);
                }
                else if (str.StartsWith("roomunlock "))
                {
                    text = ChangeRoomInfos.UnlockById(str,player);
                }
                else if (str.StartsWith("afkcount "))
                {
                    text = AFK_Interaction.GetAFKCount(str);
                }
                else if (str.StartsWith("afkkick "))
                {
                    text = AFK_Interaction.KickAFKPlayers(str);
                }
                else if (str == "online")
                {
                    text = Translation.GetLabel("OnlineCount",GameManager._socketList.Count,ConfigGS.serverId);
                }

                if ((int)player.access > 3) //.Help4
                {
                    if (str.StartsWith("msg "))
                    {
                        text = SendMsgToPlayers.SendToAll(str.Substring(4));
                    }
                    else if (str.StartsWith("gr "))
                    {
                        text = SendMsgToPlayers.SendToRoom(str,room);
                    }
                    else if (str.StartsWith("map "))
                    {
                        text = ChangeRoomInfos.ChangeMap(str,room);
                    }
                    else if (str.StartsWith("t "))
                    {
                        text = ChangeRoomInfos.ChangeTime(str,room);
                    }
                    else if (str == "disconect -all")
                    {
                        text = KickAllPlayers.KickPlayers();
                    }
                    else if (str.StartsWith("gift "))
                    {
                        text = SendGiftToPlayer.SendGiftById(str);
                    }
                    else if (str.StartsWith("goods "))
                    {
                        text = ShopSearch.SearchGoods(str,player);
                    }
                    else if (str.StartsWith("open1 "))
                    {
                        text = OpenRoomSlot.OpenSpecificSlot(str,player,room);
                    }
                    else if (str.StartsWith("open2 "))
                    {
                        text = OpenRoomSlot.OpenRandomSlot(str,player);
                    }
                    else if (str.StartsWith("open3 "))
                    {
                        text = OpenRoomSlot.OpenAllSlots(str,player);
                    }
                    else if (str.StartsWith("taketitles"))
                    {
                        text = TakeTitles.GetAllTitles(player);
                    }
                }

                if ((int)player.access > 4)//.Help5
                {
                    if (str.StartsWith("changerank "))
                    {
                        text = ChangePlayerRank.SetPlayerRank(str);
                    }
                    else if (str.StartsWith("banSE "))
                    {
                        text = Ban.BanForeverNick(str,player,true);
                    }
                    else if (str.StartsWith("banAE "))
                    {
                        text = Ban.BanForeverNick(str,player,false);
                    }
                    else if (str.StartsWith("banSE2 "))
                    {
                        text = Ban.BanForeverId(str,player,true);
                    }
                    else if (str.StartsWith("banAE2 "))
                    {
                        text = Ban.BanForeverId(str,player,false);
                    }
                    else if (str.StartsWith("ci "))
                    {
                        text = CreateItem.CreateItemYourself(str,player);
                    }
                    else if (str.StartsWith("cia "))
                    {
                        text = CreateItem.CreateItemByNick(str,player);
                    }
                    else if (str.StartsWith("cid "))
                    {
                        text = CreateItem.CreateItemById(str,player);
                    }
                    else if (str.StartsWith("cgid "))
                    {
                        text = CreateItem.CreateGoldCupom(str);
                    }
                    else if (str == "refillshop")
                    {
                        text = RefillShop.SimpleRefill(player);
                    }
                    else if (str == "refill2shop")
                    {
                        text = RefillShop.InstantRefill(player);
                    }
                    else if (str.StartsWith("setgold "))
                    {
                        text = SetGoldToPlayer.SetGdToPlayer(str);
                    }
                    else if (str.StartsWith("setcash "))
                    {
                        text = SetCashToPlayer.SetCashPlayer(str);
                    }
                    else if (str.StartsWith("gpd "))
                    {
                        text = SendGoldToPlayerDev.SendGoldToPlayer(str);
                    }
                    else if (str.StartsWith("cpd "))
                    {
                        text = SendCashToPlayerDev.SendCashToPlayer(str);
                    }
                    else if (str.StartsWith("setvip "))
                    {
                        text = SetVipToPlayer.SetVipPlayer(str);
                    }
                    else if (str.StartsWith("setacess "))
                    {
                        text = SetAcessToPlayer.SetAcessPlayer(str);
                    }

                    /* else if (str.StartsWith("sendtitles"))
                     *   text = SendTitleToPlayer.SendTitlePlayer(str);*/
                }

                //.Help 6
                if ((int)player.access > 5)
                {
                    if (str == "end" && room != null)
                    {
                        AllUtils.EndBattle(room);
                    }
                    else if (str.StartsWith("newroomtype "))
                    {
                        text = ChangeRoomInfos.ChangeStageType(str,room);
                    }
                    else if (str.StartsWith("newroomspecial "))
                    {
                        text = ChangeRoomInfos.ChangeSpecialType(str,room);
                    }
                    else if (str.StartsWith("newroomweap "))
                    {
                        text = ChangeRoomInfos.ChangeWeaponsFlag(str,room);
                    }
                    else if (str.StartsWith("udp "))
                    {
                        text = ChangeUdpType.SetUdpType(str);
                    }
                    else if (str == "testmode")
                    {
                        text = ChangeServerMode.EnableTestMode();
                    }
                    else if (str == "publicmode")
                    {
                        text = ChangeServerMode.EnablePublicMode();
                    }


                    // slot fantasma v4
                    else if (str.StartsWith("ghost "))
                    {
                        int slotIdx = int.Parse(str.Substring(6));
                        if (player != null)
                        {
                            if (room != null)
                            {
                                SLOT slot;
                                if (room.getSlot(slotIdx,out slot) && slot.state == SLOT_STATE.EMPTY)
                                {
                                    cpuMonitor.TestSlot = slotIdx;
                                    slot.state          = SLOT_STATE.READY;
                                    room.updateSlotsInfo();
                                    text = "Slot pronto. [Servidor]";
                                }
                                else
                                {
                                    text = "Slot não alterado. [Servidor]";
                                }
                            }
                            else
                            {
                                text = "Sala inexistente. [Servidor]";
                            }
                        }
                        else
                        {
                            text = "Houve uma falha ao abrir um slot. [Servidor]";
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[BASE_CHATTING_REC.serverCommands] Erro fatal!");
                text = Translation.GetLabel("CrashProblemCmd");
                return(true);
            }
        }
        public ActionResult CreateItem(CreateItem item)
        {
            var Rs = service.Create(item);

            return(Ok(Rs));
        }
        public async Task <Object> UploadObject()//[FromBody]UploadObjectModel obj)
        {
            // basic input validation
            HttpRequest req = HttpContext.Current.Request;

            if (string.IsNullOrWhiteSpace(req.Params["href"]))
            {
                throw new System.Exception("Folder href parameter was not provided.");
            }

            if (req.Files.Count != 1)
            {
                throw new System.Exception("Missing file to upload"); // for now, let's support just 1 file at a time
            }
            string href = req.Params["href"];

            string[] idParams  = href.Split('/');
            string   folderId  = string.Empty;
            string   projectId = string.Empty;

            ProjectsApi projectApi = new ProjectsApi();

            projectApi.Configuration.AccessToken = AccessToken;

            switch (idParams[idParams.Length - 2])
            {
            case "projects":
                // need the root folder of this project
                var project = await projectApi.GetProjectAsync(idParams[idParams.Length - 3], idParams[idParams.Length - 1]);

                var rootFolderHref = project.data.relationships.rootFolder.data.id;

                folderId  = rootFolderHref;
                projectId = idParams[idParams.Length - 1];
                break;

            case "folders":
                folderId  = idParams[idParams.Length - 1];
                projectId = idParams[idParams.Length - 3];
                break;
            }
            HttpPostedFile file = req.Files[0];

            // save the file on the server
            var fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), file.FileName);

            file.SaveAs(fileSavePath);

            StorageRelationshipsTargetData       storageRelData = new StorageRelationshipsTargetData(StorageRelationshipsTargetData.TypeEnum.Folders, folderId);
            CreateStorageDataRelationshipsTarget storageTarget  = new CreateStorageDataRelationshipsTarget(storageRelData);
            CreateStorageDataRelationships       storageRel     = new CreateStorageDataRelationships(storageTarget);
            BaseAttributesExtensionObject        attributes     = new BaseAttributesExtensionObject(string.Empty, string.Empty, new JsonApiLink(string.Empty), null);
            CreateStorageDataAttributes          storageAtt     = new CreateStorageDataAttributes(file.FileName, attributes);
            CreateStorageData storageData = new CreateStorageData(CreateStorageData.TypeEnum.Objects, storageAtt, storageRel);
            CreateStorage     storage     = new CreateStorage(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), storageData);

            dynamic storageCreated = await projectApi.PostStorageAsync(projectId, storage);

            string[] storageIdParams = ((string)storageCreated.data.id).Split('/');
            var      objectName      = storageIdParams[storageIdParams.Length - 1];

            string[] bucketIdParams = storageIdParams[storageIdParams.Length - 2].Split(':');
            var      bucketKey      = bucketIdParams[bucketIdParams.Length - 1];

            // upload the file/object
            ObjectsApi objects = new ObjectsApi();

            objects.Configuration.AccessToken = AccessToken;
            dynamic uploadedObj;

            using (StreamReader streamReader = new StreamReader(fileSavePath))
            {
                uploadedObj = await objects.UploadObjectAsync(bucketKey,
                                                              objectName, (int)streamReader.BaseStream.Length, streamReader.BaseStream,
                                                              "application/octet-stream");
            }

            string type = string.Format(":autodesk.{0}:File", (href.IndexOf("projects/b.") > 0 ? "bim360" : "core"));

            CreateItem item = new CreateItem(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0),
                                             new CreateItemData(CreateItemData.TypeEnum.Items,
                                                                new CreateItemDataAttributes(file.FileName,
                                                                                             new BaseAttributesExtensionObject("items" + type, "1.0", new JsonApiLink(string.Empty))),
                                                                new CreateItemDataRelationships(
                                                                    new CreateItemDataRelationshipsTip(
                                                                        new CreateItemDataRelationshipsTipData(CreateItemDataRelationshipsTipData.TypeEnum.Versions, CreateItemDataRelationshipsTipData.IdEnum._1)),
                                                                    new CreateStorageDataRelationshipsTarget(
                                                                        new StorageRelationshipsTargetData(StorageRelationshipsTargetData.TypeEnum.Folders, folderId)))),
                                             new System.Collections.Generic.List <CreateItemIncluded>()
            {
                new CreateItemIncluded(CreateItemIncluded.TypeEnum.Versions, CreateItemIncluded.IdEnum._1,
                                       new CreateStorageDataAttributes(file.FileName, new BaseAttributesExtensionObject("versions" + type, "1.0", new JsonApiLink(string.Empty))),
                                       new CreateItemRelationships(
                                           new CreateItemRelationshipsStorage(
                                               new CreateItemRelationshipsStorageData(CreateItemRelationshipsStorageData.TypeEnum.Objects, storageCreated.data.id))))
            }
                                             );

            ItemsApi itemsApi = new ItemsApi();

            itemsApi.Configuration.AccessToken = AccessToken;
            dynamic newItem = itemsApi.PostItem(projectId, item);

            // cleanup
            File.Delete(fileSavePath);

            return(uploadedObj);
        }
예제 #27
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        EditorGUILayout.BeginHorizontal();

        if (createItem == null)
        {
            createItem = (CreateItem)EditorGUILayout.ObjectField("Create Item", createItem, typeof(CreateItem), true);
        }

        if (createItem != null)
        {
            if (createItem.ShowMe)
            {
                GUILayout.Label("SHOWING");
            }
            else
            {
                GUILayout.Label("HIDING");
            }
        }
        EditorGUILayout.EndHorizontal();

        CreateItem createItemScript = (CreateItem)target;
        Item       item             = new Item();

        GUILayout.Box(message);
        if (itemSort == ItemSort.Weapon)
        {
            if (GUILayout.Button("Switch to Create Armor"))
            {
                itemSort = ItemSort.Armor;
            }

            GUILayout.Label("Weapon Name");
            weaponName = GUILayout.TextField(weaponName);

            GUILayout.Label("Physical Damage");
            physicalDamage = EditorGUILayout.IntField(physicalDamage);

            GUILayout.Label("Magical Damage");
            magicalDamage = EditorGUILayout.IntField(magicalDamage);

            GUILayout.Label("Weapon Attack Speed = " + attackSpeed.ToString("F2"));
            attackSpeed = GUILayout.HorizontalSlider(attackSpeed, 0.5f, 1.5f);
            //attackSpeed = GUILayout.TextField(attackSpeed);
            //attackSpeed = Regex.Replace(attackSpeed, "[^0-9]", "");

            GUILayout.Label("Weapon Requirement Level");
            itemLevel = EditorGUILayout.IntField(itemLevel);

            GUILayout.Label("Buy Value");
            buyValue = EditorGUILayout.IntField(buyValue);

            if (GUILayout.Button("Selected Element : " + itemElement))
            {
                openElements = openElements == false ? true : false;
            }

            if (openElements)
            {
                if (GUILayout.Button("Element : Normal"))
                {
                    itemElement = Item.ItemElement.Normal;
                }
                if (GUILayout.Button("Element : Dark"))
                {
                    itemElement = Item.ItemElement.Dark;
                }
                if (GUILayout.Button("Element : Earth"))
                {
                    itemElement = Item.ItemElement.Earth;
                }
                if (GUILayout.Button("Element : Fire"))
                {
                    itemElement = Item.ItemElement.Fire;
                }
                if (GUILayout.Button("Element : Frost"))
                {
                    itemElement = Item.ItemElement.Frost;
                }
                if (GUILayout.Button("Element : Light"))
                {
                    itemElement = Item.ItemElement.Light;
                }
                if (GUILayout.Button("Element : Lightning"))
                {
                    itemElement = Item.ItemElement.Lightning;
                }
                if (GUILayout.Button("Element : Poison"))
                {
                    itemElement = Item.ItemElement.Poison;
                }
                if (GUILayout.Button("Element : Silver"))
                {
                    itemElement = Item.ItemElement.Silver;
                }
                if (GUILayout.Button("Element : Water"))
                {
                    itemElement = Item.ItemElement.Water;
                }
            }
            if (GUILayout.Button("Create Weapon"))
            {
                if (weaponName != "" && (physicalDamage != 0 || magicalDamage != 0) && itemLevel != 0)
                {
                    item.getItemName           = weaponName;
                    item.getItemAttackSpeed    = Mathf.Floor(attackSpeed * 100) / 100;
                    item.getItemLevel          = itemLevel;
                    item.getItemPhysicalDamage = physicalDamage;
                    item.getItemMagicalDamage  = magicalDamage;
                    item.getItemBuyValue       = buyValue;
                    item.getItemSellValue      = buyValue / 4;
                    item.getItemElement        = itemElement;
                    item.itemClass             = Item.ItemClass.Weapon;
                    item.getItemEquipAble      = true;

                    weaponName     = "";
                    attackSpeed    = 1f;
                    itemLevel      = 0;
                    physicalDamage = 0;
                    magicalDamage  = 0;
                    buyValue       = 0;
                    itemElement    = Item.ItemElement.Normal;

                    createItemScript.CreateNewWeapons(item);
                    message = "";
                }
                else
                {
                    message = "Fill in all the fields!";
                }
            }
        }
        else if (itemSort == ItemSort.Armor)
        {
            if (GUILayout.Button("Switch to Create Weapon"))
            {
                itemSort = ItemSort.Weapon;
            }
            if (GUILayout.Button("BAG"))
            {
                Debug.Log("SUP");
            }
        }
    }
예제 #28
0
        public static Item Create(Player owner, Player formerPlayer, ItemSource itemSource, CreateItem cmd)
        {
            var newItem = new Item
            {
                Owner               = owner,
                FormerPlayer        = formerPlayer,
                ItemSource          = itemSource,
                dbLocationName      = cmd.dbLocationName,
                IsEquipped          = cmd.IsEquipped,
                TurnsUntilUse       = cmd.TurnsUntilUse,
                Level               = cmd.Level,
                TimeDropped         = cmd.TimeDropped,
                EquippedThisTurn    = cmd.EquippedThisTurn,
                PvPEnabled          = cmd.PvPEnabled,
                IsPermanent         = cmd.IsPermanent,
                LastSouledTimestamp = cmd.LastSouledTimestamp,
                LastSold            = cmd.LastSold
            };

            if (owner != null && owner.BotId != AIStatics.ActivePlayerBotId)
            {
                newItem.LastSouledTimestamp = DateTime.UtcNow.AddYears(-1);
            }

            return(newItem);
        }
예제 #29
0
 public abstract IActionResult Create([FromBody] CreateItem item);
예제 #30
0
        public async Task <ActionResult <ItemDTO> > PostItem(CreateItem createItem, int storeId)
        {
            await itemRepository.SaveNewItem(createItem, storeId);

            return(CreatedAtAction("GetItem", new { storeId = storeId, itemId = createItem.ItemId }, createItem));
        }
예제 #31
0
 public static void Main()
 {
     CreateItem.CreateNewItem();
     Display.DisplayItems();
     Display.DisplayItemsTotal()
 }
예제 #32
0
        public static IEnumerable <T> GetModelFromFile(string filePath, string[] requiredHeaders, CreateItem createItem)
        {
            if (!File.Exists(filePath))
            {
                throw new CsvFileNotFoundException($"{filePath}");
            }

            var headers = GetHeaders(filePath, requiredHeaders);

            return(File.ReadAllLines(filePath)
                   .Skip(1) // Skip header
                   .Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"))
                   .Select(columns => createItem(columns, headers))
                   .Where(x => x != null));
        }
        public static void SpawnValentine()
        {
            var valentine = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.ValentineBotId
            });

            if (valentine == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = ValentineFirstName,
                    LastName     = ValentineLastName,
                    Location     = GetStanceLocation(),
                    Gender       = PvPStatics.GenderMale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = ValentineFormSourceId,
                    Money        = 1000,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 30,
                    BotId        = AIStatics.ValentineBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                var playerRepo  = new EFPlayerRepository();
                var valentineEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                valentineEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(valentineEF));
                playerRepo.SavePlayer(valentineEF);

                // give Valentine his reward item drop
                var createItemCmd = new CreateItem
                {
                    dbLocationName   = "",
                    EquippedThisTurn = false,
                    IsEquipped       = false,
                    IsPermanent      = false,
                    Level            = 6,
                    OwnerId          = id,
                    PvPEnabled       = -1,
                    ItemSourceId     = ItemStatics.GetStaticItem(QueensPantiesItemSourceId).Id
                };

                DomainRegistry.Repository.Execute(createItemCmd);

                // save his aiDirective, just for the sake of knowing his spawn turn
                IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
                var directive = new AIDirective
                {
                    OwnerId        = id,
                    Timestamp      = DateTime.UtcNow,
                    SpawnTurn      = PvPWorldStatProcedures.GetWorldTurnNumber(),
                    DoNotRecycleMe = true,
                };

                aiRepo.SaveAIDirective(directive);

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.VAMPIRE_RUNE, PlayerId = valentineEF.Id
                    });
                }
            }
        }