示例#1
0
        internal string Delete(int id)
        {
            Knights data = GetById(id);

            _repo.Delete(id);
            return("Knight Retired");
        }
示例#2
0
        internal Knights Edit(Knights updated)
        {
            Knights data = GetById(updated.Id);

            //null check properties you are editing in repo
            data.Name = updated.Name != null ? updated.Name : data.Name;
            data.Age  = updated.Age != null ? updated.Age : data.Age;
            return(_repo.Edit(data));
        }
示例#3
0
        internal Knights GetById(int id)
        {
            Knights data = _repo.GetById(id);

            if (data == null)
            {
                throw new Exception("Invalid Id");
            }
            return(data);
        }
示例#4
0
 public ActionResult <Knights> Create([FromBody] Knights newKnight)
 {
     try
     {
         return(Ok(_service.Create(newKnight)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#5
0
        public Knight(List <Vector3Int> potrolPoints, Colony owner)
        {
            if (!Knights.ContainsKey(owner))
            {
                Knights.Add(owner, new List <Knight>());
            }

            Knights[owner].Add(this);
            PatrolPoints = potrolPoints;
            KeyLocation  = PatrolPoints[0];
            Owner        = owner;
        }
示例#6
0
 public ActionResult <Knights> Edit([FromBody] Knights updated, int id)
 {
     try
     {
         updated.Id = id;
         return(Ok(_service.Edit(updated)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#7
0
        public Knight(List <Vector3Int> potrolPoints, Players.Player owner)
        {
            if (!Knights.ContainsKey(owner))
            {
                Knights.Add(owner, new List <Knight>());
            }

            Knights[owner].Add(this);
            PatrolPoints = potrolPoints;
            _position    = PatrolPoints[0];
            _owner       = owner;
        }
        internal Knights Edit(Knights updatedKnight)
        {
            string  sql          = @"
      UPDATE knight
      SET
        name = @Name,
        age = @Age,
      WHERE id = @Id;
      SELECT * FROM knight WHERE id = @Id;";
            Knights returnKnight = _db.QueryFirstOrDefault <Knights>(sql, updatedKnight);

            return(returnKnight);
        }
        internal Knights Create(Knights newKnight)
        {
            string sql = @"
            INSERT INTO knight
            (name, age, castleId)
            VALUES
            (@Name, @Age, @CastleId);
            SELECT LAST_INSERT_ID();";
            int    id  = _db.ExecuteScalar <int>(sql, newKnight);

            newKnight.Id = id;
            return(newKnight);
        }
        public void RecruitKnights()
        {
            var faction = new Knights();
            var counter = 0;

            for (var i = 0; i < 5; i++)
            {
                var soldier = new Jedi();
                soldier.Weapon = faction.StandardIssueWeapon;
                faction.Soldiers.Add(soldier);
            }
            Legion.Factions.Add(faction);
        }
示例#11
0
        internal static void CityProduction(City city)
        {
            if (city == null || city.Size == 0 || city.Tile == null)
            {
                return;
            }

            Player      player     = Game.GetPlayer(city.Owner);
            IProduction production = null;

            // Create 2 defensive units per city
            if (player.HasAdvance <LaborUnion>())
            {
                if (city.Tile.Units.Count(x => x is MechInf) < 2)
                {
                    production = new MechInf();
                }
            }
            else if (player.HasAdvance <Conscription>())
            {
                if (city.Tile.Units.Count(x => x is Riflemen) < 2)
                {
                    production = new Riflemen();
                }
            }
            else if (player.HasAdvance <Gunpowder>())
            {
                if (city.Tile.Units.Count(x => x is Musketeers) < 2)
                {
                    production = new Musketeers();
                }
            }
            else if (player.HasAdvance <BronzeWorking>())
            {
                if (city.Tile.Units.Count(x => x is Phalanx) < 2)
                {
                    production = new Phalanx();
                }
            }
            else
            {
                if (city.Tile.Units.Count(x => x is Militia) < 2)
                {
                    production = new Militia();
                }
            }

            // Create city improvements
            if (production == null)
            {
                if (!city.HasBuilding <Barracks>())
                {
                    production = new Barracks();
                }
                else if (player.HasAdvance <Pottery>() && !city.HasBuilding <Granary>())
                {
                    production = new Granary();
                }
                else if (player.HasAdvance <CeremonialBurial>() && !city.HasBuilding <Temple>())
                {
                    production = new Temple();
                }
                else if (player.HasAdvance <Masonry>() && !city.HasBuilding <CityWalls>())
                {
                    production = new CityWalls();
                }
            }

            // Create Settlers
            if (production == null)
            {
                if (city.Size > 3 && !city.Units.Any(x => x is Settlers) && player.Cities.Length < 10)
                {
                    production = new Settlers();
                }
            }

            // Create some other unit
            if (production == null)
            {
                if (city.Units.Length < 4)
                {
                    if (player.Government is Republic || player.Government is Democratic)
                    {
                        if (player.HasAdvance <Writing>())
                        {
                            production = new Diplomat();
                        }
                    }
                    else
                    {
                        if (player.HasAdvance <Automobile>())
                        {
                            production = new Armor();
                        }
                        else if (player.HasAdvance <Metallurgy>())
                        {
                            production = new Cannon();
                        }
                        else if (player.HasAdvance <Chivalry>())
                        {
                            production = new Knights();
                        }
                        else if (player.HasAdvance <TheWheel>())
                        {
                            production = new Chariot();
                        }
                        else if (player.HasAdvance <HorsebackRiding>())
                        {
                            production = new Cavalry();
                        }
                        else if (player.HasAdvance <IronWorking>())
                        {
                            production = new Legion();
                        }
                    }
                }
                else
                {
                    if (player.HasAdvance <Trade>())
                    {
                        production = new Caravan();
                    }
                }
            }

            // Set random production
            if (production == null)
            {
                IProduction[] items = city.AvailableProduction.ToArray();
                production = items[Common.Random.Next(items.Length)];
            }

            city.SetProduction(production);
        }
示例#12
0
        private static IUnit CreateUnit(UnitType type, int x, int y)
        {
            IUnit unit;

            switch (type)
            {
            case UnitType.Settlers: unit = new Settlers(); break;

            case UnitType.Militia: unit = new Militia(); break;

            case UnitType.Phalanx: unit = new Phalanx(); break;

            case UnitType.Legion: unit = new Legion(); break;

            case UnitType.Musketeers: unit = new Musketeers(); break;

            case UnitType.Riflemen: unit = new Riflemen(); break;

            case UnitType.Cavalry: unit = new Cavalry(); break;

            case UnitType.Knights: unit = new Knights(); break;

            case UnitType.Catapult: unit = new Catapult(); break;

            case UnitType.Cannon: unit = new Cannon(); break;

            case UnitType.Chariot: unit = new Chariot(); break;

            case UnitType.Armor: unit = new Armor(); break;

            case UnitType.MechInf: unit = new MechInf(); break;

            case UnitType.Artillery: unit = new Artillery(); break;

            case UnitType.Fighter: unit = new Fighter(); break;

            case UnitType.Bomber: unit = new Bomber(); break;

            case UnitType.Trireme: unit = new Trireme(); break;

            case UnitType.Sail: unit = new Sail(); break;

            case UnitType.Frigate: unit = new Frigate(); break;

            case UnitType.Ironclad: unit = new Ironclad(); break;

            case UnitType.Cruiser: unit = new Cruiser(); break;

            case UnitType.Battleship: unit = new Battleship(); break;

            case UnitType.Submarine: unit = new Submarine(); break;

            case UnitType.Carrier: unit = new Carrier(); break;

            case UnitType.Transport: unit = new Transport(); break;

            case UnitType.Nuclear: unit = new Nuclear(); break;

            case UnitType.Diplomat: unit = new Diplomat(); break;

            case UnitType.Caravan: unit = new Caravan(); break;

            default: return(null);
            }
            unit.X         = x;
            unit.Y         = y;
            unit.MovesLeft = unit.Move;
            return(unit);
        }
示例#13
0
 internal Knights Create(Knights newKnight)
 {
     return(_repo.Create(newKnight));
 }