private void assignDefender(LandTerritory passedTerritory)
 {
     defender = passedTerritory;
     
     if (!attacker.Equals(defender))
     {
         main.PopupLable1.Content = "A: " + attacker.getHouseOccupied().getName()  + ": " + calculateAttack(attacker);
         main.PopupLable2.Content = "D: " + defender.getHouseOccupied().getName() + ": " + calculateDefense(defender);
         main.Popup1.IsOpen = true;
         attacker.setOrderToken(new PlaceHolderOrderToken());
     }
     CancelAttack();
     
 }
 private void assignAttacker(LandTerritory passedTerritory)
 {
     attackingInfantry = 0;
     attackingKnights = 0;
     main.takeTurn.DisableAllTerritoryButtons();
     foreach (string s in passedTerritory.getConnections())
     {
         main.resources.allLandConnections[s.Trim()].getButton().IsEnabled = true;
     }
     passedTerritory.getButton().IsEnabled = true;
     passedTerritory.getButton().Background = System.Windows.Media.Brushes.DarkOliveGreen;
     passedTerritory.getButton().Content = "Click to cancel";
     attacker = passedTerritory;
     attack = false;
 }
        private int calculateAttack(LandTerritory passedTerritory)
        {
            //TODO: ***** calculate support
            int attackPower = 0;

            attackPower += (getAttackingInfantry().Count * infantry.getAttackPower());
            attackPower += (getAttackingKnights().Count * knight.getAttackPower());
            MarchOrder marchOrder = (MarchOrder)passedTerritory.getOrderToken();
            if (marchOrder.getStar())
            {
                attackPower += 1;
            }
            else if (marchOrder.getNegToken())
            {
                attackPower -= 1;
            }
            return attackPower;
        }
