Exemple #1
0
        /// <summary>
        /// Loads moves to the MoveList
        /// </summary>
        /// <param name="reader">Binary Reader</param>
        public static void LoadMoveList(BinaryReader reader)
        {
            MoveList.move.Clear();
            int num = reader.ReadInt32();

            for (int i = 0; i < num; i++)
            {
                BaseMove temp = LoadBaseMove(reader);

                MoveList.move.Add(temp);
            }
        }
Exemple #2
0
        public DexSlot(int id)
        {
            string slotName = BaseMove.PokemonNameFromId(id);

            _texture = ModContent.GetTexture($"Terramon/Minisprites/Regular/mini{slotName}");
            Width.Set(_texture.Width, 0f);
            Height.Set(_texture.Height, 0f);

            constantRange = id - 1;

            drawcolor = Color.White;
        }
Exemple #3
0
    public Sprite Special, Physical, Status;    //TODO change to SpriteSheet

    public void OpenDescription(BaseMove newMove)
    {
        MoveData moveData = MoveData.GetData(newMove.Move);

        UI.Name.text        = moveData.Name;
        UI.Description.text = moveData.Description;
        UI.Stats.text       = "";

        TriggerType(moveData.Type);
        TriggerCategory(moveData.Category);
        TriggerStats(newMove);

        gameObject.SetActive(true);
    }
    /// <summary>
    /// Picks the last 4 moves that the given Pokemon can learn by level-up.
    /// Entries 1, 2 & 3 can be null!
    /// </summary>
    /// <param name="Pokemon">Pokemon</param>
    /// <returns>4 BaseMoves in an Array</returns>
    static BaseMove[] GetMoveList(BasePokemon Pokemon)
    {
        PokemonData Data = PokemonData.GetData(Pokemon.Monster);

        List <Move> newMoveList = new List <Move>();

        //Logger.Debug(MethodBase.GetCurrentMethod().DeclaringType, "Data.MoveList.Length = " + Data.MoveList.Length);

        for (int i = 1; i < Data.MoveList.Length; i++)
        {
            P_Moves newMove = Data.MoveList[Data.MoveList.Length - i];

            if (newMove.MoveTree == P_MoveTree.LevelUp && newMove.LvlUP <= Pokemon.Level)
            {
                newMoveList.Add(newMove.Move);
            }

            if (newMoveList.Count == 4)
            {
                break;
            }
        }

        BaseMove[] BaseMoveList = new BaseMove[4];

        for (int i = 0; i < newMoveList.Count; i++)
        {
            BaseMoveList[i] = new BaseMove()
            {
                Move       = newMoveList[i],
                CurrentPP  = MoveData.GetData(newMoveList[i]).PP,
                MaxPP      = MoveData.GetData(newMoveList[i]).PP,
                isDisabled = false
            };
        }

        if (BaseMoveList[0] != null)
        {
            return(BaseMoveList);
        }

        else
        {
            Logger.Exception(MethodBase.GetCurrentMethod().DeclaringType, "'" + Pokemon.Monster + "' does not have a valid Move in its 'Moves' variable!");

            return(null);
        }
    }
    public void SetActiveMove(BaseMove newMove)
    {
        if (newMove != null)
        {
            ActiveMove = newMove;
            Move       = ActiveMove.Move;
            MoveData   = MoveData.GetData(Move);

            gameObject.name = "MoveButton (" + MoveData.Name + ")";
            Name.text       = MoveData.Name;
        }

        else
        {
            ResetUI();
        }
    }
Exemple #6
0
        public void UpdateId(int id)
        {
            lockedNumbers.SetText("");
            slotName = BaseMove.PokemonNameFromId(id);

            if (Main.LocalPlayer.GetModPlayer <TerramonPlayer>().PokedexCompletion.Length > 0)
            {
                if (id > 151)
                {
                    caught = false;
                    return;
                }

                if (Main.LocalPlayer.GetModPlayer <TerramonPlayer>().PokedexCompletion[id - 1] == 1)
                {
                    caught = true;
                }
                else
                {
                    caught = false;
                }
            }

            if (slotName == "NOEXIST" || !caught)
            {
                HoverText = "";
            }
            else
            {
                HoverText = $"{TerramonMod.Localisation.GetLocalisedString(new LocalisedString(slotName))} [c/919191:<No. {id.ToString().PadLeft(3, '0')}>]";
            }

            if (!caught && id < 152)
            {
                lockedNumbers.SetText(id.ToString().PadLeft(3, '0'));
            }
            else
            {
                lockedNumbers.SetText("");
            }
        }
