private string GenerateMissionGatherDetail(MissionGather mission) { StringBuilder sb = new StringBuilder(); sb.Clear(); sb.AppendLine("All Required Game Items (Quantity)"); foreach (var gameItemQuatity in mission.RequiredGameItemQuantities) { sb.Append(TAB + gameItemQuatity.GameItem.Name); sb.AppendLine($" ( {gameItemQuatity.Quantity})"); } if (mission.status == Mission.MissionStatus.Incomplete) { sb.AppendLine("Game Items Yet to Gather (Quantity)"); foreach (var gameItemQuantity in mission.GameItemQuantitiesNotCompleted(_player.Inventory.ToList())) { int quantityInInventory = 0; GameItemQuantity gameItemQyantityGathered = _player.Inventory.FirstOrDefault(gi => gi.GameItem.id == gameItemQuantity.GameItem.id); if (gameItemQyantityGathered != null) { quantityInInventory = gameItemQyantityGathered.Quantity; } sb.Append(TAB + gameItemQuantity.GameItem.Name); sb.AppendLine($"({gameItemQuantity.Quantity - quantityInInventory})"); } } sb.Remove(sb.Length - 2, 2); return(sb.ToString()); }
public void RemoveItemFromInventory() { // // confirm a game item selected and is in inventory // subtract from inventory and add to location // if (_currentGameItem != null && _player.Inventory.Contains(_currentGameItem)) { // // cast selected game item // GameItemQuantity selectedgameitem = _currentGameItem as GameItemQuantity; if (selectedgameitem.GameItem.ItemID < 200 || selectedgameitem.GameItem.ItemID > 300) { if (_currentLocation.Id == 3) { _currentLocation.AddGameItemQuantityToLocation(selectedgameitem); _player.RemoveGameItemQuantityFromInventory(selectedgameitem); } else { _player.RemoveGameItemQuantityFromInventory(selectedgameitem); } } } }
public void EquipWeapon() { GameItemQuantity selectedgameitem = _currentGameItem as GameItemQuantity; if (_currentGameItem != null) { if (selectedgameitem.GameItem.ItemID < 200 && selectedgameitem.GameItem.ItemID > 100) { if (_player.WeaponCarried != null) { _player.AddGameItemQuantityToInventory(_player.WeaponCarried); } _player.WeaponCarried = selectedgameitem; _player.RemoveGameItemQuantityFromInventory(selectedgameitem); _player.CurrentWeapon = _player.WeaponName(); } else if (selectedgameitem.GameItem.ItemID > 300 && selectedgameitem.GameItem.ItemID < 400) { if (_player.ItemCarried != null) { _player.AddGameItemQuantityToInventory(_player.ItemCarried); } _player.ItemCarried = selectedgameitem; _player.RemoveGameItemQuantityFromInventory(selectedgameitem); _player.CurrentItem = _player.ReturnItemCarried(); } _currentGameItem = null; } }
public void RemoveItemFromInventory() { if (_currentGameItem != null) { GameItemQuantity selectedGameItemQuantity = _currentGameItem as GameItemQuantity; _player.RemoveGameItemFromInventory(selectedGameItemQuantity); } }
/// <summary> /// add item from location to player's inventory /// </summary> public void AddItemToInventory() { if (_currentGameItem != null && _currentLocation.GameItems.Contains(_currentGameItem)) { GameItemQuantity selectedGameItemQuantity = _currentGameItem as GameItemQuantity; _currentLocation.RemoveGameItemQuantityFromLocation(selectedGameItemQuantity); _player.AddGameItemToInventory(selectedGameItemQuantity); } }
public void EquipWeapon() { GameItemQuantity selectedgameitem = _currentGameItem as GameItemQuantity; if (_currentGameItem != null && _player.Inventory.Contains(selectedgameitem)) { if (selectedgameitem.GameItem is Weapon) { if (_player.WeaponCarried != null) { _player.AddGameItemQuantityToInventory(_player.WeaponCarried); } _player.WeaponCarried = selectedgameitem; _player.RemoveGameItemQuantityFromInventory(selectedgameitem); _player.CurrentWeapon = _player.WeaponName(); _player.MyWeapon = selectedgameitem.GameItem as Weapon; } else if (selectedgameitem.GameItem is ActionItem) { if (_player.ItemCarried != null) { _player.AddGameItemQuantityToInventory(_player.ItemCarried); } _player.ItemCarried = selectedgameitem; _player.RemoveGameItemQuantityFromInventory(selectedgameitem); _player.CurrentItem = _player.ReturnItemCarried(); } _currentGameItem = null; } else if (_currentGameItem != null && _currentLocation.GameItems.Contains(selectedgameitem)) { if (selectedgameitem.GameItem is Weapon) { if (_player.WeaponCarried != null) { _player.AddGameItemQuantityToInventory(_player.WeaponCarried); } _player.WeaponCarried = selectedgameitem; _currentLocation.RemoveGameItemQuantityFromLocation(selectedgameitem); _player.CurrentWeapon = _player.WeaponName(); _player.MyWeapon = selectedgameitem.GameItem as Weapon; } else if (selectedgameitem.GameItem is ActionItem) { if (_player.ItemCarried != null) { _player.AddGameItemQuantityToInventory(_player.ItemCarried); } _player.ItemCarried = selectedgameitem; _currentLocation.RemoveGameItemQuantityFromLocation(selectedgameitem); _player.CurrentItem = _player.ReturnItemCarried(); } _currentGameItem = null; } }
/// <summary> /// Takes item from player inventory and adds it to location. /// </summary> public void RemoveItemFromPlayerInventory() { if (_currentGameItem != null) { GameItemQuantity selectedGameItemQuantity = _currentGameItem as GameItemQuantity; _currentLocation.AddGameItemToInventory(selectedGameItemQuantity); _player.RemoveGameItemFromInventory(selectedGameItemQuantity); // OnPlayerPutDown(selectedGameItemQuantity); } }
/// <summary> /// Takes item from location and adds it to the player's inventory /// </summary> public void AddItemToPlayerInventory() { if (_currentGameItem != null && _currentLocation.LocationInventory.Contains(_currentGameItem)) { GameItemQuantity selectedGameItemQuantity = _currentGameItem as GameItemQuantity; _currentLocation.RemoveGameItemFromInventory(selectedGameItemQuantity); _player.AddGameItemToInventory(selectedGameItemQuantity); //OnPlayerPickup(selectedGameItemQuantity); } }
/// <summary> /// calculates player defense /// </summary> /// <returns></returns> public int CalculateDefense() { int calculatedDefense = 0; GameItemQuantity soldierInInventory = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "LEG"); if (soldierInInventory != null) { calculatedDefense = soldierInInventory.Quantity * 3; } return(calculatedDefense); }
/// <summary> /// calculates player attack /// </summary> /// <returns></returns> public int CalculateAttack() { int calculatedAttack = 0; GameItemQuantity soldierInInventory = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "LEG"); if (soldierInInventory != null) { calculatedAttack = soldierInInventory.Quantity * 1; } return(calculatedAttack); }
public void AddItemToInventory() { // confirm a game item selected and is in current location // subtract from location and add to inventory if (_currentGameItem != null && _currentLocation.GameItems.Contains(_currentGameItem)) { // cast selected game item GameItemQuantity selectedGameItemQuantity = _currentGameItem as GameItemQuantity; _currentLocation.RemoveGameItemQuantityFromLocation(selectedGameItemQuantity); _player.AddGameItemQuantityToInventory(selectedGameItemQuantity); OnPlayerPickUp(selectedGameItemQuantity); } }
public void AddItemToInventory() { if (_currentGameItem != null && _currentLocation.GameItems.Contains(_currentGameItem)) { // // cast selected game item // GameItemQuantity selectedGameItem = _currentGameItem as GameItemQuantity; _currentLocation.RemoveGameItemQuantityFromLocation(selectedGameItem); _player.AddGameItemQuantityToInventory(selectedGameItem); OnPlayerPickUp(selectedGameItem); } }
public void RemoveItemFromInventory() { // confirm a game item selected and is in inventory // subtract from inventory and add to location if (_currentGameItem != null) { // cast selected game item GameItemQuantity selectedGameItemQuantity = _currentGameItem as GameItemQuantity; _currentLocation.AddGameItemQuantityToLocation(selectedGameItemQuantity); _player.RemoveGameItemQuantityFromInventory(selectedGameItemQuantity); OnPlayerPutDown(selectedGameItemQuantity); } }
public void AddItemToInventory() { if (_currentGameItem != null && _currentLocation.GameItems.Contains(_currentGameItem) && (_currentLocation.Id != 2 || _currentLocation.Id != 5)) { // // cast selected game item // GameItemQuantity selectedGameItem = _currentGameItem as GameItemQuantity; if (selectedGameItem.GameItem is Currency) { OnPlayerPickUp(selectedGameItem); _currentLocation.RemoveGameItemQuantityFromLocation(selectedGameItem); } else { if (selectedGameItem.GameItem.ItemID == 307) { } _currentLocation.RemoveGameItemQuantityFromLocation(selectedGameItem); _player.AddGameItemQuantityToInventory(selectedGameItem); OnPlayerPickUp(selectedGameItem); } } else if (_currentGameItem != null && CharacterInventory.Contains(_currentGameItem)) { GameItemQuantity selectedGameItem = _currentGameItem as GameItemQuantity; if (selectedGameItem.GameItem.ItemCost == 0) { _player.AddGameItemQuantityToInventory(selectedGameItem); CharacterInventory.Remove(selectedGameItem); } else if (_player.BootyValue >= selectedGameItem.GameItem.ItemCost) { int newBoooty = _player.BootyValue; _player.AddGameItemQuantityToInventory(selectedGameItem); _player.BootyValue = newBoooty - selectedGameItem.GameItem.ItemCost; CharacterInventory.Remove(selectedGameItem); } else { _currentLocation.Message = "Please comeback with proper funds"; } } }
public void RemoveGameItemQuantityFromLocation(GameItemQuantity selectedGameItemQuantity) { GameItemQuantity gameItemQuantity = _gameItems.FirstOrDefault(i => i.GameItem.Id == selectedGameItemQuantity.GameItem.Id); if (gameItemQuantity != null) { if (selectedGameItemQuantity.Quantity == 1) { _gameItems.Remove(gameItemQuantity); } else { gameItemQuantity.Quantity--; } } UpdateLocationGameItems(); }
public void AddGameItemToLocation(GameItemQuantity selectedGameItemQuantity) { GameItemQuantity gameItemQuantity = _gameItems.FirstOrDefault(i => i.GameItem.Id == selectedGameItemQuantity.GameItem.Id); if (gameItemQuantity == null) { GameItemQuantity newGameItemQuantity = new GameItemQuantity(); newGameItemQuantity.GameItem = selectedGameItemQuantity.GameItem; newGameItemQuantity.Quantity = 1; _gameItems.Add(newGameItemQuantity); } else { gameItemQuantity.Quantity++; } UpdateLocationGameItems(); }
/// <param name="selectedGameItemQuantity">selected item</param> public void RemoveGameItemQuantityFromInventory(GameItemQuantity selectedGameItemQuantity) { // // locate selected item in inventory // GameItemQuantity gameItemQuantity = _inventory.FirstOrDefault(i => i.GameItem.Id == selectedGameItemQuantity.GameItem.Id); if (gameItemQuantity != null) { if (selectedGameItemQuantity.Quantity == 1) { _inventory.Remove(gameItemQuantity); } else { gameItemQuantity.Quantity--; } } UpdateInventoryCategories(); }
public void UseGameItem() { GameItemQuantity selectedgameitem = _currentGameItem as GameItemQuantity; if (_player.ItemCarried != null) { selectedgameitem = _player.ItemCarried; if (selectedgameitem.GameItem.ItemID < 400 && selectedgameitem.GameItem.ItemID > 300) { if (selectedgameitem.GameItem.ItemID == 301) { _gameMap.UpdateLocationAccesible(_player); UpdateAvailableTravelPoints(); } _player.HitPoints += selectedgameitem.GameItem.HealthChange; if (_player.HitPoints >= 100) { _player.Lives++; _player.HitPoints -= 100; } _player.CurrentItem = _player.UpdateItem(); } } else if (_currentGameItem != null) { if (selectedgameitem.GameItem.ItemID < 400 && selectedgameitem.GameItem.ItemID > 300) { _player.HitPoints += selectedgameitem.GameItem.HealthChange; if (_player.HitPoints >= 100) { _player.Lives++; _player.HitPoints -= 100; } _player.RemoveGameItemQuantityFromInventory(_currentGameItem); _player.CurrentWeapon = _player.ReturnItemCarried(); } } }
/// <summary> /// add selected item to inventory or update quantity if already in inventory /// </summary> /// <param name="selectedGameItemQuantity">selected item</param> public void AddGameItemQuantityToInventory(GameItemQuantity selectedGameItemQuantity) { // // locate selected item in inventory // GameItemQuantity gameItemQuantity = _inventory.FirstOrDefault(i => i.GameItem.Id == selectedGameItemQuantity.GameItem.Id); if (gameItemQuantity == null) { GameItemQuantity newGameItemQuantity = new GameItemQuantity(); newGameItemQuantity.GameItem = selectedGameItemQuantity.GameItem; newGameItemQuantity.Quantity = 1; _inventory.Add(newGameItemQuantity); } else { gameItemQuantity.Quantity++; } UpdateInventoryCategories(); }
/// <summary> /// generate the text for an gather mission detail /// </summary> /// <param name="mission">the mission</param> /// <returns>mission detail text</returns> private string GenerateMissionGatherDetail(MissionGather mission) { StringBuilder sb = new StringBuilder(); sb.Clear(); sb.AppendLine("All Required Game Items (Quantity)"); foreach (var gameItemQuantity in mission.RequiredGameItemQuantities) { sb.Append(TAB + gameItemQuantity.GameItem.Name); sb.AppendLine($" ( {gameItemQuantity.Quantity} )"); } if (mission.Status == Mission.MissionStatus.Incomplete) { sb.AppendLine("Game Items Yet to Gather (Quantity)"); foreach (var gameItemQuantity in mission.GameItemQuantitiesNotCompleted(_player.Inventory.ToList())) { // // get the current quantity of game item in inventory // int quantityInInventory = 0; GameItemQuantity gameItemQuantityGatherered = _player.Inventory.FirstOrDefault(gi => gi.GameItem.Id == gameItemQuantity.GameItem.Id); if (gameItemQuantityGatherered != null) { quantityInInventory = gameItemQuantityGatherered.Quantity; } sb.Append(TAB + gameItemQuantity.GameItem.Name); sb.AppendLine($" ( {gameItemQuantity.Quantity - quantityInInventory} )"); } } sb.Remove(sb.Length - 2, 2); // remove the last two characters that generate a blank line return(sb.ToString());; }
private void ProcessBuffUse(Buff buff) { if (buff.Id == "INS") { Player.Defense = Player.Defense + 100; } if (buff.Id == "BOL") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "LEG"); if (gameItemQuantity != null) { gameItemQuantity.Quantity += 25; Player.LegionnaireNumbers += 25; } } if (buff.Id == "TRI") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null) { gameItemQuantity.Quantity += 1000; } } }
/// <summary> /// process events when a player puts down a new game item /// </summary> /// <param name="gameItemQuantity">new game item</param> private void OnPlayerPutDown(GameItemQuantity gameItemQuantity) { _player.Wealth -= gameItemQuantity.GameItem.Value; }
/// <summary> /// process events when a player picks up a new game item /// </summary> /// <param name="gameItemQuantity">new game item</param> private void OnPlayerPickUp(GameItemQuantity gameItemQuantity) { _player.Experience += gameItemQuantity.GameItem.Experience; _player.Wealth += gameItemQuantity.GameItem.Value; }
private void OnPlayerPutDown(GameItemQuantity gameItemQuantity) { _player.Wealth -= gameItemQuantity.GameItem.Value; _player.UpdateMissionStatus(); }
private void OnPlayerPickUp(GameItemQuantity gameItemQuantity) { _player.ExperiencePoints += gameItemQuantity.GameItem.ExperiencePoints; _player.Wealth += gameItemQuantity.GameItem.Value; _player.UpdateMissionStatus(); }
/// <summary> /// Small helper method that adjusts player stats when inventory is gained. /// </summary> /// <param name="gameItem"></param> private void OnPlayerPickup(GameItemQuantity gameItemQuantity) { _player.Wealth += gameItemQuantity.GameItem.ItemValue; }
private void OnPlayerPickUp(GameItemQuantity gameItemQuantity) { _player.ExperiencePoints += gameItemQuantity.GameItem.ExperiencePoints; _player.Currency += gameItemQuantity.GameItem.Value; }
/// <summary> /// processes event for purchase button /// </summary> private void Purchase_Button_Click(object sender, RoutedEventArgs e) { string itemSelection = itemsBox.SelectionBoxItem as string; //legionnaire if (itemSelection == "50 Legionnaire -- 50 gold") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null && gameItemQuantity.Quantity >= 50) { gameItemQuantity.Quantity -= 50; _player.Treasures.Clear(); _player.Treasures.Add(gameItemQuantity); _player.LegionnaireNumbers += 50; _player.Power += 50; descriptionBox.Text = "50 Legionnaire shall be trained at once Imperator."; } else { descriptionBox.Text = "My apologies Imperator, but it seems you lack the funds for that."; } } //archer if (itemSelection == "50 Archers -- 100 gold") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null && gameItemQuantity.Quantity >= 100) { gameItemQuantity.Quantity -= 100; _player.Treasures.Clear(); _player.Treasures.Add(gameItemQuantity); _player.ArcherNumbers += 50; _player.Power += 25; if (_player.TacticalAdvantage < 5) { _player.TacticalAdvantage += 1; } descriptionBox.Text = "50 Archers shall be trained at once Imperator."; } else { descriptionBox.Text = "My apologies Imperator, but it seems you lack the funds for that."; } } //cavalry if (itemSelection == "20 Cavalrymen -- 300 gold") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null && gameItemQuantity.Quantity >= 300) { gameItemQuantity.Quantity -= 300; _player.Treasures.Clear(); _player.Treasures.Add(gameItemQuantity); _player.CavalryNumbers += 20; _player.Power += 100; descriptionBox.Text = "20 Cavalry shall be trained at once Imperator."; } else { descriptionBox.Text = "My apologies Imperator, but it seems you lack the funds for that."; } } //Centurion if (itemSelection == "5 Centurion -- 350 gold") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null && gameItemQuantity.Quantity >= 350) { gameItemQuantity.Quantity -= 350; _player.Treasures.Clear(); _player.Treasures.Add(gameItemQuantity); _player.CenturionNumbers += 5; _player.Power += 50; if (_player.TacticalAdvantage < 5) { _player.TacticalAdvantage += 2; } descriptionBox.Text = "5 Centurion shall be trained at once Imperator."; } else { descriptionBox.Text = "My apologies Imperator, but it seems you lack the funds for that."; } } //Praetor if (itemSelection == "1 Praetor -- 400 gold") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null && gameItemQuantity.Quantity >= 400) { gameItemQuantity.Quantity -= 400; _player.Treasures.Clear(); _player.Treasures.Add(gameItemQuantity); _player.PraetorNumbers += 1; _player.TacticalAdvantage = 5; descriptionBox.Text = "1 Praetor shall be trained at once Imperator."; } else { descriptionBox.Text = "My apologies Imperator, but it seems you lack the funds for that."; } } //Ballistae if (itemSelection == "2 Ballistae -- 300 gold") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null && gameItemQuantity.Quantity >= 300) { gameItemQuantity.Quantity -= 300; _player.Treasures.Clear(); _player.Treasures.Add(gameItemQuantity); _player.NumOfSeigeWeapons += 2; _player.Power += 250; descriptionBox.Text = "2 Ballistae shall be built at once Imperator."; } else { descriptionBox.Text = "My apologies Imperator, but it seems you lack the funds for that."; } } //Catapult if (itemSelection == "1 Catapult -- 700 gold") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null && gameItemQuantity.Quantity >= 700) { gameItemQuantity.Quantity -= 700; _player.Treasures.Clear(); _player.Treasures.Add(gameItemQuantity); _player.NumOfSeigeWeapons += 1; _player.Power += 500; descriptionBox.Text = "1 Catapult shall be built at once Imperator."; } else { descriptionBox.Text = "My apologies Imperator, but it seems you lack the funds for that."; } } //Small naval fleet if (itemSelection == "Small Naval Fleet -- 1000 gold") { GameItemQuantity gameItemQuantity = _player.Inventory.FirstOrDefault(i => i.GameItem.Id == "GLD"); if (gameItemQuantity != null && gameItemQuantity.Quantity >= 1000) { gameItemQuantity.Quantity -= 1000; _player.Treasures.Clear(); _player.Treasures.Add(gameItemQuantity); _player.PlayerHasShips = true; descriptionBox.Text = "Very good Imperator, We shall build you the finest fleet in the empire."; } else { descriptionBox.Text = "My apologies Imperator, but it seems you lack the funds for that."; } } }
private void OnPlayerPutDown(GameItemQuantity gameItemQuantity) { _player.Currency += gameItemQuantity.GameItem.Value; }
private void OnPlayerPickUp(GameItemQuantity gameItemQuantity) { _player.BootyValue += gameItemQuantity.GameItem.CurrencyValue; }