Example #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);
        }