Exemplo n.º 4
0
        public void DrawIt(LandTerritory passedTerritory)
        {
            passedTerritory.getStackPanel().Children.Clear();
            passedTerritory.getStackPanel().Orientation = System.Windows.Controls.Orientation.Horizontal;
            string fileString = "";

            foreach (Knight k in passedTerritory.getKnights())
            {
                fileString = "C:\\Users\\User\\Desktop\\GameOfThronesProject\\GameOfThronesUnits\\" + passedTerritory.getHouseOccupied().getName() + "Knight.jpg";
                System.Windows.Controls.Image image1 = new System.Windows.Controls.Image();
                image1.Source = new BitmapImage(new Uri(fileString, UriKind.RelativeOrAbsolute));
                passedTerritory.getStackPanel().Children.Add(image1);
            }

            foreach (Infantry i in passedTerritory.getInfantry())
            {
                fileString = "C:\\Users\\User\\Desktop\\GameOfThronesProject\\GameOfThronesUnits\\" + passedTerritory.getHouseOccupied().getName() + "Footman.jpg";
                System.Windows.Controls.Image image1 = new System.Windows.Controls.Image();
                image1.Source = new BitmapImage(new Uri(fileString, UriKind.RelativeOrAbsolute));
                passedTerritory.getStackPanel().Children.Add(image1);
            }
            
        }
 private LandTerritory parseGoodies(string line, Button button, StackPanel stackPanel)
 {
     List<string> placeHolderConnections = new List<string>();
     int numCrowns = 0;
     int numSupply = 0;
     bool hasCastle = false;
     bool hasStronghold = false;
     bool hasPort = false;
     bool isOccupied = false;
     string[] splitLine = line.Split(':');
     string name = splitLine[0];
     string[] goodies = splitLine[1].Split(',');
     LandTerritory land;
     foreach (string s in goodies)
     {
         if(s.Trim().Equals("CROWN")){
             numCrowns++;
         }
         if(s.Trim().Equals("SUPPLY")){
             numSupply++;
         }
         if(s.Trim().Equals("CASTLE")){
             hasCastle = true;
         }
         if(s.Trim().Equals("STRONGHOLD")){
             hasStronghold = true;
         }
         if(s.Trim().Equals("PORT")){
             hasPort = true;
         }
     }
     
     land = new LandTerritory(name, numSupply, numCrowns, 0, 0, 0, hasCastle, hasStronghold, isOccupied, resource.Neutral, new PlaceHolderOrderToken(), placeHolderConnections);
     allLands.Add(name, land);
     return land;
 }
 private int calculateDefense(LandTerritory passedTerritory)
 {
     //TODO **** calculate support
     int defensePower = 0;
     defensePower += (getAttackingInfantry().Count * infantry.getDefensePower());
     defensePower += (getAttackingKnights().Count * knight.getDefensePower());
     if (passedTerritory.getOrderToken() is DefenseOrder)
     {
         DefenseOrder defenseOrder = (DefenseOrder)passedTerritory.getOrderToken();
         if (defenseOrder.getStar())
         {
             defensePower += 2;
         }
         else
         {
             defensePower += 1;
         }
     }
     return defensePower;
 }
        private void MoveToNewTerritory(LandTerritory passedTerritory)
        {
            Infantry placeHolderInfantry;
            Knight placeHolderKnight;
            passedTerritory.setNumKnight(getAttackingKnights().Count);
            passedTerritory.setNumInfantry(getAttackingInfantry().Count);
            attacker.setNumKnight(attacker.getNumKnight() - getAttackingKnights().Count);
            attacker.setNumInfantry(attacker.getNumInfantry() - getAttackingInfantry().Count);
            passedTerritory.setHouseOccupied(attacker.getHouseOccupied());
            passedTerritory.setOrderToken(new PlaceHolderOrderToken());

            foreach(Knight k in getAttackingKnights())
            {
                attacker.getKnights().Remove(k);
                passedTerritory.getKnights().Add(k);
            }

            foreach(Infantry i in getAttackingInfantry())
            {    
                attacker.getInfantry().Remove(i);
                passedTerritory.getInfantry().Add(i);  
            }
        }
 public void doMarchOrder(LandTerritory passedTerritory)
 {
     if (attack)
     {
         if (passedTerritory.getOrderToken() is MarchOrder)
         {   
             showMarchTroopPopup(passedTerritory);
             assignAttacker(passedTerritory);
         }
     }
     else
     {
         //main.PopupChooseMarchTroops.IsOpen = false;
         
         //has enemy troops
         if (passedTerritory.getNumKnight() > 0 || passedTerritory.getNumInfantry() > 0 && !(passedTerritory.getHouseOccupied().Equals(attacker.getHouseOccupied())))
         {
             assignDefender(passedTerritory);
         }
         //Click on same territory to cancel attack
         else if (passedTerritory.Equals(attacker))
         {
             CancelAttack();
         }
         //Moving between friendly territories
         else if (passedTerritory.getHouseOccupied().Equals(attacker.getHouseOccupied()))
         {
             passedTerritory.setNumInfantry(passedTerritory.getNumInfantry() + getAttackingInfantry().Count);
             passedTerritory.setNumKnight(passedTerritory.getNumKnight() + getAttackingKnights().Count);
             attacker.setNumKnight(attacker.getNumKnight() - getAttackingKnights().Count);
             attacker.setNumInfantry(attacker.getNumInfantry() - getAttackingInfantry().Count);
             showMarchTroopPopup(attacker);
         }
         //Empty territory/has just a power token
         else
         {
             MoveToNewTerritory(passedTerritory);
             showMarchTroopPopup(attacker);
         }
         main.drawUnits.DrawIt(passedTerritory);
         main.drawUnits.DrawIt(attacker);
         
     }
 }
        private void routeTroops(LandTerritory passedTerritory)
        {


            if (passedTerritory.Equals(attacker))
            {

                //attacker lost

            }
            else
            {
                foreach (string s in passedTerritory.getConnections())
                {
                    if (main.resources.allLandConnections[s].getHouseOccupied().Equals(passedTerritory.getHouseOccupied()) || main.resources.allLandConnections[s].getHouseOccupied() is HouseNeutral)
                    {
                        main.resources.allLandConnections[s].getButton().IsEnabled = true;
                    }
                }

                //defender lost
                main.takeTurn.disableButtons(passedTerritory.getHouseOccupied());
            }
        }
