public IEnumerable <Models.Character> Get(int id, [FromQuery] string username) { List <Models.Character> characters = new List <Models.Character>(); int usrId = UserRepo.GetUserByUsername(username).UserID; foreach (var item in Repo.GetCharacterByCampUsr(id, usrId)) { Models.Character character = new Models.Character(); character.CharacterID = item.CharacterID; character.Name = item.Name; character.Bio = item.Bio; character.Race = Repo.GetRaceById(item.RaceID).Name; character.Class = Repo.GetClassById(item.ClassID).Name; character.CampaignName = CampRepo.GetCampaignById(item.CampaignID).Name; character.Experience = item.Experience; character.Level = item.Level; character.Str = item.Str; character.Dex = item.Dex; character.Con = item.Con; character.Int = item.Int; character.Wis = item.Wis; character.Cha = item.Cha; character.Speed = item.Speed; character.MaxHP = item.MaxHP; characters.Add(character); } return(characters); }
protected bool Equals(Models.Character other) { return(Number == other.Number && Priority == other.Priority && string.Equals(Logograph, other.Logograph) && string.Equals(Pronunciation, other.Pronunciation) && Equals(ReviewTime, other.ReviewTime) && Equals(Definitions, other.Definitions) && Equals(Usages, other.Usages) && Equals(Phrases, other.Phrases) && Equals(Idioms, other.Idioms)); }
// Gets the player's name from input and stores it to the player object public static void WelcomePlayer(Models.Character player) { while (player.Name == null) { TypingAnimation.Animate("Please enter a Player name: ", Color.DarkOrange); Console.Write("> ", Color.Yellow); var input = Console.ReadLine().Trim(); if (!string.IsNullOrWhiteSpace(input)) { player.Name = input[0].ToString().ToUpper() + input.Substring(1); } Console.Clear(); } const string welcomePlayer = "Hello, {0}!"; var playerName = new Formatter(player.Name, Color.Gold); Console.Clear(); Console.WriteLineFormatted(welcomePlayer, Color.YellowGreen, playerName); Console.WriteLine(); TypingAnimation.Animate( "Press <Enter> to spend your (" + player.Attributes.AvailablePoints + ") available Player Trait points...", Color.DarkOrange); Console.ReadLine(); Console.Clear(); }
// Constructor: Add the reference to all the Attribute Objects here public CharacterCreator() { Player = GameCharacters.Player; Charlie = GameCharacters.Charlie; Henry = GameCharacters.Henry; Ghoul = GameCharacters.Ghoul; }
private void OnMouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton != MouseButton.Left || e.ClickCount != 1) { return; } Point p = Mouse.GetPosition(MAP); if (EditorOperation == MapOperations.AddEffect || EditorOperation == MapOperations.RemoveEffect) { ConsumeEditorOperation(Convert.ToInt32(p.X), Convert.ToInt32(p.Y)); } else if (!EditorMode) { int x = (int)(p.X) / CellSize; int y = (int)(p.Y) / CellSize; //: focused on a character Models.Character chr = MapInfo.Characters.FirstOrDefault(c => c.Session.CurrentCoordinate_X.IntegerValue == x && c.Session.CurrentCoordinate_Y.IntegerValue == y); if (chr != null) { FocusedCharacter = chr; } //: move operation occured else if (FocusedCharacter != null) { UIElement[] arr = new UIElement[MAP.Children.Count]; MAP.Children.CopyTo(arr, 0); UserControls.Character characterUC = (UserControls.Character)arr.FirstOrDefault(f => f is UserControls.Character && (f as UserControls.Character).DataContext == FocusedCharacter); Canvas.SetLeft(characterUC, CellSize * x); Canvas.SetTop(characterUC, CellSize * y); FocusedCharacter.Session.CurrentCoordinate_X.IntegerValue = x; FocusedCharacter.Session.CurrentCoordinate_Y.IntegerValue = y; //: way of setting handled FocusedCharacter = null; } //if (x == focusedX && y == focusedY) //{ // focused.Visibility = Visibility.Collapsed; // focusedX = focusedY = -1; // return; //} //if (focused.Visibility == Visibility.Collapsed) focused.Visibility = Visibility.Visible; //Canvas.SetLeft(focused, x * CellSize); //Canvas.SetTop(focused, y * CellSize); //focusedX = x; //focusedY = y; } else { ConsumeEditorOperation(Convert.ToInt32(p.X), Convert.ToInt32(p.Y)); } }
public async Task <ServiceResponse <GetCharacterDto> > AddCharacter(AddCharacterDto newCharacter) { _log.LogInformation("Start Add Character process."); var character = await _dBContext.Characters.FirstOrDefaultAsync(x => x.Name == newCharacter.Name.Trim()); if (!(character is null)) { _log.LogError("Duplicated Character Name."); return(ResponseResult.Failure <GetCharacterDto>("Duplicated Character Name.")); } _log.LogInformation("Add New Character."); var addCharacter = new Models.Character { Name = newCharacter.Name, HitPoints = newCharacter.HitPoints, Strength = newCharacter.Strength, Defense = newCharacter.Defense, Intelligence = newCharacter.Intelligence }; _dBContext.Characters.Add(addCharacter); await _dBContext.SaveChangesAsync(); _log.LogInformation("Success."); var dto = _mapper.Map <GetCharacterDto>(addCharacter); _log.LogInformation("End."); return(ResponseResult.Success(dto)); }
// Helper used by the two methods above public static void RemoveCharacterAttributesByTrait(Models.Character player, ItemTrait trait) { switch (trait.RelevantCharacterAttribute) { case AttributeStrings.Defense: player.Attributes.Defense -= trait.TraitValue; break; case AttributeStrings.Dexterity: player.Attributes.Dexterity -= trait.TraitValue; break; case AttributeStrings.Luck: player.Attributes.Luck -= trait.TraitValue; break; case AttributeStrings.Stamina: player.Attributes.Stamina -= trait.TraitValue; player.MaximumHealthPoints -= CharacterDefaults.HealthPerStaminaPointIncrease * trait.TraitValue; player.HealthPoints -= CharacterDefaults.HealthPerStaminaPointIncrease * trait.TraitValue; break; case AttributeStrings.Strength: player.Attributes.Strength -= trait.TraitValue; break; case AttributeStrings.Wisdom: player.Attributes.Wisdom -= trait.TraitValue; break; case AttributeStrings.MaxCarryingCapacity: player.Attributes.MaximumCarryingCapacity -= trait.TraitValue; break; } }
public CharacterEditPage(CharacterDetailViewModel viewModel) { Data = viewModel.Data; viewModel.Title = "Edit " + viewModel.Title; InitializeComponent(); BindingContext = _viewModel = viewModel; }
public ActionResult Delete(int id, Models.Character model) { try { // TODO: Add delete logic here return(RedirectToAction("Index")); } catch { return(View()); } }
private static string GetCharacterResponse(Models.Character foundCharacter) { var random = new Random(); int randomIndex; if (string.IsNullOrEmpty(foundCharacter?.DesiredItem?.ItemName)) { randomIndex = random.Next(0, foundCharacter.CharacterAppeasedPhrases.Count); return(foundCharacter.CharacterAppeasedPhrases[randomIndex]); } randomIndex = random.Next(0, foundCharacter.CharacterPhrases.Count); return(foundCharacter.CharacterPhrases[randomIndex]); }
public static void PrintExitsToConsole(Models.Character player, Room.Models.Room currentRoom, bool animate = true) { var exits = StringDescriptionBuilder.CreateStringOfExitDescriptions(player, currentRoom.AvailableExits); if (animate) { Console.WriteLine(); TypingAnimation.Animate(exits, Color.Red); } else { Console.WriteLine(exits, Color.Red); } }
public Board PlaceCharacter(Board board) { //Check if character exists if (board.ListOfPieces.Any(p => p.Type == 1)) { return(board); } Models.Character c = new Models.Character(); c.ID = IDofPiece++; c.pos.X = 0; c.pos.Y = board.Height; board.ListOfPieces.Add(c); return(board); }
public static void PrintWeaponsToConsole(Models.Character player, Room.Models.Room currentRoom, bool animate = true) { var weapons = StringDescriptionBuilder.CreateStringOfWeaponDescriptions(player, currentRoom.RoomItems.WeaponItems); if (animate) { Console.WriteLine(); TypingAnimation.Animate(weapons == "" ? ConsoleStrings.NoWeaponsFound + "\n" : weapons, Color.Aquamarine); } else { Console.WriteLine(weapons == "" ? ConsoleStrings.NoWeaponsFound + "\n" : weapons, Color.Aquamarine); } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Character = await _context.Characters .Include(c => c.Player).Include(c => c.Campaign).FirstOrDefaultAsync(m => m.Id == id); if (Character == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Character = await _context.Characters.FindAsync(id); if (Character != null) { _context.Characters.Remove(Character); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public AboutPage() { InitializeComponent(); BindingContext = _viewModel; // Set the flag for Mock on or off... UseMockDataSource.IsToggled = (MasterDataStore.GetDataStoreMockFlag() == DataStoreEnum.Mock); SetDataSource(UseMockDataSource.IsToggled); // Example of how to add an view to an existing set of XAML. // Give the Xaml layout you want to add the data to a good x:Name, so you can access it. Here "DateRoot" is what I am using. var dateLabel = new Label { Text = DateTime.Now.ToShortDateString(), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, FontFamily = "Helvetica Neue", FontAttributes = FontAttributes.Bold, FontSize = 12, TextColor = Color.Black, }; DateRoot.Children.Add(dateLabel); // Set debug settings EnableCriticalMissProblems.IsToggled = GameGlobals.EnableCriticalMissProblems; EnableCriticalHitDamage.IsToggled = GameGlobals.EnableCriticalHitDamage; // Turn off the Debug Frame DebugSettingsFrame.IsVisible = false; // Turn off Forced Random Numbers Frame ForcedRandomValuesSettingsFrame.IsVisible = false; // Turn off Database Settings Frame DatabaseSettingsFrame.IsVisible = false; var myTestItem = new Item(); var myTestCharacter = new Models.Character(); var myTestMonster = new Models.Monster(); var myOutputItem = myTestItem.FormatOutput(); var myOutputCharacter = myTestCharacter.FormatOutput(); var myOutputMonster = myTestMonster.FormatOutput(); }
public ActionResult Create(string name) { try { // TODO: Add insert logic here Models.Character model = new Models.Character(name); Models.GlobalVariables.Characters.Add(model); //return View("Index", model); // single object return(View("Index", Models.GlobalVariables.Characters)); // list } catch { return(View()); } }
// When a user picks up or drops a weapon item, adjusts their attributes accordingly public static void UpdatePlayerAttributesFromWeaponItem(Models.Character player, WeaponItem newWeaponItem, bool removeAttributes = false) { if (newWeaponItem?.WeaponTraits == null) { return; } foreach (var trait in newWeaponItem.WeaponTraits) { if (removeAttributes) { RemoveCharacterAttributesByTrait(player, trait); } else { AddCharacterAttributesByTrait(player, trait); } } }
// Handle when the character chooses to rest public async void RestClicked(object sender, EventArgs args) { Debug.WriteLine("current player's HP before heal: " + _viewModel.BattleEngine.PlayerCurrent.RemainingHP); // This part of code is to populate the sound to play // when user clicks button //var player1 = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer(); //string filename1 = "rest.mp3"; //player1.Load(filename1); //player1.Play(); //after the rest button is clicked, we want to disable all other actions other than submit RestButton.IsEnabled = false; UseItemButton.IsEnabled = false; ableToSelectMonster = false; AttackButton.IsEnabled = false; GameNextButton.IsEnabled = true; ItemPool.IsEnabled = false; _viewModel.BattleEngine.ManualTarget = null; SelectedMonster = null; SelectedMonstersView.SelectedItem = null; //change turn type to be rest _viewModel.BattleEngine.TurnType = MoveEnum.Rest; _viewModel.BattleEngine.PlayerCurrent.RemainingHP = _viewModel.BattleEngine.PlayerCurrent.TotalHP; Models.Character character = _viewModel.BattleEngine.CharacterList.FirstOrDefault(x => x.Name == _viewModel.BattleEngine.PlayerCurrent.Name); foreach (Models.Character c in _viewModel.BattleEngine.CharacterList) { if (c == character) { c.CharacterAttribute.CurrentHealth = c.CharacterAttribute.MaxHealth; } } Debug.WriteLine("current player's HP: " + _viewModel.BattleEngine.PlayerCurrent.RemainingHP); DrawGameBoardAttackerDefender(); localMessages = "Character Rested and regained full HP!"; }
public Models.Character Get(int id) { Models.Character character = new Models.Character(); character.CharacterID = Repo.GetCharacterById(id).CharacterID; character.Name = Repo.GetCharacterById(id).Name; character.Bio = Repo.GetCharacterById(id).Bio; character.Race = Repo.GetRaceById(Repo.GetCharacterById(id).RaceID).Name; character.Class = Repo.GetClassById(Repo.GetCharacterById(id).ClassID).Name; character.CampaignName = CampRepo.GetCampaignById(Repo.GetCharacterById(id).CampaignID).Name; character.Experience = Repo.GetCharacterById(id).Experience; character.Level = Repo.GetCharacterById(id).Level; character.Str = Repo.GetCharacterById(id).Str; character.Dex = Repo.GetCharacterById(id).Dex; character.Con = Repo.GetCharacterById(id).Con; character.Int = Repo.GetCharacterById(id).Int; character.Wis = Repo.GetCharacterById(id).Wis; character.Cha = Repo.GetCharacterById(id).Cha; character.Speed = Repo.GetCharacterById(id).Speed; character.MaxHP = Repo.GetCharacterById(id).MaxHP; return(character); }
// Helper used by the two methods above public static void AddCharacterAttributesByTrait(Models.Character player, ItemTrait trait) { switch (trait.RelevantCharacterAttribute) { case AttributeStrings.Defense: player.Attributes.Defense += trait.TraitValue; break; case AttributeStrings.Dexterity: player.Attributes.Dexterity += trait.TraitValue; break; case AttributeStrings.Luck: player.Attributes.Luck += trait.TraitValue; break; case AttributeStrings.Stamina: player.Attributes.Stamina += trait.TraitValue; player.MaximumHealthPoints += CharacterDefaults.StaminaPerPointIncrease * trait.TraitValue; player.HealthPoints += CharacterDefaults.StaminaPerPointIncrease * trait.TraitValue; break; case AttributeStrings.Strength: player.Attributes.Strength += trait.TraitValue; break; case AttributeStrings.Wisdom: player.Attributes.Wisdom += trait.TraitValue; break; case AttributeStrings.MaxCarryingCapacity: player.Attributes.MaximumCarryingCapacity += trait.TraitValue; break; case AttributeStrings.CarriedItemsCount: player.Attributes.CarriedItemsCount += trait.TraitValue; break; } }
// When a user picks up or drops an inventory item, adjusts their attributes accordingly public static void UpdatePlayerAttributesFromInventoryItem(Models.Character player, InventoryItem newInventoryItem, bool removeAttributes = false) { if (newInventoryItem?.ItemTraits == null || newInventoryItem.TreatItemAs == ItemUseTypes.ConsumableAttribute || newInventoryItem.TreatItemAs == ItemUseTypes.ConsumableAmmo || newInventoryItem.TreatItemAs == ItemUseTypes.ConsumableHealth || newInventoryItem.TreatItemAs == ItemUseTypes.Document || newInventoryItem.TreatItemAs == ItemUseTypes.Key) { return; } foreach (var trait in newInventoryItem.ItemTraits) { if (removeAttributes) { RemoveCharacterAttributesByTrait(player, trait); } else { AddCharacterAttributesByTrait(player, trait); } } }
// This handles any input the player enters inside a room, // and returns the next Room when the player decides to leave the current one public static Room.Models.Room HandlePlayerInput(string fullInput, Models.Character player, Room.Models.Room currentRoom) { var inputWords = fullInput.Split(ConsoleStrings.StringDelimiters); var inputResolved = false; foreach (var inputWord in inputWords) { string substring; List <string> inventoryKeywords; Items foundItem; switch (inputWord) { // We wouldn't normally use so many fall-throughs in an application... // But for a text based game it's really handy for supporting many inputs. // We don't want the user to try a word that should work and get frustrated. case "pickup": case "pick": case "grab": case "get": case "take": case "collect": case "gather": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; var roomItemKeywords = RoomHandler.GetAllRoomItemKeywords(currentRoom); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), roomItemKeywords, currentRoom.RoomItems.InventoryItems, currentRoom.RoomItems.WeaponItems); if (foundItem != null) { InventoryHandler.HandleItemAddOrRemove(player, currentRoom, foundItem, true); inputResolved = true; } break; case "drop": case "release": case "letgo": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; inventoryKeywords = InventoryHandler.GetAllInventoryItemKeywords(player); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), inventoryKeywords, player.CarriedItems, new List <WeaponItem> { player.WeaponItem }); if (foundItem != null) { if (InventoryHandler.PickupOrDropItemIsOk(player, foundItem, false)) { InventoryHandler.HandleItemAddOrRemove(player, currentRoom, foundItem); inputResolved = true; } else { Console.WriteLine(); TypingAnimation.Animate("You cannot drop the " + foundItem.InventoryItems?.First()?.ItemName + " until you drop other items. \n" + "(The item you're trying to drop would decrease your inventory space) \n", Color.DarkOliveGreen); inputResolved = true; } } break; case "go": case "goto": case "goin": case "walk": case "run": case "enter": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; substring = CreateSubstringOfActionInput(fullInput, inputWord); var foundRoom = RoomHandler.FindAnyMatchingRoomByKeywords(substring.Trim(), currentRoom); if (foundRoom != null) { if (RoomHandler.DoesPlayerMeetRequirementsToEnter(player, currentRoom, foundRoom)) { return(foundRoom); } inputResolved = true; } break; case "talk": case "speak": case "chat": case "say": case "ask": case "tell": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; if (currentRoom.RoomCharacters.Any()) { substring = CreateSubstringOfActionInput(fullInput, inputWord); var character = RoomHandler.FindAnyMatchingCharacterByKeywords(substring.Trim(), currentRoom); if (character != null) { var characterResponse = GetCharacterResponse(character); Console.WriteLine(); Console.WriteLine(characterResponse + "\n", Color.Gold); inputResolved = true; } } else { Console.WriteLine("\nThere is no one here to talk to...", Color.DarkOliveGreen); inputResolved = true; } break; case "give": case "trade": case "offer": case "hand": case "toss": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; inputResolved = InventoryHandler.HandlePlayerTradingItem(fullInput, player, currentRoom, inputWord, inputResolved); break; case "fight": case "kill": case "attack": // TODO: Implement the combat system if an enemy is in the room... break; case "use": case "consume": case "eat": case "drink": case "read": case "look at": case "open": case "swing": case "shoot": case "fire": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; inventoryKeywords = InventoryHandler.GetAllInventoryItemKeywords(player); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), inventoryKeywords, player.CarriedItems, new List <WeaponItem> { player.WeaponItem }); if (foundItem != null) { inputResolved = InventoryHandler.HandleItemBeingUsed(player, foundItem, inputWord); } break; case "item": case "items": player.PersistDisplayedItems = true; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; inputResolved = true; break; case "weapon": case "weapons": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = true; player.PersistDisplayedExits = false; inputResolved = true; break; case "exit": case "exits": case "leave": case "door": case "doors": case "out": case "where": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = true; inputResolved = true; break; case "inventory": case "inv": case "carried": case "carrying": case "pockets": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; var playerInventory = StringDescriptionBuilder.CreateStringOfPlayerInventory(player, true); Console.WriteLine(); Console.WriteLine(playerInventory, Color.ForestGreen); inputResolved = true; break; case "character": case "status": case "stat": case "stats": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; var characterInfo = StringDescriptionBuilder.CreateStringOfPlayerInfo(player); Console.WriteLine(); Console.WriteLine(characterInfo, Color.ForestGreen); inputResolved = true; break; case "info": case "help": case "guidance": case "assist": case "assistance": case "?": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; Console.ReplaceAllColorsWithDefaults(); Console.WriteLineStyled(ConsoleStrings.GameHelp, ConsoleStringStyleSheets.GameHelpStyleSheet(Color.MediumPurple)); inputResolved = true; break; case "helpoff": case "helpon": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; player.ShowInputHelp = !player.ShowInputHelp; Console.WriteLine( player.ShowInputHelp ? "\nInput words shown above prompt text." : "\nInput words hidden from prompt text.", Color.MediumPurple); Console.WriteLine(); inputResolved = true; break; case "save": // This isn't really necessary, I just liked the idea of the user having to complete the tutorial first if (currentRoom.RoomName == "Your Bedroom") { Console.WriteLine($"\nYou need to leave {currentRoom.RoomName} before you can save.", Color.DarkOrange); inputResolved = true; break; } Console.WriteLine("\nSave the game and close? (y/n)", Color.White); Console.WriteLine("Note - This will overwrite any current save file!", Color.White); Console.Write(">", Color.White); var response = Console.ReadLine(); if (!string.IsNullOrEmpty(response) && response.ToLower()[0].Equals('y')) { return(new Room.Models.Room { RoomName = ConsoleStrings.SaveGame }); } Console.WriteLine("\nSave cancelled.", Color.White); inputResolved = true; break; } } // We don't know what the user is trying to do at this point if (!inputResolved) { Console.WriteLine(); TypingAnimation.Animate("You " + fullInput + "...", Color.Chartreuse, 40); TypingAnimation.Animate(". . . Nothing happens. \n", Color.Chartreuse, 40); } // Keeps the Item, Weapon, or Exit descriptions displayed for easier play if (!player.PersistDisplayedItems && !player.PersistDisplayedWeapons && !player.PersistDisplayedExits) { Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4); Console.ReadLine(); } Console.Clear(); Console.ReplaceAllColorsWithDefaults(); return(null); }
// Constructor: Add the reference to all the Attribute Objects here public CharacterCreator() { Player = GameCharacters.Player; Ghoul = GameCharacters.Ghoul; }
// Continuously asks user for a trait to add a point to until all available point are spent public static void SetPlayerTraits(Models.Character player) { var pendingPlayerAttributes = player.Attributes; var displayInfo = false; var playerReady = false; while (!playerReady) { string input; while (pendingPlayerAttributes.AvailablePoints > 0) { TypingAnimation.Animate( player.Name + ", you have (" + pendingPlayerAttributes.AvailablePoints + ") points to spend.", Color.Chartreuse, 20); Console.WriteLine(); Console.WriteLine("Current trait values:", Color.DarkOrange); Console.WriteLine("\t1. (Def)ense \t= " + pendingPlayerAttributes.Defense, Color.AliceBlue); if (displayInfo) { Console.WriteLine("\t - How resilient your character is to damage.", Color.Gray); Console.WriteLine(); } Console.WriteLine("\t2. (Dex)terity \t= " + pendingPlayerAttributes.Dexterity, Color.AliceBlue); if (displayInfo) { Console.WriteLine("\t - How agile or evasive your character is.", Color.Gray); Console.WriteLine(); } Console.WriteLine("\t3. (Luc)k \t= " + pendingPlayerAttributes.Luck, Color.AliceBlue); if (displayInfo) { Console.WriteLine("\t - How fortunate your character will be in their adventure.", Color.Gray); Console.WriteLine(); } Console.WriteLine("\t4. (Sta)mina \t= " + pendingPlayerAttributes.Stamina, Color.AliceBlue); if (displayInfo) { Console.WriteLine("\t - How many overall Health Points your character can have.", Color.Gray); Console.WriteLine(); } Console.WriteLine("\t5. (Str)ength \t= " + pendingPlayerAttributes.Strength, Color.AliceBlue); if (displayInfo) { Console.WriteLine("\t - How strong your character is; how much damage they can do.", Color.Gray); Console.WriteLine(); } Console.WriteLine("\t6. (Wis)dom \t= " + pendingPlayerAttributes.Wisdom, Color.AliceBlue); if (displayInfo) { Console.WriteLine("\t - How knowledgeable, sensible, or perceptive your character is " + "\n\t in regard to situations or their surroundings.", Color.Gray); Console.WriteLine(); } Console.WriteLine("\t?. Info - Toggle info on what each trait does...", Color.Gray); Console.WriteLine(); Console.WriteLine("Enter the number or trait name you'd like to add (1) point to.", Color.OrangeRed); Console.Write("> ", Color.Yellow); input = Console.ReadLine().ToLower(); if (input == "?" || input == "info") { displayInfo = !displayInfo; Console.Clear(); continue; } pendingPlayerAttributes = UpdateCharacterAttributesByInput(pendingPlayerAttributes, input); Console.Clear(); } TypingAnimation.Animate(player.Name + ", here are your final trait values: \n", Color.Red); Console.WriteLine("\tDefense \t= " + pendingPlayerAttributes.Defense, Color.AliceBlue); Console.WriteLine("\tDexterity \t= " + pendingPlayerAttributes.Dexterity, Color.AliceBlue); Console.WriteLine("\tLuck \t\t= " + pendingPlayerAttributes.Luck, Color.AliceBlue); Console.WriteLine("\tStamina \t= " + pendingPlayerAttributes.Stamina, Color.AliceBlue); Console.WriteLine("\tStrength \t= " + pendingPlayerAttributes.Strength, Color.AliceBlue); Console.WriteLine("\tWisdom \t\t= " + pendingPlayerAttributes.Wisdom, Color.AliceBlue); Console.WriteLine(); Console.WriteLine("Do you want to begin your adventure? (y/n)", Color.AntiqueWhite); Console.Write("> ", Color.Yellow); input = Console.ReadLine().ToLower(); switch (input) { case "n": case "no": pendingPlayerAttributes = new CharacterAttribute(); Console.Clear(); Console.ReplaceAllColorsWithDefaults(); break; default: playerReady = true; Console.Clear(); break; } } var healthIncrease = CharacterDefaults.HealthPerStaminaPointIncrease * (pendingPlayerAttributes.Stamina - CharacterDefaults.DefaultValueForAllAttributes); player.Attributes = pendingPlayerAttributes; player.MaximumHealthPoints += healthIncrease; player.HealthPoints += healthIncrease; }
// This handles any input the player enters inside a room, // and returns the next Room when the player decides to leave the current one public static Room.Models.Room HandlePlayerInput(string fullInput, Models.Character player, Room.Models.Room currentRoom) { var inputWords = fullInput.Split(ConsoleStrings.StringDelimiters); var inputResolved = false; foreach (var inputWord in inputWords) { string substring; Items foundItem; switch (inputWord) { case "pickup": case "grab": case "get": case "take": case "collect": case "gather": var roomItemKeywords = RoomHandler.GetAllRoomItemKeywords(currentRoom); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), roomItemKeywords, currentRoom.RoomItems.InventoryItems, currentRoom.RoomItems.WeaponItems); if (foundItem != null) { InventoryHandler.HandleItemAddOrRemove(player, currentRoom, foundItem, true); inputResolved = true; } break; case "drop": case "release": case "letgo": var inventoryKeywords = InventoryHandler.GetAllInventoryItemKeywords(player); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), inventoryKeywords, player.CarriedItems, new List <WeaponItem>() { player.WeaponItem }); if (foundItem != null) { InventoryHandler.HandleItemAddOrRemove(player, currentRoom, foundItem); inputResolved = true; } break; case "go": case "goto": case "goin": case "walk": case "run": case "enter": substring = CreateSubstringOfActionInput(fullInput, inputWord); var foundRoom = RoomHandler.FindAnyMatchingRoomByKeywords(substring.Trim(), currentRoom); if (foundRoom != null) { Console.WriteLine(); TypingAnimation.Animate("You go into " + foundRoom.RoomName + "... \n", Color.Chartreuse, 40); Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4); Console.ReadLine(); if (!currentRoom.RoomEntered) { currentRoom.RoomEntered = true; } return(foundRoom); } break; case "item": case "items": var items = StringDescriptionBuilder.CreateStringOfItemDescriptions(currentRoom.RoomItems.InventoryItems); Console.WriteLine(); TypingAnimation.Animate(items == "" ? ConsoleStrings.NoItemsFound : items, Color.Aquamarine); inputResolved = true; break; case "weapon": case "weapons": var weapons = StringDescriptionBuilder.CreateStringOfWeaponDescriptions(currentRoom.RoomItems.WeaponItems); Console.WriteLine(); TypingAnimation.Animate(weapons == "" ? ConsoleStrings.NoWeaponsFound : weapons, Color.Aquamarine); inputResolved = true; break; case "exit": case "exits": case "leave": case "door": case "doors": case "out": case "where": var exits = StringDescriptionBuilder.CreateStringOfExitDescriptions(currentRoom.AvailableExits); Console.WriteLine(); TypingAnimation.Animate(exits, Color.Red); inputResolved = true; break; case "inventory": case "inv": case "carried": case "carrying": case "pockets": var playerInventory = StringDescriptionBuilder.CreateStringOfPlayerInventory(player, true); Console.WriteLine(); Console.WriteLine(playerInventory, Color.ForestGreen); inputResolved = true; break; case "character": case "status": case "stat": case "stats": var characterInfo = StringDescriptionBuilder.CreateStringOfPlayerInfo(player); Console.WriteLine(); Console.WriteLine(characterInfo, Color.ForestGreen); inputResolved = true; break; case "info": case "help": case "guidance": case "assist": case "assistance": case "?": var exitDescriptions = StringDescriptionBuilder.CreateStringOfExitDescriptions(currentRoom.AvailableExits); Console.WriteLine(); Console.WriteLine(currentRoom.GenericRoomDescription, Color.Bisque); Console.WriteLine(exitDescriptions, Color.Red); Console.WriteLine(ConsoleStrings.GameHelp, Color.MediumPurple); inputResolved = true; break; } } if (!inputResolved) { Console.WriteLine(); TypingAnimation.Animate("You " + fullInput + "...", Color.Chartreuse, 40); TypingAnimation.Animate(". . . Nothing happens. \n", Color.Chartreuse, 40); } Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4); Console.ReadLine(); Console.Clear(); Console.ReplaceAllColorsWithDefaults(); return(null); }
/// <summary> /// Returns a list of Typographic Variants for a character supported by the font. /// </summary> public static List <TypographyFeatureInfo> GetCharacterVariants(FontVariant font, Models.Character character) { var textAnalyzer = new CanvasTextAnalyzer(character.Char, CanvasTextDirection.TopToBottomThenLeftToRight); KeyValuePair <CanvasCharacterRange, CanvasAnalyzedScript> analyzed = textAnalyzer.GetScript().First(); List <TypographyFeatureInfo> supported = new List <TypographyFeatureInfo> { TypographyFeatureInfo.None }; foreach (var feature in font.XamlTypographyFeatures) { if (feature == TypographyFeatureInfo.None) { continue; } var glyphs = textAnalyzer.GetGlyphs(analyzed.Key, font.FontFace, 24, false, false, analyzed.Value); bool[] results = font.FontFace.GetTypographicFeatureGlyphSupport(analyzed.Value, feature.Feature, glyphs); if (results.Any(r => r)) { supported.Add(feature); } } return(supported); }
public CharacterDetailPage(Models.Character character) { InitializeComponent(); BindingContext = character; }