Exemple #7
0
        private async Task SendMove(BaseMove move)
        {
            if (_client.IsAnonymous || _client.CurrentGame == null)
            {
                return;
            }

            try
            {
                await _client.SendMoveAsync(move);
            }
            catch (Exception ex)
            {
                LogError(nameof(SendMove), ex);
            }

            RefreshGame();

            chessBoardGamePanel1.ChessRepresentation = _client.CurrentGame.Representation;
            chessBoardGamePanel1.Refresh();
        }
Exemple #8
0
        public static BaseMove GetBestMove()
        {
            BaseMove bestMove      = null;
            int      bestMoveScore = int.MinValue;

            var moves = GenerateRandomMoves(Board);

            foreach (var move in moves)
            {
                move.Simulate(Board, LivingCells);
                var score = move.GetScore();
                if (score > bestMoveScore)
                {
                    bestMove      = move;
                    bestMoveScore = score;
                }
            }

            Console.Error.WriteLine("Performing move '" + bestMove + "' with score " + bestMoveScore);
            return(bestMove);
        }
        /// <summary>
        /// returns a double representing the chance to hit this pokemon
        /// Over 1 means a sure hit, less than one represents a percentage chance to hit
        /// </summary>
        /// <param name="inPoke">pokemon using the move</param>
        /// <param name="inMove">move being used</param>
        /// <returns></returns>
        public double chanceToHit(BattlePokemon inPoke, BaseMove inMove)
        {
            double chance = 0.0;
            double acc    = 0.0;
            double eva    = 0.0;

            //convert evasion and accuracy levels into actual values
            if (accuracyLevel >= 0)
            {
                acc  = (Convert.ToDouble(inPoke.accuracyLevel) + 3.0) / 3.0;
                acc *= inPoke.accuracyModifier;
            }
            if (accuracyLevel < 0)
            {
                acc  = 3.0 / (3.0 + Convert.ToDouble(inPoke.accuracyLevel));
                acc *= inPoke.accuracyModifier;
            }
            if (evasionLevel >= 0)
            {
                eva  = (Convert.ToDouble(evasionLevel) + 3.0) / 3.0;
                eva *= evasionModifier;
            }
            if (evasionLevel < 0)
            {
                eva  = 3.0 / (3.0 + Convert.ToDouble(evasionLevel));
                eva *= evasionModifier;
            }

            //if the accuracy is set to -1 it will always hit
            if (inMove.accuracy == -1)
            {
                chance = 1.0;
            }
            else
            {
                chance = (Convert.ToDouble(inMove.accuracy) / 100) * (acc / eva);
            }
            return(chance);
        }
Exemple #10
0
        public Path(Game.Celltype[,] board, int[] livingCells, BaseMove initialMove)
        {
            LivingCells = new[] { livingCells[0], livingCells[1] };
            Board       = board.Clone() as Game.Celltype[, ];

            if (initialMove is KillMove)
            {
                var killMove = (KillMove)initialMove;
                var killedId = (int)Board[killMove.Point.X, killMove.Point.Y];
                Board[killMove.Point.X, killMove.Point.Y] = Game.Celltype.Dead;

                LivingCells[killedId] = LivingCells[killedId] - 1;
            }
            else if (initialMove is BirthMove)
            {
                var birthMove = (BirthMove)initialMove;
                Board[birthMove.Kill1Point.X, birthMove.Kill1Point.Y] = Game.Celltype.Dead;
                Board[birthMove.Kill2Point.X, birthMove.Kill2Point.Y] = Game.Celltype.Dead;
                Board[birthMove.EmptyPoint.X, birthMove.EmptyPoint.Y] = (Game.Celltype)Settings.MyBotId;
                LivingCells[Settings.MyBotId] = LivingCells[Settings.MyBotId] - 1;
            }
        }
