Beispiel #1
0
        public async Task Status()
        {
            AnimaCharacter character = CharacterRepository.FindCurrentByMention <AnimaCharacter>(Context.Message.Author.Mention);

            if (character == null)
            {
                await Context.Channel.SendMessageAsync("Error 404: Character not found or not loaded!");

                return;
            }

            _ = Context.Message.DeleteAsync();
            var embed = new EmbedBuilder
            {
                Title = character.Name
            };

            embed.WithThumbnailUrl(character.ImageUrl)
            .AddField("Hp", $"{character.CurrentHp}/{character.Hp}", true)
            .AddField("Fatigue", $"{character.CurrentFatigue}/{character.Fatigue}", true)
            .AddField("Points de Ki", $"{character.CurrentKi}/{character.TotalKiPoints}", true)
            .AddField("Zéon", $"{character.CurrentZeon}/{character.ZeonPoints}", true)
            .AddField("Ppp libres", $"{character.CurrentPpp}/{character.PppFree}", true);

            await Context.User.SendMessageAsync("", false, embed.Build());
        }
Beispiel #2
0
        public async Task SetPpp(string s)
        {
            AnimaCharacter character = CharacterRepository.FindCurrentByMention <AnimaCharacter>(Context.Message.Author.Mention);

            _ = Context.Message.DeleteAsync();

            if (s == "reset")
            {
                character.CurrentPpp = character.PppFree;
            }
            else if (s.Contains("+") || s.Contains("-"))
            {
                character.CurrentPpp += Convert.ToInt32(s);
            }
            else
            {
                character.CurrentPpp = Convert.ToInt32(s);
            }

            var msg = await Context.Channel.SendMessageAsync($"{Context.User.Mention} {character.Name}'s ppp set to {character.CurrentPpp}");

            await Task.Delay(3000);

            _ = msg.DeleteAsync();
        }
        public ActionResult CharatcterList()
        {
            List <Character> characters = new List <Character>();

            characters = CharacterRepository.List();
            return(View(characters));
        }
        public ActionResult CharacterDetail(int CharacterID)
        {
            Character character = new Character();

            character = CharacterRepository.Read(CharacterID);
            return(View(character));
        }
        public async Task <CharacterInfo> GetOne(int projectId, int characterId)
        {
            var character = await CharacterRepository.GetCharacterViewAsync(projectId, characterId);

            var project = await ProjectRepository.GetProjectWithFieldsAsync(projectId);

            return
                (new CharacterInfo
            {
                CharacterId = character.CharacterId,
                UpdatedAt = character.UpdatedAt,
                IsActive = character.IsActive,
                InGame = character.InGame,
                BusyStatus = (CharacterBusyStatus)character.GetBusyStatus(),
                Groups = ToGroupHeaders(character.DirectGroups),
                AllGroups = ToGroupHeaders(character.AllGroups),
                Fields = GetFields(character, project).Where(field => field.HasViewableValue)
                         .Select(field => new FieldValue
                {
                    ProjectFieldId = field.Field.ProjectFieldId,
                    Value = field.Value,
                    DisplayString = field.DisplayString,
                }),
                PlayerUserId = character.ApprovedClaim?.PlayerUserId,
                CharacterDescription = character.Description,
                CharacterName = character.Name,
            });
        }
        public bool Create(uint dwTarget, uint dwEnrole)
        {
            Client pUser;

            if (!ServerKernel.Players.TryGetValue(dwTarget, out pUser))
            {
                DbUser user = new CharacterRepository().SearchByIdentity(dwTarget);
                if (user == null)
                {
                    return(false);
                }
                m_dwIdentity = user.Identity;
                m_szName     = user.Name;
                return(true);
            }
            if (pUser.Character == null)
            {
                return(false);
            }

            m_dwIdentity = pUser.Character.Identity;
            m_szName     = pUser.Character.Name;
            m_dwEnrole   = dwEnrole;

            return(true);
        }
        public void Create_given_a_character_it_maps_to_character()
        {
            var character = default(Character);
            var dto       = new CharacterCreateUpdateDTO
            {
                ActorId = 42,
                Name    = "Turange Leela",
                Species = "Mutant, Human",
                Planet  = "Earth"
            };

            var mock = new Mock <IFuturamaContext>();

            mock.Setup(s => s.Characters.Add(It.IsAny <Character>()))
            .Callback <Character>(c => character = c);

            using (var repository = new CharacterRepository(mock.Object))
            {
                repository.Create(dto);
            }

            Assert.Equal(42, character.ActorId);
            Assert.Equal("Turange Leela", character.Name);
            Assert.Equal("Mutant, Human", character.Species);
            Assert.Equal("Earth", character.Planet);
        }
