Exemplo n.º 1
0
        /// <summary>
        /// Returns the naive sail options that the native game object returns
        /// </summary>
        public List <Location> GetNaiveSailOptions(Pirate pirate, ILocateable destination, int moves)
        {
            if (pirate == null || destination == null || destination.GetLocation() == null)
            {
                return(new List <Location>());
            }

            Pirates.Pirate   nativePirate      = pirate.Owner == Owner.Me ? this.game.GetMyPirate(pirate.Id) : this.game.GetEnemyPirate(pirate.Id);
            Pirates.Location nativeDestination = new Pirates.Location(destination.GetLocation().Row, destination.GetLocation().Collumn);
            List <Location>  res = new List <Location>();

            foreach (Pirates.Location loc in this.game.GetSailOptions(nativePirate, nativeDestination, moves))
            {
                res.Add(new Location(loc.Row, loc.Col));
            }
            return(res);
        }
Exemplo n.º 2
0
        //////////Methods//////////

        /// <summary>
        /// Creates a new pirate based on the parameter given
        /// </summary>
        public Pirate(Pirates.Pirate p, int freePirateMaxSpeed)
        {
            this.freePirateMaxSpeed = freePirateMaxSpeed;

            this.Id = p.Id;
            this.InitialLocation = new Location(p.InitialLocation);

            if (p.Owner == Consts.ME)
            {
                this.Owner = Owner.Me;
            }
            else
            {
                this.Owner = Owner.Enemy;
            }

            this.Update(p);
        }
Exemplo n.º 3
0
        public void Brawl(Pirate anotherPirate)
        {
            if (this.IsDead || anotherPirate.IsDead)
            {
                Console.WriteLine("cant brawl with a dead man");
                return;
            }
            switch (new Random().Next(1, 4))
            {
            case 1:
                this.IsDead = true;
                break;

            case 2:
                anotherPirate.IsDead = true;
                break;

            case 3:
                Console.WriteLine("draw");
                break;
            }
        }
Exemplo n.º 4
0
        public string Brawl(Pirate enemy)
        {
            if (enemy.IsAlive)
            {
                switch (rnd.Next(0, 3))
                {
                case 0:
                    this.IsAlive = false;
                    return($"{this.Name} died!");

                case 1:
                    enemy.IsAlive = false;
                    return($"{enemy.Name} died!");

                case 2:
                    this.IsAlive  = false;
                    enemy.IsAlive = false;
                    return("Both pirates died!");
                }
            }
            return($"{enemy.Name} is dead already!");
        }
Exemplo n.º 5
0
 // Brawl(x) - where pirate fights another pirate (if that other pirate is alive) and
 // there's a 1/3 chance, 1 dies, the other dies or they both pass out.
 public void Brawl(Pirate name)
 {
     if (name.IsAlive)
     {
         var randomChance = new Random().Next(1, 4);
         if (randomChance == 1)
         {
             Die();
             Console.WriteLine($"{Name} has died");
         }
         else if (randomChance == 2)
         {
             name.Die();
             Console.WriteLine($"{name.Name} has died");
         }
         else
         {
             IsPassedOut      = true;
             name.IsPassedOut = true;
             Console.WriteLine($"{Name} and {name.Name} is passed out");
         }
     }
 }
Exemplo n.º 6
0
        public void Brawl(Pirate enemy)
        {
            var ranNum = new Random().Next(1, 4);

            switch (ranNum)
            {
            case 1:
                enemy.Die();
                Console.WriteLine("{Name}killed{ enemy.Name}.");
                break;

            case 2:
                Die();
                Console.WriteLine("{enemy.Name} killed {Name}.");
                break;

            case 3:
                enemy.Sleep();
                Sleep();
                Console.WriteLine("Both passed out.");
                break;
            }
        }
Exemplo n.º 7
0
 public void AddCrewMember(Pirate sailor)
 {
     Crew.Add(sailor);
 }
Exemplo n.º 8
0
 public void AssignCaptain(Pirate captain)
 {
     this.captain = captain;
 }
Exemplo n.º 9
0
 public void ReadyToBoard(Pirate pirate)
 {
     Sailors.Add(pirate);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Updates this pirate
        /// </summary>
        public void Update(Pirates.Pirate p)
        {
            this.nativeObject = p;

            // updates the pirate's state
            if (p.IsLost)
            {
                this.state = PirateState.Lost;
            }
            else if (p.TurnsToSober > 0)
            {
                this.state = PirateState.Drunk;
            }
            else if (p.HasTreasure)
            {
                this.state = PirateState.CarryingTreasure;
            }
            else
            {
                this.state = PirateState.Free;
            }

            // updates the pirate's location, but ONLY if the new location can possibly be inside the map
            if (p.Location != null && p.Location.Row >= 0 && p.Location.Col >= 0)
            {
                this.location = new Location(p.Location);
            }

            // updates counters
            this.turnsToSober         = p.TurnsToSober;
            this.turnsToRevive        = p.TurnsToRevive;
            this.turnsToAttackReload  = p.ReloadTurns;
            this.turnsToDefenseReload = p.DefenseReloadTurns;
            this.defenseDuration      = p.DefenseExpirationTurns;

            // updates carried treasure; should be updated to not-null manually every turn
            this.carriedTreasure = null;

            // updates powerups
            if (p.Powerups != null)
            {
                this.powerups = new List <string>(p.Powerups);
            }
            else
            {
                this.powerups = new List <string>();
            }

            // calculate current speed limit
            if (this.State == PirateState.CarryingTreasure)
            {
                this.maxSpeed = p.CarryTreasureSpeed;
            }
            else
            {
                this.maxSpeed = this.freePirateMaxSpeed;
            }

            // calculate attack radius
            this.attackRadius = Utils.Pow(p.AttackRadius, 0.5);
        }
Exemplo n.º 11
0
 public PirateShip(Pirate captain)
 {
     this.captain    = new Pirate(captain);
     this.pirates    = new Pirate[MAX_PIRATES];
     this.numPirates = 0;
 }
Exemplo n.º 12
0
 public Pirate(Pirate p)
 {
     this.name         = p.name;
     this.hasParrot    = p.hasParrot;
     this.hasWoodenLeg = p.hasWoodenLeg;
 }