<commit_before>﻿namespace BaconGameJam6.Models.Player
{
    using System;
    using System.Collections.Generic;

    using BaconGameJam6.Models.Blocks;
    using BaconGameJam6.Models.Boards;
    using BaconGameJam6.Models.States;

    public enum PlayerId
    {
        One,
        Two
    }

    public class Ship : BoardPiece
    {
        private const float Speed = 8f;

        public event EventHandler<MatchEventArgs> Match;
        public event EventHandler<MatchEventArgs> BlockDestroyed;

        private readonly List<Block> outstandingBlocks; 

        public Ship(Board board, int col, int row, PlayerId playerId)
            : base(board, col, row)
        {
            this.PlayerId = playerId;
            this.outstandingBlocks = new List<Block>();
            this.CanFire = true;
            this.CanMove = true;
        }

        public PlayerId PlayerId { get; private set; }

        public bool CanFire { get; private set; }

        public bool CanMove { get; set; }

        public void FireMainWeapon()
        {
            this.Board.Add(new Missile(this.Board, this, (int)Math.Round(this.X), this.Row));
            this.CanFire = false;
        }

        public void ReloadWeapon()
        {
            this.CanFire = true;
        }

        public void RecordHit(Block block)
        {
            this.outstandingBlocks.Add(block);
            this.BlockDestroyed(this, new MatchEventArgs(this.outstandingBlocks.ToArray()));

            if (this.outstandingBlocks.Count == 3 || this.outstandingBlocks.Count == 2 && block.BlockType != this.outstandingBlocks[0].BlockType)
            {
                this.Match(this, new MatchEventArgs(this.outstandingBlocks.ToArray()));
                this.outstandingBlocks.Clear();
            }
        }

        protected override IEnumerable<IState> OnColumnChanged(int oldColumn, int newColumn)
        {
            this.CanMove = false;
            yield return new Sliding(this);
        }
    }<commit_msg>Protecting from null ref exceptions<commit_after>﻿namespace BaconGameJam6.Models.Player
{
    using System;
    using System.Collections.Generic;

    using BaconGameJam6.Models.Blocks;
    using BaconGameJam6.Models.Boards;
    using BaconGameJam6.Models.States;

    public enum PlayerId
    {
        One,
        Two
    }

    public class Ship : BoardPiece
    {
        private const float Speed = 8f;

        public event EventHandler<MatchEventArgs> Match;
        public event EventHandler<MatchEventArgs> BlockDestroyed;

        private readonly List<Block> outstandingBlocks; 

        public Ship(Board board, int col, int row, PlayerId playerId)
            : base(board, col, row)
        {
            this.PlayerId = playerId;
            this.outstandingBlocks = new List<Block>();
            this.CanFire = true;
            this.CanMove = true;
        }

        public PlayerId PlayerId { get; private set; }

        public bool CanFire { get; private set; }

        public bool CanMove { get; set; }

        public void FireMainWeapon()
        {
            this.Board.Add(new Missile(this.Board, this, (int)Math.Round(this.X), this.Row));
            this.CanFire = false;
        }

        public void ReloadWeapon()
        {
            this.CanFire = true;
        }

        public void RecordHit(Block block)
        {
            this.outstandingBlocks.Add(block);
            if (this.BlockDestroyed != null)
            {
                this.BlockDestroyed(this, new MatchEventArgs(this.outstandingBlocks.ToArray()));
            }

            if (this.outstandingBlocks.Count == 3 || this.outstandingBlocks.Count == 2 && block.BlockType != this.outstandingBlocks[0].BlockType)
            {
                this.Match(this, new MatchEventArgs(this.outstandingBlocks.ToArray()));
                this.outstandingBlocks.Clear();
            }
        }

        protected override IEnumerable<IState> OnColumnChanged(int oldColumn, int newColumn)
        {
            this.CanMove = false;
            yield return new Sliding(this);
        }
    }
{'fraction_non_alphanumeric': 0.09033047735618115, 'fraction_numerical': 0.003916768665850673, 'mean_word_length': 1.965166908563135, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4101668', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1071, 'n_words': 253}