Пример #1
0
 public GameController(FightClubForm form, LogsForm logsForm, PlayerForm userForm, PlayerForm computerForm, GameParticipant human, GameParticipant computer)
 {
     this.userForm     = userForm;
     this.computerForm = computerForm;
     this.logsForm     = logsForm;
     this.form         = form;
     this.human        = human;
     this.computer     = computer;
 }
Пример #2
0
        private GameParticipant WoundHandler(GameParticipant user)
        {
            logsForm.UpdateLogs(user.name + " got damage 10hp \r");
            user.health -= HIT_HP; // one hit equals 10hp

            if (user.name == human.name)
            {
                userForm.UpdateHealth(user.health);
            }
            else
            {
                computerForm.UpdateHealth(user.health);
            }

            return(user);
        }
Пример #3
0
        public void StartGameRound()
        {
            // 1 step: user attack
            computer.SetBlock(GenerateComputerChoice());
            computer.GetGit(AnalyseHumanChoice(form.headRadioButton, form.bodyRadioButton, form.feetRadioButton));

            // 2 step: check if computer is alive
            computer = computer.Death();

            // 3 step: computer attack
            human.SetBlock(AnalyseHumanChoice(form.headRadioButtonBlock, form.bodyRadioButtonBlock, form.feetRadioButtonBlock));
            human.GetGit(GenerateComputerChoice());

            // 4 step: check if human is alive
            human = human.Death();
        }
        private void FightClubForm_Load(object sender, EventArgs e)
        {
            human      = new GameParticipant("You");
            computer   = new GameParticipant("Computer");
            controller = new GameController(this, logsForm, userForm, computerForm, human, computer);

            human.Block     += BlockHandler;
            human.TakeWound += WoundHandler;
            human.Die       += DeathHandler;

            computer.Block     += BlockHandler;
            computer.TakeWound += WoundHandler;
            computer.Die       += DeathHandler;

            logsForm.UpdateLogs("You, please, start attack...\r");
        }
Пример #5
0
 private GameParticipant BlockHandler(GameParticipant user, PartOfBody blockedPart)
 {
     logsForm.UpdateLogs(user.name + " blocked the attack, " + blockedPart + " kick blocked \r");
     return(user);
 }
Пример #6
0
 private GameParticipant DeathHandler(GameParticipant user)
 {
     logsForm.UpdateLogs(user.name + " was dead... \r");
     form.startFightButton.Enabled = false;
     return(user);
 }