Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.clear()
- local w, h = term.getSize()
- local cursor = 1
- player1Select = {}
- player2Select = {}
- selectedMove = "none"
- randomNum = "none"
- local function debugging2()
- shell.run("clear")
- for k, v in pairs(moves["Meditation"]["effect"]) do
- print(v)
- end
- os.pullEvent("key")
- shell.run("clear")
- end
- --###################### MOVES ####################################
- moves = {
- -- ############## NORMAL ###############
- Tackle = {
- name = "Tackle",
- type = "Normal",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 1,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 15
- },
- Growl = {
- name = "Growl",
- type = "Normal",
- doesDamage = false,
- attackForm = "phys",
- target = "opponent",
- power = 0,
- effect = {"none", "debuffDefense"},
- effectValue = 10,
- accuracy = 100,
- pp = 15
- },
- Scratch = {
- name = "Scratch",
- type = "Normal",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 1,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 15
- },
- Harden = {
- name = "Harden",
- type = "Normal",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "buffDefense"},
- effectValue = 10,
- accuracy = 100,
- pp = 15
- },
- Smoke = {
- name = "Smoke",
- type = "Normal",
- doesDamage = false,
- attackForm = "phys",
- target = "opponent",
- power = 0,
- effect = {"none", "debuffAccuracy"},
- effectValue = 10,
- accuracy = 100,
- pp = 5
- },
- BodySlam = {
- name = "Bodyslam",
- type = "Normal",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 2,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- Stomp = {
- name = "Stomp",
- type = "Normal",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- Screech = {
- name = "Screech",
- type = "Normal",
- doesDamage = false,
- attackForm = "phys",
- target = "opponent",
- power = 0,
- effect = {"none", "debuffAttack"},
- effectValue = 10,
- accuracy = 100,
- pp = 10
- },
- Heal = {
- name = "Heal",
- type = "Normal",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "heal"},
- effectValue = 5,
- accuracy = 100,
- pp = 10
- },
- Restore = {
- name = "Restore",
- type = "Normal",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "heal"},
- effectValue = 10,
- accuracy = 100,
- pp = 5
- },
- Selfdestruct = {
- name = "Selfdestruct",
- type = "Normal",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 7,
- effect = {"none", "selfdestruct"},
- effectValue = 0,
- accuracy = 100,
- pp = 5
- },
- Snore = {
- name = "Snore",
- type = "Normal",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "heal", "sleepSelf"},
- effectValue = 1000,
- accuracy = 100,
- pp = 5
- },
- -- ############## Grass ###############
- VineWhip = {
- name = "VineWhip",
- type = "Grass",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 2,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- Sundance = {
- name = "Sundance",
- type = "Grass",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "buffAttack", "buffSpecAttack"},
- effectValue = 10,
- accuracy = 100,
- pp = 10
- },
- RazorLeafs = {
- name = "Razorleafs",
- type = "Grass",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 4,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- LeafBlade = {
- name = "LeafBlade",
- type = "Grass",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 2,
- effect = {"none", "crit"},
- effectValue = 10,
- accuracy = 100,
- pp = 10
- },
- MagicalLeafs = {
- name = "MagicalLeafs",
- type = "Grass",
- doesDamage = true,
- attackForm = "spec",
- target = "self",
- power = 3,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- -- ############## Bug ###############
- HornCharge = {
- name = "HornCharge",
- type = "Bug",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- BugBite = {
- name = "BugBite",
- type = "Bug",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 2,
- effect = {"none", "debuffSpeed"},
- effectValue = 5,
- accuracy = 100,
- pp = 10
- },
- DefendOrder = {
- name = "DefendOrder",
- type = "Bug",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "buffDefense", "buffSpecDefense"},
- effectValue = 10,
- accuracy = 100,
- pp = 10
- },
- AttackOrder = {
- name = "AttackOrder",
- type = "Bug",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "buffAttack", "buffSpecAttack"},
- effectValue = 10,
- accuracy = 100,
- pp = 10
- },
- Net = {
- name = "Net",
- type = "Bug",
- doesDamage = false,
- attackForm = "phys",
- target = "opponent",
- power = 0,
- effect = {"none", "debuffSpeed"},
- effectValue = 20,
- accuracy = 100,
- pp = 10
- },
- -- ############## Poison ###############
- Poison = {
- name = "Poison",
- type = "Poison",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 1,
- effect = {"none", "poison"},
- effectValue = 100,
- accuracy = 100,
- pp = 10
- },
- SleepSpore = {
- name = "SleepSpore",
- type = "Poison",
- doesDamage = false,
- attackForm = "phys",
- target = "opponent",
- power = 0,
- effect = {"none", "sleep"},
- effectValue = 0,
- accuracy = 85,
- pp = 10
- },
- PoisonJab = {
- name = "PoisonJab",
- type = "Poison",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 2,
- effect = {"none", "poison"},
- effectValue = 0,
- accuracy = 65,
- pp = 10
- },
- -- ############## Rock ###############
- RockThrow = {
- name = "RockThrow",
- type = "Rock",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 2,
- effect = {"none"},
- effectValue = 0,
- accuracy = 95,
- pp = 10
- },
- StoneEdge = {
- name = "StoneEdge",
- type = "Rock",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none", "crit"},
- effectValue = 10,
- accuracy = 95,
- pp = 10
- },
- Reinforce = {
- name = "Reinforce",
- type = "Rock",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "buffDefense", "buffSpecDefense"},
- effectValue = 10,
- accuracy = 100,
- pp = 10
- },
- RockPolish = {
- name = "RockPolish",
- type = "Rock",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "buffSpeed"},
- effectValue = 15,
- accuracy = 100,
- pp = 10
- },
- -- ############## Ground ###############
- DirtSpikes = {
- name = "DirtSpikes",
- type = "Ground",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 2,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- Earthquake = {
- name = "Earthquake",
- type = "Ground",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 4,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 5
- },
- MudSquirt = {
- name = "MudSquirt",
- type = "Ground",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 1,
- effect = {"none", "debuffAccuracy"},
- effectValue = 5,
- accuracy = 100,
- pp = 20
- },
- -- ############## Dark ###############
- Bite = {
- name = "Bite",
- type = "Dark",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none", "flinch"},
- effectValue = 50,
- accuracy = 100,
- pp = 10
- },
- NightSlash = {
- name = "NightSlash",
- type = "Dark",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 2,
- effect = {"none", "crit"},
- effectValue = 15,
- accuracy = 100,
- pp = 10
- },
- DarkPulse = {
- name = "DarkPulse",
- type = "Dark",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 2,
- effect = {"none", "flinch"},
- effectValue = 40,
- accuracy = 100,
- pp = 10
- },
- NastyPlot = {
- name = "NastyPlot",
- type = "Dark",
- doesDamage = false,
- attackForm = "spec",
- target = "self",
- power = 0,
- effect = {"none", "buffSpecAttack"},
- effectValue = 20,
- accuracy = 100,
- pp = 5
- },
- -- ############## Ghost ###############
- OminousWind = {
- name = "OminousWind",
- type = "Ghost",
- doesDamage = false,
- attackForm = "spec",
- target = "self",
- power = 0,
- effect = {"none", "buffSpecAttack", "buffAttack", "buffDefense", "buffSpecDefense", "buffSpeed", "buffAccuracy"},
- effectValue = 5,
- accuracy = 100,
- pp = 5
- },
- ShadowClaw = {
- name = "ShadowClaw",
- type = "Ghost",
- doesDamage = true,
- attackForm = "spec",
- target = "self",
- power = 2,
- effect = {"none", "crit"},
- effectValue = 5,
- accuracy = 100,
- pp = 10
- },
- Curse = {
- name = "Curse",
- type = "Ghost",
- doesDamage = true,
- attackForm = "spec",
- target = "self",
- power = 3,
- effect = {"none", "curse"},
- effectValue = 5,
- accuracy = 100,
- pp = 5
- },
- -- ############## Psychic ###############
- Psybeam = {
- name = "Psybeam",
- type = "Psychic",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 2,
- effect = {"none", "confusion"},
- effectValue = 60,
- accuracy = 100,
- pp = 10
- },
- Psychic = {
- name = "Psychic",
- type = "Psychic",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 4,
- effect = {"none", "none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- Confusion = {
- name = "Confusion",
- type = "Psychic",
- doesDamage = false,
- attackForm = "spec",
- target = "opponent",
- power = 0,
- effect = {"none", "confusion"},
- effectValue = 100,
- accuracy = 85,
- pp = 10
- },
- Meditation = {
- name = "Meditation",
- type = "Psychic",
- doesDamage = false,
- attackForm = "spec",
- target = "self",
- power = 0,
- effect = {[1] = "none", [2] = "heal", [3] = "buffAccuracy", [4] = "buffSpecAttack"},
- effectValue = 5,
- accuracy = 100,
- pp = 10
- },
- -- ############## Water ###############
- SquirtGun = {
- name = "SquirtGun",
- type = "Water",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 2,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 15
- },
- Surf = {
- name = "Surf",
- type = "Water",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 4,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- AquaJet = {
- name = "AquaJet",
- type = "Water",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- Raindance = {
- name = "Raindance",
- type = "Water",
- doesDamage = false,
- attackForm = "spec",
- target = "self",
- power = 0,
- effect = {"none", "buffSpecAttack"},
- effectValue = 15,
- accuracy = 100,
- pp = 10
- },
- -- ############## Fire ###############
- Flamethrower = {
- name = "Flamethrower",
- type = "Fire",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 2,
- effect = {"none", "burn"},
- effectValue = 60,
- accuracy = 90,
- pp = 10
- },
- FireRing = {
- name = "FireRing",
- type = "Fire",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 3,
- effect = {"none", "burn"},
- effectValue = 60,
- accuracy = 95,
- pp = 10
- },
- FireStorm = {
- name = "FireStorm",
- type = "Fire",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none", "burn"},
- effectValue = 50,
- accuracy = 95,
- pp = 10
- },
- Armageddon = {
- name = "Armageddon",
- type = "Fire",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 8,
- effect = {"none"},
- effectValue = 0,
- accuracy = 50,
- pp = 5
- },
- -- ############## Steel ###############
- Impenetrable = {
- name = "Impenetrable",
- type = "Steel",
- doesDamage = false,
- attackForm = "spec",
- target = "self",
- power = 0,
- effect = {"none", "buffDefense"},
- effectValue = 25,
- accuracy = 100,
- pp = 5
- },
- FlashCannon = {
- name = "FlashCannon",
- type = "Steel",
- doesDamage = false,
- attackForm = "spec",
- target = "opponent",
- power = 0,
- effect = {"none", "debuffSpecDefense"},
- effectValue = 15,
- accuracy = 100,
- pp = 10
- },
- SteelFist = {
- name = "SteelFist",
- type = "Steel",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none"},
- effectValue = 0,
- accuracy = 85,
- },
- GyroBall = {
- name = "GyroBall",
- type = "Steel",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 0, --(100 - player..playerTurn.speed) / 15,
- effect = {"none"},
- effectValue = 0,
- accuracy = 95,
- pp = 15
- },
- -- ############## Electric ###############
- Shock = {
- name = "Shock",
- type = "Electric",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 3,
- effect = {"none", "paralyze"},
- effectValue = 60,
- accuracy = 100,
- pp = 15
- },
- ElectroShock = {
- name = "ElectroShock",
- type = "Electric",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 4,
- effect = {"none", "paralyze"},
- effectValue = 50,
- accuracy = 100,
- pp = 5
- },
- ChargeBeam = {
- name = "ChargeBeam",
- type = "Electric",
- doesDamage = false,
- attackForm = "spec",
- target = "self",
- power = 0,
- effect = {"none", "buffSpecAttack"},
- effectValue = 15,
- accuracy = 100,
- pp = 5
- },
- Discharge = {
- name = "Discharge",
- type = "Electric",
- doesDamage = false,
- attackForm = "spec",
- target = "opponent",
- power = 0,
- effect = {"none", "paralyze"},
- effectValue = 100,
- accuracy = 100,
- pp = 5
- },
- -- ############## Ice ###############
- IceFang = {
- name = "IceFang",
- type = "Ice",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none", "freeze"},
- effectValue = 50,
- accuracy = 95,
- pp = 5
- },
- Freeze = {
- name = "Freeze",
- type = "Ice",
- doesDamage = false,
- attackForm = "spec",
- target = "opponent",
- power = 0,
- effect = {"none", "freeze"},
- effectValue = 100,
- accuracy = 95,
- pp = 10
- },
- Blizzard = {
- name = "Blizzard",
- type = "Ice",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 2,
- effect = {"none", "freeze", "buffSpecAttack"},
- effectValue = 15,
- accuracy = 100,
- pp = 10
- },
- -- ############## Fighting ###############
- CosmicPunch = {
- name = "CosmicPunch",
- type = "Fighting",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 5,
- effect = {"none"},
- effectValue = 0,
- accuracy = 75,
- pp = 10
- },
- SuckerPunch = {
- name = "SuckerPunch",
- type = "Fighting",
- doesDamage = true,
- attackForm = "phys",
- target = "self",
- power = 2,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- RoundhouseKick = {
- name = "RoundhouseKick",
- type = "Fighting",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- Flex = {
- name = "Flex",
- type = "Fighting",
- doesDamage = false,
- attackForm = "phys",
- target = "self",
- power = 0,
- effect = {"none", "buffAttack"},
- effectValue = 15,
- accuracy = 100,
- pp = 10
- },
- -- ############## Dragon ###############
- DracoMeteor = {
- name = "DracoMeteor",
- type = "Dragon",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none", "debuffSpecDefense"},
- effectValue = 10,
- accuracy = 100,
- pp = 10
- },
- SpacialRend = {
- name = "SpacialRend",
- type = "Dragon",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none", "crit"},
- effectValue = 10,
- accuracy = 100,
- pp = 10
- },
- DragonRage = {
- name = "DragonRage",
- type = "Dragon",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 4,
- effect = {"none", "flinch"},
- effectValue = 40,
- accuracy = 100,
- pp = 10
- },
- -- ############## Flying ###############
- Fly = {
- name = "Fly",
- type = "Flying",
- doesDamage = true,
- attackForm = "spec",
- target = "opponent",
- power = 3,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- AirSlash = {
- name = "AirSlash",
- type = "Flying",
- doesDamage = true,
- attackForm = "spec",
- target = "self",
- power = 3,
- effect = {"none", "flinch"},
- effectValue = 40,
- accuracy = 100,
- pp = 10
- },
- Peck = {
- name = "Peck",
- type = "Flying",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 2,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- WingAttack = {
- name = "WingAttack",
- type = "Flying",
- doesDamage = true,
- attackForm = "phys",
- target = "opponent",
- power = 3,
- effect = {"none"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- },
- Hawkeye = {
- name = "Hawkeye",
- type = "Flying",
- doesDamage = false,
- attackForm = "spec",
- target = "self",
- power = 0,
- effect = {"none", "buffAccuracy"},
- effectValue = 20,
- accuracy = 100,
- pp = 10
- },
- Roost = {
- name = "Roost",
- type = "Flying",
- doesDamage = false,
- attackForm = "spec",
- target = "self",
- power = 0,
- effect = {"none", "roost"},
- effectValue = 0,
- accuracy = 100,
- pp = 10
- }
- }
- local function writeFile()
- handle = fs.open("moves", "w")
- handle.write(textutils.serialize(moves))
- handle.close()
- end
- writeFile()
- --selectedMove = "OminousWind"
- --print(moves[selectedMove]["effect"])
- --for k, moveEffect in ipairs(moves[selectedMove]["effect"]) do
- -- print("effect: "..moveEffect)
- --end
- --event = os.pullEvent("key")
- -- #####################################################################################################
- local function writeFile(file)
- handle = fs.open(tostring(file), "w")
- handle.write(textutils.serialize(file))
- handle.close()
- end
- local function loadPokemon()
- handle = fs.open("pokemon", "r")
- loadedFile = textutils.unserialize(handle.readLine())
- handle.close()
- end
- local function drawImage(image, x, y)
- end
- local function writeHP()
- term.setCursorPos(1, h)
- write(player1.name.." "..player1.currHp.." / "..player1.hpMax)
- term.setCursorPos((w-15)/2, h)
- write(player2.name.." "..player2.currHp.." / "..player2.hpMax)
- end
- local function selectMon1()
- number = 0
- for i = 1, #pokemon do
- number = number +1
- end
- shell.run("clear")
- print("player1 select a pokemon")
- print("use arrows to select")
- sleep(0.3)
- shell.run("clear")
- --debugging2()
- local selection = 1
- while true do
- shell.run("clear")
- print("selection: "..selection)
- print("Name: "..pokemon[selection]["name"])
- print("Level: "..pokemon[selection]["level"])
- print("Type: "..pokemon[selection]["type1"].." / "..pokemon[selection]["type2"])
- print("HP: "..pokemon[selection]["hpMax"])
- print("Attack: "..pokemon[selection]["attack"])
- print("Defense: "..pokemon[selection]["defense"])
- print("Spec. Attack: "..pokemon[selection]["specAttack"])
- print("Spec. Defense: "..pokemon[selection]["specDefense"])
- print("Speed: "..pokemon[selection]["speed"])
- print(" ")
- print("Moves:")
- print(pokemon[selection]["move1"].." | Power: "..moves[pokemon[selection]["move1"]]["power"].." | PP: "..moves[pokemon[selection]["move1"]]["pp"])
- print(pokemon[selection]["move2"].." | Power: "..moves[pokemon[selection]["move2"]]["power"].." | PP: "..moves[pokemon[selection]["move2"]]["pp"])
- print(pokemon[selection]["move3"].." | Power: "..moves[pokemon[selection]["move3"]]["power"].." | PP: "..moves[pokemon[selection]["move3"]]["pp"])
- print(pokemon[selection]["move4"].." | Power: "..moves[pokemon[selection]["move4"]]["power"].." | PP: "..moves[pokemon[selection]["move4"]]["pp"])
- --drawImage(pokemon[selection]["name"], x, y)
- local event, arg1 = os.pullEvent("key")
- if keys.getName(arg1) == "enter" or keys.getName(arg1) == "space" then
- --debugging2()
- table.insert(player1Select, pokemon[selection])
- --debugging2()
- --player1 = pokemon[selection]
- break
- elseif keys.getName(arg1) == "left" or keys.getName(arg1) == "a" then
- selection = selection - 1
- if selection == 0 then selection = number end
- elseif keys.getName(arg1) == "right" or keys.getName(arg1) == "d" then
- selection = selection + 1
- if selection > number then selection = 1 end
- end
- end
- --debugging2()
- table.remove(pokemon, selection)
- --debugging2()
- player1 = player1Select[1]
- end
- local function selectMon2()
- shell.run("clear")
- print("player2 select a pokemon")
- print("use arrows to select")
- sleep(0.3)
- shell.run("clear")
- local selection = 1
- while true do
- shell.run("clear")
- print("Name: "..pokemon[selection]["name"])
- print("Level: "..pokemon[selection]["level"])
- print("Type: "..pokemon[selection]["type1"].." / "..pokemon[selection]["type2"])
- print("HP: "..pokemon[selection]["hpMax"])
- print("Attack: "..pokemon[selection]["attack"])
- print("Defense: "..pokemon[selection]["defense"])
- print("Spec. Attack: "..pokemon[selection]["specAttack"])
- print("Spec. Defense: "..pokemon[selection]["specDefense"])
- print("Speed: "..pokemon[selection]["speed"])
- print(" ")
- print("Moves:")
- print(pokemon[selection]["move1"].." | Power: "..moves[pokemon[selection]["move1"]]["power"].." | PP: "..moves[pokemon[selection]["move1"]]["pp"])
- print(pokemon[selection]["move2"].." | Power: "..moves[pokemon[selection]["move2"]]["power"].." | PP: "..moves[pokemon[selection]["move2"]]["pp"])
- print(pokemon[selection]["move3"].." | Power: "..moves[pokemon[selection]["move3"]]["power"].." | PP: "..moves[pokemon[selection]["move3"]]["pp"])
- print(pokemon[selection]["move4"].." | Power: "..moves[pokemon[selection]["move4"]]["power"].." | PP: "..moves[pokemon[selection]["move4"]]["pp"])
- --drawImage(pokemon[selection]["name"], x, y)
- local event, arg1 = os.pullEvent("key")
- if keys.getName(arg1) == "enter" or keys.getName(arg1) == "space" then
- table.insert(player2Select, pokemon[selection])
- --player2 = pokemon[selection]
- break
- elseif keys.getName(arg1) == "left" or keys.getName(arg1) == "a" then
- selection = selection - 1
- if selection == 0 then selection = #pokemon end
- elseif keys.getName(arg1) == "right" or keys.getName(arg1) == "d" then
- selection = selection + 1
- if selection > #pokemon then selection = 1 end
- end
- end
- table.remove(pokemon, selection)
- player2 = player2Select[1]
- end
- local function selectNewMon1()
- number = 0
- for i = 1, #player1Select do
- number = number +1
- end
- shell.run("clear")
- local selection = 1
- while true do
- shell.run("clear")
- print("selection: "..selection)
- print("Name: "..player1Select[selection]["name"])
- print("Level: "..player1Select[selection]["level"])
- print("Type: "..player1Select[selection]["type1"].." / "..player1Select[selection]["type2"])
- print("HP: "..player1Select[selection]["hpMax"])
- print("Attack: "..player1Select[selection]["attack"])
- print("Defense: "..player1Select[selection]["defense"])
- print("Spec. Attack: "..player1Select[selection]["specAttack"])
- print("Spec. Defense: "..player1Select[selection]["specDefense"])
- print("Speed: "..player1Select[selection]["speed"])
- print(" ")
- print("Moves:")
- print(player1Select[selection]["move1"].." | Power: "..moves[player1Select[selection]["move1"]]["power"].." | PP: "..moves[player1Select[selection]["move1"]]["pp"])
- print(player1Select[selection]["move2"].." | Power: "..moves[player1Select[selection]["move2"]]["power"].." | PP: "..moves[player1Select[selection]["move2"]]["pp"])
- print(player1Select[selection]["move3"].." | Power: "..moves[player1Select[selection]["move3"]]["power"].." | PP: "..moves[player1Select[selection]["move3"]]["pp"])
- print(player1Select[selection]["move4"].." | Power: "..moves[player1Select[selection]["move4"]]["power"].." | PP: "..moves[player1Select[selection]["move4"]]["pp"])
- --drawImage(player1Select[selection]["name"], x, y)
- local event, arg1 = os.pullEvent("key")
- if keys.getName(arg1) == "enter" or keys.getName(arg1) == "space" then
- player1 = player1Select[selection]
- choice = true
- break
- elseif keys.getName(arg1) == "left" or keys.getName(arg1) == "a" then
- selection = selection - 1
- if selection == 0 then selection = number end
- elseif keys.getName(arg1) == "right" or keys.getName(arg1) == "d" then
- selection = selection + 1
- if selection > number then selection = 1 end
- end
- end
- end
- local function selectNewMon2()
- number = 0
- for i = 1, #player2Select do
- number = number +1
- end
- shell.run("clear")
- local selection = 1
- while true do
- shell.run("clear")
- print("selection: "..selection)
- print("Name: "..player2Select[selection]["name"])
- print("Level: "..player2Select[selection]["level"])
- print("Type: "..player2Select[selection]["type1"].." / "..player2Select[selection]["type2"])
- print("HP: "..player2Select[selection]["hpMax"])
- print("Attack: "..player2Select[selection]["attack"])
- print("Defense: "..player2Select[selection]["defense"])
- print("Spec. Attack: "..player2Select[selection]["specAttack"])
- print("Spec. Defense: "..player2Select[selection]["specDefense"])
- print("Speed: "..player2Select[selection]["speed"])
- print(" ")
- print("Moves:")
- print(player2Select[selection]["move1"].." | Power: "..moves[player2Select[selection]["move1"]]["power"].." | PP: "..moves[player2Select[selection]["move1"]]["pp"])
- print(player2Select[selection]["move2"].." | Power: "..moves[player2Select[selection]["move2"]]["power"].." | PP: "..moves[player2Select[selection]["move2"]]["pp"])
- print(player2Select[selection]["move3"].." | Power: "..moves[player2Select[selection]["move3"]]["power"].." | PP: "..moves[player2Select[selection]["move3"]]["pp"])
- print(player2Select[selection]["move4"].." | Power: "..moves[player2Select[selection]["move4"]]["power"].." | PP: "..moves[player2Select[selection]["move4"]]["pp"])
- --drawImage(player2Select[selection]["name"], x, y)
- local event, arg1 = os.pullEvent("key")
- if keys.getName(arg1) == "enter" or keys.getName(arg1) == "space" then
- player2 = player2Select[selection]
- choice = true
- break
- elseif keys.getName(arg1) == "left" or keys.getName(arg1) == "a" then
- selection = selection - 1
- if selection == 0 then selection = number end
- elseif keys.getName(arg1) == "right" or keys.getName(arg1) == "d" then
- selection = selection + 1
- if selection > number then selection = 1 end
- end
- end
- end
- local function printPokemon()
- shell.run("clear")
- print("Player1 selected: "..player1Select[1]["name"]..", "..player1Select[2]["name"]..", "..player1Select[3]["name"])
- print("player2 selected: "..player2Select[1]["name"]..", "..player2Select[2]["name"]..", "..player2Select[3]["name"])
- event = os.pullEvent("key")
- end
- local function calcAccuracy()
- --Accuracy
- roll = math.random(0, 100)
- accuracy = false
- if playerTurn == 1 then
- if moves[selectedMove]["accuracy"] + player1.accuracy >= roll then
- accuracy = true
- end
- elseif playerTurn == 2 then
- if moves[selectedMove]["accuracy"] + player2.accuracy >= roll then
- accuracy = true
- end
- end
- if moves[selectedMove]["target"] == "self" then
- accuracy = true
- end
- end
- local function STABBonus()
- --STAB bonus
- if playerTurn == 1 then
- moveType = moves[selectedMove]["type"]
- elseif playerTurn == 2 then
- moveType = moves[selectedMove]["type"]
- end
- STAB = 1
- if playerTurn == 1 and player1.type1 or player1.type2 == moveType then
- STAB = 2
- elseif playerTurn == 2 and player2.type1 or player2.type2 == moveType then
- STAB = 2
- end
- end
- local function strengthAndWeakness()
- -- strengths and weaknesses
- moveType = moves[selectedMove]["type"]
- resist = 1
- weakness = 1
- if moveType == "Normal" then
- se = { "N/A" }
- nve = { "Rock", "Steel" }
- ne = { "Ghost" }
- elseif moveType == "Grass" then
- se = { "Water", "Ground", "Rock" }
- nve = { "Fire", "Grass", "Poison", "Flying", "Bug", "Dragon", "Steel" }
- ne = { "N/A" }
- elseif moveType == "Fire" then
- se = { "Grass", "Ice", "Bug" }
- nve = { "Fire", "Water", "Rock", "Dragon" }
- ne = { "N/A" }
- elseif moveType == "Water" then
- se = { "Fire", "Ground", "Rock" }
- nve = { "Water", "Grass", "Dragon" }
- ne = { "N/A" }
- elseif moveType == "Dragon" then
- se = { "Dragon" }
- nve = { "Steel" }
- ne = { "N/A" }
- elseif moveType == "Flying" then
- se = { "Grass", "Fighting", "Bug" }
- nve = { "Electric", "Rock", "Steel" }
- ne = { "N/A" }
- elseif moveType == "Psychic" then
- se = { "Fighting", "Poison"}
- nve = { "Psychic", "Steel" }
- ne = { "Dark" }
- elseif moveType == "Dark" then
- se = { "Psychic", "Ghost" }
- nve = { "Fighting", "Dark", "Steel" }
- ne = { "N/A" }
- elseif moveType == "Bug" then
- se = { "Grass", "Psychic", "Dark" }
- nve = { "Fire", "Fighting", "Poison", "Flying", "Ghost", "Steel" }
- ne = { "N/A" }
- else
- se = { "N/A" }
- nve = { "N/A" }
- ne = { "N/A" }
- end
- for _,v in pairs(se) do
- if playerTurn == 1 then
- if v == player2.type and v == player2.type2 then
- weakness = weakness * 4
- elseif v == player2.type1 or v == player2.type2 then
- weakness = weakness * 2
- end
- elseif playerTurn == 2 then
- if v == player1.type1 and v == player1.type2 then
- weakness = weakness * 4
- elseif v == player1.type1 or v == player1.type2 then
- weakness = weakness * 2
- end
- end
- end
- for _,v in pairs(nve) do
- if playerTurn == 1 then
- if v == player2.type1 and v == player2.type2 then
- resist = resist * 4
- elseif v == player2.type or v == player2.type2 then
- resist = resist * 2
- end
- elseif playerTurn == 2 then
- if v == player1.type1 and v == player1.type2 then
- resist = resist * 4
- elseif v == player1.type1 or v == player1.type2 then
- resist = resist * 4
- end
- end
- end
- for _,v in pairs(ne) do
- if playerTurn == 1 then
- if v == player2.type1 or v == player2.type2 then
- weakness = weakness * 0
- end
- elseif playerTurn == 2 then
- if v == player1.type1 or v == player1.type2 then
- weakness = weakness * 0
- end
- end
- end
- end
- local function calcDam()
- -- Damage calculation
- if playerTurn == 1 then
- moveForm = moves[selectedMove]["attackForm"]
- elseif playerTurn == 2 then
- moveForm = moves[selectedMove]["attackForm"]
- end
- if moves[selectedMove]["doesDamage"] and accuracy == true and playerTurn == 1 then
- if moveForm == "phys" then
- baseDam = ((player1.attack) * moves[selectedMove]["power"]) / (player2.defense)
- damBonus = (baseDam/100) * math.random(1,15)
- dam = (baseDam + damBonus) * STAB * weakness / resist
- elseif moveForm == "spec" then
- baseDam = ((player1.specAttack) * moves[selectedMove]["power"]) / (player2.specDefense)
- damBonus = (baseDam/100) * math.random(1,15)
- dam = (baseDam + damBonus) * STAB * weakness / resist
- elseif moveForm == "exac" then
- dam = moves[selectedMove]["power"]
- end
- if weakness == 0 then
- dam = 0
- elseif dam < 1 then
- dam = 1
- end
- for k, moveEffect in pairs(moves[selectedMove]) do
- if moveEffect == "crit" then
- crit = math.random(1,100)
- critical = false
- if crit > 95 - moves[selectedMove]["effectValue"] then
- dam = dam * 1.5
- critical = true
- end
- else
- crit = math.random(1,100)
- critical = false
- if crit > 95 then
- dam = dam * 1.5
- critical = true
- end
- end
- end
- dam = math.ceil(dam)
- elseif moves[selectedMove]["doesDamage"] and accuracy == true and playerTurn == 2 then
- if moveForm == "phys" then
- baseDam = ((player2.attack) * moves[selectedMove]["power"]) / (player1.defense)
- damBonus = (baseDam/100) * math.random(1,15)
- dam = math.ceil((baseDam + damBonus) * STAB * weakness / resist)
- elseif moveForm == "spec" then
- baseDam = ((player2.specAttack) * moves[selectedMove]["power"]) / (player1.specDefense)
- damBonus = (baseDam/100) * math.random(1,15)
- dam = math.ceil((baseDam + damBonus) * STAB * weakness / resist)
- elseif moveForm == "exac" then
- dam = moves[selectedMove]["power"]
- end
- if weakness == 0 then
- dam = 0
- elseif dam < 1 then
- dam = 1
- end
- for k, moveEffect in pairs(moves[selectedMove]) do
- if moveEffect == "crit" then
- crit = math.random(1,100)
- critical = false
- if crit > 95 - moves[selectedMove]["effectValue"] then
- dam = dam * 1.5
- critical = true
- end
- else
- crit = math.random(1,100)
- critical = false
- if crit > 95 then
- dam = dam * 1.5
- critical = true
- end
- end
- end
- dam = math.ceil(dam)
- end
- if playerTurn == 1 and accuracy == true and moves[selectedMove]["doesDamage"] == true then
- player2.currHp = player2.currHp - dam
- if player2.currHp < 1 then
- player2.currHp = 0
- end
- elseif playerTurn == 2 and accuracy == true and moves[selectedMove]["doesDamage"] == true then
- player1.currHp = player1.currHp - dam
- if player1.currHp < 1 then
- player1.currHp = 0
- end
- end
- end
- local function buffAndDebuff()
- --debugging2()
- shell.run("clear")
- print(moves[selectedMove]["effect"])
- for k, v in pairs(moves["selectedMove"]["effect"]) do
- print(v)
- if moveEffect2 == "buffAttack" and playerTurn == 1 and accuracy == true then
- player1.attack = player1.attack + moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "buffAttack" and playerTurn == 2 and accuracy == true then
- player2.attack = player2.attack + moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "buffDefense" and playerTurn == 1 and accuracy == true then
- player1.defense = player1.defense + moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "buffDefense" and playerTurn == 2 and accuracy == true then
- player2.defense = player2.defense + moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "buffSpecDefense" and playerTurn == 1 and accuracy == true then
- player1.specDefense = player1.specDefense + moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "buffSpecDefense" and playerTurn == 2 and accuracy == true then
- player2.specDefense = player2.specDefense + moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "buffSpecAttack" and playerTurn == 1 and accuracy == true then
- player1.specAttack = player1.specAttack + moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "buffSpecAttack" and playerTurn == 2 and accuracy == true then
- player2.specAttack = player2.specAttack + moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "buffSpeed" and playerTurn == 1 and accuracy == true then
- player1.speed = player1.speed + moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "buffSpeed" and playerTurn == 2 and accuracy == true then
- player2.speed = player2.speed + moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "buffAccuracy" and playerTurn == 1 and accuracy == true then
- player1.accuracy = player1.accuracy + moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "buffAccuracy" and playerTurn == 2 and accuracy == true then
- player2.accuracy = player2.accuracy + moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "debuffAttack" and playerTurn == 1 and accuracy == true and player1.attack > 5 then
- player2.attack =player2.attack - moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "debuffAttack" and playerTurn == 2 and accuracy == true and player2.attack > 5 then
- player1.attack =player1.attack - moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "debuffDefense" and playerTurn == 1 and accuracy == true and player1.defense > 5 then
- player2.defense =player2.defense - moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "debuffDefense" and playerTurn == 2 and accuracy == true and player2.defense > 5 then
- player1.defense =player1.defense - moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "debuffSpecDefense" and playerTurn == 1 and accuracy == true and player1.specDefense > 5 then
- player2.specDefense =player2.specDefense - moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "debuffSpecDefense" and playerTurn == 2 and accuracy == true and player2.specDefense > 5 then
- player1.specDefense =player1.specDefense - moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "debuffSpecAttack" and playerTurn == 1 and accuracy == true and player1.specAttack > 5 then
- player2.specAttack = player2.specAttack - moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "debuffSpecAttack" and playerTurn == 2 and accuracy == true and player2.specAttack > 5 then
- player1.specAttack =player1.specAttack - moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "debuffSpeed" and playerTurn == 1 and accuracy == true and player1.speed > 5 then
- player2.speed = player2.speed - moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "debuffSpeed" and playerTurn == 2 and accuracy == true and player2.speed > 5 then
- player1.speed = player1.speed - moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "debuffAccuracy" and playerTurn == 1 and accuracy == true and moves[selectedMove]["accuracy"] + player1.accuracy > 5 then
- player2.accuracy =player2.accuracy - moves[selectedMove]["effectValue"]
- elseif moveEffect2 == "debuffAccuracy" and playerTurn == 2 and accuracy == true and moves[selectedMove]["accuracy"] + player2.accuracy > 5 then
- player1.accuracy =player1.accuracy - moves[selectedMove]["effectValue"]
- end
- if moveEffect2 == "heal" and playerTurn == 1 and accuracy == true then
- player1.currHp= player1.currHp + moves[selectedMove]["effectValue"]
- if player1.currHp > player1.hpMax then player1.currHp = player1.hpMax end
- elseif moveEffect2 == "heal" and playerTurn == 2 and accuracy == true then
- player2.currHp = player2.currHp + moves[selectedMove]["effectValue"]
- if player2.currHp > player2.hpMax then player2.currHp = player2.hpMax end
- end
- if moveEffect2 == "poison" and playerTurn == 1 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player2.status = "poison"
- end
- elseif moveEffect2 == "poison" and playerTurn == 2 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player1.status = "poison"
- end
- end
- if moveEffect2 == "burn" and playerTurn == 1 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player2.status = "burn"
- end
- elseif moveEffect2 == "burn" and playerTurn == 2 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player1.status = "burn"
- end
- end
- if moveEffect2 == "paralyze" and playerTurn == 1 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player2.status = "paralyze"
- player2Round = 1
- player2Paralyzed = true
- end
- elseif moveEffect2 == "paralyze" and playerTurn == 2 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player1.status = "paralyze"
- player1Round = 1
- player1Paralyzed = true
- end
- end
- if moveEffect2 == "confusion" and playerTurn == 1 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player2.status = "confusion"
- player2Confused = true
- player2Round = 0
- end
- elseif moveEffect2 == "confusion" and playerTurn == 2 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player1.status = "confusion"
- player1Confused = true
- player1Round = 0
- end
- end
- if moveEffect2 == "sleep" and playerTurn == 1 and accuracy == true and player2Sleeping == false then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player2Sleeping = true
- player2Round = 0
- player2.status = "sleep"
- end
- elseif moveEffect2 == "sleep" and playerTurn == 2 and accuracy == true and player1Sleeping == false then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player1Sleeping = true
- player1Round = 0
- player1.status = "sleep"
- end
- end
- if moveEffect2 == "sleepSelf" and playerTurn == 1 and accuracy == true then
- player1Sleeping = true
- player1Round = 1
- player1.status = "sleep"
- player1.currHp = player1.hpMax
- elseif moveEffect2 == "sleep" and playerTurn == 2 and accuracy == true then
- player2Sleeping = true
- player2Round = 1
- player2.status = "sleep"
- player2.currHp = player2.hpMax
- end
- if moveEffect2 == "flinch" and playerTurn == 1 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player2.status = "flinch"
- end
- elseif moveEffect2 == "flinch" and playerTurn == 2 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player1.status = "flinch"
- end
- end
- if moveEffect2 == "freeze" and playerTurn == 1 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player2.status = "freeze"
- player2Frozen = true
- player2Round = 1
- end
- elseif moveEffect2 == "freeze" and playerTurn == 2 and accuracy == true then
- randomNum = math.random(1,100)
- if moves[selectedMove]["effectValue"] >= randomNum then
- player1.status = "freeze"
- player1Frozen = true
- player1Round = 1
- end
- end
- if moveEffect2 == "curse" and playerTurn == 1 and accuracy == true then
- player2.status = "curse"
- player1.currHp = player1.currHp / 2
- elseif moveEffect2 == "curse" and playerTurn == 2 and accuracy == true then
- player1.status = "curse"
- player2.currHp = player2.currHp / 2
- end
- if moveEffect2 == "roost" and playerTurn == 1 and accuracy == true then
- if player1.type1 == "Flying" and player1.type2 == flying then
- player1.type1 = "Normal"
- player1.type2 = "Normal"
- elseif player1.type1 == "Flying" then
- player1.type1 = "Normal"
- elseif player1.type2 == "Flying" then
- player1.type2 = "Normal"
- end
- player1.currHp = player1currHp + (player1.maxHp / 2)
- if player1.currHp > player1.hpMax then player1.currHp = player1.hpMax end
- elseif moveEffect2 == "roost" and playerTurn == 2 and accuracy == true then
- if player2.type1 == "Flying" and player2.type2 == flying then
- player2.type1 = "Normal"
- player2.type2 = "Normal"
- elseif player2.type1 == "Flying" then
- player2.type1 = "Normal"
- elseif player2.type2 == "Flying" then
- player2.type2 = "Normal"
- end
- player2.currHp = player2currHp + (player2.maxHp / 2)
- if player2.currHp > player2.hpMax then player2.currHp = player2.hpMax end
- end
- end
- -- end
- print("buff/debuff finished")
- event = os.pullEvent("key")
- shell.run("clear")
- end
- local function pokemonAttack(move)
- shell.run("clear")
- --debugging2()
- calcAccuracy()
- --debugging2()
- buffAndDebuff()
- --debugging2()
- STABBonus()
- strengthAndWeakness()
- calcDam()
- end
- local function checkStatus()
- if playerTurn == 1 then
- if player1.status == "poison" then
- print(player1.name.." is poisoned. "..player1.name.." takes damage from the poison")
- player1.currHp = player1.currHp - 1
- end
- if player1.status == "burn" then
- print(player1.name.." is burned. "..player1.name.." takes damage from the burn")
- player1.currHp = player1.currHp - 1
- end
- if player1.status == "curse" then
- print(player1.name.." is cursed. "..player1.name.." takes damage from the curse")
- player1.currHp = math.ceil(player1.currHp / 2)
- end
- if player1.status == "sleep" then
- print(player1.name.." is sleeping. ")
- player1Round = player1Round +1
- if player1Round == 3 then
- player1Sleeping = false
- player1.status = "none"
- end
- end
- if player1.status == "confusion" then
- print(player1.name.." is confused.")
- randomNum = math.random(1,100)
- if randomNum > 0 and randomNum < 26 then
- print("It hurt itself in the confusion")
- elseif randomNum > 25 and randomNum < 51 then
- print(player1.name.." is too confused")
- end
- player1Round = player1Round +1
- if player1Round == 3 then
- player1Confused = false
- player1.status = "none"
- end
- end
- if player1.status == "flinch" then
- print(player1.name.." is flinched. ")
- player1Flinched = false
- player1.status = "none"
- end
- if player1.status == "paralyze" then
- print(player1.name.." is paralyzed. ")
- randomNum = math.random(1,100)
- if randomNum > 0 and randomNum < 61 then
- print("It can't move")
- end
- player1Round = player1Round +1
- if player1Round == 3 then
- player1Paralyzed = false
- player1.status = "none"
- end
- end
- if player1.status == "freeze" then
- print(player1.name.." is frozen. ")
- randomNum = math.random(1,100)
- if randomNum > 0 and randomNum < 61 then
- print("It can't move")
- end
- player1Round = player1Round +1
- if player1Round == 3 then
- player1Frozen = false
- player1.status = "none"
- end
- end
- elseif playerTurn == 2 then
- if player2.status == "poison" then
- print(player2.name.." is poisoned. "..player2.name.." takes damage from the poison")
- player2.currHp = player2.currHp - 1
- end
- end
- end
- local function printResult()
- if moves[selectedMove]["doesDamage"] and accuracy == true then
- if critical == true then
- print("It's a critical hit!")
- end
- if weakness == 0 then
- print("It has no effect")
- elseif weakness > resist then
- print("Its Super Effective.")
- elseif weakness < resist then
- print("Its not very Effective.")
- end
- if playerTurn == 1 then
- if switch == false then
- print("Player2's "..player2.name.." was damaged for "..dam.." points")
- print("Player2's health: "..player2.currHp)
- end
- elseif playerTurn == 2 then
- if switch == false then
- print("Player1's "..player1.name.." was damaged for "..dam.." points")
- print("Player1's health: "..player1.currHp)
- end
- end
- elseif accuracy == false then
- print("It missed")
- end
- end
- local function resolveTurn()
- shell.run("clear")
- if playerTurn == 1 then
- if switch == true then
- print("Player1 switches to "..player1.name)
- elseif itemUsed == true then
- print("Player1 uses ")
- elseif player1.status ~= "none" then
- checkStatus()
- else
- --debugging2()
- pokemonAttack(selectedMove)
- print("Player1's "..player1.name.." use "..selectedMove)
- print(" ")
- sleep(0.5)
- print("moveType "..moveType)
- end
- print("Type1 "..player2.type1)
- print("Type2 "..player2.type2)
- print(" ")
- elseif playerTurn == 2 then
- if switch == true then
- print("Player2 switches to "..player2.name)
- elseif itemUsed == true then
- print("Player2 uses ")
- elseif player2.status ~= "none" then
- checkStatus()
- else
- pokemonAttack(selectedMove)
- print("Player2's "..player2.name.." use "..selectedMove)
- print(" ")
- sleep(0.5)
- print("moveType "..moveType)
- end
- print("Type1 "..player1.type1.." Type2 "..player1.type2)
- print(" ")
- end
- print("playerTurn "..playerTurn)
- print(" ")
- print("randomNum "..randomNum)
- print("value "..moves[selectedMove]["effectValue"])
- print("1 status: "..player1.status.." 2 status "..player2.status)
- print("player1 stats "..player1.attack.." "..player1.defense.." "..player1.specAttack.." "..player1.specDefense.." "..player1.speed.." "..player1.accuracy)
- print("player2 stats "..player2.attack.." "..player2.defense.." "..player2.specAttack.." "..player2.specDefense.." "..player2.speed.." "..player2.accuracy)
- printResult()
- if playerTurn == 1 then
- playerTurn = 2
- elseif playerTurn == 2 then
- playerTurn = 1
- end
- writeHP()
- event = os.pullEvent("key")
- shell.run("clear")
- end
- local function checkFaint()
- faint = false
- if player1.currHp == 0 then
- print("Player1's "..player1.name.." fainted")
- print(" ")
- sleep(0.5)
- print("Player2 win!")
- faint = true
- event = os.pullEvent("key")
- elseif player2.currHp == 0 then
- print("Player2's "..player2.name.." fainted")
- print(" ")
- sleep(0.5)
- print("Player1 win!")
- faint = true
- event = os.pullEvent("key")
- end
- end
- local function showMoves()
- shell.run("clear")
- if playerTurn == 1 then
- print("player "..playerTurn)
- print("1: "..player1["move1"])
- print("2: "..player1["move2"])
- print("3: "..player1["move3"])
- print("4: "..player1["move4"])
- local event, arg1 = os.pullEvent("key")
- --debugging2()
- if keys.getName(arg1) == "one" then
- selectedMove = player1.move1
- --pokemonAttack(selectedMove)
- resolveTurn()
- elseif keys.getName(arg1) == "two" then
- selectedMove = player1.move2
- --pokemonAttack(selectedMove)
- resolveTurn()
- elseif keys.getName(arg1) == "three" then
- selectedMove = player1.move3
- --pokemonAttack(selectedMove)
- --debugging2()
- resolveTurn()
- elseif keys.getName(arg1) == "four" then
- selectedMove = player1.move4
- shell.run("clear")
- --pokemonAttack(selectedMove)
- --debugging2()
- resolveTurn()
- end
- elseif playerTurn == 2 then
- print("player "..playerTurn)
- print("1: "..player2["move1"])
- print("2: "..player2["move2"])
- print("3: "..player2["move3"])
- print("4: "..player2["move4"])
- local event, arg1 = os.pullEvent("key")
- --debugging2()
- if keys.getName(arg1) == "one" then
- selectedMove = player2.move1
- --pokemonAttack(selectedMove)
- resolveTurn()
- elseif keys.getName(arg1) == "two" then
- selectedMove = player2.move2
- --pokemonAttack(selectedMove)
- resolveTurn()
- elseif keys.getName(arg1) == "three" then
- selectedMove = player2.move3
- --debugging2()
- --pokemonAttack(selectedMove)
- resolveTurn()
- elseif keys.getName(arg1) == "four" then
- selectedMove = player2.move4
- --debugging2()
- --pokemonAttack(selectedMove)
- resolveTurn()
- end
- end
- end
- local function showItems()
- shell.run("clear")
- if items == "empty" then
- print("No items")
- else
- itemUsed = true
- end
- sleep(1)
- end
- local function showPokemons()
- shell.run("clear")
- if playerTurn == 1 then
- for i = 1, #player1Select do
- print(player1Select[i]["name"])
- end
- elseif playerTurn == 2 then
- for i = 1, #player2Select do
- print(player2Select[i]["name"])
- end
- end
- if playerTurn == 1 then
- event, arg1 = os.pullEvent("key")
- player1 = player1Select[arg1-1]
- elseif playerTurn == 2 then
- event, arg1 = os.pullEvent("key")
- player2 = player2Select[arg1-1]
- end
- end
- local function run()
- shell.run("clear")
- if trainer == true then
- print("Can't run")
- end
- sleep(1)
- end
- local function turnOne()
- if player1.speed > player2.speed then
- player = 1
- playerTurn = 1
- elseif player2.speed > player1.speed then
- player = 2
- playerTurn = 2
- elseif player1.speed == player2.speed then
- player = math.random(1,2)
- playerTurn = math.random(1,2)
- end
- end
- local function battle()
- switch = false
- shell.run("clear")
- print("player "..playerTurn)
- print("1. Attack")
- print("2. Items")
- print("3. Pokemons")
- print("4. Run")
- local event, arg1 = os.pullEvent("key")
- --debugging2()
- if keys.getName(arg1) == "one" then
- --debugging2()
- noAttack = false
- showMoves()
- choice = true
- elseif keys.getName(arg1) == "two" then
- showItems()
- noAttack = true
- elseif keys.getName(arg1) == "three" then
- --showPokemons()
- if playerTurn == 1 then
- selectNewMon1()
- elseif playerTurn == 2 then
- selectNewMon2()
- end
- switch = true
- choice = true
- noAttack = true
- elseif keys.getName(arg1) == "four" then
- run()
- end
- end
- -- #############################
- local function debugging()
- print("pairs(moves[Meditation])")
- for k, v in pairs(moves["Meditation"]) do
- print(tostring(k).." "..tostring(v))
- end
- os.pullEvent()
- shell.run("clear")
- -- skriver effect table
- print("ipairs(moves[Meditation])")
- for k,v in ipairs(moves["Meditation"]) do
- print(tostring(k).." "..tostring(v))
- end
- os.pullEvent()
- shell.run("clear")
- -- skriver ingenting
- print("pairs(moves[Meditation][effect])")
- for k, v in pairs(moves["Meditation"]["effect"]) do
- print(k.." "..v)
- end
- os.pullEvent()
- shell.run("clear")
- -- skriver 1 None osv
- print("ipairs(moves[Meditation][effect])")
- for k, v in ipairs(moves["Meditation"]["effect"]) do
- print(k.." "..v)
- end
- os.pullEvent()
- shell.run("clear")
- -- skriver 1 None osv
- print(" #moves[Meditation]")
- for i = 1, #moves["Meditation"] do
- print(i)
- end
- os.pullEvent()
- shell.run("clear")
- -- skriver ingenting
- print("#moves[Meditation][effect]")
- for i = 1, #moves["Meditation"]["effect"] do
- print(moves[Meditation]["effect"][i])
- end
- os.pullEvent()
- shell.run("clear")
- -- attempt to index nil value
- end
- --debugging2()
- items = "empty"
- trainer = true
- playerTurn = 1
- --debugging2()
- --shell.run("writeMoves")
- --debugging2()
- shell.run("writePokemon")
- while true do
- --loadMoves()
- --moves = loadedFile
- --for k, v in ipairs(loadedFile) do
- -- table.insert(moves, loadedFile)
- --end
- loadPokemon()
- pokemon = loadedFile
- --for k, v in ipairs(loadedFile) do
- -- table.insert(pokemon, loadedFile)
- --end
- for i = 1,3 do
- selectMon1()
- end
- --debugging2()
- for i = 1,3 do
- selectMon2()
- end
- --debugging2()
- printPokemon()
- --debugging2()
- turnOne()
- --debugging2()
- while true do
- choice = false
- while choice == false do
- battle()
- end
- --resolveTurn()
- checkFaint()
- if faint == true then
- break
- end
- resist = 1
- weakness = 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement