ravneravn

pixelmon

Nov 25th, 2013
211
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. term.setTextColor(colors.black)
  4. term.setBackgroundColor(colors.white)
  5. term.clear()
  6. local w, h = term.getSize()
  7. local cursor = 1
  8. player1Select = {}
  9. player2Select = {}
  10. selectedMove = "none"
  11. randomNum = "none"
  12. param = {...}
  13. if param == "AI" or "ai" or "Ai" then
  14. AIOn = true
  15. else
  16. AIOn = false
  17. end
  18.  
  19. switch1 = false
  20. switch2 = false
  21.  
  22.  
  23.  
  24.  
  25. local function debugging2()
  26. shell.run("clear")
  27. for k, v in pairs(moves["Meditation"]["effect"]) do
  28. print(v)
  29. end
  30. os.pullEvent("key")
  31. shell.run("clear")
  32. end
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. --###################### MOVES ####################################
  44.  
  45. moves = {
  46.  
  47. notInUse = {
  48. name = "notInUSe",
  49. type = "Normal",
  50. doesDamage = false,
  51. attackForm = "phys",
  52. target = "self",
  53. power = 0,
  54. effect = {"none"},
  55. effectValue = 0,
  56. accuracy = 100,
  57. pp = 15
  58. },
  59. -- ############## NORMAL ###############
  60. Tackle = {
  61. name = "Tackle",
  62. type = "Normal",
  63. doesDamage = true,
  64. attackForm = "phys",
  65. target = "opponent",
  66. power = 1,
  67. effect = {"none"},
  68. effectValue = 0,
  69. accuracy = 100,
  70. pp = 15
  71. },
  72.  
  73. Growl = {
  74. name = "Growl",
  75. type = "Normal",
  76. doesDamage = false,
  77. attackForm = "phys",
  78. target = "opponent",
  79. power = 0,
  80. effect = {"none", "debuffDefense"},
  81. effectValue = 10,
  82. accuracy = 100,
  83. pp = 15
  84. },
  85.  
  86. Scratch = {
  87. name = "Scratch",
  88. type = "Normal",
  89. doesDamage = true,
  90. attackForm = "phys",
  91. target = "opponent",
  92. power = 1,
  93. effect = {"none"},
  94. effectValue = 0,
  95. accuracy = 100,
  96. pp = 15
  97. },
  98.  
  99.  
  100. Harden = {
  101. name = "Harden",
  102. type = "Normal",
  103. doesDamage = false,
  104. attackForm = "phys",
  105. target = "self",
  106. power = 0,
  107. effect = {"none", "buffDefense"},
  108. effectValue = 10,
  109. accuracy = 100,
  110. pp = 15
  111. },
  112.  
  113.  
  114. Smoke = {
  115. name = "Smoke",
  116. type = "Normal",
  117. doesDamage = false,
  118. attackForm = "phys",
  119. target = "opponent",
  120. power = 0,
  121. effect = {"none", "debuffAccuracy"},
  122. effectValue = 10,
  123. accuracy = 100,
  124. pp = 5
  125. },
  126.  
  127. BodySlam = {
  128. name = "Bodyslam",
  129. type = "Normal",
  130. doesDamage = true,
  131. attackForm = "phys",
  132. target = "opponent",
  133. power = 2,
  134. effect = {"none"},
  135. effectValue = 0,
  136. accuracy = 100,
  137. pp = 10
  138. },
  139.  
  140. Stomp = {
  141. name = "Stomp",
  142. type = "Normal",
  143. doesDamage = true,
  144. attackForm = "phys",
  145. target = "opponent",
  146. power = 3,
  147. effect = {"none"},
  148. effectValue = 0,
  149. accuracy = 100,
  150. pp = 10
  151. },
  152.  
  153. Screech = {
  154. name = "Screech",
  155. type = "Normal",
  156. doesDamage = false,
  157. attackForm = "phys",
  158. target = "opponent",
  159. power = 0,
  160. effect = {"none", "debuffAttack"},
  161. effectValue = 10,
  162. accuracy = 100,
  163. pp = 10
  164. },
  165.  
  166. Heal = {
  167. name = "Heal",
  168. type = "Normal",
  169. doesDamage = false,
  170. attackForm = "phys",
  171. target = "self",
  172. power = 0,
  173. effect = {"none", "heal"},
  174. effectValue = 5,
  175. accuracy = 100,
  176. pp = 10
  177. },
  178.  
  179. Restore = {
  180. name = "Restore",
  181. type = "Normal",
  182. doesDamage = false,
  183. attackForm = "phys",
  184. target = "self",
  185. power = 0,
  186. effect = {"none", "heal"},
  187. effectValue = 10,
  188. accuracy = 100,
  189. pp = 5
  190. },
  191.  
  192. Selfdestruct = {
  193. name = "Selfdestruct",
  194. type = "Normal",
  195. doesDamage = true,
  196. attackForm = "spec",
  197. target = "opponent",
  198. power = 7,
  199. effect = {"none", "selfdestruct"},
  200. effectValue = 0,
  201. accuracy = 100,
  202. pp = 5
  203. },
  204.  
  205. Snore = {
  206. name = "Snore",
  207. type = "Normal",
  208. doesDamage = false,
  209. attackForm = "phys",
  210. target = "self",
  211. power = 0,
  212. effect = {"none", "heal", "sleepSelf"},
  213. effectValue = 1000,
  214. accuracy = 100,
  215. pp = 5
  216. },
  217.  
  218.  
  219.  
  220. -- ############## Grass ###############
  221. VineWhip = {
  222. name = "VineWhip",
  223. type = "Grass",
  224. doesDamage = true,
  225. attackForm = "phys",
  226. target = "opponent",
  227. power = 2,
  228. effect = {"none"},
  229. effectValue = 0,
  230. accuracy = 100,
  231. pp = 10
  232. },
  233.  
  234. Sundance = {
  235. name = "Sundance",
  236. type = "Grass",
  237. doesDamage = false,
  238. attackForm = "phys",
  239. target = "self",
  240. power = 0,
  241. effect = {"none", "buffAttack", "buffSpecAttack"},
  242. effectValue = 10,
  243. accuracy = 100,
  244. pp = 10
  245. },
  246.  
  247. RazorLeafs = {
  248. name = "Razorleafs",
  249. type = "Grass",
  250. doesDamage = true,
  251. attackForm = "spec",
  252. target = "opponent",
  253. power = 4,
  254. effect = {"none"},
  255. effectValue = 0,
  256. accuracy = 100,
  257. pp = 10
  258. },
  259.  
  260. LeafBlade = {
  261. name = "LeafBlade",
  262. type = "Grass",
  263. doesDamage = true,
  264. attackForm = "phys",
  265. target = "opponent",
  266. power = 2,
  267. effect = {"none", "crit"},
  268. effectValue = 10,
  269. accuracy = 100,
  270. pp = 10
  271. },
  272.  
  273. MagicalLeafs = {
  274. name = "MagicalLeafs",
  275. type = "Grass",
  276. doesDamage = true,
  277. attackForm = "spec",
  278. target = "self",
  279. power = 3,
  280. effect = {"none"},
  281. effectValue = 0,
  282. accuracy = 100,
  283. pp = 10
  284. },
  285.  
  286.  
  287. -- ############## Bug ###############
  288. HornCharge = {
  289. name = "HornCharge",
  290. type = "Bug",
  291. doesDamage = true,
  292. attackForm = "phys",
  293. target = "opponent",
  294. power = 3,
  295. effect = {"none"},
  296. effectValue = 0,
  297. accuracy = 100,
  298. pp = 10
  299. },
  300.  
  301. BugBite = {
  302. name = "BugBite",
  303. type = "Bug",
  304. doesDamage = true,
  305. attackForm = "phys",
  306. target = "opponent",
  307. power = 2,
  308. effect = {"none", "debuffSpeed"},
  309. effectValue = 5,
  310. accuracy = 100,
  311. pp = 10
  312. },
  313.  
  314. DefendOrder = {
  315. name = "DefendOrder",
  316. type = "Bug",
  317. doesDamage = false,
  318. attackForm = "phys",
  319. target = "self",
  320. power = 0,
  321. effect = {"none", "buffDefense", "buffSpecDefense"},
  322. effectValue = 10,
  323. accuracy = 100,
  324. pp = 10
  325. },
  326.  
  327. AttackOrder = {
  328. name = "AttackOrder",
  329. type = "Bug",
  330. doesDamage = false,
  331. attackForm = "phys",
  332. target = "self",
  333. power = 0,
  334. effect = {"none", "buffAttack", "buffSpecAttack"},
  335. effectValue = 10,
  336. accuracy = 100,
  337. pp = 10
  338. },
  339.  
  340. Net = {
  341. name = "Net",
  342. type = "Bug",
  343. doesDamage = false,
  344. attackForm = "phys",
  345. target = "opponent",
  346. power = 0,
  347. effect = {"none", "debuffSpeed"},
  348. effectValue = 20,
  349. accuracy = 100,
  350. pp = 10
  351. },
  352.  
  353.  
  354. -- ############## Poison ###############
  355. Poison = {
  356. name = "Poison",
  357. type = "Poison",
  358. doesDamage = true,
  359. attackForm = "phys",
  360. target = "opponent",
  361. power = 1,
  362. effect = {"none", "poison"},
  363. effectValue = 100,
  364. accuracy = 100,
  365. pp = 10
  366. },
  367.  
  368. SleepSpore = {
  369. name = "SleepSpore",
  370. type = "Poison",
  371. doesDamage = false,
  372. attackForm = "phys",
  373. target = "opponent",
  374. power = 0,
  375. effect = {"none", "sleep"},
  376. effectValue = 100,
  377. accuracy = 85,
  378. pp = 10
  379. },
  380.  
  381. PoisonJab = {
  382. name = "PoisonJab",
  383. type = "Poison",
  384. doesDamage = true,
  385. attackForm = "phys",
  386. target = "opponent",
  387. power = 2,
  388. effect = {"none", "poison"},
  389. effectValue = 0,
  390. accuracy = 65,
  391. pp = 10
  392. },
  393.  
  394. -- ############## Rock ###############
  395. RockThrow = {
  396. name = "RockThrow",
  397. type = "Rock",
  398. doesDamage = true,
  399. attackForm = "phys",
  400. target = "opponent",
  401. power = 2,
  402. effect = {"none"},
  403. effectValue = 0,
  404. accuracy = 95,
  405. pp = 10
  406. },
  407.  
  408. StoneEdge = {
  409. name = "StoneEdge",
  410. type = "Rock",
  411. doesDamage = true,
  412. attackForm = "phys",
  413. target = "opponent",
  414. power = 3,
  415. effect = {"none", "crit"},
  416. effectValue = 10,
  417. accuracy = 95,
  418. pp = 10
  419. },
  420.  
  421. Reinforce = {
  422. name = "Reinforce",
  423. type = "Rock",
  424. doesDamage = false,
  425. attackForm = "phys",
  426. target = "self",
  427. power = 0,
  428. effect = {"none", "buffDefense", "buffSpecDefense"},
  429. effectValue = 10,
  430. accuracy = 100,
  431. pp = 10
  432. },
  433.  
  434. RockPolish = {
  435. name = "RockPolish",
  436. type = "Rock",
  437. doesDamage = false,
  438. attackForm = "phys",
  439. target = "self",
  440. power = 0,
  441. effect = {"none", "buffSpeed"},
  442. effectValue = 15,
  443. accuracy = 100,
  444. pp = 10
  445. },
  446.  
  447. -- ############## Ground ###############
  448. DirtSpikes = {
  449. name = "DirtSpikes",
  450. type = "Ground",
  451. doesDamage = true,
  452. attackForm = "phys",
  453. target = "opponent",
  454. power = 2,
  455. effect = {"none"},
  456. effectValue = 0,
  457. accuracy = 100,
  458. pp = 10
  459. },
  460.  
  461. Earthquake = {
  462. name = "Earthquake",
  463. type = "Ground",
  464. doesDamage = true,
  465. attackForm = "spec",
  466. target = "opponent",
  467. power = 4,
  468. effect = {"none"},
  469. effectValue = 0,
  470. accuracy = 100,
  471. pp = 5
  472. },
  473.  
  474.  
  475. MudSquirt = {
  476. name = "MudSquirt",
  477. type = "Ground",
  478. doesDamage = true,
  479. attackForm = "spec",
  480. target = "opponent",
  481. power = 1,
  482. effect = {"none", "debuffAccuracy"},
  483. effectValue = 5,
  484. accuracy = 100,
  485. pp = 20
  486. },
  487.  
  488.  
  489. -- ############## Dark ###############
  490. Bite = {
  491. name = "Bite",
  492. type = "Dark",
  493. doesDamage = true,
  494. attackForm = "phys",
  495. target = "opponent",
  496. power = 3,
  497. effect = {"none", "flinch"},
  498. effectValue = 50,
  499. accuracy = 100,
  500. pp = 10
  501. },
  502.  
  503. NightSlash = {
  504. name = "NightSlash",
  505. type = "Dark",
  506. doesDamage = true,
  507. attackForm = "spec",
  508. target = "opponent",
  509. power = 2,
  510. effect = {"none", "crit"},
  511. effectValue = 15,
  512. accuracy = 100,
  513. pp = 10
  514. },
  515.  
  516. DarkPulse = {
  517. name = "DarkPulse",
  518. type = "Dark",
  519. doesDamage = true,
  520. attackForm = "spec",
  521. target = "opponent",
  522. power = 2,
  523. effect = {"none", "flinch"},
  524. effectValue = 60,
  525. accuracy = 100,
  526. pp = 10
  527. },
  528.  
  529. NastyPlot = {
  530. name = "NastyPlot",
  531. type = "Dark",
  532. doesDamage = false,
  533. attackForm = "spec",
  534. target = "self",
  535. power = 0,
  536. effect = {"none", "buffSpecAttack"},
  537. effectValue = 20,
  538. accuracy = 100,
  539. pp = 5
  540. },
  541.  
  542. -- ############## Ghost ###############
  543. OminousWind = {
  544. name = "OminousWind",
  545. type = "Ghost",
  546. doesDamage = false,
  547. attackForm = "spec",
  548. target = "self",
  549. power = 0,
  550. effect = {"none", "buffSpecAttack", "buffAttack", "buffDefense", "buffSpecDefense", "buffSpeed", "buffAccuracy"},
  551. effectValue = 5,
  552. accuracy = 100,
  553. pp = 5
  554. },
  555.  
  556. ShadowClaw = {
  557. name = "ShadowClaw",
  558. type = "Ghost",
  559. doesDamage = true,
  560. attackForm = "spec",
  561. target = "self",
  562. power = 2,
  563. effect = {"none", "crit"},
  564. effectValue = 5,
  565. accuracy = 100,
  566. pp = 10
  567. },
  568.  
  569. Curse = {
  570. name = "Curse",
  571. type = "Ghost",
  572. doesDamage = true,
  573. attackForm = "spec",
  574. target = "self",
  575. power = 1,
  576. effect = {"none", "curse"},
  577. effectValue = 5,
  578. accuracy = 100,
  579. pp = 5
  580. },
  581.  
  582. -- ############## Psychic ###############
  583. Psybeam = {
  584. name = "Psybeam",
  585. type = "Psychic",
  586. doesDamage = true,
  587. attackForm = "spec",
  588. target = "opponent",
  589. power = 2,
  590. effect = {"none", "confusion"},
  591. effectValue = 60,
  592. accuracy = 100,
  593. pp = 10
  594. },
  595.  
  596. Psychic = {
  597. name = "Psychic",
  598. type = "Psychic",
  599. doesDamage = true,
  600. attackForm = "spec",
  601. target = "opponent",
  602. power = 4,
  603. effect = {"none", "none"},
  604. effectValue = 0,
  605. accuracy = 100,
  606. pp = 10
  607. },
  608.  
  609. Confusion = {
  610. name = "Confusion",
  611. type = "Psychic",
  612. doesDamage = false,
  613. attackForm = "spec",
  614. target = "opponent",
  615. power = 0,
  616. effect = {"none", "confusion"},
  617. effectValue = 100,
  618. accuracy = 85,
  619. pp = 10
  620. },
  621.  
  622. Meditation = {
  623. name = "Meditation",
  624. type = "Psychic",
  625. doesDamage = false,
  626. attackForm = "spec",
  627. target = "self",
  628. power = 0,
  629. effect = {[1] = "none", [2] = "heal", [3] = "buffAccuracy", [4] = "buffSpecAttack"},
  630. effectValue = 5,
  631. accuracy = 100,
  632. pp = 10
  633. },
  634.  
  635. -- ############## Water ###############
  636. SquirtGun = {
  637. name = "SquirtGun",
  638. type = "Water",
  639. doesDamage = true,
  640. attackForm = "spec",
  641. target = "opponent",
  642. power = 2,
  643. effect = {"none"},
  644. effectValue = 0,
  645. accuracy = 100,
  646. pp = 15
  647. },
  648.  
  649. Surf = {
  650. name = "Surf",
  651. type = "Water",
  652. doesDamage = true,
  653. attackForm = "spec",
  654. target = "opponent",
  655. power = 4,
  656. effect = {"none"},
  657. effectValue = 0,
  658. accuracy = 100,
  659. pp = 10
  660. },
  661.  
  662. AquaJet = {
  663. name = "AquaJet",
  664. type = "Water",
  665. doesDamage = true,
  666. attackForm = "phys",
  667. target = "opponent",
  668. power = 3,
  669. effect = {"none"},
  670. effectValue = 0,
  671. accuracy = 100,
  672. pp = 10
  673. },
  674.  
  675. Raindance = {
  676. name = "Raindance",
  677. type = "Water",
  678. doesDamage = false,
  679. attackForm = "spec",
  680. target = "self",
  681. power = 0,
  682. effect = {"none", "buffSpecAttack"},
  683. effectValue = 15,
  684. accuracy = 100,
  685. pp = 10
  686. },
  687.  
  688.  
  689. -- ############## Fire ###############
  690. Flamethrower = {
  691. name = "Flamethrower",
  692. type = "Fire",
  693. doesDamage = true,
  694. attackForm = "spec",
  695. target = "opponent",
  696. power = 2,
  697. effect = {"none", "burn"},
  698. effectValue = 60,
  699. accuracy = 90,
  700. pp = 10
  701. },
  702.  
  703.  
  704. FireRing = {
  705. name = "FireRing",
  706. type = "Fire",
  707. doesDamage = true,
  708. attackForm = "spec",
  709. target = "opponent",
  710. power = 3,
  711. effect = {"none", "burn"},
  712. effectValue = 60,
  713. accuracy = 95,
  714. pp = 10
  715. },
  716.  
  717.  
  718. FireStorm = {
  719. name = "FireStorm",
  720. type = "Fire",
  721. doesDamage = true,
  722. attackForm = "phys",
  723. target = "opponent",
  724. power = 3,
  725. effect = {"none", "burn"},
  726. effectValue = 50,
  727. accuracy = 95,
  728. pp = 10
  729. },
  730.  
  731. Armageddon = {
  732. name = "Armageddon",
  733. type = "Fire",
  734. doesDamage = true,
  735. attackForm = "phys",
  736. target = "opponent",
  737. power = 8,
  738. effect = {"none"},
  739. effectValue = 0,
  740. accuracy = 50,
  741. pp = 5
  742. },
  743.  
  744. -- ############## Steel ###############
  745. Impenetrable = {
  746. name = "Impenetrable",
  747. type = "Steel",
  748. doesDamage = false,
  749. attackForm = "spec",
  750. target = "self",
  751. power = 0,
  752. effect = {"none", "buffDefense"},
  753. effectValue = 25,
  754. accuracy = 100,
  755. pp = 5
  756. },
  757.  
  758. FlashCannon = {
  759. name = "FlashCannon",
  760. type = "Steel",
  761. doesDamage = false,
  762. attackForm = "spec",
  763. target = "opponent",
  764. power = 0,
  765. effect = {"none", "debuffSpecDefense"},
  766. effectValue = 15,
  767. accuracy = 100,
  768. pp = 10
  769. },
  770.  
  771. SteelFist = {
  772. name = "SteelFist",
  773. type = "Steel",
  774. doesDamage = true,
  775. attackForm = "phys",
  776. target = "opponent",
  777. power = 3,
  778. effect = {"none"},
  779. effectValue = 0,
  780. accuracy = 85,
  781. },
  782.  
  783.  
  784. GyroBall = {
  785. name = "GyroBall",
  786. type = "Steel",
  787. doesDamage = true,
  788. attackForm = "spec",
  789. target = "opponent",
  790. power = 0, --(100 - player..playerTurn.speed) / 15,
  791. effect = {"none"},
  792. effectValue = 0,
  793. accuracy = 95,
  794. pp = 15
  795. },
  796.  
  797.  
  798.  
  799. -- ############## Electric ###############
  800. Shock = {
  801. name = "Shock",
  802. type = "Electric",
  803. doesDamage = true,
  804. attackForm = "spec",
  805. target = "opponent",
  806. power = 3,
  807. effect = {"none", "paralyze"},
  808. effectValue = 60,
  809. accuracy = 100,
  810. pp = 15
  811. },
  812.  
  813. ElectroShock = {
  814. name = "ElectroShock",
  815. type = "Electric",
  816. doesDamage = true,
  817. attackForm = "spec",
  818. target = "opponent",
  819. power = 4,
  820. effect = {"none", "paralyze"},
  821. effectValue = 50,
  822. accuracy = 100,
  823. pp = 5
  824. },
  825.  
  826. ChargeBeam = {
  827. name = "ChargeBeam",
  828. type = "Electric",
  829. doesDamage = false,
  830. attackForm = "spec",
  831. target = "self",
  832. power = 0,
  833. effect = {"none", "buffSpecAttack"},
  834. effectValue = 15,
  835. accuracy = 100,
  836. pp = 5
  837. },
  838.  
  839. Discharge = {
  840. name = "Discharge",
  841. type = "Electric",
  842. doesDamage = false,
  843. attackForm = "spec",
  844. target = "opponent",
  845. power = 0,
  846. effect = {"none", "paralyze"},
  847. effectValue = 100,
  848. accuracy = 100,
  849. pp = 5
  850. },
  851.  
  852. -- ############## Ice ###############
  853. IceFang = {
  854. name = "IceFang",
  855. type = "Ice",
  856. doesDamage = true,
  857. attackForm = "phys",
  858. target = "opponent",
  859. power = 3,
  860. effect = {"none", "freeze"},
  861. effectValue = 50,
  862. accuracy = 95,
  863. pp = 5
  864. },
  865.  
  866. Freeze = {
  867. name = "Freeze",
  868. type = "Ice",
  869. doesDamage = false,
  870. attackForm = "spec",
  871. target = "opponent",
  872. power = 0,
  873. effect = {"none", "freeze"},
  874. effectValue = 100,
  875. accuracy = 95,
  876. pp = 10
  877. },
  878.  
  879. Blizzard = {
  880. name = "Blizzard",
  881. type = "Ice",
  882. doesDamage = true,
  883. attackForm = "spec",
  884. target = "opponent",
  885. power = 2,
  886. effect = {"none", "freeze", "buffSpecAttack"},
  887. effectValue = 15,
  888. accuracy = 100,
  889. pp = 10
  890. },
  891.  
  892. -- ############## Fighting ###############
  893. CosmicPunch = {
  894. name = "CosmicPunch",
  895. type = "Fighting",
  896. doesDamage = true,
  897. attackForm = "phys",
  898. target = "opponent",
  899. power = 5,
  900. effect = {"none"},
  901. effectValue = 0,
  902. accuracy = 75,
  903. pp = 10
  904. },
  905.  
  906. SuckerPunch = {
  907. name = "SuckerPunch",
  908. type = "Fighting",
  909. doesDamage = true,
  910. attackForm = "phys",
  911. target = "self",
  912. power = 2,
  913. effect = {"none"},
  914. effectValue = 0,
  915. accuracy = 100,
  916. pp = 10
  917. },
  918.  
  919. RoundhouseKick = {
  920. name = "RoundhouseKick",
  921. type = "Fighting",
  922. doesDamage = true,
  923. attackForm = "phys",
  924. target = "opponent",
  925. power = 3,
  926. effect = {"none"},
  927. effectValue = 0,
  928. accuracy = 100,
  929. pp = 10
  930. },
  931.  
  932. Flex = {
  933. name = "Flex",
  934. type = "Fighting",
  935. doesDamage = false,
  936. attackForm = "phys",
  937. target = "self",
  938. power = 0,
  939. effect = {"none", "buffAttack"},
  940. effectValue = 15,
  941. accuracy = 100,
  942. pp = 10
  943. },
  944.  
  945. -- ############## Dragon ###############
  946. DracoMeteor = {
  947. name = "DracoMeteor",
  948. type = "Dragon",
  949. doesDamage = true,
  950. attackForm = "phys",
  951. target = "opponent",
  952. power = 3,
  953. effect = {"none", "debuffSpecDefense"},
  954. effectValue = 10,
  955. accuracy = 100,
  956. pp = 10
  957. },
  958.  
  959. SpacialRend = {
  960. name = "SpacialRend",
  961. type = "Dragon",
  962. doesDamage = true,
  963. attackForm = "phys",
  964. target = "opponent",
  965. power = 3,
  966. effect = {"none", "crit"},
  967. effectValue = 10,
  968. accuracy = 100,
  969. pp = 10
  970. },
  971.  
  972. DragonRage = {
  973. name = "DragonRage",
  974. type = "Dragon",
  975. doesDamage = true,
  976. attackForm = "spec",
  977. target = "opponent",
  978. power = 4,
  979. effect = {"none", "flinch"},
  980. effectValue = 40,
  981. accuracy = 100,
  982. pp = 10
  983. },
  984.  
  985. -- ############## Flying ###############
  986. Fly = {
  987. name = "Fly",
  988. type = "Flying",
  989. doesDamage = true,
  990. attackForm = "spec",
  991. target = "opponent",
  992. power = 3,
  993. effect = {"none"},
  994. effectValue = 0,
  995. accuracy = 100,
  996. pp = 10
  997. },
  998.  
  999. AirSlash = {
  1000. name = "AirSlash",
  1001. type = "Flying",
  1002. doesDamage = true,
  1003. attackForm = "spec",
  1004. target = "self",
  1005. power = 3,
  1006. effect = {"none", "flinch"},
  1007. effectValue = 40,
  1008. accuracy = 100,
  1009. pp = 10
  1010. },
  1011.  
  1012. Peck = {
  1013. name = "Peck",
  1014. type = "Flying",
  1015. doesDamage = true,
  1016. attackForm = "phys",
  1017. target = "opponent",
  1018. power = 2,
  1019. effect = {"none"},
  1020. effectValue = 0,
  1021. accuracy = 100,
  1022. pp = 10
  1023. },
  1024.  
  1025. WingAttack = {
  1026. name = "WingAttack",
  1027. type = "Flying",
  1028. doesDamage = true,
  1029. attackForm = "phys",
  1030. target = "opponent",
  1031. power = 3,
  1032. effect = {"none"},
  1033. effectValue = 0,
  1034. accuracy = 100,
  1035. pp = 10
  1036. },
  1037.  
  1038. Hawkeye = {
  1039. name = "Hawkeye",
  1040. type = "Flying",
  1041. doesDamage = false,
  1042. attackForm = "spec",
  1043. target = "self",
  1044. power = 0,
  1045. effect = {"none", "buffAccuracy"},
  1046. effectValue = 20,
  1047. accuracy = 100,
  1048. pp = 10
  1049. },
  1050.  
  1051. Roost = {
  1052. name = "Roost",
  1053. type = "Flying",
  1054. doesDamage = false,
  1055. attackForm = "spec",
  1056. target = "self",
  1057. power = 0,
  1058. effect = {"none", "roost"},
  1059. effectValue = 0,
  1060. accuracy = 100,
  1061. pp = 10
  1062. }
  1063. }
  1064.  
  1065. local function writeFile()
  1066. handle = fs.open("moves", "w")
  1067. handle.write(textutils.serialize(moves))
  1068. handle.close()
  1069. end
  1070.  
  1071. writeFile()
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077. --selectedMove = "OminousWind"
  1078. --print(moves[selectedMove]["effect"])
  1079. --for k, moveEffect in ipairs(moves[selectedMove]["effect"]) do
  1080. -- print("effect: "..moveEffect)
  1081. --end
  1082.  
  1083. --event = os.pullEvent("key")
  1084.  
  1085.  
  1086. -- #####################################################################################################
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101. local function writeFile(file)
  1102. handle = fs.open(tostring(file), "w")
  1103. handle.write(textutils.serialize(file))
  1104. handle.close()
  1105. end
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112. local function loadPokemon()
  1113. handle = fs.open("pokemon", "r")
  1114. loadedFile = textutils.unserialize(handle.readLine())
  1115. handle.close()
  1116. end
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123. local function drawImage(image, x, y)
  1124. end
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130. local function writeHP()
  1131. term.setCursorPos(1, h)
  1132. write(player1.name.." "..player1.currHp.." / "..player1.hpMax)
  1133. term.setCursorPos((w-15)/2, h)
  1134. write(player2.name.." "..player2.currHp.." / "..player2.hpMax)
  1135. end
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142. local function selectMon1()
  1143. number = 0
  1144. for i = 1, #pokemon do
  1145. number = number +1
  1146. end
  1147. shell.run("clear")
  1148. print("player1 select a pokemon")
  1149. print("use arrows to select")
  1150. sleep(0.3)
  1151. shell.run("clear")
  1152.  
  1153.  
  1154. local selection = 1
  1155. while true do
  1156. shell.run("clear")
  1157. print("selection: "..selection)
  1158. print("Name: "..pokemon[selection]["name"])
  1159. print("Level: "..pokemon[selection]["level"])
  1160. print("Type: "..pokemon[selection]["type1"].." / "..pokemon[selection]["type2"])
  1161. print("HP: "..pokemon[selection]["hpMax"])
  1162. print("Attack: "..pokemon[selection]["attack"])
  1163. print("Defense: "..pokemon[selection]["defense"])
  1164. print("Spec. Attack: "..pokemon[selection]["specAttack"])
  1165. print("Spec. Defense: "..pokemon[selection]["specDefense"])
  1166. print("Speed: "..pokemon[selection]["speed"])
  1167. print(" ")
  1168. print("Moves:")
  1169. print(pokemon[selection]["move1"].." | Power: "..moves[pokemon[selection]["move1"]]["power"].." | PP: "..moves[pokemon[selection]["move1"]]["pp"])
  1170. print(pokemon[selection]["move2"].." | Power: "..moves[pokemon[selection]["move2"]]["power"].." | PP: "..moves[pokemon[selection]["move2"]]["pp"])
  1171. print(pokemon[selection]["move3"].." | Power: "..moves[pokemon[selection]["move3"]]["power"].." | PP: "..moves[pokemon[selection]["move3"]]["pp"])
  1172. print(pokemon[selection]["move4"].." | Power: "..moves[pokemon[selection]["move4"]]["power"].." | PP: "..moves[pokemon[selection]["move4"]]["pp"])
  1173. --drawImage(pokemon[selection]["name"], x, y)
  1174.  
  1175. local event, arg1 = os.pullEvent("key")
  1176. if keys.getName(arg1) == "enter" or keys.getName(arg1) == "space" then
  1177.  
  1178. table.insert(player1Select, pokemon[selection])
  1179.  
  1180. --player1 = pokemon[selection]
  1181. break
  1182. elseif keys.getName(arg1) == "left" or keys.getName(arg1) == "a" then
  1183. selection = selection - 1
  1184. if selection == 0 then selection = number end
  1185. elseif keys.getName(arg1) == "right" or keys.getName(arg1) == "d" then
  1186. selection = selection + 1
  1187. if selection > number then selection = 1 end
  1188. end
  1189. end
  1190.  
  1191. table.remove(pokemon, selection)
  1192.  
  1193. player1 = player1Select[1]
  1194. end
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200. local function selectMon2()
  1201. shell.run("clear")
  1202. print("player2 select a pokemon")
  1203. print("use arrows to select")
  1204. sleep(0.3)
  1205. shell.run("clear")
  1206.  
  1207. local selection = 1
  1208. while true do
  1209. shell.run("clear")
  1210. print("Name: "..pokemon[selection]["name"])
  1211. print("Level: "..pokemon[selection]["level"])
  1212. print("Type: "..pokemon[selection]["type1"].." / "..pokemon[selection]["type2"])
  1213. print("HP: "..pokemon[selection]["hpMax"])
  1214. print("Attack: "..pokemon[selection]["attack"])
  1215. print("Defense: "..pokemon[selection]["defense"])
  1216. print("Spec. Attack: "..pokemon[selection]["specAttack"])
  1217. print("Spec. Defense: "..pokemon[selection]["specDefense"])
  1218. print("Speed: "..pokemon[selection]["speed"])
  1219. print(" ")
  1220. print("Moves:")
  1221. print(pokemon[selection]["move1"].." | Power: "..moves[pokemon[selection]["move1"]]["power"].." | PP: "..moves[pokemon[selection]["move1"]]["pp"])
  1222. print(pokemon[selection]["move2"].." | Power: "..moves[pokemon[selection]["move2"]]["power"].." | PP: "..moves[pokemon[selection]["move2"]]["pp"])
  1223. print(pokemon[selection]["move3"].." | Power: "..moves[pokemon[selection]["move3"]]["power"].." | PP: "..moves[pokemon[selection]["move3"]]["pp"])
  1224. print(pokemon[selection]["move4"].." | Power: "..moves[pokemon[selection]["move4"]]["power"].." | PP: "..moves[pokemon[selection]["move4"]]["pp"])
  1225. --drawImage(pokemon[selection]["name"], x, y)
  1226.  
  1227. local event, arg1 = os.pullEvent("key")
  1228. if keys.getName(arg1) == "enter" or keys.getName(arg1) == "space" then
  1229. table.insert(player2Select, pokemon[selection])
  1230. --player2 = pokemon[selection]
  1231. break
  1232. elseif keys.getName(arg1) == "left" or keys.getName(arg1) == "a" then
  1233. selection = selection - 1
  1234. if selection == 0 then selection = #pokemon end
  1235. elseif keys.getName(arg1) == "right" or keys.getName(arg1) == "d" then
  1236. selection = selection + 1
  1237. if selection > #pokemon then selection = 1 end
  1238. end
  1239. end
  1240. table.remove(pokemon, selection)
  1241. player2 = player2Select[1]
  1242. end
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248. local function selectNewMon1()
  1249. number = 0
  1250. for i = 1, #player1Select do
  1251. number = number +1
  1252. end
  1253. shell.run("clear")
  1254.  
  1255. local selection = 1
  1256. while true do
  1257. shell.run("clear")
  1258. print("selection: "..selection)
  1259. print("Name: "..player1Select[selection]["name"])
  1260. print("Level: "..player1Select[selection]["level"])
  1261. print("Type: "..player1Select[selection]["type1"].." / "..player1Select[selection]["type2"])
  1262. print("HP: "..player1Select[selection]["currHp"].." / "..player1Select[selection]["hpMax"])
  1263. print("Attack: "..player1Select[selection]["attack"])
  1264. print("Defense: "..player1Select[selection]["defense"])
  1265. print("Spec. Attack: "..player1Select[selection]["specAttack"])
  1266. print("Spec. Defense: "..player1Select[selection]["specDefense"])
  1267. print("Speed: "..player1Select[selection]["speed"])
  1268. print(" ")
  1269. print("Moves:")
  1270. print(player1Select[selection]["move1"].." | Power: "..moves[player1Select[selection]["move1"]]["power"].." | PP: "..player1Select[selection]["move1pp"].." / "..moves[player1Select[selection]["move1"]]["pp"])
  1271. print(player1Select[selection]["move2"].." | Power: "..moves[player1Select[selection]["move2"]]["power"].." | PP: "..player1Select[selection]["move2pp"].." / "..moves[player1Select[selection]["move2"]]["pp"])
  1272. print(player1Select[selection]["move3"].." | Power: "..moves[player1Select[selection]["move3"]]["power"].." | PP: "..player1Select[selection]["move3pp"].." / "..moves[player1Select[selection]["move3"]]["pp"])
  1273. print(player1Select[selection]["move4"].." | Power: "..moves[player1Select[selection]["move4"]]["power"].." | PP: "..player1Select[selection]["move4pp"].." / "..moves[player1Select[selection]["move4"]]["pp"])
  1274. --drawImage(player1Select[selection]["name"], x, y)
  1275.  
  1276. local event, arg1 = os.pullEvent("key")
  1277. if keys.getName(arg1) == "enter" or keys.getName(arg1) == "space" then
  1278. if player1Select[selection]["status"] ~= "fainted" then
  1279. selection1 = selection
  1280. --player1 = player1Select[selection]
  1281. switch1 = true
  1282. break
  1283. end
  1284. elseif keys.getName(arg1) == "left" or keys.getName(arg1) == "a" then
  1285. selection = selection - 1
  1286. if selection == 0 then selection = number end
  1287. elseif keys.getName(arg1) == "right" or keys.getName(arg1) == "d" then
  1288. selection = selection + 1
  1289. if selection > number then selection = 1 end
  1290. end
  1291. end
  1292. end
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298. local function selectNewMon2()
  1299. number = 0
  1300. for i = 1, #player2Select do
  1301. number = number +1
  1302. end
  1303. shell.run("clear")
  1304.  
  1305. local selection = 1
  1306. while true do
  1307. shell.run("clear")
  1308. print("selection: "..selection)
  1309. print("Name: "..player2Select[selection]["name"])
  1310. print("Level: "..player2Select[selection]["level"])
  1311. print("Type: "..player2Select[selection]["type1"].." / "..player2Select[selection]["type2"])
  1312. print("HP: "..player2Select[selection]["currHp"].." / "..player2Select[selection]["hpMax"])
  1313. print("Attack: "..player2Select[selection]["attack"])
  1314. print("Defense: "..player2Select[selection]["defense"])
  1315. print("Spec. Attack: "..player2Select[selection]["specAttack"])
  1316. print("Spec. Defense: "..player2Select[selection]["specDefense"])
  1317. print("Speed: "..player2Select[selection]["speed"])
  1318. print(" ")
  1319. print("Moves:")
  1320. print(player2Select[selection]["move1"].." | Power: "..moves[player2Select[selection]["move1"]]["power"].." | PP: "..player2Select[selection]["move1pp"].." / "..moves[player2Select[selection]["move1"]]["pp"])
  1321. print(player2Select[selection]["move2"].." | Power: "..moves[player2Select[selection]["move2"]]["power"].." | PP: "..player2Select[selection]["move2pp"].." / "..moves[player2Select[selection]["move2"]]["pp"])
  1322. print(player2Select[selection]["move3"].." | Power: "..moves[player2Select[selection]["move3"]]["power"].." | PP: "..player2Select[selection]["move3pp"].." / "..moves[player2Select[selection]["move3"]]["pp"])
  1323. print(player2Select[selection]["move4"].." | Power: "..moves[player2Select[selection]["move4"]]["power"].." | PP: "..player2Select[selection]["move4pp"].." / "..moves[player2Select[selection]["move4"]]["pp"])
  1324. --drawImage(player2Select[selection]["name"], x, y)
  1325.  
  1326. local event, arg1 = os.pullEvent("key")
  1327. if keys.getName(arg1) == "enter" or keys.getName(arg1) == "space" then
  1328. if player1Select[selection]["status"] ~= "fainted" then
  1329. selection2 = selection
  1330. --player2 = player2Select[selection]
  1331. switch2 = true
  1332. break
  1333. end
  1334. elseif keys.getName(arg1) == "left" or keys.getName(arg1) == "a" then
  1335. selection = selection - 1
  1336. if selection == 0 then selection = number end
  1337. elseif keys.getName(arg1) == "right" or keys.getName(arg1) == "d" then
  1338. selection = selection + 1
  1339. if selection > number then selection = 1 end
  1340. end
  1341. end
  1342. end
  1343.  
  1344.  
  1345.  
  1346.  
  1347. local function printPokemon()
  1348. shell.run("clear")
  1349. print("Player1 selected: "..player1Select[1]["name"]..", "..player1Select[2]["name"]..", "..player1Select[3]["name"])
  1350. print("player2 selected: "..player2Select[1]["name"]..", "..player2Select[2]["name"]..", "..player2Select[3]["name"])
  1351. event = os.pullEvent("key")
  1352. end
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362. local function calcAccuracy()
  1363. if playerTurn == 1 then
  1364. selectedMove = selectedMove1
  1365. elseif playerTurn == 2 then
  1366. selectedMove = selectedMove2
  1367. end
  1368. --Accuracy
  1369. roll = math.random(0, 100)
  1370. accuracy = false
  1371. if playerTurn == 1 then
  1372. if moves[selectedMove]["accuracy"] + player1.accuracy >= roll then
  1373. accuracy = true
  1374. end
  1375. elseif playerTurn == 2 then
  1376. if moves[selectedMove]["accuracy"] + player2.accuracy >= roll then
  1377. accuracy = true
  1378. end
  1379. end
  1380. if moves[selectedMove]["target"] == "self" then
  1381. accuracy = true
  1382. end
  1383. end
  1384.  
  1385.  
  1386.  
  1387.  
  1388. local function STABBonus()
  1389. --STAB bonus
  1390. if playerTurn == 1 then
  1391. moveType = moves[selectedMove]["type"]
  1392. elseif playerTurn == 2 then
  1393. moveType = moves[selectedMove]["type"]
  1394. end
  1395.  
  1396. STAB = 1
  1397. if playerTurn == 1 and player1.type1 or player1.type2 == moveType then
  1398. STAB = 2
  1399. elseif playerTurn == 2 and player2.type1 or player2.type2 == moveType then
  1400. STAB = 2
  1401. end
  1402. end
  1403.  
  1404.  
  1405.  
  1406.  
  1407. local function strengthAndWeakness()
  1408. -- strengths and weaknesses
  1409. moveType = moves[selectedMove]["type"]
  1410. resist = 1
  1411. weakness = 1
  1412. if moveType == "Normal" then
  1413. se = { "N/A" }
  1414. nve = { "Rock", "Steel" }
  1415. ne = { "Ghost" }
  1416. elseif moveType == "Grass" then
  1417. se = { "Water", "Ground", "Rock" }
  1418. nve = { "Fire", "Grass", "Poison", "Flying", "Bug", "Dragon", "Steel" }
  1419. ne = { "N/A" }
  1420. elseif moveType == "Fire" then
  1421. se = { "Grass", "Ice", "Bug" }
  1422. nve = { "Fire", "Water", "Rock", "Dragon" }
  1423. ne = { "N/A" }
  1424. elseif moveType == "Water" then
  1425. se = { "Fire", "Ground", "Rock" }
  1426. nve = { "Water", "Grass", "Dragon" }
  1427. ne = { "N/A" }
  1428. elseif moveType == "Dragon" then
  1429. se = { "Dragon" }
  1430. nve = { "Steel" }
  1431. ne = { "N/A" }
  1432. elseif moveType == "Flying" then
  1433. se = { "Grass", "Fighting", "Bug" }
  1434. nve = { "Electric", "Rock", "Steel" }
  1435. ne = { "N/A" }
  1436. elseif moveType == "Psychic" then
  1437. se = { "Fighting", "Poison"}
  1438. nve = { "Psychic", "Steel" }
  1439. ne = { "Dark" }
  1440. elseif moveType == "Dark" then
  1441. se = { "Psychic", "Ghost" }
  1442. nve = { "Fighting", "Dark", "Steel" }
  1443. ne = { "N/A" }
  1444. elseif moveType == "Bug" then
  1445. se = { "Grass", "Psychic", "Dark" }
  1446. nve = { "Fire", "Fighting", "Poison", "Flying", "Ghost", "Steel" }
  1447. ne = { "N/A" }
  1448. else
  1449. se = { "N/A" }
  1450. nve = { "N/A" }
  1451. ne = { "N/A" }
  1452. end
  1453.  
  1454. for _,v in pairs(se) do
  1455. if playerTurn == 1 then
  1456. if v == player2.type and v == player2.type2 then
  1457. weakness = weakness * 4
  1458. elseif v == player2.type1 or v == player2.type2 then
  1459. weakness = weakness * 2
  1460. end
  1461. elseif playerTurn == 2 then
  1462. if v == player1.type1 and v == player1.type2 then
  1463. weakness = weakness * 4
  1464. elseif v == player1.type1 or v == player1.type2 then
  1465. weakness = weakness * 2
  1466. end
  1467. end
  1468. end
  1469.  
  1470. for _,v in pairs(nve) do
  1471. if playerTurn == 1 then
  1472. if v == player2.type1 and v == player2.type2 then
  1473. resist = resist * 4
  1474. elseif v == player2.type or v == player2.type2 then
  1475. resist = resist * 2
  1476. end
  1477. elseif playerTurn == 2 then
  1478. if v == player1.type1 and v == player1.type2 then
  1479. resist = resist * 4
  1480. elseif v == player1.type1 or v == player1.type2 then
  1481. resist = resist * 4
  1482. end
  1483. end
  1484. end
  1485.  
  1486. for _,v in pairs(ne) do
  1487. if playerTurn == 1 then
  1488. if v == player2.type1 or v == player2.type2 then
  1489. weakness = weakness * 0
  1490. end
  1491. elseif playerTurn == 2 then
  1492. if v == player1.type1 or v == player1.type2 then
  1493. weakness = weakness * 0
  1494. end
  1495. end
  1496. end
  1497. end
  1498.  
  1499.  
  1500. local function calcDam()
  1501. -- Damage calculation
  1502. if playerTurn == 1 then
  1503. moveForm = moves[selectedMove]["attackForm"]
  1504. elseif playerTurn == 2 then
  1505. moveForm = moves[selectedMove]["attackForm"]
  1506. end
  1507.  
  1508. if moves[selectedMove]["doesDamage"] and accuracy == true and playerTurn == 1 then
  1509. if moveForm == "phys" then
  1510. baseDam = ((player1.attack) * moves[selectedMove]["power"]) / (player2.defense)
  1511. damBonus = (baseDam/100) * math.random(1,15)
  1512. dam = (baseDam + damBonus) * STAB * weakness / resist
  1513. elseif moveForm == "spec" then
  1514. baseDam = ((player1.specAttack) * moves[selectedMove]["power"]) / (player2.specDefense)
  1515. damBonus = (baseDam/100) * math.random(1,15)
  1516. dam = (baseDam + damBonus) * STAB * weakness / resist
  1517. elseif moveForm == "exac" then
  1518. dam = moves[selectedMove]["power"]
  1519. end
  1520.  
  1521. if weakness == 0 then
  1522. dam = 0
  1523. elseif dam < 1 then
  1524. dam = 1
  1525. end
  1526.  
  1527. for k, moveEffect in pairs(moves[selectedMove]["effect"]) do
  1528. if moveEffect == "crit" then
  1529. crit = math.random(1,100)
  1530. critical = false
  1531. if crit > 95 - moves[selectedMove]["effectValue"] then
  1532. dam = dam * 1.5
  1533. critical = true
  1534. end
  1535. else
  1536. crit = math.random(1,100)
  1537. critical = false
  1538. if crit > 95 then
  1539. dam = dam * 1.5
  1540. critical = true
  1541. end
  1542. end
  1543. end
  1544. dam = math.ceil(dam)
  1545.  
  1546. elseif moves[selectedMove]["doesDamage"] and accuracy == true and playerTurn == 2 then
  1547. if moveForm == "phys" then
  1548. baseDam = ((player2.attack) * moves[selectedMove]["power"]) / (player1.defense)
  1549. damBonus = (baseDam/100) * math.random(1,15)
  1550. dam = math.ceil((baseDam + damBonus) * STAB * weakness / resist)
  1551. elseif moveForm == "spec" then
  1552. baseDam = ((player2.specAttack) * moves[selectedMove]["power"]) / (player1.specDefense)
  1553. damBonus = (baseDam/100) * math.random(1,15)
  1554. dam = math.ceil((baseDam + damBonus) * STAB * weakness / resist)
  1555. elseif moveForm == "exac" then
  1556. dam = moves[selectedMove]["power"]
  1557. end
  1558.  
  1559. if weakness == 0 then
  1560. dam = 0
  1561. elseif dam < 1 then
  1562. dam = 1
  1563. end
  1564.  
  1565. for k, moveEffect in pairs(moves[selectedMove]["effect"]) do
  1566. if moveEffect == "crit" then
  1567. crit = math.random(1,100)
  1568. critical = false
  1569. if crit > 95 - moves[selectedMove]["effectValue"] then
  1570. dam = dam * 1.5
  1571. critical = true
  1572. end
  1573. else
  1574. crit = math.random(1,100)
  1575. critical = false
  1576. if crit > 95 then
  1577. dam = dam * 1.5
  1578. critical = true
  1579. end
  1580. end
  1581. end
  1582. dam = math.ceil(dam)
  1583. dam2 = dam
  1584. end
  1585.  
  1586. if playerTurn == 1 and accuracy == true and moves[selectedMove]["doesDamage"] == true then
  1587. player2.currHp = player2.currHp - dam
  1588. if player2.currHp < 1 then
  1589. player2.currHp = 0
  1590. end
  1591. elseif playerTurn == 2 and accuracy == true and moves[selectedMove]["doesDamage"] == true then
  1592. dam2 = dam
  1593. player1.currHp = player1.currHp - dam
  1594. if player1.currHp < 1 then
  1595. player1.currHp = 0
  1596. end
  1597. end
  1598. end
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605. local function buffAndDebuff()
  1606.  
  1607. shell.run("clear")
  1608. print(selectedMove)
  1609. for k, moveEffect in pairs(moves[selectedMove]["effect"]) do
  1610. print(moveEffect)
  1611.  
  1612. if moveEffect == "buffAttack" and playerTurn == 1 and accuracy == true then
  1613. player1.attack = player1.attack + moves[selectedMove]["effectValue"]
  1614. elseif moveEffect == "buffAttack" and playerTurn == 2 and accuracy == true then
  1615. player2.attack = player2.attack + moves[selectedMove]["effectValue"]
  1616. end
  1617.  
  1618. if moveEffect == "buffDefense" and playerTurn == 1 and accuracy == true then
  1619. player1.defense = player1.defense + moves[selectedMove]["effectValue"]
  1620. elseif moveEffect == "buffDefense" and playerTurn == 2 and accuracy == true then
  1621. player2.defense = player2.defense + moves[selectedMove]["effectValue"]
  1622. end
  1623.  
  1624. if moveEffect == "buffSpecDefense" and playerTurn == 1 and accuracy == true then
  1625. player1.specDefense = player1.specDefense + moves[selectedMove]["effectValue"]
  1626. elseif moveEffect == "buffSpecDefense" and playerTurn == 2 and accuracy == true then
  1627. player2.specDefense = player2.specDefense + moves[selectedMove]["effectValue"]
  1628. end
  1629.  
  1630. if moveEffect == "buffSpecAttack" and playerTurn == 1 and accuracy == true then
  1631. player1.specAttack = player1.specAttack + moves[selectedMove]["effectValue"]
  1632. elseif moveEffect == "buffSpecAttack" and playerTurn == 2 and accuracy == true then
  1633. player2.specAttack = player2.specAttack + moves[selectedMove]["effectValue"]
  1634. end
  1635.  
  1636. if moveEffect == "buffSpeed" and playerTurn == 1 and accuracy == true then
  1637. player1.speed = player1.speed + moves[selectedMove]["effectValue"]
  1638. elseif moveEffect == "buffSpeed" and playerTurn == 2 and accuracy == true then
  1639. player2.speed = player2.speed + moves[selectedMove]["effectValue"]
  1640. end
  1641.  
  1642. if moveEffect == "buffAccuracy" and playerTurn == 1 and accuracy == true then
  1643. player1.accuracy = player1.accuracy + moves[selectedMove]["effectValue"]
  1644. elseif moveEffect == "buffAccuracy" and playerTurn == 2 and accuracy == true then
  1645. player2.accuracy = player2.accuracy + moves[selectedMove]["effectValue"]
  1646. end
  1647.  
  1648. if moveEffect == "debuffAttack" and playerTurn == 1 and accuracy == true and player1.attack > 5 then
  1649. player2.attack =player2.attack - moves[selectedMove]["effectValue"]
  1650. elseif moveEffect == "debuffAttack" and playerTurn == 2 and accuracy == true and player2.attack > 5 then
  1651. player1.attack =player1.attack - moves[selectedMove]["effectValue"]
  1652. end
  1653.  
  1654. if moveEffect == "debuffDefense" and playerTurn == 1 and accuracy == true and player1.defense > 5 then
  1655. player2.defense =player2.defense - moves[selectedMove]["effectValue"]
  1656. elseif moveEffect == "debuffDefense" and playerTurn == 2 and accuracy == true and player2.defense > 5 then
  1657. player1.defense =player1.defense - moves[selectedMove]["effectValue"]
  1658. end
  1659.  
  1660. if moveEffect == "debuffSpecDefense" and playerTurn == 1 and accuracy == true and player1.specDefense > 5 then
  1661. player2.specDefense =player2.specDefense - moves[selectedMove]["effectValue"]
  1662. elseif moveEffect == "debuffSpecDefense" and playerTurn == 2 and accuracy == true and player2.specDefense > 5 then
  1663. player1.specDefense =player1.specDefense - moves[selectedMove]["effectValue"]
  1664. end
  1665.  
  1666. if moveEffect == "debuffSpecAttack" and playerTurn == 1 and accuracy == true and player1.specAttack > 5 then
  1667. player2.specAttack = player2.specAttack - moves[selectedMove]["effectValue"]
  1668. elseif moveEffect == "debuffSpecAttack" and playerTurn == 2 and accuracy == true and player2.specAttack > 5 then
  1669. player1.specAttack =player1.specAttack - moves[selectedMove]["effectValue"]
  1670. end
  1671.  
  1672. if moveEffect == "debuffSpeed" and playerTurn == 1 and accuracy == true and player1.speed > 5 then
  1673. player2.speed = player2.speed - moves[selectedMove]["effectValue"]
  1674. elseif moveEffect == "debuffSpeed" and playerTurn == 2 and accuracy == true and player2.speed > 5 then
  1675. player1.speed = player1.speed - moves[selectedMove]["effectValue"]
  1676. end
  1677.  
  1678. if moveEffect == "debuffAccuracy" and playerTurn == 1 and accuracy == true and moves[selectedMove]["accuracy"] + player1.accuracy > 5 then
  1679. player2.accuracy =player2.accuracy - moves[selectedMove]["effectValue"]
  1680. elseif moveEffect == "debuffAccuracy" and playerTurn == 2 and accuracy == true and moves[selectedMove]["accuracy"] + player2.accuracy > 5 then
  1681. player1.accuracy =player1.accuracy - moves[selectedMove]["effectValue"]
  1682. end
  1683.  
  1684. if moveEffect == "heal" and playerTurn == 1 and accuracy == true then
  1685. player1.currHp= player1.currHp + moves[selectedMove]["effectValue"]
  1686. if player1.currHp > player1.hpMax then player1.currHp = player1.hpMax end
  1687. elseif moveEffect == "heal" and playerTurn == 2 and accuracy == true then
  1688. player2.currHp = player2.currHp + moves[selectedMove]["effectValue"]
  1689. if player2.currHp > player2.hpMax then player2.currHp = player2.hpMax end
  1690. end
  1691.  
  1692. if moveEffect == "poison" and playerTurn == 1 and accuracy == true then
  1693. randomNum = math.random(1,100)
  1694. if moves[selectedMove]["effectValue"] >= randomNum then
  1695. player2.status = "poison"
  1696. end
  1697. elseif moveEffect == "poison" and playerTurn == 2 and accuracy == true then
  1698. randomNum = math.random(1,100)
  1699. if moves[selectedMove]["effectValue"] >= randomNum then
  1700. player1.status = "poison"
  1701. end
  1702. end
  1703.  
  1704. if moveEffect == "burn" and playerTurn == 1 and accuracy == true then
  1705. randomNum = math.random(1,100)
  1706. if moves[selectedMove]["effectValue"] >= randomNum then
  1707. player2.status = "burn"
  1708. end
  1709. elseif moveEffect == "burn" and playerTurn == 2 and accuracy == true then
  1710. randomNum = math.random(1,100)
  1711. if moves[selectedMove]["effectValue"] >= randomNum then
  1712. player1.status = "burn"
  1713. end
  1714. end
  1715.  
  1716. if moveEffect == "paralyze" and playerTurn == 1 and accuracy == true then
  1717. randomNum = math.random(1,100)
  1718. if moves[selectedMove]["effectValue"] >= randomNum then
  1719. player2.status = "paralyze"
  1720. player2Round = 1
  1721. player2Paralyzed = true
  1722. end
  1723. elseif moveEffect == "paralyze" and playerTurn == 2 and accuracy == true then
  1724. randomNum = math.random(1,100)
  1725. if moves[selectedMove]["effectValue"] >= randomNum then
  1726. player1.status = "paralyze"
  1727. player1Round = 1
  1728. player1Paralyzed = true
  1729. end
  1730. end
  1731.  
  1732. if moveEffect == "confusion" and playerTurn == 1 and accuracy == true then
  1733. randomNum = math.random(1,100)
  1734. if moves[selectedMove]["effectValue"] >= randomNum then
  1735. player2.status = "confusion"
  1736. player2Confused = true
  1737. player2Round = 0
  1738. end
  1739. elseif moveEffect == "confusion" and playerTurn == 2 and accuracy == true then
  1740. randomNum = math.random(1,100)
  1741. if moves[selectedMove]["effectValue"] >= randomNum then
  1742. player1.status = "confusion"
  1743. player1Confused = true
  1744. player1Round = 0
  1745. end
  1746. end
  1747.  
  1748. if moveEffect == "sleep" and playerTurn == 1 and accuracy == true and player2.status ~= "sleep" then
  1749. randomNum = math.random(1,100)
  1750. if moves[selectedMove]["effectValue"] >= randomNum then
  1751. player2Sleeping = true
  1752. player2Round = 0
  1753. player2.status = "sleep"
  1754. end
  1755. elseif moveEffect == "sleep" and playerTurn == 2 and accuracy == true and player1.status ~= "sleep" then
  1756. randomNum = math.random(1,100)
  1757. if moves[selectedMove]["effectValue"] >= randomNum then
  1758. player1Sleeping = true
  1759. player1Round = 0
  1760. player1.status = "sleep"
  1761. end
  1762. end
  1763.  
  1764. if moveEffect == "sleepSelf" and playerTurn == 1 and accuracy == true then
  1765. player1Sleeping = true
  1766. player1Round = 1
  1767. player1.status = "sleep"
  1768. player1.currHp = player1.hpMax
  1769. elseif moveEffect == "sleepSelf" and playerTurn == 2 and accuracy == true then
  1770. player2Sleeping = true
  1771. player2Round = 1
  1772. player2.status = "sleep"
  1773. player2.currHp = player2.hpMax
  1774. end
  1775.  
  1776. if moveEffect == "flinch" and playerTurn == 1 and accuracy == true then
  1777. randomNum = math.random(1,100)
  1778. if moves[selectedMove]["effectValue"] >= randomNum then
  1779. player2.status = "flinch"
  1780. end
  1781. elseif moveEffect == "flinch" and playerTurn == 2 and accuracy == true then
  1782. randomNum = math.random(1,100)
  1783. if moves[selectedMove]["effectValue"] >= randomNum then
  1784. player1.status = "flinch"
  1785. end
  1786. end
  1787.  
  1788. if moveEffect == "freeze" and playerTurn == 1 and accuracy == true then
  1789. randomNum = math.random(1,100)
  1790. if moves[selectedMove]["effectValue"] >= randomNum then
  1791. player2.status = "freeze"
  1792. player2Frozen = true
  1793. player2Round = 1
  1794. end
  1795. elseif moveEffect == "freeze" and playerTurn == 2 and accuracy == true then
  1796. randomNum = math.random(1,100)
  1797. if moves[selectedMove]["effectValue"] >= randomNum then
  1798. player1.status = "freeze"
  1799. player1Frozen = true
  1800. player1Round = 1
  1801. end
  1802. end
  1803.  
  1804. if moveEffect == "curse" and playerTurn == 1 and accuracy == true then
  1805. player2.status = "curse"
  1806. player1.currHp = math.floor(player1.currHp / 2)
  1807. if player1.currHp == 0 then player1.currHp = 1 end
  1808. elseif moveEffect == "curse" and playerTurn == 2 and accuracy == true then
  1809. player1.status = "curse"
  1810. player2.currHp = math.floor(player2.currHp / 2)
  1811. if player1.currHp == 0 then player1.currHp = 1 end
  1812. end
  1813.  
  1814. if moveEffect == "roost" and playerTurn == 1 and accuracy == true then
  1815. if player1.type1 == "Flying" and player1.type2 == flying then
  1816. player1.type1 = "Normal"
  1817. player1.type2 = "Normal"
  1818. elseif player1.type1 == "Flying" then
  1819. player1.type1 = "Normal"
  1820. elseif player1.type2 == "Flying" then
  1821. player1.type2 = "Normal"
  1822. end
  1823. player1.currHp = player1currHp + (player1.maxHp / 2)
  1824. if player1.currHp > player1.hpMax then player1.currHp = player1.hpMax end
  1825. elseif moveEffect == "roost" and playerTurn == 2 and accuracy == true then
  1826. if player2.type1 == "Flying" and player2.type2 == flying then
  1827. player2.type1 = "Normal"
  1828. player2.type2 = "Normal"
  1829. elseif player2.type1 == "Flying" then
  1830. player2.type1 = "Normal"
  1831. elseif player2.type2 == "Flying" then
  1832. player2.type2 = "Normal"
  1833. end
  1834. player2.currHp = player2currHp + (player2.maxHp / 2)
  1835. if player2.currHp > player2.hpMax then player2.currHp = player2.hpMax end
  1836. end
  1837.  
  1838. end
  1839. -- end
  1840. print("buff/debuff finished")
  1841. event = os.pullEvent("key")
  1842. shell.run("clear")
  1843. end
  1844.  
  1845.  
  1846.  
  1847. local function pokemonAttack(move)
  1848. shell.run("clear")
  1849.  
  1850. calcAccuracy()
  1851.  
  1852. buffAndDebuff()
  1853.  
  1854. STABBonus()
  1855. strengthAndWeakness()
  1856. calcDam()
  1857. end
  1858.  
  1859.  
  1860.  
  1861.  
  1862. local function checkStatus()
  1863. if playerTurn == 1 then
  1864. if player1.status == "poison" then
  1865. print(player1.name.." is poisoned. "..player1.name.." takes damage from the poison")
  1866. player1.currHp = player1.currHp - 1
  1867. if player1.currHp == 0 then player1.currHp = 1 end
  1868. writeHP()
  1869. sleep(1.5)
  1870. pokemonAttack(selectedMove)
  1871. print("Player1's "..player1.name.." use "..selectedMove)
  1872. end
  1873. if player1.status == "burn" then
  1874. print(player1.name.." is burned. "..player1.name.." takes damage from the burn")
  1875. player1.currHp = player1.currHp - 1
  1876. if player1.currHp == 0 then player1.currHp = 1 end
  1877. writeHP()
  1878. sleep(1.5)
  1879. pokemonAttack(selectedMove)
  1880. print("Player1's "..player1.name.." use "..selectedMove)
  1881. end
  1882. if player1.status == "curse" then
  1883. print(player1.name.." is cursed. "..player1.name.." takes damage from the curse")
  1884. player1.currHp = math.floor(player1.currHp / 2)
  1885. if player1.currHp == 0 then player1.currHp = 1 end
  1886. writeHP()
  1887. sleep(1.5)
  1888. pokemonAttack(selectedMove)
  1889. print("Player1's "..player1.name.." use "..selectedMove)
  1890. end
  1891. if player1.status == "sleep" then
  1892. print(player1.name.." is sleeping. ")
  1893. sleep(1.5)
  1894. player1Round = player1Round +1
  1895. selectedMove = "notInUse"
  1896. if player1Round == 3 then
  1897. player1Sleeping = false
  1898. player1.status = "none"
  1899. print("It woke up!")
  1900. pokemonAttack(selectedMove)
  1901. print("Player1's "..player1.name.." use "..selectedMove)
  1902. end
  1903. end
  1904. if player1.status == "confusion" then
  1905. print(player1.name.." is confused.")
  1906. sleep(0.5)
  1907. randomNum = math.random(1,100)
  1908. if randomNum > 0 and randomNum < 26 then
  1909. print("It hurt itself in the confusion")
  1910. player1.currHp = player1.currHp - math.ceil((player1.hpMax / 10))
  1911. writeHP()
  1912. sleep(1.5)
  1913. selectedMove = "notInUse"
  1914. elseif randomNum > 25 and randomNum < 51 then
  1915. print(player1.name.." is too confused")
  1916. sleep(1.5)
  1917. selectedMove1 = "notInUse"
  1918. else
  1919. pokemonAttack(selectedMove)
  1920. print("Player1's "..player1.name.." use "..selectedMove)
  1921. end
  1922. player1Round = player1Round +1
  1923. if player1Round == 3 then
  1924. print("It snapped out if its confusion")
  1925. player1Confused = false
  1926. player1.status = "none"
  1927. pokemonAttack(selectedMove)
  1928. print("Player1's "..player1.name.." use "..selectedMove)
  1929. end
  1930. end
  1931. if player1.status == "flinch" then
  1932. print(player1.name.." is flinched. ")
  1933. writeHP()
  1934. sleep(1.5)
  1935. selectedMove = "notInUse"
  1936. player1Flinched = false
  1937. player1.status = "none"
  1938. end
  1939. if player1.status == "paralyze" then
  1940. print(player1.name.." is paralyzed. ")
  1941. randomNum = math.random(1,100)
  1942. if randomNum > 0 and randomNum < 61 then
  1943. print("It can't move")
  1944. writeHP()
  1945. sleep(1.5)
  1946. selectedMove = "notInUse"
  1947. else
  1948. pokemonAttack(selectedMove)
  1949. print("Player1's "..player1.name.." use "..selectedMove)
  1950. end
  1951. player1Round = player1Round +1
  1952. if player1Round == 3 then
  1953. pokemonAttack(selectedMove)
  1954. print("Player1's "..player1.name.." use "..selectedMove)
  1955. player1Paralyzed = false
  1956. player1.status = "none"
  1957. end
  1958. end
  1959. if player1.status == "freeze" then
  1960. print(player1.name.." is frozen. ")
  1961. randomNum = math.random(1,100)
  1962. if randomNum > 0 and randomNum < 61 then
  1963. print("It can't move")
  1964. writeHP()
  1965. sleep(1.5)
  1966. selectedMove = "notInUse"
  1967. else
  1968. pokemonAttack(selectedMove)
  1969. print("Player1's "..player1.name.." use "..selectedMove)
  1970. end
  1971. player1Round = player1Round +1
  1972. if player1Round == 3 then
  1973. player1Frozen = false
  1974. player1.status = "none"
  1975. pokemonAttack(selectedMove)
  1976. print("Player1's "..player1.name.." use "..selectedMove)
  1977. end
  1978. end
  1979.  
  1980.  
  1981. elseif playerTurn == 2 then
  1982. if player2.status == "poison" then
  1983. print(player2.name.." is poisoned. "..player2.name.." takes damage from the poison")
  1984. player2.currHp = player2.currHp - 1
  1985. end
  1986. end
  1987. end
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994. local function printResult()
  1995. if moves[selectedMove1]["doesDamage"] or moves[selectedMove2]["doesDamage"] == true then
  1996. moveDoesDamage = true
  1997. else
  1998. moveDoesDamage = false
  1999. end
  2000.  
  2001. if accuracy == true and selectedMove ~= "notInUse" and moveDoesDamage == true then
  2002. if critical == true then
  2003. print("It's a critical hit!")
  2004. end
  2005. if weakness == 0 then
  2006. print("It has no effect")
  2007. elseif weakness > resist then
  2008. print("Its Super Effective.")
  2009. elseif weakness < resist then
  2010. print("Its not very Effective.")
  2011. end
  2012.  
  2013. if playerTurn == 1 and dam ~= nil then
  2014. if switch1 == false then
  2015. print("Player2's "..player2.name.." was damaged for "..dam.." points")
  2016. print("Player2's health: "..player2.currHp)
  2017. end
  2018. elseif playerTurn == 2 and dam2 ~= nil then
  2019. if switch2 == false then
  2020. print("Player1's "..player1.name.." was damaged for "..dam2.." points")
  2021. print("Player1's health: "..player1.currHp)
  2022. end
  2023. end
  2024. elseif accuracy == false then
  2025. print("It missed")
  2026. end
  2027. end
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034. local function resolveTurn()
  2035. shell.run("clear")
  2036. if switch1 == true then
  2037. playerTurn = 1
  2038. elseif switch2 == true then
  2039. playerTurn = 2
  2040. end
  2041. if playerTurn == 1 then
  2042. if switch1 == true then
  2043. player1 = player1Select[selection1]
  2044. print("Player1 switches to "..player1.name)
  2045. switch1 = false
  2046. elseif itemUsed == true then
  2047. print("Player1 uses ")
  2048. elseif player1.status ~= "none" then
  2049. checkStatus()
  2050. else
  2051. pokemonAttack(selectedMove)
  2052. print("Player1's "..player1.name.." use "..selectedMove)
  2053. print("moveType "..moveType)
  2054. end
  2055. print(" ")
  2056. sleep(0.5)
  2057. print("Type1 "..player2.type1)
  2058. print("Type2 "..player2.type2)
  2059. print(" ")
  2060.  
  2061. elseif playerTurn == 2 then
  2062. if switch2 == true then
  2063. if AIOn == false then
  2064. player2 = player2Select[selection2]
  2065. end
  2066. print("Player2 switches to "..player2.name)
  2067. switch2 = false
  2068. elseif itemUsed == true then
  2069. print("Player2 uses ")
  2070. elseif player2.status ~= "none" then
  2071. checkStatus()
  2072. else
  2073. pokemonAttack(selectedMove)
  2074. print("Player2's "..player2.name.." use "..selectedMove2)
  2075. print("moveType "..moveType)
  2076. end
  2077. print(" ")
  2078. sleep(0.5)
  2079. print("Type1 "..player1.type1.." Type2 "..player1.type2)
  2080. print(" ")
  2081. end
  2082.  
  2083.  
  2084.  
  2085. print("playerTurn "..playerTurn)
  2086. print(" ")
  2087. print("1 status: "..player1.status.." 2 status "..player2.status)
  2088. print(" ")
  2089. print("player1 stats "..player1.attack.." "..player1.defense.." "..player1.specAttack.." "..player1.specDefense.." "..player1.speed.." "..player1.accuracy)
  2090. print("player2 stats "..player2.attack.." "..player2.defense.." "..player2.specAttack.." "..player2.specDefense.." "..player2.speed.." "..player2.accuracy)
  2091. print(" ")
  2092.  
  2093. printResult()
  2094.  
  2095. writeHP()
  2096. event = os.pullEvent("key")
  2097. shell.run("clear")
  2098. end
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109. local function checkFaint()
  2110. allFainted = false
  2111. faint1 = 0
  2112. faint2 = 0
  2113. if player1.currHp == 0 then
  2114. print("Player1's "..player1.name.." fainted")
  2115. print(" ")
  2116. sleep(1)
  2117. player1.status = "fainted"
  2118. for i = 1, #player1Select do
  2119. if player1Select[i]["status"] == "fainted" then
  2120. faint1 = faint1 +1
  2121. end
  2122. end
  2123. if faint1 == #player1Select then
  2124. shell.run("clear")
  2125. print("Player2 win!")
  2126. allFainted = true
  2127. else
  2128. selectNewMon1()
  2129. player1 = player1Select[selection1]
  2130. end
  2131. end
  2132. if player2.currHp == 0 then
  2133. print("Player2's "..player2.name.." fainted")
  2134. print(" ")
  2135. sleep(1)
  2136. player2.status = "fainted"
  2137. for i = 1, #player2Select do
  2138. if player2Select[i]["status"] == "fainted" then
  2139. faint2 = faint2 +1
  2140. end
  2141. end
  2142. if faint2 == #player2Select then
  2143. shell.run("clear")
  2144. print("Player1 win!")
  2145. allFainted = true
  2146. elseif AIOn == true then
  2147. while true do
  2148. AIselect = math.random(1, #player2Select)
  2149. if player2Select[AIselect]["status"] ~= "fainted" then
  2150. player2 = player2Select[AIselect]
  2151. switch2 = true
  2152. break
  2153. end
  2154. end
  2155. else
  2156. selectNewMon2()
  2157. player2 = player2Select[selection2]
  2158. end
  2159. end
  2160. end
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168. local function showMoves()
  2169. while true do
  2170. shell.run("clear")
  2171. if playerTurn == 1 then
  2172. print("player "..playerTurn)
  2173. print("1: "..player1["move1"])
  2174. print("2: "..player1["move2"])
  2175. print("3: "..player1["move3"])
  2176. print("4: "..player1["move4"])
  2177.  
  2178. local event, arg1 = os.pullEvent("key")
  2179.  
  2180. if keys.getName(arg1) == "one" and player1.move1pp ~= 0 then
  2181. selectedMove = player1.move1
  2182. selectedMove1 = player1.move1
  2183. player1.move1pp = player1.move1pp -1
  2184. --resolveTurn()
  2185. break
  2186. elseif keys.getName(arg1) == "two" and player1.move2pp ~= 0 then
  2187. selectedMove = player1.move2
  2188. selectedMove1 = player1.move2
  2189. player1.move2pp = player1.move2pp -1
  2190. --resolveTurn()
  2191. break
  2192. elseif keys.getName(arg1) == "three" and player1.move3pp ~= 0 then
  2193. selectedMove = player1.move3
  2194. selectedMove1 = player1.move3
  2195. player1.move3pp = player1.move3pp -1
  2196. --resolveTurn()
  2197. break
  2198. elseif keys.getName(arg1) == "four" and player1.move4pp ~= 0 then
  2199. selectedMove = player1.move4
  2200. selectedMove1 = player1.move4
  2201. shell.run("clear")
  2202. player1.move4pp = player1.move4pp -1
  2203. --resolveTurn()
  2204. break
  2205. end
  2206. elseif playerTurn == 2 then
  2207. print("player "..playerTurn)
  2208. print("1: "..player2["move1"])
  2209. print("2: "..player2["move2"])
  2210. print("3: "..player2["move3"])
  2211. print("4: "..player2["move4"])
  2212.  
  2213. local event, arg1 = os.pullEvent("key")
  2214.  
  2215. if keys.getName(arg1) == "one" and player2.move1pp ~= 0 then
  2216. selectedMove = player2.move1
  2217. selectedMove2 = player2.move1
  2218. player2.move1pp = player2.move1pp -1
  2219. --resolveTurn()
  2220. break
  2221. elseif keys.getName(arg1) == "two" and player2.move2pp ~= 0 then
  2222. selectedMove = player2.move2
  2223. selectedMove2 = player2.move2
  2224. player2.move2pp = player2.move2pp -1
  2225. --resolveTurn()
  2226. break
  2227. elseif keys.getName(arg1) == "three" and player2.move3pp ~= 0 then
  2228. selectedMove = player2.move3
  2229. selectedMove2 = player2.move3
  2230. player2.move3pp = player2.move3pp -1
  2231. --resolveTurn()
  2232. break
  2233. elseif keys.getName(arg1) == "four" and player2.move4pp ~= 0 then
  2234. selectedMove = player2.move4
  2235. selectedMove2 = player2.move4
  2236. player2.move4pp = player2.move4pp -1
  2237. --resolveTurn()
  2238. break
  2239. end
  2240. end
  2241. end
  2242. end
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249. local function showItems()
  2250. shell.run("clear")
  2251. if items == "empty" then
  2252. print("No items")
  2253. else
  2254. itemUsed = true
  2255. end
  2256. sleep(1)
  2257. end
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267. local function run()
  2268. shell.run("clear")
  2269. if trainer == true then
  2270. print("Can't run")
  2271. end
  2272. sleep(1)
  2273. end
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279. local function initiative()
  2280. if player1.speed > player2.speed then
  2281. player = 1
  2282. playerTurn = 1
  2283. elseif player2.speed > player1.speed then
  2284. player = 2
  2285. playerTurn = 2
  2286. elseif player1.speed == player2.speed then
  2287. player = math.random(1,2)
  2288. playerTurn = math.random(1,2)
  2289. end
  2290. end
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298. local function battle()
  2299. while true do
  2300. shell.run("clear")
  2301. print("player "..playerTurn)
  2302. print("1. Attack")
  2303. print("2. Items")
  2304. print("3. Pokemons")
  2305. print("4. Run")
  2306.  
  2307. local event, arg1 = os.pullEvent("key")
  2308.  
  2309. if keys.getName(arg1) == "one" then
  2310.  
  2311. noAttack = false
  2312. showMoves()
  2313. choice = true
  2314. break
  2315. elseif keys.getName(arg1) == "two" then
  2316. showItems()
  2317. noAttack = true
  2318. elseif keys.getName(arg1) == "three" then
  2319. --showPokemons()
  2320. if playerTurn == 1 then
  2321. selectNewMon1()
  2322. switch1 = true
  2323. selectedMove = "notInUse"
  2324. elseif playerTurn == 2 then
  2325. selectNewMon2()
  2326. switch2 = true
  2327. selectedMove = "notInUse"
  2328. end
  2329. noAttack = true
  2330. break
  2331. elseif keys.getName(arg1) == "four" then
  2332. run()
  2333. end
  2334. end
  2335. end
  2336.  
  2337.  
  2338.  
  2339. local function AI()
  2340. while true do
  2341. attackChoice = math.random(1,4)
  2342. if attackChoice == 1 and player2.move1pp ~= 0 then
  2343. selectedMove2 = player2.move1
  2344. break
  2345. elseif attackChoice == 2 and player2.move2pp ~= 0 then
  2346. selectedMove2 = player2.move2
  2347. break
  2348. elseif attackChoice == 3 and player2.move3pp ~= 0 then
  2349. selectedMove2 = player2.move3
  2350. break
  2351. elseif attackChoice == 4 and player2.move4pp ~= 0 then
  2352. selectedMove2 = player2.move4
  2353. break
  2354. end
  2355. end
  2356. end
  2357.  
  2358.  
  2359.  
  2360. local function restart()
  2361. shell.run("clear")
  2362. print(#player1Select)
  2363. for i = 1, #player1Select do
  2364. player1Select[i]["currHp"] = player1Select[i]["hpMax"]
  2365. player1Select[i]["status"] = "none"
  2366. player2Select[i]["currHp"] = player1Select[i]["hpMax"]
  2367. player2Select[i]["status"] = "none"
  2368.  
  2369. player1Select[i]["move1pp"] = moves[player1Select[i]["move1"]]["pp"]
  2370. player1Select[i]["move2pp"] = moves[player1Select[i]["move2"]]["pp"]
  2371. player1Select[i]["move3pp"] = moves[player1Select[i]["move3"]]["pp"]
  2372. player1Select[i]["move4pp"] = moves[player1Select[i]["move4"]]["pp"]
  2373.  
  2374. player2Select[i]["move1pp"] = moves[player2Select[i]["move1"]]["pp"]
  2375. player2Select[i]["move2pp"] = moves[player2Select[i]["move2"]]["pp"]
  2376. player2Select[i]["move3pp"] = moves[player2Select[i]["move3"]]["pp"]
  2377. player2Select[i]["move4pp"] = moves[player2Select[i]["move4"]]["pp"]
  2378. end
  2379. faint1 = 0
  2380. faint2 = 0
  2381. resist = 1
  2382. weakness = 1
  2383. end
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390. -- #############################
  2391. local function debugging()
  2392. print("pairs(moves[Meditation])")
  2393. for k, v in pairs(moves["Meditation"]) do
  2394. print(tostring(k).." "..tostring(v))
  2395. end
  2396. os.pullEvent()
  2397. shell.run("clear")
  2398. -- skriver effect table
  2399.  
  2400. print("ipairs(moves[Meditation])")
  2401. for k,v in ipairs(moves["Meditation"]) do
  2402. print(tostring(k).." "..tostring(v))
  2403. end
  2404. os.pullEvent()
  2405. shell.run("clear")
  2406. -- skriver ingenting
  2407.  
  2408. print("pairs(moves[Meditation][effect])")
  2409. for k, v in pairs(moves["Meditation"]["effect"]) do
  2410. print(k.." "..v)
  2411. end
  2412. os.pullEvent()
  2413. shell.run("clear")
  2414. -- skriver 1 None osv
  2415.  
  2416. print("ipairs(moves[Meditation][effect])")
  2417. for k, v in ipairs(moves["Meditation"]["effect"]) do
  2418. print(k.." "..v)
  2419. end
  2420. os.pullEvent()
  2421. shell.run("clear")
  2422. -- skriver 1 None osv
  2423.  
  2424. print(" #moves[Meditation]")
  2425. for i = 1, #moves["Meditation"] do
  2426. print(i)
  2427. end
  2428. os.pullEvent()
  2429. shell.run("clear")
  2430. -- skriver ingenting
  2431.  
  2432. print("#moves[Meditation][effect]")
  2433. for i = 1, #moves["Meditation"]["effect"] do
  2434. print(moves[Meditation]["effect"][i])
  2435. end
  2436. os.pullEvent()
  2437. shell.run("clear")
  2438. -- attempt to index nil value
  2439. end
  2440.  
  2441.  
  2442.  
  2443. items = "empty"
  2444. trainer = true
  2445. playerTurn = 1
  2446.  
  2447.  
  2448.  
  2449. shell.run("writePokemon")
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458. while true do
  2459.  
  2460. loadPokemon()
  2461. pokemon = loadedFile
  2462.  
  2463.  
  2464.  
  2465. for i = 1,3 do
  2466. selectMon1()
  2467. end
  2468.  
  2469. for i = 1,3 do
  2470. selectMon2()
  2471. end
  2472.  
  2473. restart()
  2474.  
  2475. printPokemon()
  2476.  
  2477. if AIOn == true then
  2478. playerTurn = 1
  2479. end
  2480.  
  2481. while true do
  2482. if AIOn == true then
  2483. battle()
  2484. AI()
  2485. else
  2486. initiative()
  2487. for i = 1, 2 do
  2488. print("Player"..playerTurn.."'s turn")
  2489. sleep(1)
  2490. battle()
  2491. if playerTurn == 1 then
  2492. playerTurn = 2
  2493. elseif playerTurn == 2 then
  2494. playerTurn = 1
  2495. end
  2496. shell.run("clear")
  2497. end
  2498. end
  2499.  
  2500. if AIOn == true then
  2501. initiative()
  2502. end
  2503.  
  2504. for i = 1, 2 do
  2505. resolveTurn()
  2506. checkFaint()
  2507. if playerTurn == 1 then
  2508. playerTurn = 2
  2509. elseif playerTurn == 2 then
  2510. playerTurn = 1
  2511. end
  2512. end
  2513.  
  2514. switch1 = false
  2515. switch2= false
  2516.  
  2517. if allFainted == true then
  2518. restart()
  2519. break
  2520. end
  2521. end
  2522.  
  2523. end
RAW Paste Data