예제 #1
0
 public virtual void TakeTurn(Combat combat)
 {
     MaintainStatusEffects();
 }
예제 #2
0
        public override void TakeTurn(Combat combat)
        {
            var actionsRemaining = new List <string>()
            {
                "major", "minor"
            };

            _movementRemaining = MovementSpeedFeet;
            MaintainStatusEffects();

            //while (actionsRemaining.Count > 0)
            //{
            Console.Clear();
            Prioritize();
            // Console.WriteLine("prioritized");

            // if hp is over half:
            if (CurrentHp.Value > (Hp / 2))
            {
                // Console.WriteLine("hp greater than half");
                // if an entity is known, attempt to attack:
                if (KnownEntities.Count > 0 && actionsRemaining.Contains("major"))
                {
                    Engage(KnownEntities[0]);
                    actionsRemaining.Remove("major");
                }
                // if npc has been attacked by unknown entity, search:
                if (Attackers.Count > KnownEntities.Count && actionsRemaining.Contains("minor"))
                {
                    Search();
                    actionsRemaining.Remove("minor");
                }
            }
            // if hp is less than or equal to half and above 1/4th:
            else if (CurrentHp.Value > (Hp / 4))
            {
                // if holding a consumable, use item:
                var heldConsumable = (Consumable)(Items.FirstOrDefault(i => i is Consumable));
                if (heldConsumable != null && actionsRemaining.Contains("major"))
                {
                    UseItem(heldConsumable.Name);
                    actionsRemaining.Remove("major");
                }
                // if an item is known, attempt to pick it up
                if (KnownItems.Count > 0 &&
                    (_maxCarryWeight - _currentWeightCarried) >= KnownItems[0].Weight &&
                    actionsRemaining.Contains("minor"))
                {
                    Engage(KnownItems[0]);
                    actionsRemaining.Remove("minor");
                }
                // if npc has been attacked by unknown entity, search:
                if (Attackers.Count > KnownEntities.Count && actionsRemaining.Contains("minor"))
                {
                    Search();
                    actionsRemaining.Remove("minor");
                }
                // if an entity is known, attempt to attack:
                if (KnownEntities.Count > 0 && actionsRemaining.Contains("major"))
                {
                    Engage(KnownEntities[0]);
                    actionsRemaining.Remove("major");
                }
                // if not hidden, attempt to hide:
                if (this.HiddenDc <= 0 && actionsRemaining.Contains("minor"))
                {
                    Hide();
                }
            }
            // if hp is below 1/4th:
            else
            {
                Flee();
                // if not hidden, attempt to hide:
                if (this.HiddenDc <= 0 && actionsRemaining.Contains("minor"))
                {
                    Hide();
                }
                // if holding a consumable, use item:
                var heldConsumable = (Consumable)(Items.FirstOrDefault(i => i is Consumable));
                if (heldConsumable != null && actionsRemaining.Contains("major"))
                {
                    UseItem(heldConsumable.Name);
                    actionsRemaining.Remove("major");
                }
                // if an item is known, attempt to pick it up
                if (KnownItems.Count > 0 &&
                    (_maxCarryWeight - _currentWeightCarried) >= KnownItems[0].Weight &&
                    actionsRemaining.Contains("minor"))
                {
                    Engage(KnownItems[0]);
                    actionsRemaining.Remove("minor");
                }
            }
            //}
            Console.WriteLine($"{Name}'s turn is over.");
            PressAnyKeyToContinue();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.Clear();
            Console.OutputEncoding = Encoding.UTF8;
            var map1      = new Map(10, 10);
            var testSword = new Sword
                            (
                "Sword", 10, 10, true,
                damageType: "ice"
                            );

            testSword.SetLocation(new MapPoint(6, 6, map1));

            // var testHammer = new Warhammer
            // (
            //     "Furious Hammer", 100.0, 36.4, false,
            //     abilityMods: new Dictionary<string, int> {{"CON", 2}, {"WIS", -2}}
            // );

            var testTome = new Tome
                           (
                "Fire Tome", 160, 24, damageType: "fire", damageBonus: 2
                           );

            testTome.SetLocation(new MapPoint(2, 3, map1));

            var healthPotion1 = new Consumable
                                (
                "Minor Health Potion", 30, 3, new List <StatusEffect>()
            {
                new StatusEffect("healing", 0, "CurrentHp", Dice.D4.Roll(3, true), false, false)
            }
                                );

            var sentientNpc1 = new SentientNpc
                               (
                name: "Theodas", level: 10, gender: 'm',
                race: new Elf("DEX", "INT"), caste: new Wizard(),
                abilityScoreValues: new [] { 8, 10, 10, 18, 14, 12 },
                team: 0, aggression: Aggression.High,
                location: new MapPoint(5, 7, map1)
                               );

            var giantRat1 = new NonSentientNpc
                            (
                name: "Giant Rat", level: 5, gender: 'n',
                abilityScoreValues: new [] { 12, 14, 10, 4, 6, 10 },
                team: 1, aggression: Aggression.High,
                location: new MapPoint(2, 3, map1)
                            );

            var broodMother1 = new NonSentientNpc
                               (
                name: "Rat Brood Mother", level: 7, gender: 'f',
                abilityScoreValues: new [] { 14, 12, 14, 4, 18, 11 },
                team: 1, aggression: Aggression.High,
                location: new MapPoint(2, 4, map1)
                               );

            var player1 = new Player
                          (
                name: "Dyfena", level: 10, gender: 'f',
                race: new Elf("DEX", "WIS"), caste: new Cleric(),
                abilityScoreValues: new [] { 16, 14, 10, 10, 18, 8 },
                location: new MapPoint(6, 5, map1)
                          );
            var player2 = new Player
                          (
                name: "Eldfar", level: 10, gender: 'm',
                race: new Elf("INT", "WIS"), caste: new Wizard(),
                abilityScoreValues: new [] { 8, 10, 10, 18, 12, 10 },
                location: new MapPoint(4, 6, map1)
                          );
            var player3 = new Player
                          (
                name: "Stinthad", level: 10, gender: 'm',
                race: new Dwarf("STR", "CON"), caste: new Fighter(),
                abilityScoreValues: new [] { 18, 12, 16, 10, 18, 8 },
                location: new MapPoint(6, 7, map1)
                          );

            map1.AddObjects
            (
                new List <IMappable>
            {
                new Wall(new MapPoint(0, 0, map1)),
                new Wall(new MapPoint(1, 0, map1)),
                new Wall(new MapPoint(2, 0, map1)),
                new Wall(new MapPoint(3, 0, map1)),
                new Wall(new MapPoint(4, 0, map1)),
                new Wall(new MapPoint(5, 0, map1)),
                new Wall(new MapPoint(6, 0, map1)),
                new Wall(new MapPoint(7, 0, map1)),
                new Wall(new MapPoint(8, 0, map1)),
                new Wall(new MapPoint(9, 0, map1)),
                new Wall(new MapPoint(0, 1, map1)),
                new Wall(new MapPoint(0, 2, map1)),
                new Wall(new MapPoint(0, 3, map1)),
                new Wall(new MapPoint(0, 4, map1)),
                new Wall(new MapPoint(0, 5, map1)),
                new Wall(new MapPoint(0, 6, map1)),
                new Wall(new MapPoint(0, 7, map1)),
                new Wall(new MapPoint(0, 8, map1)),
                new Wall(new MapPoint(0, 9, map1)),
                new Wall(new MapPoint(1, 9, map1)),
                new Wall(new MapPoint(2, 9, map1)),
                new Wall(new MapPoint(3, 9, map1)),
                new Wall(new MapPoint(4, 9, map1)),
                new Wall(new MapPoint(5, 9, map1)),
                new Wall(new MapPoint(6, 9, map1)),
                new Wall(new MapPoint(7, 9, map1)),
                new Door(new MapPoint(8, 9, map1)),
                new Wall(new MapPoint(9, 9, map1)),
                new Wall(new MapPoint(9, 1, map1)),
                new Wall(new MapPoint(9, 2, map1)),
                new Wall(new MapPoint(9, 3, map1)),
                new Wall(new MapPoint(9, 4, map1)),
                new Wall(new MapPoint(9, 5, map1)),
                new Wall(new MapPoint(9, 6, map1)),
                new Wall(new MapPoint(9, 7, map1)),
                new Wall(new MapPoint(9, 8, map1)),
                player1,
                // player2,
                // player3,
                testSword,
                testTome,
                broodMother1
            }
            );

            foreach (var obj in map1.Objects)
            {
                if (obj is Entity)
                {
                    var entity = (Entity)obj;
                    entity.AddItem(healthPotion1);
                }
            }

            var combat1 = new Combat(new List <Entity> {
                player1, broodMother1
            });

            combat1.StartCombat();
        }