Exemple #11
0
        public IActionResult Move(string gameIdString, [FromBody] BaseMove move)
        {
            bool validId = Guid.TryParse(gameIdString, out Guid gid);

            if (!validId)
            {
                _logger.LogWarning($"{GetCurrentUser()} has sent a move to the game with ID {gameIdString} but the ID is not a valid GUID.");
                return(BadRequest("Game ID is not valid."));
            }

            var result = _repository.Move(GetCurrentUser(), gid, move);

            switch (result.MoveRequestResultStatus)
            {
            case ChessGameMoveRequestResultStatuses.Ok:
                _logger.LogInformation($"{GetCurrentUser()} has sent a move to the game with ID {gameIdString}.");
                return(Ok(result));

            case ChessGameMoveRequestResultStatuses.WrongTurn:
                _logger.LogInformation($"{GetCurrentUser()} has sent a move to the game with ID {gameIdString} in the wrong turn.");
                return(Forbidden(result));

            case ChessGameMoveRequestResultStatuses.InvalidMove:
                _logger.LogInformation($"{GetCurrentUser()} has sent a move to the game with ID {gameIdString} but it was an invalid move.");
                return(Forbidden(result));

            case ChessGameMoveRequestResultStatuses.NoMatchFound:
                _logger.LogWarning($"{GetCurrentUser()} has sent a move to the game with ID {gameIdString} but the match was not found.");
                return(NotFound(gameIdString));

            case ChessGameMoveRequestResultStatuses.MultipleMatchesFound:
                _logger.LogError($"{GetCurrentUser()} has sent a move to the game with ID {gameIdString} but multiple matches were found.");
                return(Conflict(result));

            default:
                return(InternalServerError());
            }
        }
Exemple #12
0
        //This region is for loading and saving Base Moves, mostly for the Move Index
        #region BaseMove
        public static void SaveBaseMove(BaseMove inMove, BinaryWriter writer)
        {
            //name
            //description
            //movescript
            //effectscript
            //type
            //kind
            //basepp
            //priority
            //power
            //accuracy

            writer.Write(inMove.name);
            writer.Write(inMove.description);
            writer.Write(inMove.moveScript);
            writer.Write(inMove.effectScript);
            writer.Write(inMove.moveType);
            writer.Write(inMove.moveKind);
            writer.Write(inMove.basePP);
            writer.Write(inMove.basePriority);
            writer.Write(inMove.power);
            writer.Write(inMove.accuracy);
        }
Exemple #13
0
 public Move(BaseMove cBase)
 {
     Base     = cBase;
     PP       = cBase.PP;
     IsRanged = cBase.IsRanged;
 }
        /// <summary>
        /// Testing battle engine
        /// </summary>
        private void startBattle()
        {
            Trainer trainer = new Trainer();

            //BaseStatsList.initialize();


            BaseMove tackle = new BaseMove("Tackle", "hits the opponent hard", 50, 100, "Normal", "Physical", 35);

            tackle.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove party = new BaseMove("Party", "hits the opponent hard", 10, 100, "Normal", "Physical", 35);

            party.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                        ShowMessage(target.pokemon.Nickname..'\'s attack decreased!')
                                    end
                                ";
            BaseMove bubble = new BaseMove("Bubble", "waters the opponent", 20, 100, "Water", "Special", 30);

            bubble.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove smile = new BaseMove("Smile", "waters the opponent", 100, 100, "Water", "Special", 30);

            smile.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                        ShowMessage(target.pokemon.Nickname..' died of cuteness!')
                                    end
                                ";
            BaseMove ember = new BaseMove("Ember", "fires the opponent", 40, 100, "Fire", "Special", 25);

            ember.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";

            BaseMove pinkiesense = new BaseMove("Pinkie Sense", "Confuses the opponent", 40, 100, "Fire", "Special", 25);

            pinkiesense.moveScript = @"  if user:hits(move, target) then
                                        s = target.pokemon.Nickname..' is confused!'
                                        ShowMessage(s)
                                    end
                                ";


            ActivePokemon charmander = new ActivePokemon(BaseStatsList.basestats);
            ActivePokemon squirtle   = new ActivePokemon(BaseStatsList.basestats);

            charmander.baseStat  = BaseStatsList.GetBaseStats("Charmander");
            charmander.level     = 20;
            charmander.currentHP = charmander.HP;
            charmander.setNickname("Charmander");
            charmander.addExp(charmander.expAtLevel(charmander.level) - 1);
            squirtle.baseStat  = BaseStatsList.GetBaseStats("Squirtle");
            squirtle.level     = 20;
            squirtle.currentHP = squirtle.HP;
            squirtle.setNickname("Pinkie Pie");
            squirtle.addExp(squirtle.expAtLevel(squirtle.level) - 1);


            charmander.move[0] = new ActiveMove(tackle);
            charmander.move[1] = new ActiveMove(ember);
            squirtle.move[0]   = new ActiveMove(party);
            squirtle.move[1]   = new ActiveMove(smile);
            squirtle.move[2]   = new ActiveMove(pinkiesense);

            player.addPokemon(squirtle);
            trainer.addPokemon(charmander);

            ScreenHandler.PushScreen(new BattleScreen(graphics, content, font, player, trainer));
        }
        /// <inheritdoc />
        public DbBaseMove CovertToDbChessMove(BaseMove move)
        {
            if (move == null)
            {
                return(null);
            }

            switch (move)
            {
            case KingCastlingMove castling:
                return(new DbKingCastlingMove
                {
                    Owner = castling.Owner,
                    CastlingType = castling.CastlingType,
                    CreatedAt = DateTime.UtcNow,
                    FromColumn = castling.From.Column.ToString(),
                    FromRow = castling.From.Row,
                    ToColumn = castling.To.Column.ToString(),
                    ToRow = castling.To.Row,
                    MoveId = Guid.NewGuid()
                });

            case PawnPromotionalMove promotionalMove:
                return(new DbPawnPromotionalMove
                {
                    Owner = promotionalMove.Owner,
                    PromoteTo = promotionalMove.PromoteTo,
                    CreatedAt = DateTime.UtcNow,
                    FromColumn = promotionalMove.From.Column.ToString(),
                    FromRow = promotionalMove.From.Row,
                    ToColumn = promotionalMove.To.Column.ToString(),
                    ToRow = promotionalMove.To.Row,
                    MoveId = Guid.NewGuid(),
                });

            case PawnEnPassantMove enPassantMove:
                return(new DbPawnEnPassantMove
                {
                    Owner = enPassantMove.Owner,
                    CreatedAt = DateTime.UtcNow,
                    FromColumn = enPassantMove.From.Column.ToString(),
                    FromRow = enPassantMove.From.Row,
                    ToColumn = enPassantMove.To.Column.ToString(),
                    ToRow = enPassantMove.To.Row,
                    MoveId = Guid.NewGuid(),
                    CapturePositionColumn = enPassantMove.CapturePosition.Column.ToString(),
                    CapturePositionRow = enPassantMove.CapturePosition.Row
                });

            case BaseChessMove chessMove:
                return(new DbChessMove
                {
                    Owner = chessMove.Owner,
                    CreatedAt = DateTime.UtcNow,
                    FromColumn = chessMove.From.Column.ToString(),
                    FromRow = chessMove.From.Row,
                    ToColumn = chessMove.To.Column.ToString(),
                    ToRow = chessMove.To.Row,
                    MoveId = Guid.NewGuid()
                });

            case SpecialMove specialMove:
                return(new DbSpecialMove
                {
                    Owner = specialMove.Owner,
                    Message = specialMove.Message,
                    CreatedAt = DateTime.UtcNow,
                    MoveId = Guid.NewGuid()
                });

            default:
                throw new ArgumentOutOfRangeException(nameof(move));
            }
        }
    [SerializeField] private DamageChecker dCheck;      //공격판정 쪽



    // Start is called before the first frame update
    void Start()
    {
        aControl = GetComponent <AnimateControl>();
        bMove    = GetComponent <BaseMove>();
        dCheck   = GetComponent <DamageChecker>();
    }
