Beispiel #1
0
        public override string action()
        {
            string error = "";

            loadNecessaryData();
            if (!data.isValidAttack(firstLand, secondLand, nTanks))
            {
                error = "some data are not correct";
            }
            if (error.Equals(""))
            {
                error = "FORCE_NEXT_PHASE";
                data.setDefendPhase(secondLand);
                string message = manageMessage.messageInitiateCombat(firstLand, secondLand, nTanks);
                view.updateLogEvent(manageMessage.readInitiateCombat(message));
                DataSender.SendAttackDeclared(message);
                if (!controller.isLocalMode())
                {
                    nextPhaseLoad = new StateWait(controller, data, manageMessage, view);
                }
                else
                {
                    nextPhaseLoad = new StateDefend(controller, data, manageMessage, view);
                    controller.setLocalMode();
                    controller.setFirstLand(firstLand);
                    controller.setSecondLand(secondLand);
                    controller.setTank1(nTanks);
                }
            }
            return(error);
        }
        private void next()
        {
            if (!controller.isLocalMode())
            {
                view.updatePhase(data.getPlayer(), data.getPhase());
                nextPhaseLoad = new StateWait(controller, data, manageMessage, view);
            }

            else
            {
                controller.setLocalMode();
                nextPhaseLoad = new StateDeploy(controller, data, manageMessage, view);
            }
        }
        public override string action()
        {
            string error = "";

            loadNecessaryData();
            int lossTanksAttacker = data.getTankOfLand(firstLand);
            int lossTanksDefender = data.getTankOfLand(secondLand);

            error = data.attack(firstLand, secondLand, nTanksAttacker, nTanksDefender);
            if (error.Equals(""))
            {
                error = "FORCE_NEXT_PHASE";
                data.setAttackPhase(firstLand);
                lossTanksAttacker -= data.getTankOfLand(firstLand);
                lossTanksDefender -= data.getTankOfLand(secondLand);
                string result = "";
                if (data.getPlayerByLand(secondLand).Equals(data.getPlayerByLand(firstLand)))
                {
                    result = "The land has been conquered";
                }
                else
                {
                    result = "The land has not been conquered";
                }
                string message = manageMessage.messageDefend(secondLand, firstLand, lossTanksAttacker, lossTanksDefender, "" + nTanksDefender, result);
                view.updateLogEvent(manageMessage.readDefend(message));
                DataSender.SendAttacco(message);
                if (!controller.isLocalMode())
                {
                    nextPhaseLoad = new StateWait(controller, data, manageMessage, view);
                }
                else
                {
                    controller.setLocalMode();
                    nextPhaseLoad = new StateAttack(controller, data, manageMessage, view);
                }
            }
            return(error);
        }
 public override StateControl nextPhaseForced()
 {
     if (nTanksRemain > 0)
     {
         nextPhaseLoad = this;
         view.showMessage("You have to deploy ALL your tanks !!!");
     }
     else
     {
         if (!data.isAllPlayerRunOutOfTanks())
         {
             recycle();
         }
         else
         {
             loadStart();
         }
     }
     if (controller.isLocalMode())
     {
         controller.setLocalMode();
     }
     return(nextPhaseLoad);
 }