예제 #4
0
        public override void TakeTurn(Combat combat)
        {
            var actionsRemaining = new List <string>()
            {
                "major", "minor", "move"
            };

            _movementRemaining = MovementSpeedFeet;
            bool turnOver = false;

            while (!turnOver)
            {
                MaintainStatusEffects();
                TakingTurn = true;
                // Check if turn is over:
                if (_movementRemaining <= 0)
                {
                    actionsRemaining.Remove("move");
                }
                if (actionsRemaining.Count == 0)
                {
                    Console.WriteLine($"{Name}'s turn is over because {Pronouns[0].ToLower()} has no actions left.");
                    PressAnyKeyToContinue();
                    turnOver = true;
                }

                Location.Map.PrintMap();

                // Prompt player:
                string formattedMovement = _movementRemaining != 0 ? $"({_movementRemaining} ft) " : "";
                Console.WriteLine($"\nEnter an action or type 'pass' to pass your turn. {Name} has a {actionsRemaining.FormatToString("and")} action {formattedMovement}remaining.\n");
                // List IEntityActions:
                foreach (var action in Actions)
                {
                    if (actionsRemaining.Contains(action.Type))
                    {
                        Console.WriteLine($"- {action.Command} {action.Description} ({action.Type})");
                    }
                }
                Console.WriteLine($"\nTry 'help' for a list of other commands.\n");

                string input = Console.ReadLine().ToLower();
                // If IEntityAction command, parse input:
                if (Actions.Any(a => a.Command == input.Split(' ')[0]))
                {
                    string        inputCommand = input.Split(' ')[0];
                    IEntityAction inputAction  = Actions.FirstOrDefault(a => a.Command == inputCommand);
                    if (actionsRemaining.Contains(inputAction.Type))
                    {
                        bool actionExecuted = false;
                        if (inputAction is TargetedAction)
                        {
                            var    inputTargetedAction = (TargetedAction)inputAction;
                            string inputTarget         = string.Join(' ', input.Split(' ').Skip(1));
                            actionExecuted = inputTargetedAction.Execute(inputTarget);
                        }
                        else if (inputAction is NonTargetedAction)
                        {
                            var inputNonTargetedAction = (NonTargetedAction)inputAction;
                            actionExecuted = inputNonTargetedAction.Execute();
                        }
                        PressAnyKeyToContinue();
                        if (actionExecuted)
                        {
                            actionsRemaining.Remove(inputAction.Type);
                        }
                    }
                    else
                    {
                        Console.WriteLine($"{Name} does not have a {inputAction.Type} action remaining.");
                        PressAnyKeyToContinue();
                    }
                }
                // Check for other commands:
                else if (input == "stats")
                {
                    Console.WriteLine(GetAllStats());
                    PressAnyKeyToContinue();
                }
                else if (input == "order")
                {
                    Console.WriteLine(combat.GetInitiativeOrder());
                    PressAnyKeyToContinue();
                }
                else if (input == "help")
                {
                    Console.WriteLine($"- stats - List {Name}'s stats.");
                    Console.WriteLine($"- order - Show current initiative order.");
                    PressAnyKeyToContinue();
                }
                else if (input == "pass")
                {
                    Console.WriteLine($"{Name} is passing {Pronouns[2].ToLower()} turn.");
                    PressAnyKeyToContinue();
                    turnOver = true;
                }
                else
                {
                    Console.WriteLine($"'{input}' could not be recognized. Please enter a valid command.");
                    PressAnyKeyToContinue();
                }
                Console.Clear();
            }
            Console.Clear();
            TakingTurn = false;
        }