Beispiel #8
0
        public async Task SetCharacterStance(string s = "")
        {
            _ = Context.Message.DeleteAsync();
            L5RCharacter character = CharacterRepository.FindCurrentByMention <L5RCharacter>(Context.Message.Author.Mention);

            if (character == null)
            {
                await Context.Channel.SendMessageAsync("Error 404: Character not found or not loaded!");

                return;
            }

            try
            {
                character.SetCurrentStance(s);
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention} {ex.Message}");
            }

            var msg = await Context.Channel.SendMessageAsync($"{Context.User.Mention} Posture modifiée!");

            await Task.Delay(3000);

            _ = msg.DeleteAsync();
        }
 public CharacterViewModel(Character character, CharacterRepository repository) : base(character, repository)
 {
     AlchemyRank    = IntToSkillRankConverter.Convert(character.AlchemyLevel, out _alchemyRankLevel);
     CookingRank    = IntToSkillRankConverter.Convert(character.CookingLevel, out _cookingRankLevel);
     ProcessingRank = IntToSkillRankConverter.Convert(character.ProcessingLevel, out _processingRankLevel);
     GatheringRank  = IntToSkillRankConverter.Convert(character.GatheringLevel, out _gatheringRankLevel);
     FishingRank    = IntToSkillRankConverter.Convert(character.FishingLevel, out _fishingRankLevel);
 }
Beispiel #10
0
        private static void CreateCharacter(CharacterRepository repo)
        {
            Character newCharacter = UserIO.PromptUserForNewCharacter();

            newCharacter = repo.Create(newCharacter);

            UserIO.DisplayCharacter(repo.ReadById(newCharacter.Id));
        }
Beispiel #11
0
 public DataRepository(ITimeService time, MilvanethDbContext context)
 {
     Character = new CharacterRepository(time, context);
     Retainer  = new RetainerRepository(time, context);
     History   = new HistoryRepository(time, context);
     Listing   = new ListingRepository(time, context);
     Overview  = new OverviewRepository(time, context);
 }
Beispiel #12
0
 async void SaveClicked(object sender, EventArgs e)
 {
     try
     {
         character.ClassID = getCharacterClassID();
         character.Race    = pickerRace.SelectedItem.ToString();
         character.Gender  = pickerGender.SelectedItem.ToString();
         if (character.ClassID > 0)
         {
             CharacterRepository ch = new CharacterRepository();
             if (character.ID == 0)
             {
                 await ch.AddCharacter(character);
             }
             else
             {
                 await ch.UpdateCharacter(character);
             }
             thisApp.needCharacterRefresh = true;
             await Navigation.PopAsync();
         }
         else
         {
             await DisplayAlert("Class Not Selected:", "You must set the class.", "Ok");
         }
     }
     catch (AggregateException ex)
     {
         string errMsg = "";
         foreach (var exception in ex.InnerExceptions)
         {
             errMsg += Environment.NewLine + exception.Message;
         }
         await DisplayAlert("One or more exceptions has occurred:", errMsg, "Ok");
     }
     catch (ApiException apiEx)
     {
         var sb = new StringBuilder();
         sb.AppendLine("Errors:");
         foreach (var error in apiEx.Errors)
         {
             sb.AppendLine("-" + error);
         }
         thisApp.needCharacterRefresh = true;
         await DisplayAlert("Problem Saving the Character:", sb.ToString(), "Ok");
     }
     catch (Exception ex)
     {
         if (ex.GetBaseException().Message.Contains("connection with the server"))
         {
             await DisplayAlert("Error", "No connection with the server.", "Ok");
         }
         else
         {
             await DisplayAlert("Error", "Could not complete operation.", "Ok");
         }
     }
 }
Beispiel #13
0
        public async Task Given_invalid_character_id_during_delete_should_throw_an_exception()
        {
            //arrange
            var invalidCharacterId = 0;
            var repository         = new CharacterRepository(DbContext, new UnitOfWork(DbContext));

            //act, assert
            await Assert.ThrowsAsync <NotFoundException>(() => repository.DeleteAsync(invalidCharacterId));
        }