Exemple #17
0
        public static void StartRandomEncounter(Player player)
        {
            //This is only a test implementation for now
            //Starts random battle with Starly, Rattata, or HootHoot
            Trainer trainer = new Trainer();


            BaseMove tackle = new BaseMove("Tackle", "hits the opponent hard", 50, 100, "Normal", "Physical", 35);

            tackle.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove scratch = new BaseMove("Scratch", "hits the opponent hard", 40, 100, "Normal", "Physical", 35);

            scratch.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove growl = new BaseMove("Growl", "Lowers target's attack", 0, 100, "Normal", "Special", 40);

            growl.moveScript = @" if user:hits(move, target) then
                                    target:changeStat('Attack', -1)
                                    ShowMessage(target.pokemon.Nickname .. 'has had their attack lowered')
                                    end
                                ";
            BaseMove foresight = new BaseMove("Foresight", "Negates accuracy reduction moves", 0, "Normal", "Status", 40);

            foresight.moveScript = @"target:changeStat('Accuracy', 12)
                                    target:changeStat('Accuracy', -6)
                                    ShowMessage(target.pokemon.Nickname .. 'has had their accuracy reset')
                                ";
            BaseMove quickattack = new BaseMove("Quick Attack", "Always strikes first", 40, 100, "Normal", "Physical", 30);

            quickattack.basePriority = 1;
            quickattack.moveScript   = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove tailwhip = new BaseMove("Tail Whip", "Lowers target's defense", 0, 100, "Normal", "Special", 40);

            tailwhip.moveScript = @" if user:hits(move, target) then
                                    target:changeStat('Defense', -1)
                                    ShowMessage(target.pokemon.Nickname .. 'has had their defense lowered')
                                    end
                                ";


            ActivePokemon enemy  = new ActivePokemon(BaseStatsList.basestats);
            Random        random = new Random();
            int           r      = random.Next(3);

            switch (r)
            {
            case 0:
                enemy.baseStat = BaseStatsList.GetBaseStats("Starly");
                enemy.move[0]  = new ActiveMove(tackle);
                enemy.move[1]  = new ActiveMove(growl);
                enemy.move[2]  = new ActiveMove(quickattack);
                break;

            case 1:
                enemy.baseStat = BaseStatsList.GetBaseStats("Hoothoot");
                enemy.move[0]  = new ActiveMove(tackle);
                enemy.move[1]  = new ActiveMove(growl);
                enemy.move[2]  = new ActiveMove(foresight);
                break;

            case 2:
                enemy.baseStat = BaseStatsList.GetBaseStats("Rattata");
                enemy.move[0]  = new ActiveMove(tackle);
                enemy.move[1]  = new ActiveMove(tailwhip);
                enemy.move[2]  = new ActiveMove(quickattack);
                break;

            default: return;
            }

            enemy.level     = 5;
            enemy.currentHP = enemy.HP;
            enemy.addExp(enemy.expAtLevel(enemy.level) - 1);

            trainer.addPokemon(enemy);

            ScreenHandler.TopScreen.IsVisible = false;
            ScreenHandler.PushScreen(new BattleScreen(graphics, content, font, player, trainer));
        }
