This commit is contained in:
Kyle Coburn 2015-04-24 21:34:49 -07:00
parent 06bd4965a1
commit cf356f5a88
5 changed files with 17 additions and 17 deletions

View File

@ -4,13 +4,14 @@ local Battle
local Combat = require "ai.combat" local Combat = require "ai.combat"
local Strategies local Strategies
local Data = require "data.data"
local Bridge = require "util.bridge" local Bridge = require "util.bridge"
local Memory = require "util.memory" local Memory = require "util.memory"
local Menu = require "util.menu" local Menu = require "util.menu"
local Paint = require "util.paint" local Paint = require "util.paint"
local Utils = require "util.utils" local Utils = require "util.utils"
local Data = require "data.data"
local Inventory = require "storage.inventory" local Inventory = require "storage.inventory"
local Pokemon = require "storage.pokemon" local Pokemon = require "storage.pokemon"
@ -23,8 +24,6 @@ local extraEncounter, maxEncounters
local battleYolo local battleYolo
local encountersSection local encountersSection
local yellow = YELLOW
Control.areaName = "Unknown" Control.areaName = "Unknown"
Control.getMoonExp = true Control.getMoonExp = true
Control.yolo = false Control.yolo = false
@ -96,7 +95,7 @@ local controlFunctions = {
startMtMoon = function() startMtMoon = function()
Control.canDie(false) Control.canDie(false)
Control.getMoonExp = not yellow Control.getMoonExp = not Data.yellow
end, end,
moon1Exp = function() moon1Exp = function()
@ -208,9 +207,9 @@ function Control.canCatch(partySize)
partySize = Memory.value("player", "party_size") partySize = Memory.value("player", "party_size")
end end
local pokeballs = Inventory.count("pokeball") local pokeballs = Inventory.count("pokeball")
local minimumCount = (yellow and 3 or 4) - partySize local minimumCount = (Data.yellow and 3 or 4) - partySize
if pokeballs < minimumCount then if pokeballs < minimumCount then
if yellow and Pokemon.inParty("nidoran", "nidorino", "nidoking") and Pokemon.inParty("pidgey", "spearow") then if Data.yellow and Pokemon.inParty("nidoran", "nidorino", "nidoking") and Pokemon.inParty("pidgey", "spearow") then
return false return false
end end
Strategies.reset("pokeballs", "Not enough PokeBalls", pokeballs) Strategies.reset("pokeballs", "Not enough PokeBalls", pokeballs)
@ -230,7 +229,7 @@ function Control.shouldCatch(partySize)
if not shouldCatch then if not shouldCatch then
return false return false
end end
if yellow and not Inventory.contains("pokeball") then if Data.yellow and not Inventory.contains("pokeball") then
return false return false
end end
if not partySize then if not partySize then
@ -274,7 +273,7 @@ function Control.set(data)
if controlFunction then if controlFunction then
controlFunction(data) controlFunction(data)
else else
p("INVALID CONTROL", data.c, GAME_NAME) p("INVALID CONTROL", data.c, Data.gameName)
end end
end end
@ -384,7 +383,7 @@ end
function Control.init() function Control.init()
Battle = require("action.battle") Battle = require("action.battle")
Strategies = require("ai."..GAME_NAME..".strategies") Strategies = require("ai."..Data.gameName..".strategies")
end end
return Control return Control

View File

@ -8,6 +8,8 @@ local Shop = require "action.shop"
local Textbox = require "action.textbox" local Textbox = require "action.textbox"
local Walk = require "action.walk" local Walk = require "action.walk"
local Data = require "data.data"
local Bridge = require "util.bridge" local Bridge = require "util.bridge"
local Input = require "util.input" local Input = require "util.input"
local Memory = require "util.memory" local Memory = require "util.memory"
@ -15,7 +17,6 @@ local Menu = require "util.menu"
local Player = require "util.player" local Player = require "util.player"
local Utils = require "util.utils" local Utils = require "util.utils"
local Data = require "data.data"
local Inventory = require "storage.inventory" local Inventory = require "storage.inventory"
local Pokemon = require "storage.pokemon" local Pokemon = require "storage.pokemon"
@ -338,7 +339,7 @@ strategyFunctions.fightBulbasaur = function()
end end
if Battle.isActive() and Battle.opponentAlive() then if Battle.isActive() and Battle.opponentAlive() then
local resetMessage, customReason local resetMessage, customReason
if Memory.double("battle", "our_attack") < 2 then if Memory.double("battle", "our_attack") <= 2 then
resetMessage = "Growled to death." resetMessage = "Growled to death."
customReason = true customReason = true
else else
@ -368,7 +369,8 @@ strategyFunctions.catchNidoran = function()
if not Control.canCatch() then if not Control.canCatch() then
return true return true
end end
local catchableNidoran = Pokemon.isOpponent("nidoran") and Memory.value("battle", "opponent_level") > 2 local opponent = Battle.opponent()
local catchableNidoran = opponent == "nidoran" and Memory.value("battle", "opponent_level") > 2
local pokeballs = Inventory.count("pokeball") local pokeballs = Inventory.count("pokeball")
local caught = Memory.value("player", "party_size") - 1 local caught = Memory.value("player", "party_size") - 1
if pokeballs < (catchableNidoran and 5 or 6) - caught * 2 then if pokeballs < (catchableNidoran and 5 or 6) - caught * 2 then
@ -2028,7 +2030,7 @@ end
function Strategies.initGame(midGame) function Strategies.initGame(midGame)
if midGame then if midGame then
Strategies.setYolo("bulbasaur") Strategies.setYolo("bulbasaur", true)
stats.squirtle = { stats.squirtle = {
attack = 11, attack = 11,
defense = 11, defense = 11,

View File

@ -122,8 +122,8 @@ function Strategies.resetTime(timeLimit, explanation, custom)
end end
end end
function Strategies.setYolo(name) function Strategies.setYolo(name, forced)
if not RESET_FOR_TIME then if not forced and not RESET_FOR_TIME then
return false return false
end end
local minimumTime = Strategies.getTimeRequirement(name) local minimumTime = Strategies.getTimeRequirement(name)

View File

@ -923,7 +923,7 @@ end
function Strategies.initGame(midGame) function Strategies.initGame(midGame)
if midGame then if midGame then
-- Strategies.setYolo("") -- Strategies.setYolo("", true)
if Pokemon.inParty("nidoking") then if Pokemon.inParty("nidoking") then
local attDV, defDV, spdDV, sclDV = Pokemon.getDVs("nidoking") local attDV, defDV, spdDV, sclDV = Pokemon.getDVs("nidoking")
p(attDV, defDV, spdDV, sclDV) p(attDV, defDV, spdDV, sclDV)

1
external/json.lua vendored
View File

@ -108,7 +108,6 @@ function json.encode (v)
assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. tostring(v)) assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. tostring(v))
end end
--- Decodes a JSON string and returns the decoded value as a Lua data structure / value. --- Decodes a JSON string and returns the decoded value as a Lua data structure / value.
-- @param s The string to scan. -- @param s The string to scan.
-- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. -- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1.