Exemplo n.º 10
0
 private void showMarchTroopPopup(LandTerritory passedTerritory)
 {
     main.PopupChooseMarchTroops.IsOpen = true;
     main.KnightListBox.Items.Clear();
     main.FootmanListBox.Items.Clear();            
     int count = 0;
     main.KnightListBox.Items.Add(count);
     foreach (Knight k in passedTerritory.getKnights())
     {
         count++;
         if (!k.getRouted())
         {
             main.KnightListBox.Items.Add(count);
         }     
     }
     count = 0;
     main.FootmanListBox.Items.Add(count);
     foreach (Infantry i in passedTerritory.getInfantry())
     {
         count++;
         if (!i.getRouted())
         {
             main.FootmanListBox.Items.Add(count);
         }     
     }
 }
        public void performButtonFunction(LandTerritory passedTerritory)
        {
            switch (turnPhase)
            {
                case TurnPhase.PlaceTokens:
                    //takeTurn.updateDisableButtons();
                    currentTerritory = passedTerritory;
                    ChooseOrderTokenPopup.IsOpen = false;
                    ChooseOrderTokenPopup.IsOpen = true; 
                   //passedTerritory.setOrderToken(new MarchOrder(false, true, false));
                    //passedText.Text = takeTurn.territoryPrintOut(passedTerritory);
                    break;
                case TurnPhase.Westeros:

                    break;
                case TurnPhase.Raid:

                    break;
                case TurnPhase.March:
                     resolveMarch.doMarchOrder((LandTerritory)passedTerritory);

                    break;
                case TurnPhase.ConsolidatePower:


                    turnNum++;
                    break;
               }
        }
Exemplo n.º 12
0
        public void setHouseStartingLand(House house, LandTerritory land, int numInfantry, int numKnights, int numSiegeEngine)
        {
            List<Infantry> infantry = new List<Infantry>();
            List<Knight> knight = new List<Knight>();
            land.setHouseOccupied(house);
            land.setNumInfantry(numInfantry);
            for (int i = 0; i < numInfantry; i++)
            {
                infantry.Add(new Infantry());
            }
            land.setInfantry(infantry);
            land.setNumKnight(numKnights);
            for (int i = 0; i < numKnights; i++)
            {
                knight.Add(new Knight());
            }
            land.setKnights(knight);

            main.drawUnits.DrawIt(land);
        }
Exemplo n.º 13
0
 public string territoryPrintOut(LandTerritory passedTerritory)
 {
     string str = (territoryTextToString(passedTerritory.getHouseOccupied().getName(), passedTerritory.getNumInfantry(), passedTerritory.getNumKnight(),
                   passedTerritory.getNumSiegeEngine(), passedTerritory.getOrderToken(), passedTerritory));
     return str;
 }
Exemplo n.º 14
0
        public void performBattle(LandTerritory attacker, LandTerritory defender)
        {

            if (attacker.getNumInfantry() + attacker.getNumKnight() > defender.getNumInfantry() + defender.getNumKnight())
            {
                attacker.setOrderToken(new PlaceHolderOrderToken());
                main.ConfirmAttack_Click();
            }
            else
            {

            }
        }
Exemplo n.º 15
0
        public string territoryTextToString(string name, int infantry, int knights, int siegeEngine, OrderToken order, LandTerritory land)
        {
            string returnString = name + "- ";
            if (infantry > 0)
            {
                returnString += " F: " + infantry;
            }
            if (knights > 0)
            {
                returnString += " K: " + knights;
            }
            if (siegeEngine > 0)
            {
                returnString += " SE: " + siegeEngine;
            }


            returnString += order.toString();

            return returnString;
        }