Exemple #18
0
    // Use this for initialization
    void Start()
    {
        BaseMove tackle = new BaseMove("Tackle", PType.Normal, Category.Physical, 35, 50, 100);

        movesLearned.Add(tackle, 1);
    }
Exemple #19
0
 public bool ValidateMove(ChessRepresentation representation, BaseMove move)
 {
     return(GenerateMoves(representation).Contains(move));
 }
Exemple #20
0
        public static void AddNewPokemon(Player player, string pokemonname, int level)
        {
            BaseMove tackle = new BaseMove("Tackle", "hits the opponent hard", 50, 100, "Normal", "Physical", 35);

            tackle.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove scratch = new BaseMove("Scratch", "hits the opponent hard", 40, 100, "Normal", "Physical", 35);

            scratch.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove pound = new BaseMove("Pound", "hits the opponent hard", 40, 100, "Normal", "Physical", 35);

            pound.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove growl = new BaseMove("Growl", "Lowers target's attack", 0, 100, "Normal", "Special", 40);

            growl.moveScript = @" if user:hits(move, target) then
                                    target:changeStat('Attack', -1)
                                    ShowMessage(target.pokemon.Nickname .. 'has had their attack lowered')
                                    end
                                ";
            BaseMove foresight = new BaseMove("Foresight", "Negates accuracy reduction moves", 0, "Normal", "Status", 40);

            foresight.moveScript = @"target:changeStat('Accuracy', 12)
                                    target:changeStat('Accuracy', -6)
                                    ShowMessage(target.pokemon.Nickname .. 'has had their accuracy reset')
                                ";
            BaseMove quickattack = new BaseMove("Quick Attack", "Always strikes first", 40, 100, "Normal", "Physical", 30);

            quickattack.basePriority = 1;
            quickattack.moveScript   = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove tailwhip = new BaseMove("Tail Whip", "Lowers target's defense", 0, 100, "Normal", "Special", 40);

            tailwhip.moveScript = @" if user:hits(move, target) then
                                    target:changeStat('Defense', -1)
                                    ShowMessage(target.pokemon.Nickname .. 'has had their defense lowered')
                                    end
                                ";
            BaseMove ember = new BaseMove("Ember", "fires the opponent", 40, 100, "Fire", "Special", 25);

            ember.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove bubble = new BaseMove("Bubble", "waters the opponent", 20, 100, "Water", "Special", 30);

            bubble.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";
            BaseMove razorleaf = new BaseMove("Razor Leaf", "Sends razor sharp leaves at the target", 55, 95, "Grass", "Special", 25);

            razorleaf.moveScript = @"  if user:hits(move, target) then
                                        user:doDamageTo(move, target)
                                    end
                                ";


            ActivePokemon newPokemon = new ActivePokemon(BaseStatsList.basestats);

            switch (pokemonname)
            {
            case "Charmander":
                newPokemon.baseStat = BaseStatsList.GetBaseStats("Charmander");
                newPokemon.move[0]  = new ActiveMove(scratch);
                newPokemon.move[1]  = new ActiveMove(growl);
                newPokemon.move[2]  = new ActiveMove(ember);
                break;

            case "Mudkip":
                newPokemon.baseStat = BaseStatsList.GetBaseStats("Piplup");
                newPokemon.move[0]  = new ActiveMove(pound);
                newPokemon.move[1]  = new ActiveMove(growl);
                newPokemon.move[2]  = new ActiveMove(bubble);
                break;

            case "Chikorita":
                newPokemon.baseStat = BaseStatsList.GetBaseStats("Chikorita");
                newPokemon.move[0]  = new ActiveMove(tackle);
                newPokemon.move[1]  = new ActiveMove(growl);
                newPokemon.move[2]  = new ActiveMove(razorleaf);
                break;

            default:
                newPokemon.baseStat = BaseStatsList.GetBaseStats("Piplup");
                newPokemon.move[0]  = new ActiveMove(pound);
                newPokemon.move[1]  = new ActiveMove(growl);
                newPokemon.move[2]  = new ActiveMove(bubble);
                break;
            }

            newPokemon.level     = 7;
            newPokemon.currentHP = newPokemon.HP;
            newPokemon.addExp(newPokemon.expAtLevel(newPokemon.level) - 1);
            player.currentPokemon[0] = newPokemon;
        }
