private void battleButton_Click(object sender, EventArgs e) { int idx = battleBox.SelectedIndex; int turn = r.Next(1, 3); monster mymons = dbmons[idx]; if (enemy.Hp > 0) { if (turn == 1) { mymons.myAttack(enemy, historyRtb); enemy.eAttack(mymons, historyRtb); statPlayer(mymons); statEnemy(enemy); } else if (turn == 2) { enemy.eAttack(mymons, historyRtb); mymons.myAttack(enemy, historyRtb); statEnemy(enemy); statPlayer(mymons); } if (enemy.Hp <= 0) { victory(mymons); } else if (mymons.Hp <= 0) { defeated(mymons); } } else { MessageBox.Show("Tidak ada musuh!"); } }
private void battleButton_Click(object sender, EventArgs e) { int idx = battleBox.SelectedIndex; if (battleBox.Items.Count > 0 && idx > -1) { battleList.Items.Clear(); monster mymons = dbmons[idx]; monster enemy = new monster(); mymons.Hp = mymons.Maxhp; do { statsBattle(mymons, enemy); if (mymons.Hp > 0) { mymons.myAttack(enemy, battleList); } battleList.Items.Add("\n"); statsBattle(mymons, enemy); if (enemy.Hp > 0) { enemy.eAttack(mymons, battleList); } battleList.Items.Add("\n"); } while (mymons.Hp > 0 && enemy.Hp > 0); if (enemy.Hp <= 0) { enemy.Hp = 0; victory(mymons); } else if (mymons.Hp <= 0) { mymons.Hp = 0; totalmons -= 1; defeated(mymons); } } else { MessageBox.Show("You don't have any monster!"); } }