예제 #1
0
        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());
        }
        /// <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());;
        }