Esempio n. 1
0
        public override void StartChoosingAction(BattleData battleData)
        {
            base.StartChoosingAction(battleData);

            if (actionHasBeenChosen)
            {
                return;
            }

            if (!ActivePokemon.HasUsableMove)
            {
                SetChosenAction(new Action(this)
                {
                    type = Action.Type.Fight,
                    fightUsingStruggle = true,
                    fightMoveTarget    = battleData.participantPlayer
                });
            }

            int  chosenMoveIndex;
            bool selectingMove = true;

            do
            {
                List <int> validMoveIndexes = new List <int>();

                for (int moveIndex = 0; moveIndex < 4; moveIndex++)
                {
                    if (!Pokemon.Moves.PokemonMove.MoveIdIsUnset(ActivePokemon.moveIds[moveIndex]))
                    {
                        validMoveIndexes.Add(moveIndex);
                    }
                }

                chosenMoveIndex = validMoveIndexes[battleData.RandomRange(0, validMoveIndexes.Count)];

                if (ActivePokemon.movePPs[chosenMoveIndex] > 0)
                {
                    selectingMove = false;
                }
            }while (selectingMove);

            SetChosenAction(new Action(this)
            {
                type            = Action.Type.Fight,
                fightMoveIndex  = chosenMoveIndex,
                fightMoveTarget = battleData.participantPlayer
            });
        }
        public override void StartChoosingAction(BattleData battleData)
        {
            base.StartChoosingAction(battleData);

            if (actionHasBeenChosen)
            {
                return;
            }

            int  actionItemTargetIndex = activePokemonIndex;
            Item actionItem;

            List <BattleItem> validItems = new List <BattleItem>();

            foreach (BattleItem item in BattleItem.registry)
            {
                if (item.CheckCompatibility(GetPokemon()[actionItemTargetIndex]))
                {
                    validItems.Add(item);
                }
            }

            if (validItems.Count > 0)
            {
                actionItem = validItems[battleData.RandomRange(0, validItems.Count)];
            }
            else
            {
                Debug.LogWarning("No valid item found. Choosing item with id 0");
                actionItem = BattleItem.GetBattleItemById(0);
            }

            chosenAction = new Action(this)
            {
                type                    = Action.Type.UseItem,
                useItemItemToUse        = actionItem,
                useItemTargetPartyIndex = actionItemTargetIndex
            };

            actionHasBeenChosen = true;
        }
 public static int GetRandomThrashingDuration(BattleData battleData)
 => battleData.RandomRange(2, 4);
 public static int GetRandomTauntDuration(BattleData battleData)
 => battleData.RandomRange(3, 6);
 public static int GetRandomEncoreDuration(BattleData battleData)
 => battleData.RandomRange(3, 8);
                => battleData.RandomRange(3, 7);     //Need to use one more than intended turn count as timer is decreased on the inflicting turn

                public static int GetRandomConfusionDuration(BattleData battleData)
                => battleData.RandomRange(2, 6);
 public static int GetRandomBoundDuration(BattleData battleData)
 => battleData.RandomRange(3, 7);     //Need to use one more than intended turn count as timer is decreased on the inflicting turn
        public override void StartChoosingAction(BattleData battleData)
        {
            base.StartChoosingAction(battleData);

            if (actionHasBeenChosen)
            {
                return;
            }

            int  actionItemTargetIndex = activePokemonIndex;
            Item actionItem;

            List <MedicineItem> validItems = new List <MedicineItem>();

            foreach (MedicineItem item in MedicineItem.registry)
            {
                if (item.CheckCompatibility(GetPokemon()[actionItemTargetIndex]))
                {
                    validItems.Add(item);
                }
            }

            if (validItems.Count > 0)
            {
                actionItem = validItems[battleData.RandomRange(0, validItems.Count)];
            }
            else
            {
                Debug.LogWarning("No valid item found. Choosing item with id 0");
                actionItem = MedicineItem.GetMedicineItemById(0);
            }

            int moveIndex = -1;

            if (actionItem is PPRestoreMedicineItem)
            {
                PPRestoreMedicineItem ppRestoreActionItem = (PPRestoreMedicineItem)actionItem;
                if (ppRestoreActionItem.isForSingleMove)
                {
                    for (int i = 0; i < GetPokemon()[actionItemTargetIndex].moveIds.Length; i++)
                    {
                        if (!Pokemon.Moves.PokemonMove.MoveIdIsUnset(GetPokemon()[actionItemTargetIndex].moveIds[i]))
                        {
                            Pokemon.Moves.PokemonMove move = Pokemon.Moves.PokemonMove.GetPokemonMoveById(GetPokemon()[actionItemTargetIndex].moveIds[i]);
                            if (GetPokemon()[actionItemTargetIndex].movePPs[i] < move.maxPP)
                            {
                                moveIndex = i;
                                break;
                            }
                        }
                    }
                }
            }

            chosenAction = new Action(this)
            {
                type                    = Action.Type.UseItem,
                useItemItemToUse        = actionItem,
                useItemTargetPartyIndex = actionItemTargetIndex,
                useItemTargetMoveIndex  = moveIndex
            };
            actionHasBeenChosen = true;
        }