public GamePokeCreateTextResponse Execute(GamePokeCreateTextRequest request) { if (request.Game.Finish > request.Now) { return(CurrentRun(request)); } else { return(Finished(request)); } }
private void X(StringBuilder text, GamePokeCreateTextRequest request) { var choice = request.Game; var pokeNames = EventBot.Models.GoMap.Helper.PokeNames; var values = this.getPokeBaseValuesQuery.Execute(new GetPokeBaseValuesRequest()); var targetPoke = new PokeData { PokeMoveType = (ElementType)request.Game.TargetPokeMoveTyp, Values = values[request.Game.TargetPokeId] }; var pokes = new PokeData[] { new PokeData { PokeId = choice.Choice1PokeId, Name = pokeNames[choice.Choice1PokeId], PokeMoveType = (ElementType)choice.Choice1PokeMoveTyp, Values = values[choice.Choice1PokeId] }, new PokeData { PokeId = choice.Choice2PokeId, Name = pokeNames[choice.Choice2PokeId], PokeMoveType = (ElementType)choice.Choice2PokeMoveTyp, Values = values[choice.Choice2PokeId] }, new PokeData { PokeId = choice.Choice3PokeId, Name = pokeNames[choice.Choice3PokeId], PokeMoveType = (ElementType)choice.Choice3PokeMoveTyp, Values = values[choice.Choice3PokeId] }, new PokeData { PokeId = choice.Choice4PokeId, Name = pokeNames[choice.Choice4PokeId], PokeMoveType = (ElementType)choice.Choice4PokeMoveTyp, Values = values[choice.Choice4PokeId] }, }; var y = pokes.Select(x => MatchOrder(targetPoke, x)); var grouped = y.GroupBy(x => x.Points, x => x.PokeData).OrderByDescending(x => x.Key); foreach (var result in grouped) { text.AppendLine(PointsAsIcon(result.Key) + " (" + result.Key.ToString("0.000") + ")"); foreach (var poke in result.OrderBy(x => x.Name)) { var textType = " (" + Translate(poke.Values.type1) + (poke.Values.type2 == null ? "" : ", " + Translate(poke.Values.type2.Value)) + ")"; text.AppendLine(" " + poke.Name + textType); } var currentPokes = result.Select(x => x.PokeId).ToArray(); var orderedVotes = request.Votes.Where(x => currentPokes.Contains(x.Choice)).OrderBy(x => x.Created); foreach (var vote in orderedVotes) { text.AppendLine(" " + vote.UserName); } } }
private GamePokeCreateTextResponse CurrentRun(GamePokeCreateTextRequest request) { var pokeNames = EventBot.Models.GoMap.Helper.PokeNames; StringBuilder text = new StringBuilder($"{(request.Game.Finish - request.Now).Seconds} Sek."); text.AppendLine(); text.AppendLine("Gegner:"); CreatePokeWithTyping(text, request.Game.TargetPokeId, request.Game.TargetPokeMoveTyp); text.AppendLine("Wahl 1:"); CreatePokeWithTyping(text, request.Game.Choice1PokeId, request.Game.Choice1PokeMoveTyp); text.AppendLine("Wahl 2:"); CreatePokeWithTyping(text, request.Game.Choice2PokeId, request.Game.Choice2PokeMoveTyp); text.AppendLine("Wahl 3:"); CreatePokeWithTyping(text, request.Game.Choice3PokeId, request.Game.Choice3PokeMoveTyp); text.AppendLine("Wahl 4:"); CreatePokeWithTyping(text, request.Game.Choice4PokeId, request.Game.Choice4PokeMoveTyp); var keyBoardPoke1 = new[] { new InlineKeyboardButton(pokeNames[request.Game.Choice1PokeId]) { CallbackData = request.Game.Choice1PokeId.ToString() }, }; var keyBoardPoke2 = new[] { new InlineKeyboardButton(pokeNames[request.Game.Choice2PokeId]) { CallbackData = request.Game.Choice2PokeId.ToString() }, }; var keyBoardPoke3 = new[] { new InlineKeyboardButton(pokeNames[request.Game.Choice3PokeId]) { CallbackData = request.Game.Choice3PokeId.ToString() }, }; var keyBoardPoke4 = new[] { new InlineKeyboardButton(pokeNames[request.Game.Choice4PokeId]) { CallbackData = request.Game.Choice4PokeId.ToString() }, }; var inlineKeyboard = new InlineKeyboardMarkup(new InlineKeyboardButton[4][] { keyBoardPoke1, keyBoardPoke2, keyBoardPoke3, keyBoardPoke4 }); return(new GamePokeCreateTextResponse(Text: text.ToString(), InlineKeyboardMarkup: inlineKeyboard, ParseMode: ParseMode.Markdown)); }
private GamePokeCreateTextResponse Finished(GamePokeCreateTextRequest request) { var values = this.getPokeBaseValuesQuery.Execute(new GetPokeBaseValuesRequest()); var targetPoke = values[request.Game.TargetPokeId]; var pokeNames = EventBot.Models.GoMap.Helper.PokeNames; StringBuilder text = new StringBuilder(); text.AppendLine("Ergebnis:"); text.AppendLine(pokeNames[request.Game.TargetPokeId] + " (" + Translate(targetPoke.type1) + (targetPoke.type2 == null ? "" : ", " + Translate(targetPoke.type2.Value)) + ")"); // CreateTextLine(text, request.Votes.Where(x => x.Choice == request.Game.Choice1PokeId), // request.Game.TargetPokeId, request.Game.TargetPokeMoveTyp, request.Game.Choice1PokeId, request.Game.Choice1PokeMoveTyp); // CreateTextLine(text, request.Votes.Where(x => x.Choice == request.Game.Choice2PokeId), // request.Game.TargetPokeId, request.Game.TargetPokeMoveTyp, request.Game.Choice2PokeId, request.Game.Choice2PokeMoveTyp); // CreateTextLine(text, request.Votes.Where(x => x.Choice == request.Game.Choice3PokeId), // request.Game.TargetPokeId, request.Game.TargetPokeMoveTyp, request.Game.Choice3PokeId, request.Game.Choice3PokeMoveTyp); // CreateTextLine(text, request.Votes.Where(x => x.Choice == request.Game.Choice4PokeId), // request.Game.TargetPokeId, request.Game.TargetPokeMoveTyp, request.Game.Choice4PokeId, request.Game.Choice4PokeMoveTyp); X(text, request); return(new GamePokeCreateTextResponse(Text: text.ToString())); }