Exemple #21
0
 public ChessRepresentation ApplyMove(ChessRepresentation representationParam, BaseMove move)
 {
     return(ApplyMove(representationParam, move, true));
 }
Exemple #22
0
 public static double typeStrength(BaseMove inMove, ActivePokemon inPoke)
 {
     return(typeStrength(inMove.moveType, inPoke.baseStat.Type1.ToString(), inPoke.baseStat.Type2.ToString()));
 }
Exemple #23
0
        private ChessRepresentation ApplyMove(ChessRepresentation representationParam, BaseMove move, bool validateMove)
        {
            if (validateMove && !ValidateMove(representationParam, move))
            {
                throw new ChessIllegalMoveException();
            }

            var representation = representationParam.Clone();

            // Removing en passant flags if the move wasn't a special move. (Usually DrawOffer)
            if (move is BaseChessMove)
            {
                var pawns = Positions.PositionList.Select(x => representation[x])
                            .Where(x => x != null)
                            .Where(x => x.Owner != representation.CurrentPlayer)
                            .OfType <Pawn>()
                            .Select(x => x)
                            .ToArray();

                foreach (var pawn in pawns)
                {
                    pawn.IsEnPassantCapturable = false;
                }
            }

            switch (move)
            {
            case SpecialMove _:
                break;

            case KingCastlingMove castlingMove:
                representation.Move(castlingMove.From, castlingMove.To);
                representation.Move(castlingMove.RookFrom, castlingMove.RookTo);
                representation[castlingMove.To].HasMoved     = true;
                representation[castlingMove.RookTo].HasMoved = true;
                break;

            case PawnEnPassantMove pawnEnPassantMove:
                representation.Move(pawnEnPassantMove.From, pawnEnPassantMove.To);
                representation[pawnEnPassantMove.CapturePosition] = null;
                representation[pawnEnPassantMove.To].HasMoved     = true;
                break;

            case PawnPromotionalMove pawnPromotionalMove:
                representation.Move(pawnPromotionalMove.From, pawnPromotionalMove.To);
                representation[pawnPromotionalMove.To]          = ChessPieces.Create(pawnPromotionalMove.PromoteTo, representation[pawnPromotionalMove.To].Owner);
                representation[pawnPromotionalMove.To].HasMoved = true;
                break;

            case BaseChessMove chessMove:
                var movingPiece = representation[chessMove.From];
                representation.Move(chessMove.From, chessMove.To);
                representation[chessMove.To].HasMoved = true;

                // Setting en passant flag if needed
                if (movingPiece.Kind == PieceKind.Pawn && Math.Abs(chessMove.From.Row - chessMove.To.Row) == 2 && chessMove.From.Column == chessMove.To.Column)
                {
                    ((Pawn)representation[chessMove.To]).IsEnPassantCapturable = true;
                }
                break;
            }

            representation.TogglePlayer();
            representation.History.Add(move);

            return(representation);
        }