Beispiel #14
0
        public async static Task HandleFile(IAttachment attachment, string mention)
        {
            if (Path.GetExtension(attachment.Filename) != ".xlsx")
            {
                throw new ArgumentException("Format de fichier incorrect.");
            }

            using (HttpClient hclient = new HttpClient())
            {
                Stream stream;
                try
                {
                    stream = await hclient.GetStreamAsync(attachment.Url);
                }
                catch (Exception)
                {
                    try
                    {
                        stream = await hclient.GetStreamAsync(attachment.ProxyUrl);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                MemoryStream memoryStream = new MemoryStream();
                stream.CopyTo(memoryStream);
                using (ExcelPackage package = new ExcelPackage(memoryStream))
                {
                    PlayableCharacter character = null;
                    ExcelWorkbook     workbook  = package.Workbook;
                    ExcelWorksheet    worksheet = workbook.Worksheets["Feuille de personnage"];
                    if (worksheet != null)//Fiche de perso anima
                    {
                        character = new AnimaCharacter(worksheet, mention);
                    }
                    worksheet = workbook.Worksheets["Stat"];
                    if (worksheet != null)//Fiche de perso L5R => peut encore changer
                    {
                        character = new L5RCharacter(worksheet, mention);
                    }

                    int charIndex = CharacterRepository.Characters.FindIndex(x => x.Player == mention && x.Name == character.Name);

                    if (charIndex == -1)
                    {
                        CharacterRepository.Characters.Add(character);
                    }
                    else
                    {
                        CharacterRepository.Characters[charIndex] = character;
                    }

                    CharacterRepository.SaveExcelCharacter(package, mention, character.Name);
                }
            }
        }
Beispiel #15
0
        public static List <MessageConfig> SkipTurn(int chatId)
        {
            //TODO: написать тип SkipStatus
            CharacterRepository character = new CharacterRepository();
            var res        = GameCommandService.SkipTurn(chatId);
            var memberlist = MemberRepository.ReadMemberList(MemberRepository.ReadLobbyId(chatId));
            var username   = character.Read(chatId).CharacterName;

            List <MessageConfig> msg = new List <MessageConfig>();
            //TODO
            var lobby      = LobbyRepository.Read(MemberRepository.ReadLobbyId(chatId));
            var nextPlayer = lobby.Players[lobby.CurrentTurn];

            if (res.CanMakeTurn)
            {
                if (res.PickChest)
                {
                    msg.Add(new MessageConfig
                    {
                        Answer   = String.Format(Answers.SkipTurn.RandomAnswer(), username) + '\n' + String.Format(Answers.MoveChest.RandomAnswer(), username),
                        PlayerId = chatId
                    });

                    msg.AddRange(memberlist
                                 .Where(m => m.UserId != chatId)
                                 .Select(m => new MessageConfig
                    {
                        Answer   = String.Format(AnswersForOther.SkipTurn.RandomAnswer(), username) + '\n' + String.Format(AnswersForOther.MoveChest.RandomAnswer(), username),
                        PlayerId = m.UserId
                    }));
                }
                else
                {
                    msg.Add(new MessageConfig
                    {
                        Answer   = String.Format(Answers.SkipTurn.RandomAnswer(), username) + '\n',
                        PlayerId = chatId
                    });

                    msg.AddRange(memberlist
                                 .Where(m => m.UserId != chatId)
                                 .Select(m => new MessageConfig
                    {
                        Answer   = String.Format(AnswersForOther.SkipTurn.RandomAnswer(), username),
                        PlayerId = m.UserId
                    }));
                }
                msg.Find(e => e.PlayerId == nextPlayer.TelegramUserId).KeyBoardId = GetKeyboardType(nextPlayer);
                return(msg);
            }
            msg.Add(new MessageConfig
            {
                Answer   = String.Format(Answers.NoTurn.RandomAnswer()),
                PlayerId = chatId,
            });
            return(msg);
        }
Beispiel #16
0
 public HomeController()
 {
     characterRepository   = new CharacterRepository(DbContext);
     menuRepository        = new MenuRepository(DbContext);
     contentRepository     = new ContentRepository(DbContext);
     productTypeRepository = new ProductTypeRepository(DbContext);
     productRepository     = new ProductRepository(DbContext);
     contentTypeRepository = new ContentTypeRepository(DbContext);
 }
Beispiel #17
0
        private static void UpdateCharacter(CharacterRepository repo, Character characterInfo)
        {
            string name = UserIO.PromptUser("Please Enter a name");

            characterInfo.Name = name;
            repo.Update(characterInfo.Id, characterInfo);
            Console.Clear();
            UserIO.DisplayCharacter(repo.ReadById(characterInfo.Id));
        }
Beispiel #18
0
        public CharacterRepositoryShould()
        {
            var dbLogger = new Mock <ILogger <InMemoryContext> >();
            var db       = new InMemoryContext(dbLogger.Object);

            var logger = new Mock <ILogger <CharacterRepository> >();

            _characterRepository = new CharacterRepository(db, logger.Object);
        }
Beispiel #19
0
        public async Task <ActionResult> AddForCharacter(int projectid, int characterid)
        {
            var field = await CharacterRepository.GetCharacterAsync(projectid, characterid);

            if (field == null)
            {
                return(HttpNotFound());
            }
            return(View("Add", AddClaimViewModel.Create(field, CurrentUserId)));
        }
Beispiel #20
0
 private static void ReadCharacterById(CharacterRepository repo)
 {
     Character characterInfo = repo.ReadById(UserIO.PromptUserForInt("Enter Id"));
     if (characterInfo != null)
     {
         UserIO.DisplayCharacter(characterInfo);
         // Update Character
         UpdateCharacter(repo, characterInfo);
     }
 }
        public void Dispose_disposes_context()
        {
            var mock = new Mock <IFuturamaContext>();

            using (var repository = new CharacterRepository(mock.Object))
            {
            }

            mock.Verify(m => m.Dispose());
        }
        /// <summary>
        /// Verifies that the provided <see cref="characterId"/>
        /// is owned by the current User claim.
        /// </summary>
        /// <param name="characterId"></param>
        /// <returns></returns>
        public async Task <bool> VerifyCharacterOwnedByAccount(int characterId)
        {
            int accountId = ClaimsReader.GetUserIdInt(User);

            //TODO: Do we want to expose this to non-controlers?
            //First we should validate that the account that is authorized owns the character it is requesting session data from

            return((await CharacterRepository.CharacterIdsForAccountId(accountId).ConfigureAwait(false))
                   .Contains(characterId));
        }
        private static UpdateCharacterHandler CreateHandler(SeiyuuMoeContext dbContext)
        {
            var characterRepository = new CharacterRepository(dbContext);

            var jikanUrl     = ConfigurationReader.JikanUrl;
            var jikanClient  = new Jikan(jikanUrl);
            var jikanService = new JikanService(jikanClient);

            return(new UpdateCharacterHandler(characterRepository, jikanService));
        }
        public async Task <ActionResult> Delete(int projectid, int characterid)
        {
            var field = await CharacterRepository.GetCharacterAsync(projectid, characterid);

            if (field == null)
            {
                return(HttpNotFound());
            }
            return(View(field));
        }
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
            ExecutionContext executionContext)
        {
            Story data = await req.GetFromBody <Story>();

            var results = CharacterRepository.CreateNew(executionContext, "StoryCharacters").GetAllForStory(data.PrimaryKey);

            return((ActionResult) new OkObjectResult(new RequestResponse <Character>(results)));
        }
        private CharacterHealthService InitilizeEnvironment()
        {
            //Typically would use a faking library to fake the repository and not use concrete classes, but since the repository is fake anyway this seemed easier for now and gets the general point across
            CharacterRepository    characterRepository    = new CharacterRepository();
            CharacterHealthService characterHealthService = new CharacterHealthService(characterRepository);
            List <Character>       characters             = new List <Character>();

            characters.Add(DemoStartup.InitilizeDemoCharacter(characterHealthService));
            CharacterRepository.InitilizeCharacterArray(characters);
            return(characterHealthService);
        }
        //[Test]
        public void Create()
        {
            var mobRepo = new MobileRepository();
            var mob     = mobRepo.Create(1, "TestMob");

            var repo   = new CharacterRepository();
            var actual = repo.Create(mob);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.ID, Is.GreaterThanOrEqualTo(1));
        }
        public void Find_given_42_returns_character()
        {
            using (var repository = new CharacterRepository(_context))
            {
                var dto = repository.Find(1);

                Assert.Equal("Fry", dto.Name);
                Assert.Equal("Billy West", dto.ActorName);
                Assert.Equal(1, dto.NumberOfEpisodes);
            }
        }
Beispiel #29
0
        // TODO: Add Character and Armor Controllers
        public static void ConfigureControllers(DataContext context, Mapper mapper, out PotionController potionController, out WeaponController weaponController, out ArmorController armorController, out CharacterController characterController)
        {
            PotionRepository    potionRepository    = new PotionRepository(context);
            WeaponRepository    weaponRepository    = new WeaponRepository(context);
            ArmorRepository     armorRepository     = new ArmorRepository(context);
            CharacterRepository characterRepository = new CharacterRepository(context);

            potionController    = new PotionController(potionRepository, mapper);
            weaponController    = new WeaponController(weaponRepository, mapper);
            armorController     = new ArmorController(armorRepository, mapper);
            characterController = new CharacterController(characterRepository, mapper);
        }
Beispiel #30
0
        public async Task DeleteAsync_given_non_existing_characterId_returns_false()
        {
            using (var connection = await CreateConnectionAsync())
                using (var context = await CreateContextAsync(connection))
                {
                    var repository = new CharacterRepository(context);

                    var deleted = await repository.DeleteAsync(0);

                    Assert.False(deleted);
                }
        }