Beispiel #1
0
        public bool Battle()
        {
            var pc = C.Room.PlayerController;

            if (IR != null)
            {
                var ir = IR;
                IR = null;
                ir.Init(pc.Game);
LOOP:
                Console.Write(Name + " Battle: ");
                var line = Console.ReadLine();
                var ai   = new ActionInput(pc.Game.Settings.Mode.XBound());
                var pm   = ir.CurrentI == -1 ? null : pc.Game.OnboardPokemons[ir.CurrentI + pc.Player.TeamIndex];
                switch (line)
                {
                case "":
                    if (ir.IsSendOut)
                    {
                        var ii = new List <int>();
                        for (int i = 1; i < 6; ++i)
                        {
                            var p = pc.Game.Player.GetPokemon(i);
                            if (p != null && p.Hp.Value > 0)
                            {
                                ii.Add(i);
                            }
                        }
                        ai.SendOut(0, pc.Game.Player.GetPokemon(ii[Random.Next(0, ii.Count)]));
                    }
                    else
                    {
                        var moves = pm.Moves;
                        int i;
                        for (i = 0; i < 4; ++i)
                        {
                            if (moves[i] == null)
                            {
                                break;
                            }
                        }
                        ai.UseMove(ir.CurrentI, moves[Random.Next(0, i)], false);
                    }
                    break;

                case "ok":
                    pc.GiveUp();
                    return(false);

                case "mega !1":
                case "mega !2":
                case "mega !3":
                case "mega !4":
                    if (ir.CanMega)
                    {
                        var move = pm.Moves[line[6] - '1'];
                        if (move == null)
                        {
                            goto default;
                        }
                        ai.UseMove(ir.CurrentI, move, true);
                    }
                    else
                    {
                        Console.WriteLine("Cannot Mega");
                    }
                    break;

                case "!1":
                case "!2":
                case "!3":
                case "!4":
                {
                    var move = pm.Moves[line[1] - '1'];
                    if (move == null)
                    {
                        goto default;
                    }
                    ai.UseMove(ir.CurrentI, move, false);
                }
                break;

                case "!1 00":
                case "!2 00":
                case "!3 00":
                case "!4 00":
                case "!1 10":
                case "!2 10":
                case "!3 10":
                case "!4 10":
                case "!1 01":
                case "!2 01":
                case "!3 01":
                case "!4 01":
                case "!1 11":
                case "!2 11":
                case "!3 11":
                case "!4 11":
                {
                    var move = pm.Moves[line[1] - '1'];
                    if (move == null)
                    {
                        goto default;
                    }
                    ai.UseMove(ir.CurrentI, move, false, line[3] - '0', line[4] - '0');
                }
                break;

                case "#1":
                case "#2":
                case "#3":
                case "#4":
                case "#5":
                case "#6":
                {
                    var p = PM[line[1] - '1'];
                    if (p == null || p.Hp.Value == 0 || p.Owner.GetPokemon(0) == p)
                    {
                        goto default;
                    }
                    if (pm != null)
                    {
                        ai.Switch(ir.CurrentI, p);
                    }
                    else
                    {
                        ai.SendOut(ir.CurrentI, p);
                    }
                }
                break;

                default:
                    Console.WriteLine("ERROR");
                    goto LOOP;
                }
                pc.Input(ai);
            }
            return(true);
        }