Exemple #24
0
        public void PlayRound(Game game, int playerIndex, bool isChild = false, int depth = 0, bool isStart = false, List <BaseMove> additionalMoves = null)
        {
            List <BaseMove> moves = GetAvailableMoves();

            if (additionalMoves != null && additionalMoves.Any())
            {
                if (moves == null)
                {
                    moves = new List <BaseMove>();
                }

                moves.AddRange(additionalMoves);
            }

            int      bestScore = int.MinValue;
            BaseMove bestMove  = null;
            Player   player    = playerIndex == 0 ? game.Player1 : game.Player2;

            player.Depth = depth;

            if (isStart)
            {
                player.Board.PlayStartTurnAbilities(player);
            }

            if (moves != null && moves.Any())
            {
                var index = 0;
                foreach (var move in moves)
                {
                    index++;

                    Game     temporaryGame   = game.Clone();
                    BaseMove transformedMove = move.TransformInGame(temporaryGame);

                    if (playerIndex == 0)
                    {
                        List <BaseMove> resultedMoves = temporaryGame.Player1.MakeMove(transformedMove);
                        temporaryGame.Player1.PlayRound(temporaryGame, playerIndex, true, depth + 1, additionalMoves: resultedMoves);
                        int playerScore = temporaryGame.Player1.GetScore();
                        int enemyScore  = temporaryGame.Player1.Enemy.GetScore();
                        int score       = playerScore - enemyScore;
                        if (score > bestScore)
                        {
                            bestScore = score;
                            bestMove  = move;
                        }
                    }
                    else
                    {
                        List <BaseMove> resultedMoves = temporaryGame.Player2.MakeMove(transformedMove);
                        temporaryGame.Player2.PlayRound(temporaryGame, playerIndex, true, depth + 1, additionalMoves: resultedMoves);
                        int playerScore = temporaryGame.Player2.GetScore();
                        int enemyScore  = temporaryGame.Player2.Enemy.GetScore();
                        int score       = playerScore - enemyScore;
                        if (score > bestScore)
                        {
                            bestScore = score;
                            bestMove  = move;
                        }
                    }
                }
            }

            if (bestMove != null)
            {
                List <BaseMove> resultedMoves = MakeMove(bestMove, !isChild);
                PlayRound(game, playerIndex, isChild, additionalMoves: resultedMoves);
            }

            if (moves == null || !moves.Any())
            {
                player.Board.PlayEndTurnAbilities(player);
                foreach (var card in player.Board.Cards)
                {
                    card.Attack         -= card.TemporaryAttack;
                    card.TemporaryAttack = 0;

                    card.ApplyDamage(player, card.TemporaryHealth, player);
                    card.TemporaryHealth = 0;
                }
            }
        }
Exemple #25
0
 private static int?GetColumn(BaseMove move)
 {
     return(move.Type == MoveType.QUIT ? (int?)null : ((BoardMove)move).Column);
 }
