Imports System, Microsoft.VisualBasic
Dim name, attack1, attack2 As String
Dim health, attack1Damage, attack2Damage, attack2Prob As Single
Dim attackChoice As Integer
Dim computerAttackChoice As Integer
Dim pokemon1, pokemon2, player, computer As Pokemon
pokemon1.name = "Pikachu"
pokemon1.attack1 = "Gnaw"
pokemon1.attack1Damage = 10
pokemon1.attack2 = "Thunder Jolt"
pokemon1.attack2Damage = 30
pokemon1.attack2Prob = .3
pokemon2.name = "Charmander"
pokemon2.attack1 = "Scratch"
pokemon2.attack1Damage = 10
pokemon2.attack2 = "Ember"
pokemon2.attack2Damage = 20
pokemon2.attack2Prob = .5
Console.WriteLine("Would you like to choose pikachu (P) or charmander (C)?")
userChoice = Console.ReadLine()
Else If userChoice = "C" Then
Console.WriteLine("The player's name is " & player.name)
Console.WriteLine("The player's health is " & player.health)
Console.WriteLine("The player's first attack is " & player.attack1)
Console.WriteLine("The player's first attack deals " & player.attack1Damage & " damage")
Console.WriteLine("The player's second attack is " & player.attack2)
Console.WriteLine("The player's second attack deals " & player.attack2Damage & " damage")
Console.WriteLine("The player's second attack probability is " & player.attack2Prob)
Do While player.health > 0 And computer.health > 0
Console.WriteLine("Choose an attack: ")
Console.WriteLine("1. " & player.attack1)
Console.WriteLine("2. " & player.attack2)
Console.WriteLine("Please make a selection: ")
attackChoice = Console.ReadLine()
call weakAttack(player, computer)
Console.WriteLine("Current health of player: " & player.health)
Console.WriteLine("Current health of computer: " & computer.health)
Else If attackChoice = 2 Then
call strongAttack(player, computer)
Console.WriteLine("Current health of player: " & player.health)
Console.WriteLine("Current health of computer: " & computer.health)
If computer.health > 0 Then
computerAttackChoice = Int(Rnd() * 2 + 1)
If computerAttackChoice = 1 Then
call weakAttack(computer, player)
Console.WriteLine("Current health of player: " & player.health)
Console.WriteLine("Current health of computer: " & computer.health)
Else If computerAttackChoice = 2 Then
call strongAttack(computer, player)
Console.WriteLine("Current health of player: " & player.health)
Console.WriteLine("Current health of computer: " & computer.health)
If player.health > 0 And computer.health <= 0 Then
Console.WriteLine(computer.name & " has fainted! The player wins!")
Else If player.health <= 0 And computer.health > 0 Then
Console.WriteLine(player.name & " has fainted! The computer wins!")
Private Sub weakAttack(ByRef attacker As Pokemon, ByRef defender As Pokemon)
Console.WriteLine(attacker.name & " uses " & attacker.attack1)
Console.WriteLine(defender.name & " takes " & attacker.attack1Damage & " damage")
defender.health = defender.health - attacker.attack1Damage
Private Sub strongAttack(ByRef attacker As Pokemon, ByRef defender As Pokemon)
Dim attackRoll As Integer = Rnd()
If attackRoll <= attacker.attack2prob Then
Console.WriteLine(attacker.name & " uses" & " " & attacker.attack2)
Console.WriteLine(defender.name & " takes" & " " & attacker.attack2Damage & " damage")
defender.health = defender.health - attacker.attack2Damage
Console.WriteLine(attacker.name & " uses" & " " & attacker.attack2)
Console.WriteLine("The attack missed")