Exemple #26
0
 // Use this for initialization
 void Start()
 {
     BaseMove tackle = new BaseMove("Tackle", PType.Normal, Category.Physical, 35, 50, 100);
     movesLearned.Add(tackle, 1);
 }
        public override void Load()
        {
            // Load movedb

            BaseMove.LoadMoveDb();

            // Initalize Discord RP on Mod Load
            if (!Main.dedServ)
            {
                client        = new DiscordRpcClient("790364236554829824");
                client.Logger = new ConsoleLogger()
                {
                    Level = LogLevel.Warning
                };
                //

                Logger.Info("Attempting to establish Discord RP connection");

                // Subscribe to events
                client.OnReady += (sender, e) =>
                {
                    Logger.Info("Established connection");
                    Console.WriteLine("Received Ready from user {0}", e.User.Username);
                };

                client.OnPresenceUpdate += (sender, e) =>
                {
                    Console.WriteLine("Received Update! {0}", e.Presence);
                };

                client.OnError += (sender, e) =>
                {
                    Logger.Error("Could not start Discord RP. Reason: " + e.Message);
                };

                //Connect to the RPC
                client.Initialize();

                client.SetPresence(new RichPresence()
                {
                    Details = "In Menu",
                    State   = "Playing v0.4.2",
                    Assets  = new Assets()
                    {
                        LargeImageKey  = "largeimage2",
                        LargeImageText = "Merry Christmas!"
                    }
                });
            }

            BaseMove._mrand = new UnifiedRandom(BaseMove._seed = new Random().Next());
            //Load all mons to a store
            LoadPokemons();

            if (Main.netMode != NetmodeID.Server)
            {
                if (Localisation == null)
                {
                    Localisation = new LocalisationManager(locale);
                }
                locale = new Bindable <string>(Language.ActiveCulture.Name);

                storage = new ModStorage("Terramon");                                                                  //Initialise local resource store
                Store   = new ResourceStore <byte[]>(new EmbeddedStore());                                             //Make new instance of ResourceStore with dependency what loads data from ModStore
                Store.AddStore(new StorageCachableStore(storage, new WebStore()));                                     //Add second dependency what checks if data exist in local store.
                                                                                                                       //If not and provided URL load data from web and save it on drive
                Textures = new Texture2DStore(Store);                                                                  //Initialise cachable texture store in order not creating new texture each call

                Localisation.AddLanguage(GameCulture.English.Name, new LocalisationStore(Store, GameCulture.English)); //Adds en-US.lang file handling
                Localisation.AddLanguage(GameCulture.Russian.Name, new LocalisationStore(Store, GameCulture.Russian)); //Adds ru-RU.lang file handling
#if DEBUG
                UseWebAssets = true;
                var ss = Localisation.GetLocalisedString(new LocalisedString(("title", "Powered by broken code")));//It's terrible checking in ui from phone, so i can ensure everything works from version string
                //Main.versionNumber = ss.Value + "\n" + Main.versionNumber;
#endif
                Ref <Effect> screenRef      = new Ref <Effect>(GetEffect("Effects/ShockwaveEffect")); // The path to the compiled shader file.
                Ref <Effect> whiteShaderRef = new Ref <Effect>(GetEffect("Effects/whiteshader"));     // The path to the compiled shader file.
                Filters.Scene["Shockwave"] = new Filter(new ScreenShaderData(screenRef, "Shockwave"), EffectPriority.VeryHigh);
                Filters.Scene["Shockwave"].Load();
                GameShaders.Misc["WhiteTint"] = new MiscShaderData(whiteShaderRef, "ArmorBasic");

                ChooseStarter = new ChooseStarter();
                ChooseStarter.Activate();
                ChooseStarterBulbasaur = new ChooseStarterBulbasaur();
                ChooseStarterBulbasaur.Activate();
                ChooseStarterCharmander = new ChooseStarterCharmander();
                ChooseStarterCharmander.Activate();
                ChooseStarterSquirtle = new ChooseStarterSquirtle();
                ChooseStarterSquirtle.Activate();
                PokegearUI = new PokegearUI();
                PokegearUI.Activate();
                PokegearUIEvents = new PokegearUIEvents();
                PokegearUIEvents.Activate();
                evolveUI = new EvolveUI();
                evolveUI.Activate();
                UISidebar = new UISidebar();
                UISidebar.Activate();
                Moves = new Moves();
                Moves.Activate();
                PartySlots = new PartySlots();
                PartySlots.Activate();
                _exampleUserInterface    = new UserInterface();
                _exampleUserInterfaceNew = new UserInterface();
                PokegearUserInterfaceNew = new UserInterface();
                evolveUserInterfaceNew   = new UserInterface();
                _uiSidebar  = new UserInterface();
                _moves      = new UserInterface();
                _partySlots = new UserInterface();
                _battle     = new UserInterface();
                ParentPokemonNPC.HighlightTexture = new Dictionary <string, Texture2D>();
                ParentPokemon.HighlightTexture    = new Dictionary <string, Texture2D>();

                //_exampleUserInterface.SetState(ChooseStarter); // Choose Starter
#if DEBUG
                _exampleUserInterface.SetState(new TestState());
#endif
                _exampleUserInterfaceNew.SetState(PokegearUI);       // Pokegear Main Menu
                PokegearUserInterfaceNew.SetState(PokegearUIEvents); // Pokegear Events Menu
                evolveUserInterfaceNew.SetState(evolveUI);
                _uiSidebar.SetState(UISidebar);
                _moves.SetState(Moves);
                _partySlots.SetState(PartySlots);
                _battle.SetState(BattleMode.UI = new BattleUI());// Automatically assign shortcut

                summaryUI = new AnimatorUI();
                summaryUI.Activate();

                summaryUIInterface = new UserInterface();
                summaryUIInterface.SetState(summaryUI);
            }


            if (Main.dedServ)
            {
                return;
            }

            Scheduler = new Scheduler(Thread.CurrentThread, schedulerClock = new GameTimeClock());

            FirstPKMAbility  = RegisterHotKey("First Pokémon Move", Keys.Z.ToString());
            SecondPKMAbility = RegisterHotKey("Second Pokémon Move", Keys.X.ToString());
            ThirdPKMAbility  = RegisterHotKey("Third Pokémon Move", Keys.C.ToString());
            FourthPKMAbility = RegisterHotKey("Fourth Pokémon Move", Keys.V.ToString());

            CompressSidebar = RegisterHotKey("Compress Sidebar", Keys.RightShift.ToString());

            PartyCycle = RegisterHotKey("Quick Spawn First Party Pokémon", Keys.RightAlt.ToString());
        }